akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef pair<int,int> pii;

int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};

int main() {
  int w,h;
  while(cin >> w>>h,w||h) {
    char ba[w][h];
    REP(j,h) {
      REP(i,w)
        cin >> ba[i][j];
    }
    REP(y,h) {
      REP(x,w) {
        if (ba[x][y] == 'W') {
          queue<pii> Q;
          Q.push(pii(x,y));

          bool visited[w][h];
          memset(visited,0,sizeof(visited));

          while(!Q.empty()) {
            int x1 = Q.front().first;
            int y1 = Q.front().second;
            Q.pop();
            
///            if (!visited[x1][y1] && (ba[x1][y1] == 'w' || ba[x1][y1] == '*')) break;
            if (visited[x1][y1]) continue;
            visited[x1][y1] = 1;
            
            if (ba[x1][y1] == 'b')
              ba[x1][y1] = '*';
            else if (ba[x1][y1] == '.')
              ba[x1][y1] = 'w';
            else if (ba[x1][y1] != 'W')
              continue;
            
            
            REP(k,4) {
              int xx = x1+dx[k];
              int yy = y1+dy[k];

              if (xx<0||xx>=w||yy<0||yy>=h) continue;
              
              if (ba[xx][yy] != 'W' && ba[xx][yy] != 'B')
                Q.push(pii(xx,yy));
            }
          }
        } else if (ba[x][y] == 'B') {
          queue<pii> Q;
          Q.push(pii(x,y));

          bool visited[w][h];
          memset(visited,0,sizeof(visited));
          while(!Q.empty()) {
            int x1 = Q.front().first;
            int y1 = Q.front().second;
            Q.pop();
            //         if (!visited[x1][y1] && (ba[x1][y1] == 'b' || ba[x1][y1] == '*')) break;
            if (visited[x1][y1]) continue;
            visited[x1][y1] = 1;


            if (ba[x1][y1] == 'w')
              ba[x1][y1] = '*';
            else if (ba[x1][y1] == '.')
              ba[x1][y1] = 'b';
            else if (ba[x1][y1] != 'B')
              continue;
            
            REP(k,4) {
              int xx = x1+dx[k];
              int yy = y1+dy[k];

              if (xx<0||xx>=w||yy<0||yy>=h) continue;
              
              if (ba[xx][yy] != 'W' && ba[xx][yy] != 'B')
                Q.push(pii(xx,yy));
            }
          }
        }

      }
    }
    int res1 = 0, res2 = 0;
    REP(y,h) {
      REP(x,w) {
        if (ba[x][y] == 'w') res1++;
        else if (ba[x][y] == 'b') res2++;
      }
    }
    cout << res2 <<" " << res1 << endl; 
  }
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
#define rep( i, n ) for (int i = 0; i < ( long long )(n); i++)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;
    

int main(){
    int n;
    int ans=0;
    cin>>n;
    vector<int>a(n);
    rep(i,n){
        cin>>a[i];
    }

    rep(i,n){
        if(((i+1)%2==1)&&(a[i]%2==1)) ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 3616
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] str = sc.nextLine().split(" ");
		String a = str[0];
		String b = str[1];
		
        String str1 = "";
        for(int i = 0; i < Integer.valueOf(b); i++) {
        	str1+=a;
        }
        
        String str2 = "";
        for(int i = 0; i < Integer.valueOf(a); i++) {
        	str2+=b;
        }
        int result = Integer.compare(Integer.valueOf(a), Integer.valueOf(b));
        if(result == 0) System.out.println(str1);
        else if(result == -1) System.out.println(str1);
        else if(result == 1) System.out.println(str2);
	}
}

Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> W(N+1);
    for(int i=1; i<=N; i++) {
        cin >> W[i];
    }

    partial_sum(W.begin(), W.end(), W.begin());
    int ans = INT32_MAX;
    for(int i=0; i<=N; i++) {
        int S1 = W[i];
        int S2 = W[N] - W[i];
        ans = min(ans, abs(S1-S2));
    }

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


Measured memory_bytes: 256
s=input()
n=len(s)
for i in range(0,n//2):
    if s[i]!=s[n-1-i]:
        print('No')
        exit(0)
for i in range(0,(n-1)//2):
    if s[i]!=s[n-1-i]:
        print('No')
        exit(0)
for i in range((n+3)//2-1,n):
    if s[i]!=s[(n+((n+3)//2-1))-1-i]:
        print('No')
        exit(0)
print('Yes')

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

struct Node{
    int key;
    Node *p,*l,*r;//parent,left,rightの意味
};

Node *root,*NIL;//虚無nodeとrootnode

void insert(int v){//keyがvな節点を受け取る関数。
    Node *y=NIL;//親を設定する用
    Node *x=root;//rootを設定
    Node *z;//挿入するやつ
    z=(Node*)malloc(sizeof(Node));
    z->key=v;
    z->l=NIL;
    z->r=NIL;
    while(x!=NIL){//xがNIL、つまり葉になるまで続ける
        y=x;//一つ下へ向かう時に親を保存しておく
        if(z->key < x->key){
            x=x->l;//視点をxに
        }else{
            x=x->r;
        }
    }
    z->p=y;//以下で、親の方にも追加しないと。
    if(y==NIL){
        root=z;
    }else{
        if(z->key < y->key){
            y->l=z;
        }else{
            y->r=z;
        }
    }
}
//出力用関数を二つ用意
void preorder(Node *u){
    if(u==NIL)return;
    cout<<" "<<u->key;
    preorder(u->l);
    preorder(u->r);
}
void inorder(Node *u){
    if(u==NIL)return;
    inorder(u->l);
    cout<<" "<<u->key;
    inorder(u->r);
}

int main(){
    int n;cin>>n;
    string order;int v;
    for(int i=0;i<n;i++){
        cin>>order;
        if(order=="insert"){
            cin>>v;insert(v);
        }else{
            inorder(root);cout<<endl;
            preorder(root);cout<<endl;
        }
    }
    return 0;
}


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


int main()
{

    int a,b,nd=0,x,y,z=1,i,X,sum=0;

    scanf("%d",&a);

    int A[a];

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

        scanf("%d",&A[i]);

    }




    for(i=0;i<a;i++,z++)
    {

       if(A[i]!=z) sum++;


    }


    if(sum<=2)printf("YES\n");

    else printf("NO\n");


    return 0;

}

Measured memory_bytes: 1660
import java.util.Scanner;

class Main{
    public static int n;
    
    public static void main(String[] args){
	int i;
	Scanner scan = new Scanner(System.in);
	n = scan.nextInt();
	int A[] = new int[n];
	for(i=0 ; i<n ; i++){
	    A[i] = scan.nextInt(); 
	}

	int j;
	int q = scan.nextInt();
	int S[] = new int[q];
	for(i=0 ; i<q ; i++){
	    S[i] = scan.nextInt();
	}

	for(i=0 ; i<q ; i++){
	    if( solve(0, S[i], A)==true )System.out.println("yes");
	    else System.out.println("no");
	}	
    }
    
    public static boolean solve(int i, int m, int A[]){
	boolean res;
	if(m == 0)return true;
	if(i >= n)return false;
	res = solve(i + 1, m, A) || solve(i + 1, m - A[i], A);
	return res;
    }
    
}




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

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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define MOD 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<P> vpi;
typedef pair<ll,ll> Pl;
typedef vector<ll> vl;
typedef vector<Pl> vpl;

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(b <= 0) return -1;
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

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

int main() {
    int N,ans = 0;
    cin >> N;
    vi p(N);
    rep(i,N) cin >> p[i];

    rep(i,N){
        if(i+1 == p[i]){
            if(i != N-1 && p[i+1] == i+2){
                i++;
            }
            ans++;
            continue;
        }
    } 

    cout << ans;
    //printf("%.15lf", ans);
    cout << "\n";
    return 0;
}


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

int main()
{
    int maxa=1e9;
    int n, k, s; cin>>n>>k>>s;
    for(int i=0; i<k; ++i) cout<<s<<' ';
    if (s==maxa) maxa--;
    for(int i=k; i<n; ++i) cout<<maxa<<' ';
    cout<<endl;
}


Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,ans = "";
    rep(i,3){
        cin >> s;
        ans += s[i];
    }
    PRINT(ans);
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int N,i,flag=0,cnt=0;
    int D[110][3];
    scanf("%d",&N);
    for(i=1;i<=N;i++){
        scanf("%d",&D[i][1]);
        scanf("%d",&D[i][2]);
    }

    for(i=1;i<=N;i++){
        if(D[i][1]==D[i][2]){
            cnt++;
        }else{
            cnt=0;
        }
        
        if(cnt==3){
            flag=1;
        }


    }

    if(flag==1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;


}

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

using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  int n; cin >> n;
  vector<int> nums(n);
  rep_i(i, n){
    cin >> nums[i];
  }
  int q; cin >> q;
  int b, m, e;
  rep_i(i, q){
    cin >> b >> m >> e;
    // scanf("%d %d",&left,&right);
		// reverse(V.begin()+left,V.begin()+right);
    // reverse(&nums[b], &nums[e]);
    rotate(nums.begin() + b, nums.begin() + m, nums.begin() + e);
  }
  for (vector<int>::iterator itr = nums.begin(); itr != nums.end(); itr++){
    if(itr == nums.begin()){
      cout << *itr;
      continue;
    }
    cout << " " << *itr;
  }
  cout << endl;
}


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

#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 EPS (1e-7)
#define INF 1e9

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};

const ll mod=1000000000+7;
const int MAX_N=1000;

int main(){
	string s,t;
	cin>>s>>t;
	bool flag=true;
	for(int i=s.size()-t.size();i>=0;i--){
		if(flag){
			bool judge=true;
			for(int j=0;j<t.size();j++){
				if(s[i+j]==t[j])continue;
				if(s[i+j]!='?')judge=false;
			}
			if(judge){
				for(int j=0;j<t.size();j++){
					if(s[i+j]=='?')s[i+j]=t[j];
				}
				flag=false;
			}
		}
	}
	if(flag){
		cout<<"UNRESTORABLE"<<endl;
		return 0;
	}
	for(int i=0;i<s.size();i++){
		if(s[i]=='?')s[i]='a';
	}
	REP(i,s.size()){
		cout<<s[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 384
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
s=[0]
x=0
for i in a:
    x+=i
    s.append(x)
cs=Counter(s).most_common()
x=0
for i,j in cs:
    x+=j*(j-1)//2
print(x)

Measured memory_bytes: 48764
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {
    double x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2  >> y2;
    cout << setprecision(10) << sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1)) << endl;
    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
	  result=(result*base)%modulus;
	  exponent=exponent>>1;
	  base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll r;
int main(){FAST;
cin>>r;
cout<<3*r*r;
return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
N,M=[int(_) for _ in input().split()]
iCost = 0
for a, b in sorted([int(_) for _ in input().split()] for _ in range(N)):
    if b < M:
        iCost += a*b
        M -= b
    else:
        iCost += a*M
        print(iCost)
        exit()


Measured memory_bytes: 21652
from collections import deque

H,W = map(int,input().split())
Ch,Cw = map(int,input().split())
Dh,Dw = map(int,input().split())

maze = [list(input()) for _ in range(H)]

que = deque([(0,Ch-1,Cw-1)])
adjecents = [(1,0),(0,1),(-1,0),(0,-1)]
while que:
    step,h,w = que.popleft()
    if h == Dh-1 and w == Dw-1:
        print(step)
        exit()
    if maze[h][w] == "#":
        continue
    else:
        maze[h][w] = "#"
        for a,b in adjecents:
            x = h + a
            y = w + b
            if 0 <= x < H and 0<= y < W:
                if maze[x][y] == ".":
                    que.appendleft((step,x,y))
                else:
                    for i in range(-2,3):
                        for j in range(-2,3):
                            x = h + i
                            y = w + j
                            if 0 <= x < H and 0<= y < W and maze[x][y] == ".":
                                que.append((step+1,x,y))

print(-1)

Measured memory_bytes: 323932
# include <cstdio>
# include <iostream>
# include <string>
using namespace std;
# define MAX 233
int c[10][10];
int a[MAX][MAX];
int main(void)
{
	int h,w; scanf("%d %d",&h,&w);
	for ( int i = 0;i < 10;i++ ) {
		for ( int j = 0;j < 10;j++) {
			scanf("%d",&c[i][j]);
		}
	}

	for ( int i = 1;i <= h;i++ ) {
		for ( int j = 1;j <= w;j++ ) {
			scanf("%d",&a[i][j]);
		}
	}

	for ( int i = 0;i < 10;i++ ) {
		for ( int j = 0;j < 10;j++ ) {
			for ( int k = 0;k < 10;k++ ) {
				c[j][k] = min(c[j][k],c[j][i]+c[i][k]);			
			}
		}
	}
	int res = 0;
	for ( int i = 1;i <= h;i++ ) {
		for ( int j = 1;j <= w;j++ ) {
			if ( a[i][j]!=1 && a[i][j]!=-1 ) {
				res += c[a[i][j]][1];
			}
		}
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 384
import math
import numpy as np

N = int(input())
root_N = int(math.floor(math.sqrt(N))+1)

res = []
for a in range(1, root_N):
  if (N/a).is_integer():
    res.append(a + N/a - 2)

res = np.array(res)
print(int(res.min()))

Measured memory_bytes: 14308
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  ll ans = 0;
  ll x[N],y[N];
  bool used[N];
  set<P> X;
  set<P> Y;
  priority_queue<P, vector<P>, greater<P>> Q;
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
    X.insert(make_pair(x[i],i));
    Y.insert(make_pair(y[i],i));
    used[i] = false;
  }
  used[0] = true;
  X.erase(make_pair(x[0],0));
  Y.erase(make_pair(y[0],0));
  auto itrx = X.lower_bound(make_pair(x[0],0));
  auto itry = Y.lower_bound(make_pair(y[0],0));
  if (itrx != X.end()) {
    Q.push(make_pair(abs(itrx->F - x[0]),itrx->S));
  }
  if (itrx != X.begin()) {
    Q.push(make_pair(abs(prev(itrx)->F - x[0]),prev(itrx)->S));
  }
  if (itry != Y.end()) {
    Q.push(make_pair(abs(itry->F - y[0]),itry->S));
  }
  if (itry != Y.begin()) {
    Q.push(make_pair(abs(prev(itry)->F - y[0]),prev(itry)->S));
  }
  for (int i = 0; i < N-1; i++) {
    while (!Q.empty()) {
      P p = Q.top();
      Q.pop();
      if (!used[p.S]) {
        used[p.S] = true;
        int a = p.S;
        ans += p.F;
        X.erase(make_pair(x[a],a));
        Y.erase(make_pair(y[a],a));
        auto _itrx = X.lower_bound(make_pair(x[a],a));
        auto _itry = Y.lower_bound(make_pair(y[a],a));
        if (_itrx != X.end()) {
          Q.push(make_pair(abs(_itrx->F - x[a]),_itrx->S));
        }
        if (_itrx != X.begin()) {
          Q.push(make_pair(abs(prev(_itrx)->F - x[a]),prev(_itrx)->S));
        }
        if (_itry != Y.end()) {
          Q.push(make_pair(abs(_itry->F - y[a]),_itry->S));
        }
        if (_itry != Y.begin()) {
          Q.push(make_pair(abs(prev(_itry)->F - y[a]),prev(_itry)->S));
        }
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int main(){
    int N;
    cin >> N;
    vector<pair<int, int>> P;
    // パソコンは1、電源は-1をsecondに入れて、座標でソート
    for(int c : {1, -1}) for(int i=0; i<N; i++){
        int x;
        cin >> x;
        P.emplace_back(x, c);
    }
    sort(P.begin(), P.end());

    // sumは「パソコンは1、電源は-1」の累積和。このabsが保留しているパソコンまたは電源の数
    int sum = 0;
    int64_t ans = 1;
    for(auto& p : P){
        int c = p.second;
        // sumとcが異符号ならペアが作れる
        if(sum*c < 0) mul(ans, abs(sum));
        sum += c;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
 
using namespace std;
 
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.10lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
const int mod = 1000 * 1000 * 1000 + 7;
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;
 
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;
 
int dx[6] = {-1,-1,0,0,1,1};
int dy[6] = {-1,0,-1,1,0,1};

int n;
int a[200005];
map<int,int>mp;

int main(){
    int n;
    cin>>n;
    bool flag=true;
    for(int i=0;i<n;++i){
        cin>>a[i];
        mp[a[i]]+=1;
        if(mp[a[i]]>1){
            flag=false;
        }
    }
    cout<<(flag?"YES":"NO")<<endl;
    return 0;
}

Measured memory_bytes: 10368
n,m = map(int, input().split())
matrix = []
vector = []
for i in range(n):
    a = list(map(int, input().split()))
    matrix.append(a)
for j in range(m):
    vector.append(int(input()))
for k in range(n):
    entry = 0
    for l in range(m):
        entry += (matrix[k][l] * vector[l])
    print(entry)


Measured memory_bytes: 6012
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        long k = Long.parseLong(sc.next());
        int[] a = new int[n+1];
        for(int i = 1; i <= n; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        
        List<Integer> list = new ArrayList<>();
        list.add(1);
        int j = 1;
        for(int i = 1; i <= n; i++){
            j = a[j];
            list.add(j);
        }
        Set<Integer> set = new HashSet<>();
        int b = 0;
        int d = 0;
        for(int i = 0; i < list.size(); i++){
            if(!set.add(list.get(i))){
                b = list.get(i);
                d = i;
                break;
            }
        }
        int c = 0;
        for(int i = 0; i < list.size(); i++){
            if(list.get(i) == b){
                c = i;
                break;
            }
        }
        if(k <= c){
            System.out.println(list.get((int)k));
        }else{
            int e = d-c;
            int f = (int)((k-c)%e);
            System.out.println(list.get(c+f));
        }
    }
}

Measured memory_bytes: 64012
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
 
int  main(){
int n;
cin >> n;
ll maxx = 0,minn=10e16;
for(int i=0;i<n;i++){
    ll a,b;
    cin >> a >> b;
    maxx = max(a,maxx);
    minn = min(minn,b);
}
ll ans = maxx+minn;
cout << ans << endl;
}
 


Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool cnt_divisor(int n) {
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (n % i == 0) {
      cnt++;
    }

    if (cnt > 8) {
      return false;
    }
  }

  return cnt == 8;
}

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  int ans = 0;
  for (int i = 1; i <= n; i += 2) {
    if (cnt_divisor(i)) {
      ans++;
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 // freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  string s;
  cin>>s;
  ll i=0;
  while(i<s.size())
  {
  	if(s[i]=='7')
  	{
  		Yes
  		return 0;
  	}
  	i++;
  }
  No
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector< vector<int> > B(2*K+1,vector<int>(2*K+1,0)), W = B;
  for(int i = 0; i < N; ++i){
    int x, y;
    char c;
    cin >> x >> y >> c;
    x %= 2*K;
    y %= 2*K;
    ++x;
    ++y;
    if(c == 'B') ++B[x][y];
    else ++W[x][y];
  }
  for(int i = 0; i <= 2*K; ++i){
    for(int j = 0; j < 2*K; ++j){
      W[i][j+1] += W[i][j];
      B[i][j+1] += B[i][j];
    }
  }
  for(int i = 0; i < 2*K; ++i){
    for(int j = 0; j <= 2*K; ++j){
      W[i+1][j] += W[i][j];
      B[i+1][j] += B[i][j];
    }
  }
  int ans = 0;
  for(int i = 1; i <= K; ++i){
    for(int j = 1; j <= K; ++j){
      int t = W[i+K-1][j+K-1] - W[i-1][j+K-1] - W[i+K-1][j-1] + W[i-1][j-1]
        + W[i-1][j-1]
        + B[i-1][j+K-1] - B[i-1][j-1]
        + B[i+K-1][j-1] - B[i-1][j-1]
        + W[2*K][j-1] - W[i+K-1][j-1]
        + W[i-1][2*K] - W[i-1][j+K-1]
        + B[2*K][j+K-1] - B[i+K-1][j+K-1] - B[2*K][j-1] + B[i+K-1][j-1]
        + B[i+K-1][2*K] - B[i+K-1][j+K-1] - B[i-1][2*K] + B[i-1][j+K-1]
        + W[2*K][2*K] - W[2*K][j+K-1] - W[i+K-1][2*K] + W[i+K-1][j+K-1];
      ans = max({ans, t, N-t});
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 31616
from collections import Counter
h,w=map(int,input().split())
s=[]
for i in range(h):
    s+=input()
c=sorted([j%4 for i,j in Counter(s).items()])[::-1]
c=Counter(c)
rh=h%2
rw=w%2
k=0
od=c[1]+c[3]
non4=c[2]+od
if rh*rw==1:
    if od!=1:
        k=1
    if c[1]+c[2]*2+c[3]*3>w+h-1:
        k=1
elif rh==0 and rw==0:
    if non4>0:
        k=1
elif rh==1:
    if od>0:
        k=1
    if c[2]*2>w:
        k=1
else:  # rw==1
    if od>0:
        k=1
    if c[2]*2>h:
        k=1
ans=['Yes','No']
print(ans[k])

Measured memory_bytes: 39152
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	uint64_t R, G, B, N;
	uint64_t i, j;
	uint64_t kotae = 0;
	if (scanf("%" SCNu64 "%" SCNu64 "%" SCNu64 "%" SCNu64, &R, &G, &B, &N) != 4) return 1;
	for (i = 0; R * i <= N; i++) {
		for (j = 0; R * i + G * j <= N; j++) {
			if ((N - (R * i + G * j)) % B == 0) kotae++;
		}
	}
	printf("%" PRIu64 "\n", kotae);
	return 0;
}


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

int main() {
    vector<int> atoz(26,0);
    string s;
    while (getline(cin, s)) {
        for (int i = 0; i < s.size(); i++) {
            char c = s.at(i);
            if (c >= 'A' && c <= 'Z') {
                atoz.at(c-'A')++;
            } else if (c >= 'a' && c <= 'z') {
                atoz.at(c-'a')++;
            }
        }
    }
    for (char c = 'a'; c <= 'z'; c++) {
        printf("%c : %d\n", c, atoz.at(c-'a'));
    }
}


Measured memory_bytes: 3344
import java.util.Scanner;

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

        if(n % 10 == 3) {
            System.out.println("bon");
        } else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6|| n % 10 == 8) {
            System.out.println("pon");
        }
        else {
            System.out.println("hon");
        }

        scan.close();
    }
}

Measured memory_bytes: 35528
#include <stdio.h>
#define dif 32
int main(){
    char ch;
    while(1){
        scanf("%c",&ch);
        
        if(ch == '\n') break;
        
        if('a' <= ch && ch <= 'z'){
            printf("%c",ch - dif);
        }else if('A' <= ch && ch <= 'Z'){
            printf("%c",ch + dif);
        }else{
            printf("%c",ch);
        }
        
        
    }
    printf("\n");
}


Measured memory_bytes: 2148
#include <iostream>
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<utility>
#include<numeric>
#include<functional>
#include<algorithm>
#include<queue>
#include<map>
#include<string>

#define FOR(i, a, b) for(int i=a; i<b; i++)
#define COUT(a) cout << a << endl;

using namespace std;
using Int = long long;
using P = pair<Int, Int>;

int main() {
    Int a, b, c;

    /*a = 1;
    b = 6;
    c = 3;*/

    Int buf[3];

    cin >> a >> b >> c;

    buf[0] = abs(a-b);
    buf[1] = abs(b-c);
    buf[2] = abs(c-a);

    if (buf[0] <= buf[1]) {
        if (buf[1] <= buf[2]){
            buf[2] = 0;
        }
        else {
            buf[1] = 0;
        }
    }
    else if(buf[0] <= buf[2]){
        buf[2] = 0;
    }
    else {
        buf[0] = 0;
    }

   cout << buf[0] + buf[1] + buf[2]  << endl;

    return 0;
}

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

int main(void){

    char S[11];
    int T[11] = {0};
    int X[11] = {0};
    scanf("%s", S);
    
    int i, j;
    int max_s = -1;
    int max_e = -1;
    int max_len = 0;
    for(i=0; S[i]!='\0'; i++) {
        if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
            T[i] = 1;
        }
    }

    i = 0;
    while(S[i] !='\0') {
        // 同じ場所から順に右に探索
        if(T[i] == 1) {
           // printf("nice !S[%d] = %c\n", i, S[i]); 
           for(j=i; S[j]!='\0'; j++) {
               if(T[j] == 1) {
                   // printf("T[%d] = 1\n", j);
                   if(j - i + 1 > max_len) {
                       max_len = j - i + 1;
                       max_s = i;
                       max_e = j;
                       // printf("kiroku kousin\n");
                    }
               }
               else{
                   i++;
                   // printf("quit, next\n");
                   break;
               }
           }
           i++;
           // printf("searching end. next i\n");
        }
        else{
           // printf("S[%d] = %c, zannen\n", i, S[i]); 
            i++;
        }
    }

    //printf("%d, %d, %d\n", max_s, max_e, max_len);
    printf("%d\n", max_len);

    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <numeric>

using namespace std;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...)
#endif
#define sz(x) ((int)(x).size())
#define forn(i, n) for (int i = 0; i < (n); i++)

#ifdef DEBUG
struct Timestamper {
  string msg;
  clock_t start;

  Timestamper(const string &_msg) : msg(_msg), start(clock()) {}
  ~Timestamper() {
    eprintf("[ %s ] Time=%.3lfs\n", msg.c_str(), (clock() - start) * 1.0 / CLOCKS_PER_SEC);
  }
} __timestamper("end");
#else
struct Timestamper {};
#endif

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int inf = 1e9;

int cache[1 << 16];
int solve(int msk) {
  if (!msk) return 0;
  if (cache[msk]) return cache[msk];

  int ans = inf;
  for (int i = 15; i >= 0; i--) if (msk & (1 << i)) {
    ans = min(ans, 1 + solve(msk ^ (1 << i)));
    for (int si = 0; si < i; si++) if (msk & (1 << si)) {
      int si2 = i ^ si;
      int cans = solve(msk ^ (1 << i) ^ (1 << si) ^ (1 << si2)) + 1;
      if (msk & (1 << si2)) cans++;
      ans = min(ans, cans);
    }
    break;
  }
  return cache[msk] = ans;
}

vector<vector<pii>> es;
vi cnts;

void dfs(int v, int par = -1) {
  int tails = 0;
  for (pii e : es[v])
    if (e.first == par) {
      tails ^= e.second;
    } else {
      dfs(e.first, v);
      tails ^= e.second;
    }
//  eprintf("v=%d, tails=%d\n", v, tails);
  cnts[tails]++;
}

int main() {
  #ifdef DEBUG
  freopen(".in", "r", stdin);
  freopen(".out", "w", stdout);
  #endif

  int n;
  while (scanf("%d", &n) >= 1) {
    es = vector<vector<pii>>(n);
    forn (i, n - 1) {
      int a, b, w;
      scanf("%d%d%d", &a, &b, &w);
      es[a].eb(b, w);
      es[b].eb(a, w);
    }
    cnts = vi(16, 0);
    dfs(0);
    cnts[0] = 0;
    eprintf("cnts:\n");
//    forn (i, 16)
//      eprintf("  [%d]=%d\n", i, cnts[i]);
    int ans = 0;
    int msk = 0;
    forn (i, 16) {
      ans += cnts[i] / 2;
      if (cnts[i] & 1) {
        msk |= 1 << i;
      }
    }
    eprintf("preans=%d\n", ans);
    ans += solve(msk);
    printf("%d\n", ans);
    eprintf("=====\n");
    fflush(stdout);
  }
  return 0;
}


Measured memory_bytes: 11776
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    if(a<b){
        cout<<"a < b"<<endl;
    }
    else if(a>b){
        cout<<"a > b"<<endl;
    }
    else{
        cout<<"a == b"<<endl;
    }
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll N; cin >> N;
    vll A(N); vll B(N); 
    vll dif(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    for(int i=0; i<N; i++){
        cin >> B[i];
    }
    for(int i=0; i<N; i++){
        dif[i] = A[i] - B[i];
    }
    sort(dif.begin(),dif.end());
    if(dif[0] >= 0){cout << 0;}
    else{
    ll sum = 0;
    for(auto x: dif){
        sum += x;
    }
    if(sum < 0){cout << -1;}
    else{int h = N-1;
    int k = 0;
    while(dif[k] < 0&&k != h){
        if(0-dif[k] < dif[h]){
            dif[h] += dif[k];
            dif[k] = 0;
            k++;
        }
        else if(0-dif[k] == dif[h]){
            dif[k] = 0;
            dif[h] = 0;
            h--; k++;
        }
        else{
            dif[k] += dif[h];
            dif[h] = 0;
            h--;
        }
    }
    if(k == h){
        if(dif[k] >= 0){
            cout << k+N-h;
        }
        else{
            cout << -1;
        }
    }
    else{
        cout << k+N-h;
    }
    }
    }
}
   

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define MAX 5000011
#define LOG 20
using namespace std;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);	
	int n;
	cin>>n;
	if(n <= 999)cout<<"ABC";
	else cout<<"ABD";
	return 0;
}

Measured memory_bytes: 256
import math

K = int(input().strip())

ans = 0
for a in range(1,K+1):
    tmp = 0
    for b in range(1,K+1):
        for c in range(b + 1,K+1):
            tmp += math.gcd(a, math.gcd(b,c))
    tmp *= 2
    for b in range(1, K + 1):
        tmp += math.gcd(a, b)
    ans += tmp

print(ans)

Measured memory_bytes: 9192
#include <stdio.h>
int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r); 
      if (x >= r && x+r <= W&&y >= r && y+r <= H){                
    printf("Yes\n");
}
      else {
    printf("No\n");
}
    return 0;
}


Measured memory_bytes: 2104
#include<cstdio>
int a[505][505],ans[250005][4],tot;
int main()
{
	int n,m;scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++) scanf("%d",&a[i][j]);
	for(int i=1;i<=n;i++)
	for(int j=1;j<m;j++)
	if(a[i][j]&1)
	{
		a[i][j]--;a[i][j+1]++;
		ans[++tot][0]=i,ans[tot][1]=j,ans[tot][2]=i,ans[tot][3]=j+1;
	}
	for(int i=1;i<n;i++)
	if(a[i][m]&1)
	{
		a[i][m]--;a[i+1][m]++;
		ans[++tot][0]=i,ans[tot][1]=m,ans[tot][2]=i+1,ans[tot][3]=m;
	}
	printf("%d\n",tot); 
	for(int i=1;i<=tot;i++) printf("%d %d %d %d\n",ans[i][0],ans[i][1],ans[i][2],ans[i][3]);
	return 0;
}

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

using namespace std;
using ll = long long;

#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
#define in cin
#define out cout

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	double n;
	cin >> n;
	int ans = (n + 1) / 2;
	cout << fixed << setprecision(6) << double(ans) / n << endl;
}



Measured memory_bytes: 3732
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll s;cin >>s;
  ll inf=1000000007;
  ll dp[2020];
  rep(i,s+1)dp[i]=0;
  dp[0]=1;
  dp[1]=0;
  dp[2]=0;
  dp[3]=1;
  for(int i=4; i<s+1;i++){
    for(int j=0;j<i-2;j++){
      dp[i]+=dp[j];
      dp[i]%=inf;
    }
  }
  cout <<dp[s]<<endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(30);
#define ll long long
#define pi 3.14159265359
using namespace std;

int main()
{
    IOS;
    ll n,x,q,b,c,s=0;
    cin>>n;
    map<int,int> m;
    while(n--){
        cin>>x;
        s+=x;
        m[x]++;
    }
    cin>>q;
    while(q--){
        cin>>b>>c;
        s=s+(c-b)*m[b];
        m[c]+=m[b];
        m[b]=0;
        cout<<s<<'\n';
    }
    return 0;
}


Measured memory_bytes: 8044
#include <cstdio>
#include <cmath>

using namespace std;

#define PI 4 * atan(1.0)

int main(void){
	int w, r, d = 0;
	double x = 0, y = 0;
	while(1){
		scanf("%d%*c%d%*c",&w,&r);
		if(w == 0 && r == 0){
			break;
		}
		x += w * cos(d * PI / 180);
		y += w * sin(d * PI / 180);
		d += r;
	}
	printf("%d\n%d\n",(int)y,(int)x);
	return 0;
}

Measured memory_bytes: 1032
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct node{
    int key;
    struct node *parent,*left,*right;
}node;
#define N 500000

int m;
node t[N],*NIL,*root;

void insert(node *t,node *z){
    node *y=NIL;
    node *x=root;
    while(x!=NIL){
        y=x;
        if(z->key<x->key)x=x->left;
        else x=x->right;
        z->parent=y;
    }
    if(y==NIL)root=z;
    else if(z->key<y->key)y->left=z;
    else y->right=z;

}

void inparse(node *u){
  if(u==NIL)return;
  inparse(u->left);
  printf(" %d",u->key);
  inparse(u->right);
}

void preparse(node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preparse(u->left);
  preparse(u->right);
}

int main(){
    int i,n;
    char str[6];
    node *z;

    scanf("%d",&m);
    for(i=0;i<m;i++){
        scanf("%s",str);
        if(strcmp(str,"insert")==0){
        
            scanf("%d",&n);
            
            z=(node *)malloc(sizeof(node));
            z->key=n;
            
            z->left=NIL;
            z->right=NIL;
            insert(t,z);
        }
        else if(strcmp(str,"print")==0){
            inparse(root); 
            printf("\n"); 
            preparse(root);
            printf("\n");  
        }
    }
    return 0;
}


Measured memory_bytes: 25168
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	string s; ll k; cin >> s >> k;
	ll len = s.length();
	ll one = 0;
	ll ans = 0;
	Rep(i, len){
		if(s[i] - '0' == 1){
			one += 1;
		}else{
			ans = s[i] - '0';
			break;
		}
	}
	if(one >= k){
		cout << 1 << endl;
	}else{
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>
using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
// #define ost tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define    int                      long long int
#define    ld                       long double
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int ttt; cin >> ttt; while(ttt--)
#define    ff                       first
#define    ss                       second
#define    all(container)            container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    sp(x)                    setprecision(x)
#define    bp                       __builtin_popcount

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}

int32_t main()
{
    speed upp
    int n;
    cin>>n;
    ld r=2*n;
    r=r*((ld)(3.141592653589793238));
    cout<<fixed<<sp(15)<<r;
}

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

#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define mo 998244353
string str;
//map<int, int>::iterator itr; 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;cin>>n;
    ll m=0,f=0;
    for(int i=1;i<=5000000;i++){
        m=m*10+7;
        m=m%n;
        if(m==0){
            cout<<i;f=1;break;
        }
    }
    if(f==0)
    cout<<-1;
    return 0;
}


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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

vector<int> g[maxn];
int ans[maxn];
map<pair<int, int>, int> mp;
int k = 0;

void dfs(int u, int p = -1, int prev = -1) {
    int color = 1;
    for (auto x: g[u]) {
        if (color == prev)
            color++;
        if (ans[mp[{min(u, x), max(u, x)}]] == 0)
            ans[mp[{min(u, x), max(u, x)}]] = color, color++;
    }
    for (auto x : g[u]) {
        if (x != p) {
            dfs(x, u, ans[mp[{min(u, x), max(u, x)}]]);
        }
    }
    k = max(k, color);
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;

        g[a].push_back(b);
        g[b].push_back(a);
        if (a > b)swap(a, b);
        mp[{a, b}] = i;
    }

    dfs(1);
    cout << k -1 << endl;
    for (int i = 0; i < n - 1; i++)
        cout << ans[i] << endl;
}

Measured memory_bytes: 17792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N= 1e5 + 5;
const ll mod=1e9 + 7;

int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    ll n;
    string str;
    cin>>n>>str;
    if(n&1)return cout<<"No" , 0;
    string s = str.substr(0,n/2);
    string t = str.substr(n/2);
    if(s==t)cout<<"Yes";
    else cout<<"No";
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAX = 100001;
int n, v1[MAX], v2[MAX], ans;
int main() {
  scanf("%d", &n);
  for(int i = 1, v; i <= n; ++i) {
    scanf("%d", &v);
    if(i%2 == 1) ++v1[v];
    else ++v2[v];
  }
  int v1maxp1 = 0, v2maxp2 = 0;
  int v1maxp2 = 0, v2maxp1 = 0;
  for(int i = 1; i < MAX; ++i) {
    if(v1[v1maxp1] < v1[i]) v1maxp1 = i;
    else if(v2[v2maxp2] < v2[i]) v2maxp2 = i;
    if(v2[v2maxp1] < v2[i]) v2maxp1 = i;
    else if(v1[v1maxp2] < v1[i]) v1maxp2 = i;
  }
  int ans = min(n-v1[v1maxp1]-v2[v2maxp2],
                n-v1[v1maxp2]-v2[v2maxp1]);
  printf("%d\n", ans);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define int ll
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAX = 1e6 + 10;

int a[MAX];
int bb[MAX];
void solve() {
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        bb[a[i]]++;
    }
    int begin=__gcd(a[0],a[1]);
    int ji=0;
    if(begin>1){
        ji++;
    }
    for(int i=2;i<n;i++){
        begin=__gcd(begin,a[i]);
        if(begin>1){
            ji++;
        }
    }
    if(begin>1){
        cout<<"not coprime";
    }else if(ji!=0){
        cout<<"setwise coprime";
    }else{
        for(int i=2;i<MAX;i++){
            int ji=0;
            for(int j=i;j<MAX;j+=i){
                ji+=bb[j];
            }
            if(ji>1){
                cout<<"setwise coprime";
                return;
            }
        }
        cout<<"pairwise coprime";
    }
}

signed main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int _ = 1;
    //cin>>_;
    while (_--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 19124
def time_to_i(s):
    tt = list(map(int, s.split(':')))
    return tt[0] * 3600 + tt[1] * 60 + tt[2]

while True:
    n = int(input())
    if n == 0: break
    tmp = []
    for i in range(n):
        tmp.append(input().split())
    table = []
    for t in tmp:
        table.append((time_to_i(t[0]), 1)) # 1: departure, 0: arrival
        table.append((time_to_i(t[1]), 0))
    table.sort(key=lambda x:(x[0], x[1]))
    trains = 1
    for t in table:
        if t[1] == 1:
            if trains > 0:
                trains -= 1
        else:
            trains += 1
    print(trains)

Measured memory_bytes: 15156
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn func(a: &Vec<i64>, tar: i64) -> i64 {
    let mut tmp = 0;
    let mut sum = 0;
    let mut sig = tar;
    for i in 0..a.len() {
        sum += a[i];
        if sum.signum() != sig {
            let d = sum.abs() + 1;
            tmp += d;
            sum += d * sig;
        }
        sig *= -1;
    }
    tmp
}


fn main() {
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = line[0];
    let a: Vec<i64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let ans = cmp::min(func(&a, 1), func(&a, -1));

    println!("{}", ans);
}


Measured memory_bytes: 6524
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
typedef long long ll;
using namespace std;

int main() {
    int n, k, d, a;
    scan2Int(n, k);
    bool men[n];
    rep(i, n) men[i] = false;
    rep(step, k) {
        scanInt(d);
        rep(i, d) {
            scanInt(a);
            a -= 1;
            men[a] = true;
        }
    }
    int count = 0;
    rep(i, n) {
        if (!men[i]) count++;
    }
    printInt(count);
    return 0;
}


Measured memory_bytes: 3768