akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
using namespace std;

int main(){
    int N,D;
    cin >> N >> D;
    int ans = N / (2 * D + 1);
    if (N % (2 * D + 1) != 0)
    {
        /* code */
        ans++;
    }
    cout << ans << endl;
    

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define show(x) cout<<x<<'\n'
#define showh(x) cout<<x<<' '
#define go(i,a,n) for(ll i=a;i<n;i++)
#define gor(i,a,n) for(ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
bool prime[100001];
bool ispoweroftwo(ll x)
{
    return x && !(x & (x-1));
}
ll xorcal(ll n)
{
    if(n%4==0)
        return n;
    if(n%4==1)
        return 1;
    if(n%4==2)
        return n+1;
    if(n%4==3)
        return 0;
}
void sieve(ll n)
{
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(ll i=2;i*i<=n;i++)
    {
        if(prime[i]==true)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                prime[j]=false;
            }
        }
    }
    show(prime[89]);
}
bool isprime(ll n)
{
    if (n<=1) return false;
    if (n<=3) return true;

    if(n%2==0 or n%3==0) return false;

    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0 or n%(i+2)==0) return false;
    }
    return true;
}

ll modinverse(ll a,ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m; a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
       x += m0;

    return x;
}

ll gcd(ll a,ll b)
{
    if(a==0)
    {
        return b;
    }
    return(b%a,a);
}

ll power(ll A, ll B)
{
    if (A == 0)
        return 0;
    if (B == 0)
        return 1;

    ll y;
    if (B % 2 == 0) {
        y = power(A, B / 2);
        y = (y * y) % mod;
    }

    else {
        y = A % mod;
        y = (y * power(A, B - 1) % mod) % mod;
    }

    return (ll)((y + mod) % mod);
}
bool isperfect(ld x)
{
    return ((sqrt(x))==floor(sqrt(x)));
}
int main()
{
    ios_base::sync_with_stdio(false);
    ll n,d;
    cin>>n>>d;
    ll des[n][d];
    go(i,0,n)
    {
        go(j,0,d)
        {
            cin>>des[i][j];
        }
    }
    ll count=0;
    go(i,0,n)
    {
        ll k=i+1;
        while(k!=n)
        {
           ll db=0;
           go(j,0,d)
           {
              db+=(des[i][j]-des[k][j])*(des[i][j]-des[k][j]);
           }
           if(isperfect((ld)db))
           {
               count++;
           }
           k++;
        }
    }
    show(count);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b==c ||b+c==a || c+a==b)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int k = sc.nextInt();
        String s = sc.next();
        sc.close();

        if(s.length() <=k ){
            System.out.println(s);
        }
        else{
            System.out.println(s.substring(0, k) + "...");
        }
    }
}

Measured memory_bytes: 38696
#include<iostream>
int main()
{
    int A,B,C;
    C =1;
    std::cin>>A>>B;
    int i=0;
    while(1){
        C += A-1;
        i++;
        if(C>=B)break;
    }
    if(B==1)std::cout<<0<<std::endl;
    else std::cout<<i<<std::endl;
}

Measured memory_bytes: 256
import java.util.Scanner

import scala.annotation.tailrec
import scala.io.StdIn._

object Main extends App {

  val Array(n,m,q) = readLine().split(" ").map(_.toInt)
  val Qs = Array.fill(q) {
    val Array(a,b,c,d) = readLine().split(" ").map(_.toInt)
    Item(a-1,b-1,c,d)
  }
  case class Item(a: Int, b: Int, c: Int, d: Int)

  var ans = 0
  def solve() = {
    dfs(Vector.empty, 1, n)
    ans
  }

  def dfs(A: Vector[Int], lastNum: Int, n: Int): Unit = {
    if(lastNum <= m) {
      if(n == 0) {
        val score = Qs.foldLeft(0) { case (acc, Item(a,b,c,d)) =>
          if(A(b) - A(a) == c) acc + d else acc
        }
        ans = Math.max(score, ans)
      } else {
        for (i <- lastNum to m)
          dfs(A :+ i, i, n-1)
      }
    }
  }

  println(solve())

}



Measured memory_bytes: 57356
#include<bits/stdc++.h>
using namespace std;

const int N = 1e5;
const int MOD = 1e9+7;

int n,m;
bool fail[N+5];

int memo[N+5];

int f(int x){
	if(x==n) return 1;
	if(fail[x]) return 0;
	if(x > n) return 0;
	int &ret = memo[x];
	if(ret!=-1) return ret;
	ret = (f(x+1) + f(x+2))%MOD;
	return ret; 
}

int main(){
	memset(memo,-1,sizeof(memo));
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int x;
		scanf("%d",&x);
		fail[x] = 1;
	}
	int ans = f(0);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3840
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cnt = 0
for i in range(n):
    if(a[i]-b[i]>=0):
        cnt += b[i]
    elif(a[i]-b[i]<0):
        cnt += a[i]
        b[i] -= a[i]
        if(a[i+1]-b[i]>=0):
            cnt += b[i]
            a[i+1] -= b[i]
        elif(a[i+1]-b[i]<0):
            cnt += a[i+1]
            a[i+1] = 0
print(cnt)            
            
        

Measured memory_bytes: 18396
#include <bits/stdc++.h>
using namespace std;

int main() {
    string s;
    cin >> s;
    if (s.at(0) == s.at(1) && s.at(1) == s.at(2)) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
// यथा चतुर्भिः कनकं परीक्ष्यते निघर्षणच्छेदनतापताडनैः।
// तथा चतुर्भिः पुरुषः परीक्ष्यते त्यागेन शीलेन गुणेन कर्मणा॥
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv std::vector<int>
#define mapii std::map<int,int>
#define mpaci std::map<char,int>
#define umapii std::unordered_map<int,int>
#define umapci std::unordered_map<char,int>
#define seti std::set<int>
#define useti std::unordered_set<int>
#define qi std::queue<int>
#define qc std::queue<char>
#define sti std::stack<int>
#define stc std::stack<char>
#define endl "\n"
#define test(i) cout<<i<<endl
#define tests(i) cout<<"i: "<<i<<endl;
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
#define all(x) x.begin(),x.end() 
#define printv(v) for(auto x: v){ cout<< x << " ";}
#define pi 3.14159265358979323846
#define setprc(x) setprecision(x)
void file(){
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
bool sortdesk(const pair<int,int> &a, const pair<int,int> &b){return a.ff>b.ff;}
bool sortdesv(const pair<int,int> &a, const pair<int,int> &b){return a.ss>b.ss;}
bool sortascv(const pair<int,int> &a, const pair<int,int> &b){return a.ss<b.ss;}
bool sortasck(const pair<int,int> &a, const pair<int,int> &b){return a.ff<b.ff;}
bool is_prime(int n){if(n==1){return false;}int i=2;while(i*i<=n){if(n%i==0){return false;}i+=1;}return true;}
int gcd(int a, int b){if (b == 0){return a;} return gcd(b, a % b);}
int cntdiv(int n){int cnt=0;for(int i=1;i<=sqrt(n);++i){if(n%i==0){if(n/i==i)++cnt;else{cnt = cnt + 2;}}}return cnt;}
lld posnegmod(lld a,lld b){//return (x%mod+mod)%mod;
long long int r = a % b;
    return r < 0 ? r + b : r;
}
// cout<<fixed<<setprecision(20)
// lld fact(lld n);
// lld nCr(lld n,lld r){return fact(n) / (fact(r) * fact(n - r));}
// lld fact(lld n){ lld res = 1; for(lld i = 2; i <= n; i++){res = res * i;}return res;} 
// const int maxi = 1e6+10;
// vector<lld> v[maxi];
// vector<lld> h(maxi);
// vector<long long> a(maxi,0);
// lld res=0;
// void dfs(int x){
//     if(a[x]){
//         return;
//     }
//     a[x]=1;
//     int flag=1;
//     for(int i:v[x]){
//         if(h[x]<=h[i]){
//             flag=0;
//             break;
//         }
//     }
//     if(flag){
//         ++res;
//     }
// }

void test_case(){
    int a,b,c,d,k;
    cin>>a>>b>>c>>d>>k;
    int x= a*60+b;
    int y= c*60+d;
    if(y-x>=k){
        cout<<y-x-k;
        return;
    }
    cout<<-1;
}

int main(){
    fastio;
    file();
    int T=1;
    // int T;
    // cin>>T;
    for(int nr=1;nr<=T;++nr) {
        // cout<<"Case #"<<nr<<": ";
        test_case();
    }
}


Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
using ll=long long;
using ull=unsigned long long;
template<typename T>using min_queue=priority_queue<T,vector<T>,greater<T>>;
template<typename T>using max_queue=priority_queue<T>;
#define Debug(x) cerr<<#x<<" = "<<x<<endl
#define Debug2(x,y) cerr<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define Rep(i,a,b) for (int i=(a);i<=(b);i++)
#define repit(it,a) for (__typeof(a.begin()) it=a.begin();it!=a.end();++it)
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define printtime eprintf("\n\nTime elasped : %.3f seconds.\n\n",clock()*1.0/1000)
#define RET(p,x) return p<<x<<endl,0
#define all(a) (a).begin(),(a).end()
#define reunique(v) v.erase(unique(all(v)),v.end())
#define sz(a) (int)a.size()
#define X first
#define Y second
#define fill_inf(a) memset(a,-19999873,sizeof(a))
#define fill_neginf(a) memset(a,-19999872,sizeof(a))
#define fill_0(a) memset(a,0,sizeof(a))
#define fill_neg1(a) memset(a,0,sizeof(a))
#define __str__(x) #x
#define sqr(x) ((x)*(x))
const int inf=1e9;
const long long lnf=1e18;
const long long h1=239017,h2=731604233;
const long long mod=1000000007,mod2=1000000009;
const long double pi=3.141592653589793238462643383279;
const long double EPS=1e-9;
int n,m;
vector<string> v;
int main()
{
	ios_base::sync_with_stdio(false);cin.tie();cout.tie();
	cout<<setprecision(15);
	cin>>n>>m;
	swap(n,m);
	if (m!=1)
	{
		m--;
		while (m>=50)
		{
			string s=string(100,'.');
			for (int i=0;i<100;i+=2)
			{
				s[i]='#';
			}
			v.push_back(s);
			s=string(100,'#');
			v.push_back(s);
			m-=50;
		}
		if (m)
		{
			string s=string(100,'.');
			for (int i=0;i<2*m;i+=2)
			{
				s[i]='#';
			}
			v.push_back(s);
			s=string(100,'#');
			v.push_back(s);
		}
	}
	else
	{
		v.push_back('#'+string(99,'.'));
	}
	v.push_back(string(100,'.'));
	n--;
	while (n>=50)
	{
		string s=string(100,'.');
		for (int i=0;i<100;i+=2)
		{
			s[i]='#';
		}
		v.push_back(s);
		s=string(100,'.');
		v.push_back(s);
		n-=50;
	}
	if (n)
	{
		string s=string(100,'.');
		for (int i=0;i<2*n;i+=2)
		{
			s[i]='#';
		}
		v.push_back(s);
	}
	while (v.size()<100) v.push_back(string(100,'.'));
	cout<<"100 100\n";
	for (int i=0;i<v.size();++i)
	{
		cout<<v[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
def count_diff(a,b):
    cnt = 0
    for c1,c2 in zip(a, b):
        if c1 != c2:
            cnt += 1
    return cnt

S = str(input())
T = str(input())
mn = 100000

for i in range(len(S)-len(T)+1):
    s = S[i:i+len(T)]
    x = count_diff(s,T)
    mn = min(mn,x)

print(mn)

Measured memory_bytes: 9060
#include<stdio.h>
#define N 1001
static const int INFTY = (1<<21);

int n, M[N][N];
int color[N], d[N], f[N], tt;
int Q[N*2], head, tail;

void init(){
  head = tail = 1;
}

void enqueue(int x){
  Q[tail++] = x;
}

int empty(){
  return head == tail;
}

int dequeue(){
  int x = Q[head++];
  return x;
}

void bfs(int s){
  int i, u, v;
  init();
  enqueue(s);
  for ( i = 0; i < n; i++ )d[i] = INFTY;
  d[s] = 0;
  while(!empty()){
    u = dequeue();
    for ( v = 0; v < n; v++ ){
      if ( M[u][v] == 0 ) continue;
      if ( d[v] != INFTY ) continue;
      d[v] = d[u] + 1;
      enqueue(v);
    }
  }
  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i+1,((d[i]==INFTY)?(-1):d[i]));
  }
}

main(){
  int  u, k, v, i, j; 

  scanf("%d", &n);

  for ( i = 0; i <n; i++ ){
    for ( j = 0; j <n; j++ ) M[i][j] = 0;
  }
  
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    u--;
    for ( j = 0; j < k; j++ ){
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }
  
  bfs(0);

  return 0;
}



Measured memory_bytes: 2072
/*ITP1_2_D*/
#include<stdio.h>
int main(void){
   int w,h,x,y,r;
   scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
   if(x<r || y<r){
      printf("No\n");
      return 0;
   }
   if(w<x+r || h<y+r){
      printf("No\n");
      return 0;
   }
   printf("Yes\n");
   return 0;
}

Measured memory_bytes: 1816
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N;
    cin >> N;

    vector<int> L(2 * N);
    for (int i = 0; i < 2 * N; i++) {
        cin >> L[i];
    }
    int ans = 0;
    sort(L.begin(), L.end(), greater<int>());
    for (int i = 0; i < 2 * N; i += 2) {
        ans += L[i + 1];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


	public class Main {
		
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			char[] num = sc.next().toCharArray();
			int sum = 0;
			
			for(int i=0;i<num.length;i++) {
				int n = num[i]-'0';
				sum += n;
			}
			
			if(sum%9==0) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
	    }
				
	}
	


Measured memory_bytes: 40500
/*此题打表*/
#include<bits/stdc++.h>//头文件
using namespace std;
int a,b,c;
int main(){
    cin>>a>>b>>c;
    if(a==5&&b==5&&c==7){cout<<"YES"<<endl;return 0;}
    if(a==5&&b==7&&c==5){cout<<"YES"<<endl;return 0;}
    if(a==7&&b==5&&c==5){cout<<"YES"<<endl;return 0;}//三种情况
    else cout<<"NO"<<endl;//其他结果
    return 0;//结束
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using LL = long long;

int main(){
    LL x, y;
    cin >> x >> y;
    LL ans = abs(abs(x)-abs(y));
    if(x*y > 0){
        if(x > y)   ans += 2;
    }else if(x*y < 0){
        ans++;
    }else{
        if(x > y)   ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            ll rev = n / i;
            if(abs(rev - i) >= 2) ans += rev - 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int cur=0,ans=0;
  string s;
  cin>>s;
  s+='A';
  for(int i=0;i<=3;i++){
    if(s[i]=='R') cur++;
    else ans=max(ans,cur), cur=0;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3620
n=int(input())
ans=[0]*10000
for x in range(1,101):
    for y in range(x,101):
        for z in range(y,101):
            k=x**2+y**2+z**2+x*y+y*z+z*x
            if k<=10**4:
                if x==y and x==z:
                    ans[k-1]+=1
                elif x==y and x!=z:
                    ans[k-1]+=3
                elif x!=y and y==z:
                    ans[k-1]+=3
                elif x!=y and x!=z:
                    ans[k-1]+=6
for x in range(n):
    print(ans[x])

Measured memory_bytes: 9272
N=int(input())

answer=999999999999

def digit(N):
 total=0
 listN=list(str(N))
 for i in range(len(listN)):
  total+=int(listN[i])
 return total

for i in range(1,N):
 A=i
 B=N-i
 answer=min(digit(A)+digit(B),answer)

print(answer)
  
 


Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
const int MAXN=100005;

int n,ans=0,a[MAXN];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	for(int i=1;i<=n;++i){
		if(i==a[i]) ++ans,a[i+1]=a[i];
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
static const long long MOD_NUM = 1000000007LL;

static void C_task();
#if 1
int main()
{
	C_task();
	fflush(stdout);
	return 0;
}
#endif
static void C_task()
{
	int N;
	getint(N);
	std::vector<int> xn(N, 0);

	for (int i = 0; i < N; i++) {
		std::cin >> xn[i];
	}

	int sumMin = 1000000 * 2;
	for (int x = 0; x <= 100; x++) {
		int sum = 0;
		for (int i = 0; i < N; i++) {
			sum += (xn[i] - x) * (xn[i] - x);
		}
		sumMin = tp_min(sumMin, sum);
	}
	printf("%d\n", sumMin);
}



Measured memory_bytes: 256
#include <stdio.h>
#define RANGE 10010
 
int C[RANGE] = {0};
 
int main()
{
    int i, j;
    int N;
    int a;
    scanf("%d", &N);
    for (i=0; i<N; i++) {
        scanf("%d", &a);
        C[a]++;
    }
     
    int last = 0;
    for (i=0; i<RANGE; i++) {
        if (C[i] != 0) {
            last = i;
        }
    }
     
    for (i=0; i<last; i++) {
        for (j=0; j<C[i]; j++) {
            printf("%d ", i);            
        }
    }
    for (i=0; i<C[last]-1; i++) {
        printf("%d ", last);
    }
    printf("%d\n", last);
     
    return 0;
}



Measured memory_bytes: 2104
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	long long X, Y;
	scanf("%lld%lld", &X, &Y);
	if (X == 0 || Y == 0) {
		if (X > Y) {
			printf("%lld\n", llabs(Y - X) + 1);
		}
		else if (X < Y) {
			printf("%lld\n", llabs(Y - X));
		}
	}
	else if (X * Y > 0) {
		if (X < Y) {
			printf("%lld\n", Y - X);
		}
		else if (X > Y) {
			printf("%lld\n", X - Y + 2);
		}
	}
	else if (X * Y < 0) {
		printf("%lld\n", llabs(llabs(X) - llabs(Y)) + 1);
	}
	return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		set<int>aset;
		for (int i = 1; i < N; ++i) {
			int k = (i*i) % N;
			aset.emplace(k);
		}
		vector<int>nums(N);
		for (auto it = aset.begin(); it != aset.end(); ++it) {
			for (auto jt =next( it); jt != aset.end(); ++jt) {
				int sa = *it - *jt;
				if (sa < 0)sa += N;
				if (sa > (N - 1) / 2)sa = N - sa;
				nums[sa]++;
			}
		}
		for (int i = 1; i <= (N - 1) / 2; ++i) {
			cout << nums[i]*2 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3264
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <fstream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <assert.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(s) begin(s),end(s)
#define ITE(c) typeof((c).begin())
#define VIEW(dat) for(auto v : dat){cout<<v<<endl;}
#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(a,b) make_pair((a),(b))

using namespace std;

int main(){
	int m, S, s, y, n, t, c;
	double p;
	vector<int> dat;

	//ifstream cin("in.txt");

	cin>>m;
	rep(I,m){
		cin>>S>>y>>n;
		dat.clear();
		dat.reserve(n);
		rep(i,n){
			cin>>t>>p>>c;
			s=S;
			if(t){
				rep(j,y){
					double B=s*p;
					s+=B-c;
				}
				dat.push_back(s);
			}else{
				int r=0;
				rep(j,y){
					double B=s*p;
					s-=c;
					r+=B;
				}
				dat.push_back(s+r);
			}
		}
		sort(ALL(dat));
		cout<<dat[n-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRT(v) sort(v.begin(),v.end())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int a;
    cin >> a;
    //処理
    //出力
    if(a<=999) cout << "ABC" << ENT;
  	else cout << "ABD" << ENT;
    return 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 5e5 + 5;
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        //freopen("test.txt", "r", stdin);
        ll x, y, z;
        cin >> x >> y >> z;
        swap(x, y);
        swap(x, z);
        cout << x << " " << y << " " << z;
}
/*
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main(){

    string S,T;
    cin >> S >>T;

    int ans=0;
    for (size_t i = 0; i < 3; i++)
    {
        if(S[i]==T[i])ans++;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int64_t gcd(int64_t a, int64_t b){
	return (b > 0)? gcd(b, a % b) : a ;
}

int64_t lcm(int64_t a, int64_t b){
	return a / gcd(a, b) * b;
}

int main(void) {
    int64_t N, M;
    cin >> N >> M;
    vector<int64_t> a(N);
    for(int i=0; i<N; i++) {
        cin >> a[i];
        a[i] >>= 1;
    }

    vector<int> d(N);
    for(int i=0; i<N; i++) {
        for(int j=0; ; j++) {
            if(a[i] >> j & 1) {
                d[i] = j;
                break;
            }
        }
    }
    if(count(d.begin(), d.end(), d[0]) != N) {
        cout << 0 << endl;
        return 0;
    }

    int64_t l = 1;
    for(int i=0; i<N; i++) {
        l = lcm(l, a[i]);
        if(l > M) {
            cout << 0 << endl;
            return 0;
        }
    }

    cout << M/l - M/(2*l) << endl;
    return 0;
}


Measured memory_bytes: 1408
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n,l;cin>>n>>l;
  vi x;
  rep(i, 0, n){ x.pb(l+i); }
  sort(
      all(x),
      [&](auto &left, auto &right){return abs(left) < abs(right);}
      );
  dump(x);
  cout << accumulate(x.begin()+1, x.end(), 0LL) << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl
 
using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;
 
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;
 
template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }
 
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    vi n(3);
    REP(i,3) cin >> n[i];
    sort(ALL(n));
    cout << n[0] + n[1] << endl;
}

Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    //中間m、期末f、再試験r
    //int m, f, r;
    int m = 0;
    int f = 0;
    int r = 0;
    int sum =0;
    
    while(m!=-1 || f!=-1 || r!=-1){
        cin >> m >> f >> r;
        
        sum = m + f;
        
        if(m==-1 && f==-1 && r==-1){
            break;
        }
        
        if(m ==-1 || f ==-1){
            cout << "F" << endl;
        }else {
            if(sum >= 80){
                cout << "A" << endl;
            }else if(sum >= 65){
                cout << "B" << endl;
            }else if((sum >= 50) || r >= 50){
                cout << "C" << endl;
            }else if(sum >= 30){
                cout << "D" << endl;
            }else{
                cout << "F" << endl;
            }    
        }
    }
    
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;

using P = pair<long, long>;

int main(){
    int N, M;
    vector<P> p;
    cin >> N >> M;
    
    for (int i = 0; i < N; ++i) {
        int Ai, Bi;
        cin >> Ai >> Bi;
        p.push_back(P(Ai, Bi));
    }
    
    long m = 0, c = 0;
    
    sort(p.begin(), p.end(), [](P &f, P &s){ return f.first < s.first; });
    
    for (int i = 0; i < p.size(); ++i) {
        int n = M - c;
        int b = 0;
        auto pi = p[i];
        
        if (pi.second >= n) b = n;
        else b = pi.second;
        
        m += b * pi.first;
        c += b;
        
        if (c >= M) break;
    }
    
    cout << m << endl;
}


Measured memory_bytes: 2420
k=int(input())
two={4,6,9,10,14,21,22,25,26}
f={8,12,18,20,27}
if k in two:
    print(2)
elif k in f:
    print(5)
elif k==16:
    print(14)
elif k==24:
    print(15)
elif k==28 or k==30:
    print(4)
elif k==32:
    print(51)
else:
    print(1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;

int main() { /* ここに書く */

  long long X,N;
  cin >> X;
  N = 100;
  
  int i = 0;
  
  while( N<X )
  { N = N*1.01;
  i++;}
  
  cout << i << endl;
  
    }

Measured memory_bytes: 3540
x,k,d = map(int,input().split())
if x==0:
	print((k%2)*d)
	exit(0)
l = 1
h = k
ans = float('inf')
much = float('inf')
pos = x
if x>0 : di = -1
elif x<0: di=1
while l<=h:
	# ~ print("l",l,"h",h)
	m = (l+h)//2
	# ~ print("m",m)
	tmp = x+di*m*d
	# ~ print("tmp",tmp)
	if tmp>0:
		if x>0 : l=m+1
		else: h = m-1
		# ~ print("l",l,"h",h)
	elif tmp<0:
		if x>0: h = m-1
		else:l=m+1
		# ~ print("l",l,"h",h)
	else:
		ans = 0
		much = m
		break
	if abs(tmp) < ans:
		ans = abs(tmp)
		much = m
		# ~ print("much",much,"ans",ans)
	# ~ print("\n\n\n\n")
reste = k-much
if reste%2==0: print(ans)
else:print(min(abs(ans+d), abs(ans-d)))


Measured memory_bytes: 9164
#include <stdio.h>
#include <stdlib.h>

int main()
{   int a,b,c,d;
    while(scanf("%d%d%d",&a,&b,&c)==3)
    {
        a=a-b;
        d=a%c;
        printf("%d\n",d);
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <vector>

#define FOR(i, n) for (int i = 0; i < n; i++)

using namespace std;

int main(){
    cin.tie(NULL);
    cout.tie(NULL);
    ios_base::sync_with_stdio(false);
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--, b--, c--, d--;
    vector<bool> x(n);
    FOR (i, n){
        char e;
        cin >> e;
        x[i] = (e == '#');
    }
    if (c < d){
        for (int i = a; i < c; i++)
            if (x[i] && x[i + 1]){
                cout << "No" << endl;
                return 0;
            }
        for (int i = b; i < d; i++)
            if (x[i] && x[i + 1]){
                cout << "No" << endl;
                return 0;
            }
        cout << "Yes" << endl;
        return 0;
    }
    for (int i = a; i < c; i++)
        if (x[i] && x[i + 1]){
            cout << "No" << endl;
            return 0;
        }
    for (int i = b - 1; i < d; i++)
        if (!x[i] && !x[i + 1] && !x[i + 2]){
            cout << "Yes" << endl;
            return 0;
        }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	
	int n;
	cin >> n;
	
	int ans = n;
	for(int i = 0; i <= n; i++){
		int cnt = 0;
		int t = i;
		while(t > 0){
			cnt += t % 6;
			t /= 6;
		}
		t = n - i;
		while(t > 0){
			cnt += t % 9;
			t /= 9;
		}
		if(ans > cnt) ans = cnt;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<time.h>
#include<stdlib.h>
#include<math.h>
#include<cmath>
#include<iomanip>

using namespace std;

int main(){
    double a = 0; double b = 0; double x = 0;
    cin >> a; cin >> b; cin >> x;
    double th = 0;
    if(x == 0.5*a*a*b){
        th = atan(a/b);
    }
    else if(x < 0.5*a*a*b){
        double l = (2*x)/(b*a);
        th = atan(l/b);
    }
    else{
        double k = 2*(b - x/(a*a));
        th = atan(a/k);
    }
    double ans = 90 - (th/M_PI)*180;
    std::cout << std::fixed;
    std::cout << std::setprecision(8) << ans; // "3.14"
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(void){


int n,i,ai,max,min;


double sum;


sum=0.0;


max=-1000000;


min=1000000;


scanf("%d",&n);


for(i=0;i<n;i++){


scanf("%d",&ai);


if(ai<min){


min=ai;


}


if(max<ai){


max=ai;


}


sum=sum+ai;


}


printf("%d %d %.0lf\n",min,max,sum);


return 0;


}

Measured memory_bytes: 632
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<random>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define inf 1145141919
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int>P;
typedef pair<int, P> PP;
struct edge { int to, cost; };

signed main() {
	int x, y; cin >> x >> y;
	cout << x + y / 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
const ll maxn = 2e6+100;
const ll mod=1e9+7;

ll gt[maxn];
ll gt1[maxn];
ll tich[maxn];
ll nck(ll n,ll k)
{
    return ((gt[n]*gt1[n-k])%mod*gt1[k])%mod;
}
ll mu(ll a,ll n)
{
    if (n==1) return a;
    if (n==0) return 1;
    ll h=mu(a,n/2);
    if (n%2==0)
    {
        return (h*h)%mod;
    }
    return ((h*h)%mod*a)%mod;

}
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // freopen("test.txt", "r", stdin);
    if (fopen("pump.in","r"))
    {
        freopen("pump.in","r", stdin);
        freopen("pump.out", "w",stdout);
    }
    ll n;
    cin>>n ;
    if (n==1)
    {
        cout <<0;
        return 0;
    }
   ll ans=0;
   tich[0]=1;
   gt[0]=1;
   for (int i=1;i<maxn;i++)
   {
       gt[i]=(gt[i-1]*i)%mod;
   }
   gt1[maxn-1]=mu(gt[maxn-1],mod-2);
   for (int i=maxn-2;i>=0;i--)
   {
       gt1[i]=(gt1[i+1]*(i+1))%mod;
   }
   for (int i=1;i<=n;i++)
   {
       tich[i]=(tich[i-1]*8)%mod;
   }
   ll nw=2;
   for (int i=2;i<=n;i++)
   {
      nw*=2;
      nw%=mod;
      ans=(ans+(tich[n-i]*((nw-2+mod)%mod)%mod*nck(n,i)))%mod;
   }
   cout <<ans;








}


Measured memory_bytes: 42600
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int parent[MAX]; /* 集合 */

void initSet(int n) /* 集合の初期化 */
{
  rep(i, 0, n + 1) parent[i] = i;
}

int root(int x) /* 集合の根を探索 */
{
  if (x == parent[x])
    return x;
  return parent[x] = root(parent[x]);
}

int main(void)
{
  lli n, m;
  scanf("%lld %lld", &n, &m);

  int a[MAX], b[MAX];
  rep(i, 0, m) scanf("%d %d", &a[i], &b[i]);

  initSet(n);
  lli size[MAX]; // size[i]: 島iを根とする集合のサイズ
  rep(i, 0, n + 1) size[i] = 1;
  lli inc[MAX];
  inc[m] = n * (n - 1) / 2;
  for (int i = m - 1; i > 0; i--)
  {
    int ra = root(a[i]);
    int rb = root(b[i]);
    if (ra == rb)
      inc[i] = inc[i + 1];
    else
    {
      inc[i] = inc[i + 1] - (size[rb] * size[ra]);
      parent[ra] = rb;
      size[rb] += size[ra];
    }
  }

  rep(i, 1, m + 1) printf("%lld\n", inc[i]);

  return 0;
}


Measured memory_bytes: 3968
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int64_t> a(3*N);
    for(int i=0; i<3*N; i++) {
        cin >> a[i];
    }

    vector<int64_t> l(N+1);
    l[0] = accumulate(a.begin(), a.begin()+N, 0L);
    priority_queue<int64_t, vector<int64_t>, greater<int64_t>> pq1;
    for(int i=0; i<N; i++) {
        pq1.emplace(a[i]);
    }
    for(int i=1; i<=N; i++) {
        int64_t A = a[N+i-1];
        if(A > pq1.top()) {
            l[i] = l[i-1] - pq1.top() + A;
            pq1.pop();
            pq1.emplace(A);
        } else {
            l[i] = l[i-1];
        }
    }

    vector<int64_t> r(N+1);
    r[N] = accumulate(a.end()-N, a.end(), 0L);
    priority_queue<int64_t> pq2;
    for(int i=3*N-1; i>=2*N; i--) {
        pq2.emplace(a[i]);
    }
    for(int i=N-1; i>=0; i--) {
        int64_t A = a[N+i];
        if(A < pq2.top()) {
            r[i] = r[i+1] - pq2.top() + A;
            pq2.pop();
            pq2.emplace(A);
        } else {
            r[i] = r[i+1];
        }
    }

    int64_t ans = numeric_limits<int64_t>::min();
    for(int i=0; i<=N; i++) {
        ans = max(ans, l[i] - r[i]);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6516
#include<iostream>
#include<algorithm>
using namespace std;
int a[10000], b[10000], w, h;
int solve(int i) {
	int x = 0, y = 0, ans = 0, j;
	x = max(a[i] - a[i + 1], a[i + 1] - a[i]);
	y = max(b[i] - b[i + 1], b[i + 1] - b[i]);
	ans = ans + x + y;
	for (j = 0;j<=min(w,h) ; j++) {
		if (a[i] - a[i + 1] > j && b[i] - b[i+1] > j) ans--;
		else if(a[i + 1] - a[i] > j && b[i + 1] - b[i] > j) ans--;
	}
	return ans;
}
int main() {
	int n, i, answer = 0;
	cin >> w >> h >> n;
	for (i = 1; i <= n; i++) {
		cin >> a[i] >> b[i];
	}
	for (i = 1; i < n; i++) {
		answer = solve(i) + answer;
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <vector>

int main() {
	int n, w;
	std::cin >> n >> w;
	std::vector<int> min_weight(n * 100 + 1, w + 1);
	min_weight[0] = 0;
	int value, weight;
	for (auto i = 0; i < n; ++i) {
		std::cin >> value >> weight;
		for (auto value_index = min_weight.size() - 1; value_index >= value; --value_index) {
			if (min_weight[value_index] > min_weight[value_index - value] + weight)
				min_weight[value_index] = min_weight[value_index - value] + weight;
		}
	}
	for (int i = min_weight.size() - 1; i >= 0; --i) {
		if (min_weight[i] != w + 1) {
			std::cout << i << std::endl;
			break;
		}
	}
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
void solve()
{
    string s,t;
    cin>>s>>t;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]!=t[i])
        {
            cout<<"No";
            return;
        }
    }
    if(s.length()-t.length()!=-1)
    {
        cout<<"No";
        return;
    }
    cout<<"Yes";
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 100000;
int N,M,Q;
int A[Nmax], B[Nmax], D[Nmax], C[Nmax], V[Nmax];
int color[Nmax], dmax[Nmax];
vector<vector<int> > graph;

void colorize(int v, int d, int c){
	if(dmax[v] >= d) return;
	dmax[v] = d;
	if(color[v] == 0) color[v] = c;
	//cout << v << ":" << c << endl;
	if(d == 0) return;
	for(int i=0; i<graph[v].size(); i++){
		colorize(graph[v][i], d-1, c);
	}
}

int main(){
	cin >> N >> M;
	graph = vector< vector<int> >(N);
	for(int i=0; i<M; i++){
		cin >> A[i] >> B[i];
		A[i]--;
		B[i]--;
		graph[A[i]].push_back(B[i]);
		graph[B[i]].push_back(A[i]);
	}
	cin >> Q;
	for(int i=0; i<Q; i++){
		cin >> V[i] >> D[i] >> C[i];
		V[i]--;
	}

	for(int i=0; i<N; i++) dmax[i] = -1;
	for(int i=Q-1; i>=0; i--){
		colorize(V[i], D[i], C[i]);
	}

	for(int i=0; i<N; i++){
		//cout << color[i] << " " << dmax[i] << endl;
		cout << color[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 9176
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main(){
	int n,r; cin >> n >> r;
	if(n >= 10) cout << r << endl;
	else{
		cout << r + 100 * (10-n) << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        String res;
        if((B-A-1)%2==0){
            res = "Borys";
        }else{
            res = "Alice";
        }
        
        System.out.println(res);
        
        }
    }

Measured memory_bytes: 35884
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] pow2 = {1,2,4,8,16,32,64};
		for(int i = 6; i >= 0; i--){
			if(N >= pow2[i]){
				System.out.println(pow2[i]);
				break;
			}
		}
	}
}

Measured memory_bytes: 21972
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b){return *(int*)a - *(int*)b;}
int main(void){
	int n,m,ans=0;
	scanf("%d %d",&n,&m);
	int x[m];
	for(int i=0;i<m;i++)scanf("%d",&x[i]);
	qsort(x, m, sizeof(int), compare_int);
	int diff[m-1];
	for(int i=0;i<m-1;i++){
		diff[i] = x[i+1] - x[i];
	}
	qsort(diff, m-1, sizeof(int), compare_int);
	for(int i=0;i<m-n;i++){
		ans += diff[i];
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1396
#include <cstdio>
#include <queue>
#include <algorithm>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> P;

int n, m;
char c[1000][1001];

int main(){
	scanf("%d%d", &n, &m);
	rep(i, n){
		scanf("%s", c[i]);
	}

	queue<P> q;
	rep(i, n){
		rep(j, m){
			if(c[i][j] != '.'){
				q.push(P(i, j));
			}
		}
	}

	int a = 0;
	while(!q.empty()){
		/*
		rep(i, n){
			puts(c[i]);
		}
		printf("%d\n", q.size());
		*/

		set<P> s;
		set<P> t;
		int y = q.size();
		rep(k, y){
			P v = q.front();
			q.pop();
			if(c[v.first][v.second] == '.'){
				continue;
			}
			int z = 0;
			
			for(int i = -1; i <= 1; ++i){
				for(int j = -1; j <= 1; ++j){
					int x = v.first + i;
					int y = v.second + j;
					if((i != 0 || j != 0) && 0 <= x && x < n && 0 <= y && y < m){
						if(c[x][y] == '.'){
							++z;
						}
					}
				}
			}
			if(z >= c[v.first][v.second] - '0'){
				s.insert(v);
				for(int i = -1; i <= 1; ++i){
					for(int j = -1; j <= 1; ++j){
						int x = v.first + i;
						int y = v.second + j;
						if((i != 0 || j != 0) && 0 <= x && x < n && 0 <= y && y < m){
							if(c[x][y] != '.'){
								t.insert(P(x, y));
							}
						}
					}
				}
			}
		}
		if(!s.empty()){
			++a;
		}
		for(auto it = s.begin(); it != s.end(); ++it){
			c[it->first][it->second] = '.';
			// printf("s %d\n", s.size());
		}
		for(auto it = t.begin(); it != t.end(); ++it){
			q.push(*it);
			// printf("t %d\n", t.size());
		}
	}
	printf("%d\n", a);
	return 0;
}

Measured memory_bytes: 11456
#include <iostream>
#include <vector>
using namespace std;

int main ()
{
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; ++i) {
      cin >> A[i];
  }
  long long ans = 0;
  for (int i = 0; i < N - 1; ++i) {
    long long diff = A[i+1] - A[i];
    if (diff < 0) {
      ans += -1 * diff;
      A[i+1] += -1 * diff;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(v) sort(all(v)),v.erase(unique(all(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    //freopen("input.txt", "r", stdin);
  #endif // LOCAL
  double r;
  cin >> r;
  cout << setprecision(10) << fixed;
  cout << 2.0 * pi * r << endl;
  return 0;
}



Measured memory_bytes: 3804
#include<iostream>
#include<sstream>
using namespace std;

template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main()
{
  int m;
  cin>>m;
  for(;m--;)
    {
      long long int money;
      cin>>money;
      int year;
      cin>>year;
      int n;
      cin>>n;
      long long int ans=0;
      for(;n--;)
	{
	  int a,c;
	  double b;
	  long long int tmp=money;
	  cin>>a>>b>>c;
	  if(a==0)
	    {
	      int risi=0;
	      for(int i=0;i<year;i++)
		{
		  risi+=tmp*b;
		  tmp-=c;
		}
	      ans=max(ans,risi+tmp);
	    }
	  else
	    {
	      for(int i=0;i<year;i++)
		{
		  tmp+=tmp*b;
		  tmp-=c;
		}
	      ans=max(ans,tmp);
	    }
	}
      cout<<ans<<endl;
    }
}

Measured memory_bytes: 1232
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, X = MAP()
A = LIST()

dp = list2d(N, N, INF)
for i in range(N):
    k = 0
    for j in range(i, i-N, -1):
        j %= N
        dp[i][k] = min(dp[i][(k-1)%N], A[j])
        k += 1

ans = [0] * N
for i in range(N):
    for j in range(N):
        ans[j] += dp[i][j]
    ans[i] += i * X
print(min(ans))


Measured memory_bytes: 73564
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで

int main() {
    // 入力
    int n;
    cin >> n;
    pair<pair<string, int>, int> pair_data[110];

    rep(i, n) {
        string restaurant;
        int    score;
        cin >> restaurant >> score;
        auto tmp = restaurant;

        // 要素を追加 make_pair(キー、値)
        pair_data[i] = make_pair(make_pair(restaurant, -score), i);
    }

    // 処理
    sort(pair_data, pair_data + n);

    // 出力
    rep(i, n) { cout << pair_data[i].second + 1 << endl; }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
	cin>>a>>b>>c;
	int minv=999999999;
	if(a+b<minv)minv=a+b;
	if(a+c<minv)minv=a+c;
	if(c+b<minv)minv=c+b;
	cout<<minv;
	return 0;
}


Measured memory_bytes: 256