akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int h, w;
	cin >> h >> w;
	vector<vector<int>> v(h, vector<int>(w));
	rep(i,h) rep(j,w) cin >> v[i][j];
	vector<pair<pii, pii>> ans;
	int k = 0;
	int li = h - 1;
	int lj = h % 2 == 0 ? 0: w - 1;
	for (int i = 0; i < h; i++) {
		if (i % 2 == 0) {
			for (int j = 0; j < w; j++) {
				if (i == li && j == lj) continue;
				if (k == 0) {
					if (v[i][j] % 2 == 0) continue;
					else {
						int ni = j != w - 1? i: i + 1;
						int nj = j != w - 1? j + 1: j;
						ans.push_back(make_pair(make_pair(i, j), make_pair(ni, nj)));
						k = 1;
					}
				} else {
					if (v[i][j] % 2 == 1) k = 0;
					else {
						int ni = j != w - 1? i: i + 1;
						int nj = j != w - 1? j + 1: j;
						ans.push_back(make_pair(make_pair(i, j), make_pair(ni, nj)));
					}
				}
			}
		} else {
			for (int j = w - 1; j >= 0; j--) {
				if (i == li && j == lj) continue;
				if (k == 0) {
					if (v[i][j] % 2 == 0) continue;
					else {
						int ni = j != 0 ? i: i + 1;
						int nj = j != 0 ? j - 1: j;
						ans.push_back(make_pair(make_pair(i, j), make_pair(ni, nj)));
						k = 1;
					}
				} else {
					if (v[i][j] % 2 == 1) k = 0;
					else {
						int ni = j != 0 ? i: i + 1;
						int nj = j != 0 ? j - 1: j;
						ans.push_back(make_pair(make_pair(i, j), make_pair(ni, nj)));
					}
				}
			}
		}
	}
	int n = ans.size();
	cout << n << endl;
	rep(i,n) {
		cout << 1 + ans[i].first.first << " " << 1 + ans[i].first.second << " " << 1 + ans[i].second.first << " " <<	1 + ans[i].second.second << endl;
	}
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 6368
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> dp(n + 1, 1e9);
  dp[0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 1; i + j <= n; j *= 6) {
      dp[i + j] = min(dp[i + j], dp[i] + 1);
    }
    for (int j = 1; i + j <= n; j *= 9) {
      dp[i + j] = min(dp[i + j], dp[i] + 1);
    }
  }
  cout << dp[n] << endl;
  return 0;
}

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

#define MAX 100001

struct Node {
	int p, l, r;
};

Node T[MAX];
int D[MAX];

void show (int u) {
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";
	
	if(T[u].p == -1)        cout << "root, ";
	else if(T[u].l == -1)   cout << "leaf, ";
	else                    cout << "internal node, ";
	
	cout << "[";
	int c = T[u].l;
	for(int i = 0; c != -1; ++i) {
		if(i != 0)   cout << ", ";
		cout << c;
		c = T[c].r;
	}
	cout << "]" << endl;
}

int rec(int u, int p) {
	D[u] = p;
	if(T[u].r != -1)   rec(T[u].r, p);
	if(T[u].l != -1)   rec(T[u].l, p + 1);
}

int main(void) {
	int n, d, v, c, l, r;
	
	cin >> n;
	for(int i = 0; i < n; ++i) {
		T[i].p = T[i].r = T[i].l = -1;
	}
	
	for(int i = 0; i < n; ++i) {
		cin >> v >> d;
		for(int j = 0; j < d; ++j) {
			cin >> c;
			if(j == 0)   T[v].l = c;
			else T[l].r = c;
			l = c;
			T[c].p = v;
		}
	}
	
	r = 0;
	while(T[r].p != -1)   ++r;
	
	rec(r, 0);
	
	for(int i = 0; i < n; ++i)   show(i);
	
	return 0;
}



Measured memory_bytes: 7780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;


main(){
    int l,r,d;
    cin>>l>>r>>d;
    int count=0;
    for(int i=l;i<=r;i++){
        if(i%d == 0) count++;
    }
    cout<<count;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<limits.h>
#include<math.h>

int int_comp(const void*a,const void*b){return *(int*)a-*(int*)b;}
int frag[100];
int num[100];
void fx(int n,int k)
{
    int f,i,j;
    for(i=0;i<n;i++){
        f=frag[i];
        if(f==0){
            frag[i]=1;
            num[n-k]=i+1;
            if(k==1){
                //num[]に数字が入ってる
            }
            else{
                fx(n,k-1);
            }
            frag[i]=0;
        }
    }
}

int main()
{
    char c;

    scanf("%c",&c);
    printf("%c\n",c+1);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <math.h>
#include <map>
using namespace std;
int n;
int main(){
    cin >> n;
    string w[n];
    for(int i=0; i<n; i++) cin >> w[i];
    bool match = 1;
    bool dup = 1;
    for(int i=0; i<n-1; i++){
        if(w[i].back() != w[i+1].front()){
            match = false;
        }
    }
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            if(w[i] == w[j]){
                dup = false;
            }
        }
    }
    if(dup && match){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,w;
    cin>>n>>w;
    vector<ll>dp(w+1);
    for(ll i=0;i<n;i++)
    {
        ll n1,w1;
        cin>>w1>>n1;
        for(ll j=(w-w1);j>=0;j--)
        {
            dp[j+w1]=max(dp[j+w1],dp[j]+n1);
        }
    }
    cout<<dp[w];

}


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

int main() {
 int n,d,cnt=0,sum;
 double sn;
 cin >> n >> d;
 vector<vector<int>> a(n, vector<int>(d));
 for(int i=0;i<n;i++){
   for(int j=0;j<d;j++){
   cin >> a[i][j];
   }
 }
 for(int i=0;i<n;i++){
   for(int m=i+1;m<n;m++){
     sum=0;
     for(int j=0;j<d;j++){
        sum+=pow(abs(a[i][j]-a[m][j]),2);
     }
     sn=sqrt(sum);
     if(sn==ceil(sn))cnt++;
   }
 }
 cout << cnt << endl;
}


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

using namespace std;


int main(){
	long long N,M;
	cin>>N>>M;
	string s;
	cin>>s;
	reverse(s.begin(),s.end());
	vector<long long> out;
	long long nowpos=0;
	long long nextpos=0;
	while(true){
		for(int i=M; i>=0; i--){
			nextpos = nowpos+i;
			if(i==0){
				cout<<-1<<endl;
				return 0;
			}
			if(nextpos<s.size()){
				if(s[nextpos]=='0'){
					out.push_back(i);
					nowpos=nextpos;
					break;
				}
			}
		}
		if(nextpos==s.size()-1){
			break;
		}
	}
	reverse(out.begin(),out.end());
	for(int i=0; i<out.size(); i++){
		cout<<out[i]<<endl;
	}


	return 0;
}


Measured memory_bytes: 1528
n,k,c=map(int, input().split())
s=input()
L=[0]*k
R=[0]*k
m=0
l=0
for i in range(k):
    while s[m]=="x":
        m+=1
    L[i]=m
    m+=c+1
    while s[n-l-1]=="x":
        l+=1
    R[i]=n-l-1
    l+=c+1
for i in range(k):
    if R[k-i-1]==L[i]:
        print(L[i]+1)

Measured memory_bytes: 50764
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<int> A;
void input(){
    fast_io();
    cin >> N;
    A = fetch_vec<int>(N);
}

int solve(){
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if(i%2==0 && A[i]%2==1) ans++;
    }
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <vector>
#include <climits>
typedef long long ll;
using namespace std;
int main() {
    ll N, min = LLONG_MAX;
    vector<ll> A(5);
    cin >> N;
    for (int i = 0; i < 5; i++) {
        cin >> A[i];
        if (A[i] < min) {
            min = A[i];
        }
    }
    cout << (ll)ceil(N / (double)min) + 4 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, n) for (int i = 1; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    
    vector<int> S(1000010, 0);
    rep(i, N) ++S[A[i]];
    int ans = 0;
    rep(i, N) {
        bool flag = true;
        for (int j = 1; j * j <= A[i]; ++j) {
            if (A[i] % j == 0) {
                if (j == A[i]) {
                    if (S[j] - 1) flag = false;
                } else {
                    if (S[j]) flag = false;
                }
                if (A[i] / j == A[i]) {
                    if (S[A[i] / j] - 1) flag = false;
                } else {
                    if (S[A[i] / j]) flag = false;
                }
            }
        }
        if (flag) ++ans;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 7932
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

template <class T>
void read(T &x)
{
	char ch;
	for (ch=getchar();(ch<'0'||ch>'9')&&ch!='-';) ch=getchar();
	x=0;int t=1;if (ch=='-') {ch=getchar();t=-1;}
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	x*=t;
}

int main()
{
	unsigned a,b,c;scanf("%u%u%u",&a,&b,&c);
	if (a+b<c) printf("%u\n",a+b+1+b); else printf("%u\n",b+c); 
	return 0;
}


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


int main() {
	long long int n,m;
	cin>>n>>m;
    if(n%m==0){
        cout<<0<<endl;
    }else{
        long long int z=n%m;
        long long int ans=min(z,abs(z-m));
        cout<<ans<<endl;
    }

	return 0;
}

Measured memory_bytes: 256
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

A = []
B = [[False for i in range(3)] for j in range(3)]
l = []
for i in range(3):
    A.append(iil())
    for item in A[i]:
        l.append(item)


n = ii()
for i in range(n):
    call = ii()
    if call in l:
        p = l.index(call)
        B[p//3][p%3] = True

if B[0][0]*B[0][1]*B[0][2] == 1:
    print('Yes')
elif B[1][0]*B[1][1]*B[1][2] == 1:
    print('Yes')
elif B[2][0]*B[2][1]*B[2][2] == 1:
    print('Yes')
elif B[0][0]*B[1][1]*B[2][2] == 1:
    print('Yes')
elif B[0][2]*B[1][1]*B[2][0] == 1:
    print('Yes')
elif B[0][0]*B[1][0]*B[2][0] == 1:
    print('Yes')
elif B[0][1]*B[1][1]*B[2][1] == 1:
    print('Yes')
elif B[0][2]*B[1][2]*B[2][2] == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
// import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        ) {

      String[] lns = in.readLine().split(" ");
      int n = Integer.parseInt(lns[0]);
      int m = Integer.parseInt(lns[1]);
      City[] city = new City[m];
      City[] city2 = new City[m];
      int[] p = new int[n+1];

      int x,y;
      for(int i=0; i<m; i++) {
        lns = in.readLine().split(" ");
        x = Integer.parseInt(lns[0]);
        y = Integer.parseInt(lns[1]);
        city2[i] = city[i] = new City(i, x, y);
      }

      Arrays.parallelSort(city2, new Comparator<City>() {
        public int compare(City a, City b) {
          if(a.y == b.y) return 0;
          return a.y > b.y ? 1 : -1;
        }
      });

      for (City c : city2)
        c.no = ++p[c.p];

      // String no;
      StringBuilder buf = new StringBuilder();
      String[] pre0 = {"000000","00000","0000","000","00","0",""};
      for(int i=0; i<m; i++) {
        // no = String.format("%06d%06d", city[i].p,city[i].no);
        buf.append(pre0[len(city[i].p)])
           .append(city[i].p);

        buf.append(pre0[len(city[i].no)])
           .append(city[i].no)
           .append('\n');
        // out.println(no);
      }
      // out.flush();
      System.out.print(buf);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  int len(int n) {
    int i=1;
    for(int j=10; ; i++,j*=10)
      if(n<j) break;
    return i;
  }
  class City {
    int s;
    int p;
    int y;
    int no;

    public City(int s, int p, int y) {
      this.s = s;
      this.p = p;
      this.y = y;
    }
  }
}

Measured memory_bytes: 53988
#include<stdio.h>
#define MAX 100000

int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}

int main(){
	int H, i, A[MAX+1];
	scanf("%d",&H);
	
	for(i=1;i<= H;i++){
		scanf("%d",&A[i]);
	}
	
	for(i=1;i<= H;i++){
		printf("node %d: key = %d, ",i,A[i]);
		if(parent(i)>=1){
			printf("parent key = %d, ",A[parent(i)]);
		}
		if(left(i)<=H){
			printf("left key = %d, ",A[left(i)]);
		}
		if(right(i) <= H){
			printf("right key = %d, ",A[right(i)]);
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 2116
import sys
n=int(input())
dp=[0,0,0]


for _ in range(n):
    c=list(map(int,input().split()))
    ndp=[0,0,0]
    for i in range(3):
        for j in range(3):
            if i!=j:
                ndp[j]=max(ndp[j],dp[i]+c[i])
    dp=ndp

print(max(dp))


Measured memory_bytes: 46680
def count_data(s):
    judge_list = ['AC', 'WA', 'TLE', 'RE']
    for judge in judge_list:
        ans = s.count(judge)
        print('{} x {}'.format(judge, ans))

n = int(input())
s = []
for i in range(n):
    s.append(input())

count_data(s)


Measured memory_bytes: 16240
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    if(__builtin_popcount(n)==1) {printf("No\n");return 0;}
    printf("Yes\n");
    if(n&1)
    {
        for(int i=1;i<3;i++)
            printf("%d %d\n",i,i+1);
        printf("%d %d\n",3,1+n);
        for(int i=1;i<3;i++)
            printf("%d %d\n",i+n,i+1+n);
        for(int i=4;i<=n;i+=2)
        {
            printf("%d %d\n",i,i+1);
            printf("%d %d\n",i+1,1);
            printf("%d %d\n",1,i+n);
            printf("%d %d\n",i+n,i+n+1);
        }
    }
    else
    {
        for(int i=1;i<3;i++)
            printf("%d %d\n",i,i+1);
        printf("%d %d\n",3,1+n);
        for(int i=1;i<3;i++)
            printf("%d %d\n",i+n,i+1+n);
        for(int i=4;i<n;i+=2)
        {
            printf("%d %d\n",i,i+1);
            printf("%d %d\n",i+1,1);
            printf("%d %d\n",1,i+n);
            printf("%d %d\n",i+n,i+n+1);
        }
        int x,y;
        for(int i=0;;i++)
        {
            if(1<<i&n)
            {
                x=1<<i;break;
            }
        }
        y=n^x^1;
        //cout<<"X:"<<x<<' '<<y<<endl;
        printf("%d %d\n",n,y);
        printf("%d %d\n",n+n,x==2?2:(x+n));
    }
}


Measured memory_bytes: 2304
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    int n;
    cin >> n;
    vector<ll> a(n), b(n+1);
    REP(i, n) cin >> a[i];

    REP(i, n) b[a[i]] = i+1;

    REP(i, n-1) cout << b[i+1] << " ";
    cout << b[n];
    cout << endl;
    return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i<b; i++)
typedef long long ll;
int main() {
    
    long long int ans,k,a,b;
    cin >> k >> a >> b;
    
    if(b-a >= 2) {
        long long int cnt = (k-(a-1))/2;
        ans = a;
        ans += cnt * (abs(b-a));
        ans += (k-(a-1))%2;
        cout << ans << endl;
    } else {
        cout << k+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;

int power(int b,int e,int p){
	int ret = 1;
	while(e>0){
		if((e&1)!=0){	
			ret = (ret*b)%p;
		}
		b = (b*b)%p;
		e>>=1;
	}
	return ret%p;
}

bool fermat(int p){
	if(p<=1)return false;
	if(p!=2 && p%2==0)return false;
	if(p!=3 && p%3==0)return false;
	if(p!=5 && p%5==0)return false;
	if(p!=7 && p%7==0)return false;
	if(p!=11 && p%11==0)return false;

	for(int x=0;x<100;++x){
		int a = rand()%(p-1)+1;
		if(power(a,p-1,p)!=1)return false;
	}
	return true;
}
int main(){
	int n;
	while(scanf("%d",&n)==1,n){
		if(n%2==0)n--;
		while(n>=5){
			if(fermat(n) && fermat(n-2)){
				cout<<n-2<<" "<<n<<endl;
				break;
			}
			n-=2;	
		}
	}
	return 0;

}

Measured memory_bytes: 1212
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	int p[n];
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	
	int count = 0;
	for (int i = 1; i < n - 1; i++) {
		if ((p[i-1] < p[i]) && (p[i] < p[i+1])) {
			count++;
		} else if ((p[i-1] > p[i]) && (p[i] > p[i+1])) {
			count++;
		}
	}
	
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
        String a=sc.next(),b=sc.next(),c=sc.next();
        if(a.charAt(a.length()-1)==b.charAt(0)&&
            b.charAt(b.length()-1)==c.charAt(0)){
             System.out.print("YES");   
        }
        else System.out.println("NO");    
       sc.close();
    }
} 

 


Measured memory_bytes: 35392
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,n)  for(ll i=0;i<n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef pair<int,int> pii;
int main()
{
	IOS;
	//int t; cin>>t;
	//ll M=pow(10,9)+7;
	int t=1;
	while(t)
	{
		int n; cin>>n;
		//int e=10000;
		long long a[n+1]={0};
		for(int i=1;i<=100;i++)
		{
			for(int j=1;j<=100;j++)
			{
				for(int k=1;k<=100;k++)
				{
					long long w=i*i+j*j+k*k+i*j+j*k+k*i;
					if(w<=n)
						a[w]++;
				}
			}
		}
		for(int i=1;i<=n;i++)
		{
			cout<<a[i]<<"\n";
		}
		t--;
	}
	return 0;
}

Measured memory_bytes: 3676
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const ll INF = 1e9;
inline ll read(){
	ll X = 0,w = 0 ;
	char ch = 0;
	while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
	while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
	return w ? -X : X;
}

ll dat[100005];
ll dp[1005][1005];
bool was[1005][1005];
ll DP(ll l,ll r)
{
	if(l==r or was[l][r])
	{
		return dp[l][r];
	}
	was[l][r]=1;
	dp[l][r]=1e18;
	ll sum=dat[l];
	for(ll i=l+1;i<=r;i++)
	{
		dp[l][r]=min(dp[l][r],DP(l,i-1)+DP(i,r));
		sum+=dat[i];
	}
	dp[l][r]+=sum;
	return dp[l][r];
}
int main() 
{
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++)
	{
		cin>>dat[i];
	}
	cout<<DP(1,n);
    return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <vector>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    vector<int> A(N);
    int ret = 0;
    for(int i = 0; i < N; ++i){
        cin >> A[i];
        ret += A[i]-1;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include <cstdio>
using namespace std;

const int r_MAX = 100,c_MAX = 100;
int n[r_MAX][c_MAX];

void input(int r,int c){
	for (int i1 = 0; i1 < r; i1++){
		for (int i2 = 0; i2 < c; i2++){
			cin >> n[i1][i2];
		}
	}
}

void list(int r,int c){
	int allsum = 0;
	for (int i1 = 0; i1 < r; i1++){
		int sum = 0;
		for (int i2 = 0; i2 < c; i2++){
			cout << n[i1][i2] << ' ';
			sum += n[i1][i2];
		}
		cout << sum << endl;
		allsum += sum;
	}
	for (int i2 = 0; i2 < c; i2++){
		int sum = 0;
		for (int i1 = 0; i1 < r; i1++){
			sum += n[i1][i2];
		}
		cout << sum <<' ';
	}
	cout << allsum << endl;
}

int main(){

	int r, c;
	cin >> r >> c;

	input(r, c);

	list(r, c);

	return 0;
}


Measured memory_bytes: 3096
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
//#include"matrix.h"
using namespace std;
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define REP(i,x,y) for(ll (i)=(x);(i)<(y);(i)++)
#define RREP(i,x,y) for(ll (i)=(x);(i)>=(y);(i)--)
#define sqr(x) ((x)*(x))
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
#define fst first
#define snd second
#define itm1 fst
#define itm2 snd.fst
#define itm3 snd.snd
#define sz(v) ((ll)v.size())
#define oo 200000000000
//#define EPS 1e-9

//#define pi acos(-1)
#define MOD 1000000007
#define MAXN 999409605
#define cot 20
//#define N 300005
//#define min -9042414321442
#define INF 1065435634
#define N1 90
//typedef long double ld;
typedef  long long ll;
//typedef short int ll;
//typedef ll ll;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef pair<ll,ii> tri;
typedef vector<ll> vi;

#define N 243555   
#define M 31
//#define cap 1000000000
#define bas 31

inline ll ma(ll a, ll b){ return ((a-b>0)? a:b);}
inline ll mi(ll a, ll b){return ((a-b>0)? b:a);}
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;
}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);
}
#else
#define trace(...)
#endif

inline ll go(ll a){
  ll ans=0;
  while(a) ans+=a%10, a/=10;
  return ans;
}
ll dp[N], ar[N];
inline ll chek(ll &n){
  ll flag=1;
  REP(i,0,n-1) if(ar[i+1]-ar[i]>1) flag=0;
  if(ar[0]!=0) flag=0;
  return flag;
}
inline void solve(ll &n){
  ll ans=0;
  REP(i,0,n) ans+=dp[i];
  cout<<ans<<endl; 
}
int main(){
  fastio;
  ll n, ans=0; cin>>n;
  REP(i,0,n) cin>>ar[i];
  REP(i,0,n) dp[i]=i==0? i:(ar[i-1]+1==ar[i])? (dp[i-1]+1,ans++):(ar[i],ans+=ar[i]);
  if(chek(n)) cout<<ans<<endl;
  else cout<<"-1"<<endl;
  return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n,0);
  rep(i,k){
    int d; cin >> d;
    rep(j,d){
      int x; cin >> x; x--;
      a[x]++;
    }
  }
  int ans = 0;
  rep(i,n){
    if(a[i]==0) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
n, m = map(int, input().split())
mod = 10**9 + 7

fac = [1] * (m + 1)
for i in range(m):
    fac[i + 1] = fac[i] * (i + 1) % mod

def modinv(a):
    b = mod
    u = 1
    v = 0
    while b:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    u %= mod
    if u < 0:
        u += m
    return u

ans = fac[m] * fac[n] % mod
tmp = 0
for k in range(n + 1):
    tmp2 = fac[m - k]
    tmp2 = tmp2 * modinv(fac[n - k]) % mod
    tmp2 = tmp2 * modinv(fac[k]) % mod
    if k % 2 == 0:
        tmp = (tmp + tmp2) % mod
    else:
        tmp = (tmp - tmp2) % mod
ans = ans * tmp % mod
inv = modinv(fac[m - n])
ans = ans * inv % mod
ans = ans * inv % mod
print(ans)


Measured memory_bytes: 72024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main(){
    int x_1,x_2,x_3,x_4,y_1,y_2,y_3,y_4;
    cin >> x_1 >> y_1 >> x_2 >> y_2;
    int m,n;
    x_3 = x_2 - (y_2 - y_1);
    y_3 = y_2 + (x_2 - x_1);
    x_4 = x_1 - (y_2 - y_1);
    y_4 = y_1 + (x_2 - x_1);
    cout << x_3 << " "<< y_3 << " "<< x_4 << " "<< y_4 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<long long> r(87);
    r.at(0) = 2;
    r.at(1) = 1;
    for (int i = 2; i < n + 1; i++) {
        r.at(i) = r.at(i - 1) + r.at(i - 2);
    }
    cout << r.at(n) << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	private void doit(){
		Scanner sc =new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int r = sc.nextInt();
			if((n|r) == 0) break;
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i = n ; i >= 1; i--){
				list.add(i);
			}
			for(int i = 0; i < r; i++){
				int p = sc.nextInt() - 1;
				int c = sc.nextInt();
				
				ArrayList<Integer> list2 = new ArrayList<Integer>();
				for(int j = p; j < p + c; j++){
					list2.add(list.get(j));
				}
				while(c-- > 0){
					//System.out.println("pass");
					list.remove(p);
				}
				for(int j = 0; j < list.size(); j++){
					list2.add(list.get(j));
				}
				list.clear();
				list.addAll(list2);
				//System.out.println(list2.toString());
			}
			System.out.println(list.get(0));
		}
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define vvv(type, c, m, n, l, i) vector<vector<vector<type>>> c(m, vector<vector<type>>(n, vector<type>(l, i)));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	int n, m; cin >> n >> m;
	vv(int, v, n, m, 0);
	rep(i, 0, n) {
		rep(j, 0, m) {
			cin >> v[i][j];
		}
	}
	vi b(m);
	rep(i, 0, m) {
		cin >> b[i];
	}
	rep(i, 0, n) {
		int ans = 0;
		rep(j, 0, m) {
			ans = ans + v[i][j] * b[j];
		}
		P(ans);
	}
	return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int a, b;
    cin>>a>>b;
    if(b%a==0)cout<<a+b<<endl;
    else cout<<b-a<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int h,w;
string s[555],a[555],b[555];
main()
{
	cin>>h>>w;
	for(int i=0;i<h;i++)
	{
		cin>>s[i];
		a[i]=b[i]=s[i];
		if(i%2==0)
		{
			for(int j=1;j<w;j++)a[i][j]='#';
		}
		else
		{
			for(int j=0;j<w-1;j++)b[i][j]='#';
		}
		b[i][0]=a[i][w-1]='#';
	}
	for(int i=0;i<h;i++)cout<<a[i]<<endl;
	cout<<endl;
	for(int i=0;i<h;i++)cout<<b[i]<<endl;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#pragma GCC optimize(4)
using namespace std;
int main(){
	bool a[3]={};
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(s[i]=='C') a[1]=1;
		if(s[i]=='F'&&a[1]) a[2]=1; 
	}
	if(a[2]) cout<<"Yes"; 
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	double n = 0, a, b, c, d, e, f, sum = 0, num = 0, uio = 0;
	int test[2] = { 0 };
	cin >> a >> b >> c >> d >> e >> f;
	for (int h = 0; h <= f / a / 100; h++) {
		for (int i = 0; i <= f / b / 100; i++) {
			if (h != 0 || i != 0) {
				for (int j = 0; j <= (f - (h * a * 100 + i * b * 100)) / c; j++) {
					for (int k = 0; k <= (f - (h * a * 100 + i * b * 100)) / d; k++) {
						if (h * a * 100 + i * b * 100 + j * c + k * d <= f) {
							sum = h * a * 100 + i * b * 100;
							num = j * c + k * d;
							if (num / sum >= uio && num <= sum / 100 * e) {
								uio = num / sum;
								test[0] = sum + num; test[1] = num;
							}
						}
					}
				}
			}
		}
	}
	cout << test[0] << ' ' << test[1] << endl;
	cin >> n;
}

Measured memory_bytes: 256
a = list(map(int,input().split()))
N = a[0]
M = a[1]
dct = {}
for i in range(N):
    temp = list(map(int,input().split()))
    if temp[0] in dct:
        val = dct[temp[0]] + temp[1]
        dct[temp[0]] = val
    else:
        dct[temp[0]] = temp[1]

dct = sorted(dct.items())
ruiseki = 0
loop = 0

cost = []
nums = []
ans = 0
lendct = len(dct)
for i in range(lendct):
    cost.append(dct[i][0])
    nums.append(dct[i][1])
if nums[0] >= M:
    print(str(cost[0]*M))
else:
    ans += cost[0]*nums[0]
    for i in range(1, 100001):
        nums[i] += nums[i-1]
        if nums[i] >= M:
            print(str(ans + cost[i]*(M - nums[i-1])))
            break
        ans += cost[i]*(nums[i]-nums[i-1])


Measured memory_bytes: 22964
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;
const LL MOD = 1000000007;

int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	int len = (int)s.length();
	vector<vector<LL>> dp(len + 1, vector<LL>(13));
	for (int j = 0; j < 10; ++j) {
		dp[0][0] = 1;
	}
	LL r = 1;
	for (int i = 0; i < len; ++i) {
		int col = len - i - 1;
		if (s[col] == '?') {
			for (int d = 0; d < 10; ++d) {
				LL v = r * d;
				for (int j = 0; j < 13; ++j) {
					LL w = (v + j) % 13;
					dp[i + 1][w] = (dp[i + 1][w] + dp[i][j]) % MOD;
				}
			}
		} else {
			LL d = s[col] - '0';
			LL v = r * d;
			for (int j = 0; j < 13; ++j) {
				LL w = (v + j) % 13;
				dp[i + 1][w] = (dp[i + 1][w] + dp[i][j]) % MOD;
			}
		}
		r = (r * 10) % 13;
	}
	LL ans = dp[len][5];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 13696
import java.util.*;
public class Main{
  static ArrayList<Integer>[] graph;
  static boolean[] visited;
  static int n;
  static int cnt;
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    n = sc.nextInt();
    int m = sc.nextInt();
    graph = new ArrayList[n+1];
    for(int i=1;i<=n;i++)graph[i]=new ArrayList<>();
    visited = new boolean[n+1];
    int[][] ab = new int[m+1][2];
    for(int i=1;i<=m;i++){
      int a = sc.nextInt();
      int b = sc.nextInt();
      graph[a].add(b);
      graph[b].add(a);
      ab[i][0]=a;
      ab[i][1]=b;
    }
    int ans = 0;
    for(int i=1;i<=m;i++){
      cnt=0;
      Arrays.fill(visited,false);
      if(dfs(ab[i][0],ab[i][1],1))ans++;
    }
    System.out.println(ans);
  }
  public static boolean dfs(int a,int b,int now){
    cnt++;
    if(cnt==n)return false;
    visited[now]=true;
    for(int i:graph[now]){
      if(!visited[i]&&!(now==a&&i==b)&&!(now==b&&i==a)){
        if(!dfs(a,b,i))return false;
      }
    }
    return true;
  }
}

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

int main()
{
   int l,r,d,i,cnt=0;
   cin>>l>>r>>d;
   for(i=l;i<=r;i++)
   {
       if(i%d==0)
        ++cnt;
   }
   cout<<cnt<<endl;
}


Measured memory_bytes: 3632
# ans

N, Y = map(int, input().split())

for a in range(N+1):
  for b in range(N+1-a):
    c = N - a - b
    if 10000 * a + 5000 * b + 1000 * c == Y:
      print(a,b,c)
      exit()
        
print(-1,-1,-1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;
using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int a[205], G[205][205];
queue <int> q;

int main() {
  int n; read(n);
  for (RI i = 1; i <= n; ++i)
    for (RI j = 1; j <= n; ++j) {
      char ch = gc();
      while (ch != '0' && ch != '1') ch = gc();
      if (ch == '1') G[i][j] = 1;
    }
  int ans = 0;
  for (RI i = 1; i <= n; ++i) {
    memset(a, 0, sizeof(a));
    a[i] = 1;
    q.push(i);
    while (!q.empty()) {
      int t = q.front(); q.pop();
      for (RI i = 1; i <= n; ++i)
        if (G[t][i]) {
          if (!a[i]) a[i] = a[t] + 1, q.push(i);
          else if (abs(a[i] - a[t]) != 1) return puts("-1"), 0;
        }
    }
    for (RI j = 1; j <= n; ++j)
      ans = max(ans, a[j]);
  }
  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
const ll mod = 1e9 + 7;
const int inf = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N)cin >> A[i];
	allsort(A);
	ll sum=0;
	int x=-1;
	rep(i, N-1) {
		sum += A[i];
		if (sum * 2 < A[i + 1])x = i;
	}
	cout << (x==-1 ? N:N-x-1) << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
ll read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
ll gcd(ll a,ll b)
{
	return (!b)?a:gcd(b,a%b);
}
int main()
{
   ll a,b,c,d;
   cin>>a>>b>>c>>d;
   ll aa=(b-a+1ll);
   ll com=c/gcd(c,d)*d;
   ll ans=(b/c)-(b/com)+(b/d);
   ll ans1=((a-1)/c)-((a-1)/com)+((a-1)/d);
   //cout<<aa<<" "<<ans<<" "<<ans1<<"\n";
   cout<<aa-(ans-ans1);
}


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

int main(){
    int  h,m,s;
    
    cin>>s;
    
    h=s/3600;s %=3600;
    m=s/60;s %=60;
    
    cout<<h<<":"<<m<<":"<<s<<endl;
    
    return 0;
    
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
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;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N){
  switch (N%10)
  {
  case 0:
  case 1:
  case 6:
  case 8:
    cout<<"pon"<<endl;
    break;
  case 2:
  case 4:
  case 5:
  case 7:
  case 9:
    cout<<"hon"<<endl;

    break;
  case 3:
    cout<<"bon"<<endl;
    break;
  }
}

int main(){
  cout<<setprecision(1000);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3764
import sys
import numpy as np
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = np.array([0] + lr())
A_cum = A.cumsum().tolist()
beauties = []
for i, j in itertools.combinations(range(N+1), 2):
    beauties.append(A_cum[j] - A_cum[i])

beauties = np.array(beauties)
j = 0
def check(x):
    return np.sum(beauties&x == x) >= K

answer = 0
for i in range(40, -1, -1):
    if check(answer + (1 << i)):
        answer += 1 << i

print(answer)
# 00


Measured memory_bytes: 36176
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
    // Your code here!
    char s[100];
    
    scanf("%s", s);
    
    int n=strlen(s);
    
    for(int i=0; i<n/2; i++){
        if(s[i] != s[n-1-i]){
            printf("No");
            return 0;
        }
    }
    for(int i=0; i<(n-1)/4; i++){
        if(s[i] != s[(n-1)/2-1-i]){
            printf("No");
            return 0;
        }
    }
    for(int i=0; i<(n-1)/4; i++){
        if(s[(n+1)/2+i] != s[n-1-i]){
            printf("No");
            return 0;
        }
    }
    
    printf("Yes");
    return 0;
}


Measured memory_bytes: 128
using System;

namespace ABC087_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = int.Parse(Console.ReadLine());
            var B = int.Parse(Console.ReadLine());
            var C = int.Parse(Console.ReadLine());
            var X = int.Parse(Console.ReadLine());
            var cnt = 0;

            for (int i = 0; i <= A; i++)
                for (int j = 0; j <= B; j++)
                    for (int k = 0; k <= C; k++)
                        if (500 * i + 100 * j + 50 * k == X)
                            cnt++;

            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 11092
import math
 
def comb(n,k,p):
    if k < 0 or k > n:
        return 0
    if n == 0 or k == 0:
        return 1
    a=math.factorial(n) % p
    b=math.factorial(k) % p
    c=math.factorial(n-k) % p
    return (a*mypow(b,p-2,p)*mypow(c,p-2,p)) % p
 
def mypow(a,b,p):
    if b == 0: return 1
    if b % 2 == 0:
        d=mypow(a,b//2,p)
        return d*d % p
    if b % 2 == 1:
        return (a*mypow(a,b-1,p )) % p

n, k = map(int, input().split())
mod = 1000000007

for i in range(1,k+1):
    ans = comb(n-k+1,i,mod) * comb(k-1,i-1,mod) % mod
    print(ans)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;

template<class T>bool chmax(T &a, const T &b) { if( a < b ) { a = b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) { if( b < a ) { a = b; return 1; } return 0;}

#ifdef LOCAL
	#define eprintf(...) printf(__VA_ARGS__)
#else
	#define eprintf(...) 1
#endif

#define ROUNDUP(a, b) 		( ((a) + ((b) - 1) ) / (b))
#define SET_ZERO(a)	 		( memset((a), 0, sizeof(a)))
#define SET_NUM_ARRAY(a,b)	( memset((a), b, sizeof(a)))
//#define int long long int //dont forget to change int to signed
bool pairCompare(const ii& firstElof, const ii& secondElof)
{
    return firstElof.second < secondElof.second;
}
int main() {
	int N, M;
	cin >> N >> M;
	ii range[100009];
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		range[i] = ii(a-1 , b-2);
	}
	sort(range, range+M, pairCompare);

	int ctr = 1;
	for (int i = 1, x = range[0].second; i < M; i++) {
		if (range[i].first > x) {
			ctr++;
			x = range[i].second;
		}
	}
	
	printf("%d\n", ctr);
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
    cout.precision(20);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int cnt = 1;
    ll ans = 0;
    while (n) {
        if (cnt % 3 != 0 && cnt % 5 != 0) {
            ans += cnt;
        }
        n--;
        cnt++;
    }
    cout << ans;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	 int n, k;
	 string s;
	 cin >> n >> k;
	 cin >> s;
	 s[k-1] += 32;

	 cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int H, W; cin >> H >> W;
    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            string S; cin >> S;
            if (S == "snuke") {
                cout << (char)('A' + w) << (h + 1) << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn=new Scanner(System.in);
	String S = stdIn.next();
	if(S.contains("a")&&S.contains("b")&&S.contains("c")){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <math.h>
#include <map>
#include <numeric>
#include <stack>
#include <queue>
#include <functional>
#include <stdio.h>
#define ll long long
#define pl pair<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define vvvb vector<vector<vector<bool> > >
#define rep(i,a) for(ll i = 0;i<a;++i)
#define rep1(i,a) for(ll i = 1;i<a;++i)
#define rrep(i,a) for(ll i = a;i>=0;--i)
#define mod 1000000007
#define inf 10010010010
using namespace std;



int main(){
	ll n, m; cin >> n >> m;
	vb bre(n+1,false);
	rep(i, m){
		ll t; cin >> t;
		bre[t] = true;
	}
	vl dp(n+2,0);
	dp[n] = 1;
	dp[n + 1] = 0;
	rrep(i, n - 1){
		if (bre[i]) continue;
		dp[i] = (dp[i + 1] + dp[i + 2])%mod;
	}
	cout << dp[0] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

int main(){

	int ans,length;

	ll** dp = new ll*[80000];
	for(int i = 0; i < 80000; i++)dp[i] = new ll[11];

	char buf[80001];

	while(true){
		scanf("%s",buf);
		if(buf[0] == '0')break;

		//dp????????????
		for(length = 0; buf[length] != '\0';length++){
			for(int i = 0; i < 11; i++)dp[length][i] = 0;
		}

		dp[0][buf[0] - '0']++;

		for(int i = 1; i < length; i++){
			if(buf[i] != '0'){
				dp[i][buf[i] - '0']++;
			}

			for(int k = 0; k < 11; k++){
				dp[i][(10*k+buf[i]-'0')%11] += dp[i-1][k];
			}
		}

		ans = 0;

		for(int i = 0; i < length; i++)ans += dp[i][0];

		printf("%d\n",ans);
	}

    return 0;
}

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

long long N, D, Q, d[500010], q, x[500010], dp[500010];

int main() {
    scanf("%lld%lld", &N, &D);
    x[0] = D, dp[N+1] = 1;
    for(int i = 1; i <= N; i++) {
        scanf("%lld", &d[i]);
        x[i] = min(abs(x[i-1] - d[i]), x[i-1]);
    }
    for(int i = N; i > 0; i--) {
        dp[i] = dp[i+1];
        if(dp[i+1] > abs(dp[i+1] - d[i])) dp[i] = dp[i+1]+d[i];
    }
    scanf("%lld", &Q);
    while(Q--) {
        scanf("%lld", &q);
        if(x[q-1] < dp[q+1]) printf("NO\n");
        else printf("YES\n");
    }
}

Measured memory_bytes: 13696
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, s, n) for (ll i = s; i < (n); i++)
#define repr(i, n) for (ll i = n-1; i >= 0; i--)
using namespace std;

const int mod = 2019;
int main(){
  string s;
  cin >> s;
  int n = s.size();
  vector<int> dp(n+1);
  vector<int> count(mod, 0);
  dp[n] = 0;
  count[0]++;
  int x = 1;
  repr(i, n){
    int num = (s[i] - '0');
    num = (num * x) % mod;
    x = (x * 10) % mod;
    dp[i] = (dp[i+1] + num) % mod;
    count[dp[i]]++;
  }
  int ans = 0;
  rep(i, mod){
    ans += count[i] * (count[i] - 1) / 2;
  }
  cout << ans << endl;
  
  return 0;
}


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

int main()
{
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); ++i)
  {
    s[i] = (s[i] == '1' ? '9' : '1');
  }
  cout << s << endl;
}

Measured memory_bytes: 256
import scala.io.StdIn._

object Main extends App {


  val n = readInt()
  val A = readLine().split(" ").map(_.toInt)

  def solve(): String = {
    val sorted = A.sorted
    (1 until A.length).foreach { i =>
      if(sorted(i-1) == sorted(i)) return "NO"
    }
    "YES"
  }

  println(solve())

}



Measured memory_bytes: 77416