akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;

string its(int n){
    stringstream s;
    s << n;
    return s.str();
}

int main(){
    int n,m;
    
    while(cin >> n >> m ,n+m){
        vector<int> v;
        for(int i = 0 ; i < n ; i++) v.push_back(i+1);
    
        int cnt = 1,t = 0;
        string str;
        
        while(m--){
            bool check = false;
            
            cin >> str;
            if(cnt%15==0){
                if(str != "FizzBuzz"){
                    check = true;
                }
            }
            else if(cnt%3==0){
                if(str != "Fizz"){
                    check = true;
                }
            }
            else if(cnt%5==0){
                if(str != "Buzz"){
                    check = true;
                }
            }
            else{
                if(str!=its(cnt)){
                    check = true;
                }
            }
            
            if(check&&v.size() > 1){
                v.erase(v.begin()+t);
                t %= v.size();
            }
            else t = (t+1)%v.size();
                
            cnt++;
        }
        for(int i = 0 ; i < v.size() ; i++){
            if(!i) cout << v[i];
            else cout << ' ' << v[i];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1268
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		BufferedReader r =
            new BufferedReader(new InputStreamReader(System.in), 1);
        String s = r.readLine();
        int size = Integer.parseInt(s);
        long min = 0,max = 0,sum = 0;
        s = r.readLine();
        String[] strData = s.split(" ");
        for (int count = 0; count < size; count++){
        		long tmp = Long.parseLong(strData[count]);
        		if(count == 0){
        			min = max = sum = tmp;
        		} else {
        			if (min > tmp) {
        				min = tmp;
        			}
        			if (max < tmp) {
        				max = tmp;
        			}
        			sum += tmp;
        		}
        }
        System.out.print(min);
        System.out.print(" ");
        System.out.print(max);
        System.out.print(" ");
        System.out.print(sum);
        System.out.print("\n");
    }
}

Measured memory_bytes: 39440
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = n - 1; i >= 0; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<ll> vll;

const int MAXN = 100005;
ll mod=1000000007;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	vi d(3);
	rep(i,3)cin>>d[i];
	vii q;
	rep(i,n){
		string s;
		cin>>s;
		if(s == "AB") q.emplace_back(0,1);
		else if(s == "BC") q.emplace_back(1,2);
		else q.emplace_back(0,2);
	}
	q.emplace_back(0,1);
	string ans;
	auto add = [&](int a,int b){
		d[a]++;
		d[b]--;
		ans+='A'+a;	
		ans+='\n';
	};
	rep(i,n){
		int a = q[i].F;
		int b = q[i].S;
		if(!d[a] and !d[b]){
			cout<<"No"<<nl;
			return 0;
		}
		if(!d[a]){
			add(a,b);
		}
		else if(!d[b]){
			add(b,a);	
		}
		else {
			int na = q[i+1].F;
			int nb = q[i+1].S;
			if( a == na || a == nb){
				add(a,b);
			}
			else{
				add(b,a);
			}
		}
	}
	cout<<"Yes"<<nl;
	cout<<ans<<nl;
	return 0;
}



Measured memory_bytes: 4552
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstring>

using namespace std;

int main()
{
	set<string> list;
	int n;

	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		string str;
		char input[11];

		scanf("%s", input);
		str = input;

		list.insert(str);
	}

	printf("%d\n", list.size());

	return 0;
}

Measured memory_bytes: 18968
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f
#define INF 0x3f3f3f3f
#define pb push_back
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define ms(a, x) memset(a, x, sizeof(a))
#define for0(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, int> pli;
typedef pair<long long, long long> pll;
const int mod = 1e9 + 7;
const int N = 1e5+10;
const int M = 1e6+10;
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline ll Pow(ll a, ll b) { ll ans = 1; for( ; b; b >>= 1) { if(b&1) ans = ans * a % mod; a = a * a % mod;} return ans;}
inline ll Mul ( ll a, ll b)  { ll lf = a * ( b >> 25ll ) % mod * ( 1LL << 25 ) % mod; ll rg = a * ( b & ( ( 1ll << 25 ) - 1 ) ) % mod; return ( lf + rg ) % mod;}
//==================================================================================================================================================================//

int n, h[N], dp[N];

int main() {
   scanf("%d", &n);
   ms(dp, inf); dp[n] = 0;
   for1(i, n) scanf("%d", h+i);
   for(int i = n; i; --i) {
      if(i == 2) dp[i-1] = min(dp[i-1], dp[i] + abs(h[i] - h[i-1]));
      else {
         dp[i-1] = min(dp[i-1], dp[i] + abs(h[i] - h[i-1]));
         dp[i-2] = min(dp[i-2], dp[i] + abs(h[i] - h[i-2]));
      }
   }
   printf("%d\n", dp[1]);
   return 0;
}

Measured memory_bytes: 4616
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9+7)
#define INF ((int)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;

LL modinv(LL a){
	LL b = MOD, u = 1, v = 0;
	while(b){
		LL t = a / b;
		a -= t * b;swap(a, b);
		u -= t * v;swap(u, v);
	}
	u%=MOD;
	if(u < 0) u += MOD;
	return u;

}
LL exp(LL a, LL b){
	LL res = 1;
	LL sum = a;
	while(b){
		if(b&1)res = (res * sum) % MOD;
		sum = (sum * sum) % MOD;
		b>>=1;
	}
	return res;
}

int main(){
	int N;
	cin >> N;
	map<LL, LL> m;
	LL ans = 0;
	LL sum = 0;
	m[0]=1;
	REP(i, N){
		LL d;
		cin >> d;
		sum+=d;
		ans += m[sum];
		++m[sum];
	}
	cout << ans << endl;
	return 0;
}


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

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

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   int gcd(int a,int b){return b?gcd(b,a%b):a;};

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

int main(){
    int a1, a2, a3; cin >> a1 >> a2 >> a3;
    cout << max({a1, a2, a3}) - min({a1, a2, a3}) << endl;
}

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

int main() {
  int R;
  cin >>R;
  if(R<1200){
    cout <<"ABC" <<endl;
    return 0;
  }
  else if(R<2800){
    cout <<"ARC" <<endl;
    return 0;
  }
  else{
    cout <<"AGC" <<endl;
    return 0;
  }
  return 0;
}

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

int main() {
    int N;
    double v;
    vector<double> vs;
    cin >> N;
    for (int i=0; i < N; ++i) {
        cin >> v;
        vs.push_back(-v);
    }
    if (N == 1) {
        cout << -vs[0] << endl;
        return 0;
    }
    make_heap(vs.begin(), vs.end());
    while (true) {
        double v1 = vs.front();
        pop_heap(vs.begin(), vs.end());
        vs.pop_back();
        double v2 = vs.front();
        pop_heap(vs.begin(), vs.end());
        vs.pop_back();
        double v3 = (v1 + v2) / 2.0;
        if (vs.empty()) {
            cout << -v3 << endl;
            break;
        }
        vs.push_back(v3);
        push_heap(vs.begin(), vs.end());
    }
    return 0;
}

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

int main(){
 string s;
 string t;
 int a,b;
 string u;

 cin>>s>>t>>a>>b>>u;

 if(u==s){
     cout<<a-1<<" "<<b; 
 }
 else{
     cout<<a<<" "<<b-1;
 }


}

Measured memory_bytes: 256
N, M = map(int, input().split())
job ={}
for _ in range(N):
  a, b = map(int, input().split())
  job.setdefault(a, []).append(-1*b)
reward = 0
import heapq
joblist =[]
for i in range(M):
  try:
    job_temp=job[i+1]
    for i in range(len(job_temp)):
      heapq.heappush(joblist, job_temp[i])
  except KeyError:
    pass
  try:
    choice = heapq.heappop(joblist)
  except IndexError:
    choice = 0
  reward += choice
print(-1*reward)  

Measured memory_bytes: 27320
#include <stdio.h>
#define N 300
void gyouretsu(int,int);
int main()
{
  int i,count;
  int ROW,COLUMN;
  int mat1[N],mat2[N];

  count=0;

  while(1)
  {
    scanf("%d %d",&ROW,&COLUMN);

    if(ROW==0 && COLUMN==0) break;

    mat1[count]=ROW;
    mat2[count]=COLUMN;
    count++;
  }

  for(i=0;i<count;i++)
  {
    gyouretsu(mat1[i],mat2[i]);
  }

  return 0;
}

void gyouretsu(int x,int y)
{
  int i,j;
  for(i=0;i<x;i++)
  {
    for(j=0;j<y;j++)
    {
      printf("#");
    }
    printf("\n");
  }
  printf("\n");
}

Measured memory_bytes: 576
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main()
{
	string S; cin >> S;

	int a = stoi(S.substr(0, 2));
	int b = stoi(S.substr(2, 2));
	cerr << a << " " << b << endl;
	if (a >= 13 && b >= 13 || a == 0 && b >= 13 || a >= 13 && b == 0 || a == 0 && b == 0)cout << "NA" << endl;
	else if (a < 13 && b < 13 && a != 0 && b != 0)cout << "AMBIGUOUS" << endl;
	else if (a >= 13 || a == 0)cout << "YYMM" << endl;
	else if (b >= 13 || b == 0)cout << "MMYY" << endl;


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;
char s[53][53];
int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr); 
	cout.tie(nullptr); 
	cout.setf(ios::fixed); 
	cout.precision(20);

	ll h, w;
	cin >> h >> w;
	REP(i,1,h+1) {
		REP(j, 1, w+1) {
			cin >> s[i][j];
		}
	}
	REP(i, 1, h + 1) {
		REP(j, 1, w + 1) {
			if (s[i][j] == '.') continue;
			else if (s[i][j] == '#' && s[i + 1][j] == '#') continue;
			else if (s[i][j] == '#' && s[i][j + 1] == '#') continue;
			else if (s[i][j] == '#' && s[i - 1][j] == '#') continue;
			else if (s[i][j] == '#' && s[i][j - 1] == '#')continue;
			else {
				//cout << i << " " << j << endl;
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

void hoge(int N, int Q){

   string a[N];
   int b[N], c[N], d[2*N];
   for(int i=0; i<N; i++){
      cin>> a[i]>> b[i]>> c[i];
      d[2*i]=c[i]-b[i]+1;
      d[2*i+1]=c[i];
   }

   for(int q=0; q<Q; q++){
      int e;
      cin>> e;
      for(int i=0; i+1<2*N; i+=2){
         if(d[i]<=e&&e<=d[i+1]){
            cout<< a[i/2]<< " "<< e-d[i]+1<< endl;
            goto ikd;
         }
      }
      cout<< "Unknown"<< endl;
      ikd:;
   }
}

int main(){

   while(1){
      int N, Q;
      cin>> N>> Q;
      if(!(N||Q)) break;

      hoge(N, Q);
   }

   return 0;
}

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

int main(){
    int k,a,b;
    cin>>k>>a>>b;

    for(int i=a; i<=b; i++){
        if(i%k==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using boost::adaptors::reversed;
using boost::irange;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

template <typename T>
vector<size_t> argsort(const vector<T> &target) {
    vector<size_t> idx(target.size());
    iota(idx.begin(), idx.end(), 0);
    sort(idx.begin(), idx.end(), [&target](size_t i1, size_t i2) {return target[i1] < target[i2];});
    return idx;
}

int main() {
    ll N, M;
    cin >> N >> M;
    vector<pair<ll, ll>> abs(M);
    for (auto && i: irange(0LL, M)){
        ll a, b;
        cin >> a >> b;
        abs.at(i) = make_pair(a, b);
    }
    sort(abs.begin(), abs.end());
    unsigned int i = 0;
    ll ret = 1;
    while(i < M){
        pair<ll, ll> now = abs.at(i);
        ll start_now, end_now;
        tie(start_now, end_now) = now;
        while (true){
            i++;
            if (i >= M) break;
            pair<ll, ll> target = abs.at(i);
            ll start_target, end_target;
            tie(start_target, end_target) = target;
//            cout << "start_target " << start_target << " end_now " << end_now << endl;
            if (start_target >= end_now){
                ret += 1;
                break;
            } else {
                start_now = start_target;
                end_now = min(end_now, end_target);
            }
        }
    }
    cout << ret;


    return 0;
}

Measured memory_bytes: 1792
MOD=10**9+7
N,K=map(int,input().split())
d=[0]
d+=[pow(K//i,N,MOD) for i in range(1,K+1)]
for i in reversed(range(1,K+1)):
    j=2
    while(i*j<=K):
        d[i]=(d[i]-d[i*j]+MOD)%MOD
        j+=1
ans=0
for i in range(1,K+1):
    ans=(ans+d[i]*i%MOD)%MOD
print(ans)

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

int main(){
    string p, s;
    cin >> p >> s;

    //文字列を二つつなげる
    p = p + p;
    bool flag = false;

    for(int i = 0; i < (int)p.size() - (int)s.size() + 1; i++){
        //pのi文字目から連続したs.size()文字を抜き出す
        string t = p.substr(i, s.size());

        if(t == s){
            flag = true;
            break;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = -100100100;

int main(){
    int n;
    cin >>n;
    vector<int> w(n);
    rep(i,n)cin >> w.at(i);
    int d = -1*INF;
    for(int t = 0;t<n-1;++t){
        int s1,s2;
        s1 = 0;
        s2 = 0;
        for(int i = 0; i<=t;++i)s1+=w.at(i);
        for(int j=t+1;j<n;++j)s2+=w.at(j);
        d = min(abs(s1-s2),d);
    }
    cout << d << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<algorithm>
using namespace std;
int main(void){
	int n, v[20], c[20];
	int s[20],ans=0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &v[i]);
	for (int i = 0; i < n; i++){
		scanf("%d", &c[i]);
		s[i] = v[i] - c[i];
	}
	sort(s, s + n);
	for (int i = n - 1; s[i] > 0&&i!=-1; i--) {
		ans += s[i];
	}

	printf("%d", ans);


	return 0;
} 


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	long long a ,b;
	scanf("%lld %lld", &a, &b);
	if(((a<0)&&(b>0)) || (a==0) || (b==0))
	{
		printf("Zero");
	}
	else if((a<0)&&(b<0))
	{
		if(a==b)
		{
			printf("negative");
		}
		else if((b-a)%2==0)
		{
			printf("Negative");
		}
		else
		{
			printf("Positive");
		}
	}
	else
	{
		printf("Positive");
	}
	return 0;
 } 

Measured memory_bytes: 128
import math

def doc_string():
	"""
	I can fly.
	"""

while True:
	tz = map(int,raw_input().split())
	if tz == [0,0,0]:
		break

	til = math.hypot(*sorted(tz)[:2]) / 2
	for i in xrange(int(raw_input())):
		gate = int(raw_input())
		if gate > til:
			print "OK"
		else:
			print "NA"

Measured memory_bytes: 6332
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.next();

        for(int i=0; i<str.length() - 2; i++){

            if(str.charAt(i) == str.charAt(i+1)){
                 System.out.println((i+1) + " "+ (i+2));
                 return;
            }

            if(str.charAt(i) == str.charAt(i+2)){
                System.out.println((i+1) + " "+ (i+3));
                return;
            }

        }

        if(str.charAt(str.length() -  2) == str.charAt(str.length() - 1)){
            System.out.println((str.length() -  1) + " "+ str.length());
        }else{
            System.out.println(-1+ " "+ -1);
        }
    }
}

Measured memory_bytes: 40852
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   long long N,M;
   cin >> N >> M;
   vector<long long> A;
   for(long long i=0;i<N;i++){
      long long a;
      cin >> a;
      A.emplace_back(a);
   }
   sort(A.begin(), A.end());
   long long S[N+1];
   S[N]=0;
   for(long long i=N-1; i>=0; i--){
      S[i]=S[i+1]+A[i];
   }
   long long right=A[N-1]*2+1;
   long long left=1;
   while(left+1 < right){
      long long mid = (right+left)/2;
      long long sum=0;
      for(long long i=0; i<N; i++){
         long long key = mid-A[i];
         auto it = lower_bound(A.begin(),A.end(),key);
         long long num = A.end()-it;
         sum+=num;
      }
      if(sum < M){
         right = mid;
      }
      else{
         left = mid;
      }
   }
   long long ans = 0;
   for(long long i=N-1; i>=0; i--){
      long long key = right-A[i];
      auto it = lower_bound(A.begin(),A.end(),key);
      long long ind = it-A.begin();
      long long num = N-ind;
      M-=num;
      ans += num*A[i]+S[ind];
   }
   ans += M*left;
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 1908
def slove():
    import sys
    import collections
    import copy
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    ab = collections.defaultdict(list)
    for i in range(m):
        a, b = list(map(int, input().rstrip('\n').split()))
        ab[a] += [b]
        ab[b] += [a]
    td = collections.defaultdict(list)
    td[1]
    q = [[1, td]]
    ans = []
    while True:
        if len(q) != 0:
            p, d = q.pop()
            if len(d) != n:
                for v in ab[p]:
                    if v not in d:
                        td = copy.deepcopy(d)
                        td[v]
                        q.append([v, td])
            else:
                ans.append([d])
        else:
            print(len(ans))
            exit()


if __name__ == '__main__':
    slove()


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

int main() {
    int a, b;

    cin >> a >> b;

    if ((a + b) % 2 == 0) {
        cout << (a + b) / 2 << endl;
    } else {
        cout << (a + b) / 2 + 1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

vector<int> eT;

void es( int n ){
	for( int i = 0; i < n; ++i ) eT.push_back(i);
}

int wurzel( int x ){
	if( eT.at(x) == x ){
		return x;
	} else {
		return eT.at(x) = wurzel( eT.at(x) );
	}
}

void verbinden( int x, int y ){
	x = wurzel(x);
	y = wurzel(y);
	if( x == y ) return;
	eT.at(x) = y;
}

bool gleich( int x, int y ){
	return wurzel(x) == wurzel(y);
}

int main(){
	int n, m;
	cin >> n >> m;
	es(n);
	vector<int> p(n);
	for( int &i : p ) cin >> i;
	for( int i = 0; i < m; ++i ){
		int x, y;
		cin >> x >> y;
		verbinden(x-1, y-1);
	}
	int ans = 0;
	for( int i = 0; i < n; ++i ){
		if( gleich( p.at(i)-1, i ) ) ++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
int main()
{
	char x[200];
	int i,n,OK=0;
	std::cin>>x;
	n= sizeof(x);
	for(i=0;i<n;i++)
	{
		if(x[i]=='C'){OK++;break;}
	}
	for(i;i<n;i++)
	{
		if(x[i]=='F'){std::cout<<"Yes";return 0;}
	}
	std::cout<<"No";return 0;
}

Measured memory_bytes: 256
import heapq
N,M,S = map(int,input().split())
MAX_COST = 2500
S = min(S, MAX_COST)

G = [ [] for _ in range(N) ]
for i in range(M):
  u,v,s,t = map(int,input().split())
  u, v = u-1, v-1
  G[u].append([v, s, t])
  G[v].append([u, s, t])

change_rate, change_cost = [], []
for i in range(N):
  rate, cost = map(int,input().split())
  change_rate.append(rate)
  change_cost.append(cost)

# dp[i][silver] = 頂点iにいて、銀貨をsilver枚持つときの最小時間
dp = [ [float('inf')]*(MAX_COST+1) for _ in range(N) ]
dp[0][S] = 0

# time,node,silver
pq = [(0,0,S)]
while pq:
  time,node,silver = heapq.heappop(pq)

  # going through exchange station
  next_silver = min(silver + change_rate[node], MAX_COST)
  next_time = time + change_cost[node]
  if next_time < dp[node][next_silver]:
    dp[node][next_silver] = next_time
    heapq.heappush(pq, (next_time, node, next_silver))

  for nei, ns, nt in G[node]:
    remain_silver = min(silver - ns, MAX_COST)
    if remain_silver < 0: continue

    next_time = time + nt
    if dp[nei][remain_silver] > next_time:
      dp[nei][remain_silver] = next_time
      heapq.heappush(pq, (next_time, nei, remain_silver))

for d in dp[1:]:
  print(min(d))

Measured memory_bytes: 99420
h,w = map(int,input().split())
s = [str(input()) for _ in range(h)]
#h,w = 3,3
#s = ['.#.', '#.#', '.#.']

data = [ [0 for _ in range(w)] for _ in range(h) ]
data2 = [ [0 for _ in range(w+2)] for _ in range(h+2) ]

for i in range(h):
  for j in range(w):
    if s[i][j] == '#':
      data[i][j] = 1

for i in range(h+2):
  if i == 0 or i == h+1:
    continue 
  for j in range(w+2):
    if j == 0 or j == w+1:
      continue
    data2[i][j] = data[i-1][j-1]

ck = 1
for i in range(1,h+1):
  for j in range(1,w+1):
    if data2[i][j] :
      if not (data2[i-1][j] or data2[i][j+1] or data2[i+1][j] or data2[i][j-1]) :
        ck = 0
        break
  if not ck :
    break

if ck :
  print('Yes')
else :
  print('No')

Measured memory_bytes: 3188
// AtCoder Beginner Contest 115 - B.cpp
#include <iostream>
#include <algorithm>
using namespace std;
int arr[100], N;

int main()
{
    int sum = 0, mx = 0;
    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> arr[i], sum += arr[i], mx = max(mx, arr[i]);
    sum -= mx / 2;
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                while(sc.hasNext()){
                        String b = Integer.toString(sc.nextInt(), 2); 
                        String s = ""; 
                        for(int i = 0; i < b.length(); i++){
                                if(b.charAt(b.length()-1-i) == '1'){
                                        if(!s.equals("")){
                                                s += " ";
                                        }   
                                        s += (int)Math.pow(2,i);
                                }   
                        }   
                        System.out.println(s);
                }   
                sc.close();
        }   
}

Measured memory_bytes: 12000
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;
inline int toInt(string s){int v;istringstream i(s);i>>v;return v;}
template<class T> inline string toString(T x){ostringstream o;o<<x;return o.str();}
template<class T> void pv(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}
const int INF = 1000000000;
const double EPS = 1e-10;

// a < b;
bool LE(const double a, const double b) {
	return (a < b + EPS);
}

int main() {
	string name[8] = {"AAA", "AA", "A", "B", "C", "D", "E", "NA"};
	double m500[8] = {35.50, 37.50, 40.00, 43.00, 50.00, 55.00, 1 * 60 + 10, 100000000};
	double m1000[8] = {1 * 60 + 11, 1 * 60 + 17, 1 * 60 + 23, 1 * 60 + 29, 1 * 60 + 45, 1 * 60 + 56, 2 * 60 + 28, 100000000};
#if 0
	for(int i = 0; i < 7; i++) {
		cout << name[i] + ":" << m500[i] << ":" << m1000[i] << endl;
	}
#endif
	
	for(double a, b; cin >> a >> b;) {
		int i = 0;
		while(LE(m500[i], a) || LE(m1000[i], b)) i++;
		cout << name[i] << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int main(){
    int n,m;
    cin >> n >> m ;
    if (n == m)
    {
        cout << "Yes" << endl ;
    }else
    {
        cout << "No" << endl ;
    }
    
    
}

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

using namespace std;

// ---------------------
// repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// ---------------------
#define INF 922337203685477580
#define IINF (1<<21)
typedef long long ll;



int main() {
  int n;

  while (1) {
    cin >> n;

    // dump(n);

    if (n == 0) break;

    int a[500];
    REP(i, 500) {
      a[i] = 0;
    }

    int skipflg = 0;

    char ipt[500];
    REP(i, n) {
      cin >> ipt[i];
      // cout << ipt[i];
    }

    REP(i, n) {
      char person = ipt[i];
      a[(int)person] += 1;

      int b[500];
      memcpy(b, a, 500*sizeof(int));
      // dump(b[(int)person]);
      sort(b, b + 500);

      // dump((int)person);
      // dump(b[0]);
      // dump(b[499]);
      // dump(b[498]);

      if (b[499] > b[498] + n - i - 1) {

        // search person
        char p;
        REP(t, 500) {
          if (b[499] == a[t]) {
            p = (char)t;
            break;
          }
        }
        cout << p << " " << i + 1 << endl;
        skipflg = 1;
        break;
      }
    }
    if (!skipflg) {
      cout << "TIE" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3060
//ProblemE

//#define USE_STDIO
//#define USE_LOG
//#define FILE_ERR

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#ifndef debug
#define debug(...)
#endif // !LOG

//include
#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iomanip>

using namespace std;

//for
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define forbe(i, begin, end) for(decltype(begin) i = (begin); i != (end); ++i)
#define forbes(i, begin, end, step) for(decltype(begin) i = (begin); i != (end); i += (step))

//int
using ll = long long;
using ull = unsigned long long;
using uint = unsigned;

//pair
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
#define fi first
#define se second

//vector
template <typename Value>
static inline void fillv(Value& x, const Value& val) { x = val; }
template <typename Vector, typename Value>
static inline void fillv(Vector& v, const Value& val) { for (auto& x : v) fillv(x, val); }

static inline void Solve();

int main(int argc, char* argv[]) {
#ifdef REDIRECT_STDIO
	REDIRECT_STDIO;
#endif // REDIRECT_STDIO

	Solve();
	return 0;
}

constexpr int MAXN = 2000;
constexpr int INF = 0x7FFFFFFF;
int a[MAXN];
int b[MAXN];
int n, k, q;

vector<pii> get_ps(int i) {
	vector<pii> rst;
	for (int j = 0; j <= n; j++) {
		if (j < n && b[j] >= b[i]) {
			if (rst.empty() || rst.back().second != j - 1) {
				rst.push_back({ j, j });
			}

			rst.back().second = j;
		}
		else {
			if (!rst.empty() && rst.back().second - rst.back().first + 1 < k) {
				rst.pop_back();
			}
		}
	}
	return rst;
}

int tmp[MAXN];
int solve(int i) {
	for (int j = 0; j < n; j++) b[j] = a[j];
	auto ps = get_ps(i);
	bool hasi = false;
	vector<int> minv;

	for (auto &p : ps) {
		if (p.first <= i && i <= p.second) {
			hasi = true;
		}
		int num = p.second - p.first + 1;
		nth_element(b + p.first, b + p.first + num - k, b + p.second + 1);
		for (auto it = b + p.first; it <= b + p.first + num - k; it++) {
			minv.push_back(*it);
		}
	}

	if (!hasi) return INF;
	if ((int)minv.size() < q) return INF;
	nth_element(minv.begin(), minv.begin() + q - 1, minv.end());
	return minv[q - 1] - a[i];
}

//ProblemE
void Solve() {
	cin >> n >> k >> q;
	forn(i, n) cin >> a[i];

	int ans = INF;
	for (int i = 0; i < n; i++) {
		ans = min(ans, solve(i));
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<string> W(N);
    for (int i = 0; i < N; i++) {
        cin >> W[i];
    }
    //this was the original idea ->to use set ds for checking if the strings are same
    set<string> st;
    for (int i = 0; i < N; i++) {
        if (i > 0 && (st.find(W[i]) != st.end() || W[i - 1].back() != W[i][0])) {
            cout << "No" << endl;
            return 0;
        }
        st.insert(W[i]);
    }
    cout << "Yes" << endl;
}


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



using namespace std;
long long mod;
long long dp[305][305];
bool vis[305][305];
long long ans[305][305];
long long comb[1005][1005];
bool vis2[305];
int K;long long rec(int n,int i);
long long rec2(int n,int l){
   // cout << n << " " << l << " A" << endl;
    if(vis2[n]) return (ans[n][K+1]-ans[n][l]+mod)%mod;
    vis2[n]=1;
    for(int i=1;i<=K+1;++i) ans[n][i]=(ans[n][i-1]+rec(n,i))%mod;
   // cout << n << " " << l << " " << "B" << endl;
    return (ans[n][K+1]-ans[n][l]+mod)%mod;
}
long long rec(int n,int l){

    if(n==0) return 1;
    if(l>K) return 0;
    if(n==1) return K-l+1;
    if(vis[n][l]) return dp[n][l];
    vis[n][l]=1;
        for(int j=0;j<n;++j){
            int u=n-j-1;
            dp[n][l]=(dp[n][l]+((comb[n-1][j]*(rec2(j,l)))%mod)*rec(u,l))%mod;
        }

    return dp[n][l];

}

int main(){
    int n,k,m;
    cin >> n >> k >> m;
    mod=m;
    K=k;
    for(int i=0;i<=1000;++i) comb[i][0]=1;
    for(int i=1;i<=1000;++i){
        for(int j=1;j<=i;++j){
            comb[i][j]=(comb[i-1][j]+comb[i-1][j-1])%m;
        }
    }
    cout << (rec(n,1)+mod)%mod << endl;
    return 0;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = 1; i <= (int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

//const ll mod=1000000007;

int main() {
    int N;
    cin >> N;
    set<string> s;
    rep(i,N) {
        string a;
        cin >> a;
        s.insert(a);
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 19232
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	int N; cin>>N;
	vector<vector<bool>> shop(N,vector<bool>(10));
	vector<vector<int>> earn(N,vector<int>(11));
	rep(i,N){
		rep(j,10){
			int t; cin>>t;
			if(t == 0)shop[i][j] = false;
			else shop[i][j] = true;
		}
	}
	rep(i,N){
		rep(j,11){
			cin>>earn[i][j];
		}
	}

	ll ans = -INF;
	REP(bit, (1<<10)-1){
		vector<bool> open(10);
		rep(i,10){
			if(bit & (1<<i))open[i] = true;
		}
		ll e_ans = 0;
		rep(j,N){
			int cnt = 0;
			rep(k,10){
				if(open[k] && shop[j][k]) ++cnt;
			}
			e_ans += earn[j][cnt];
		}
		ans = max(ans, e_ans);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
H,W=list(map(int,raw_input().split()))
a = []
for i in range(H):
    a.append(list(raw_input()))
#print a

cnt=0
for i in range(H):
	for j in range(W):
		#print i,j
		if i-1>-1 and j-1>-1 and a[i-1][j-1]=="#":cnt+=1
		if i-1>-1 and a[i-1][j]=="#":cnt+=1
		if i-1>-1 and j+1<W and a[i-1][j+1]=="#":cnt+=1
		if j+1<W and a[i][j+1]=="#":cnt+=1
		if j-1>-1 and a[i][j-1]=="#":cnt+=1
		if j-1>-1 and i+1<H and a[i+1][j-1]=="#":cnt+=1
		if i+1<H and a[i+1][j]=="#":cnt+=1
		if i+1<H and j+1<W and a[i+1][j+1]=="#":cnt+=1
		
		#print i,j,cnt
		if a[i][j]==".":
			a[i][j]=cnt
		cnt=0
			


for i in range(H):
	maped_num = map(str, a[i])
	s = ''.join(maped_num)
	print s

Measured memory_bytes: 2696
N = int(input())
card = list(map(int, input().split()))
card.sort(reverse = True)

A = 0
B = 0

for i in range(1, N+1):
    if i % 2 == 1:
        A += card[i-1]
    else:
        B += card[i-1]

print(A -B)

Measured memory_bytes: 3064
// Contest.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>
#include <map>
#include <math.h>
#include <iomanip>
#include <stack>

using namespace std;


int main() {
	int x, y;
	cin >> x >> y;
	if (x%y == 0) {
		cout << -1;
		return 0;
	}
	else {
		for (long long int i = x; i < 100000000000000000; i += x) {
			if (i%y == 0)continue;
			else {
				cout << i;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
Max, Min = 0, 10**5
for i in range(m):
    l, r = map(int, input().split())
    if l>Max:
        Max = l
    if r<Min:
        Min = r
if Max <= Min:
    print(Min-Max+1)
else:
    print(0)

Measured memory_bytes: 43624
fun main(args: Array<String>) {
    val n = readLine()!!.toLong()

    fun f(n: Long): List<Long> {
        val r = mutableListOf<Long>()
        var i = 1L
        while (i * i <= n) {
            if (n % i == 0L) {
                r.add(i)
                if (i * i != n) r.add(n / i)
            }
            i++
        }
        return r
    }

    var ans = 0

    for (l in f(n)) {
        if (l == 1L) continue
        var x = n
        while (x % l == 0L) x /= l
        if (x % l == 1L) ans++
    }

    ans += f(n - 1).size - 1

    println(ans)
}


Measured memory_bytes: 31904
// AOJ 0519: Worst Reporter
// 2017.10.28 bal4u@uu
// 2018.1.20

#include <stdio.h>

int to[5001][100], hi[5001];
int q[5001], top, end;
int count[5001];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int tsort(int n)
{
    int i, j, k, f;

//  for (i = 0; i < n; i++) for (j = 0; j < hi[i]; j++) count[to[i][j]]++;

    top = end = 0;
    for (i = 0; i < n; i++) if (!count[i]) q[end++] = i;
    f = 0;
    while (top < end) {
		f |= (end - top) > 1;
		i = q[top++];
        printf("%d\n", i+1);
        for (j = 0; j < hi[i]; j++) {
            k = to[i][j];
            if (--count[k] == 0) q[end++] = k;
        }
    }
	return f;
}

int main()
{
	int n, m, a, b;

	n = in(), m = in();
	while (m--) {
		a = in()-1, b = in()-1;
		to[a][hi[a]++] = b;
		count[b]++;
	}
	putchar('0' + tsort(n));
	putchar('\n');
	return 0;
}



Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    long long int n,i,j,m,mod=1000000007;
    cin>>n>>m;
    string s[n];
    for(i=0;i<n;i++)
    {
        cin>>s[i];
    }
    long long int a[n][m]={0};
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            a[i][j]=0;
        }
    }
    a[0][0]=1;
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            if(s[i][j]=='.'&&(i+j!=0))
            {
                if(i==0)
                {
                    a[i][j]=a[i][j-1];
                }
                else if(j==0)
                {
                    a[i][j]=a[i-1][j];
                }
                else
                {
                    a[i][j]=(a[i-1][j]+a[i][j-1])%mod;
                }
            }
        }
    }
    cout<<a[n-1][m-1];
    return 0;
}




Measured memory_bytes: 9088
A, B, K = map(int, input().split())
num_list = []
for i in range(K):
    num_list.append(A + i)
for i in range(K):
    num_list.append(B - i)
num_list = sorted(set(num_list))

for i in num_list:
    if A <= i <= B:
        print(i)


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

typedef long long int ll;

int main() {
	int k;
	cin >> k;
	if(k == 1) {
		cout << 1 << endl;
		cout << "1 " << endl;
	} else if(k == 2) {
		cout << 2 << endl;
		cout << "1 2 \n2 1 " << endl;
	} else {
		int n = (k + 3) / 4;
		n *= 2;
		cout << n << endl;

		for(int x = 0; x < n; ++x) {
			for(int y = 0; y < n; ++y) {
				int color = 2 * ((x + y) % n) + x % 2;
				/*
				if(color == k) color--;
				if(n % 4 == 1 && color == k - 2) color--;
				*/
				if(k % 4 == 3) {
					// 0 .. 2n
					if(color == 2 * n - 1) color--;
				} else if (k % 4 == 2) {
					if(color == 2 * n - 1 || color == 2 * n - 2) color = 2 * n - 3;
					else if(color == 2 * n - 3) color--;
				} else if (k % 4 == 1) {
					if(color == 2 * n - 1 || color == 2 * n - 2) color = 2 * n - 4;
					else if(color == 2 * n - 3 || color == 2 * n - 4) color = 2 * n - 5;
					else if(color == 2 * n - 5) color--;
				}
				color++;
				cout << color << " ";
			}
			cout << endl;
		}
	}
}


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

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

	string s;
	int k;
	cin >> s >> k;

	int n = s.size();

	set <string> S;
	for (int i = 0; i < n; ++i) {
		string cur = "";
		for (int j = i; j < min(i + 5, n); ++j) {
			cur += s[j];
			S.insert(cur);
		}
	}

	for (auto &i : S) {
		--k;
		if (k == 0) {
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int question = 1 + 2 + 3;
        System.out.println(String.format("%s", question - a - b));
        sc.close();
    }
}


Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

template<class T = ll>
struct Edge {
  int to;
  T cost;
  Edge() {}
  Edge(int to, T cost) : to(to), cost(cost) {}
  bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

template<class T = ll>
vector<T> Dijkstra(vector<vector<Edge<T>>> &edges, int st) {

  int V = (int)edges.size();
  const int INF = numeric_limits<T>::max();
  vector<T> dist(V, INF);
  dist[st] = 0;

  priority_queue<Edge<T>, vector<Edge<T>>, greater<Edge<T>>> p_que;
  p_que.emplace(st, dist[st]);

  while (!p_que.empty()) {

    Edge<T> now(p_que.top().to, p_que.top().cost);
    p_que.pop();

    if (dist[now.to] < now.cost) continue;
    for (const Edge<T> &e : edges[now.to]) {
      T tmp_cost = now.cost + e.cost;
      if (dist[e.to] > tmp_cost) {
        dist[e.to] = tmp_cost;
        p_que.emplace(e.to, dist[e.to]);
      }
    }
  }

  return dist;
}

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

  int N;
  cin>>N;

  int u,v,len;
  vector<vector<Edge<int> > > edges(N);
  for(int i=0;i<N-1;i++){
    cin>>u>>v>>len; u--; v--;
    edges[u].emplace_back(v,len);
    edges[v].emplace_back(u,len);
  }

  auto ans = Dijkstra<int>(edges,0);

  for (auto& i : ans) {
    if(i%2){
      cout<<1<<"\n";
    }else{
      cout<<0<<"\n";
    }
  }
}


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

int main(){
    int n;
    string s, t;
    cin >> n >> s >> t;
    for(int i = 0; i < n; i++){
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll m=0,n,c=0,x,t;
    cin>>n>>x>>t;
    if(n%x==0)
    {
        cout<<(n/x)*t<<endl;
    }
    else
    {
        cout<<((n/x)*t) + t<<endl;
    }
}


Measured memory_bytes: 3596
import java.io.*;
import java.util.*;

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public int[] nextIntArray(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLongArray(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
}

class Algorithm {
  private static void swap(Object[] list, int a, int b) {
    Object tmp = list[a];
    list[a] = list[b];
    list[b] = tmp;
  }
  
  public static <T extends Comparable<? super T>> boolean nextPermutation(T[] ts) {
    int rightMostAscendingOrderIndex = ts.length - 2;
    while (rightMostAscendingOrderIndex >= 0 &&
        ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0) {
      rightMostAscendingOrderIndex--;
    }
    if (rightMostAscendingOrderIndex < 0) {
      return false;
    }
    
    int rightMostGreatorIndex = ts.length - 1;
    while (ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) >= 0) {
      rightMostGreatorIndex--;
    }
    
    swap(ts, rightMostAscendingOrderIndex, rightMostGreatorIndex);
    for (int i = 0; i < (ts.length - rightMostAscendingOrderIndex - 1) / 2; i++) {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    }
    return true;
  }
}

public class Main {
  private static long solve(int r, int g, int b, int n) {
    int count = 0;
    for (int i = 0; r * i <= n; i++) {
      int rest = n - r * i;
      for (int j = 0; g * j <= rest; j++ ) {
        if ((rest - g * j) % b == 0) {
          count++;
        }
      }
    }
    return count;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int r = reader.nextInt();
    int g = reader.nextInt();
    int b = reader.nextInt();
    int n = reader.nextInt();
    out.println(solve(r, g, b, n));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}



Measured memory_bytes: 21076
// C - Make a Rectangle
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, n, w = 0, ans = 0, count = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n;
  vlli d(n);
  map<lli, lli> g;
  rep(i, 0, n)
  {
    cin >> d[i];
    g[d[i]]++;
  }
  for (auto x : g)
  {
    if (x.second >= 2)
    {
      count = max(count, x.first);
      ans = x.first;
    }
  }
  for (auto x : g)
  {
    if (x.second >= 2 && x.first != ans)
    {
      w = max(w, x.first);
    }
  }
  ans = count * w;

  for (auto x : g)
  {
    if (x.second >= 4)
    {
      h = x.first * x.first;
      if (h >= ans)
      {
        ans = h;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 10148