akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct edge{
	int to,c;
	edge(){}
	edge(int tt,int cc){
		to=tt;
		c=cc;
	}
};

struct data{
	int vg,vb,bit,c;
	data(){}
	data(int v1,int v2,int bb,int cc){
		vb=v1;
		vg=v2;
		bit=bb;
		c=cc;
	}
	bool operator<(const data &d)const{
		return c>d.c;
	}
};

int n,m;
int dp[51][51][1<<10];
vector<edge> G[51];
vector<edge> G2[51];
int d[51],e[51];
vector<P> vid;
int siz[1001];
int id[1001];
int id2[1001];

void solve(){
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<(1<<10);k++){
				dp[i][j][k]=INF;
			}
		}
	}
	dp[0][0][0]=0;
	priority_queue<data> que;
	que.push(data(0,0,0,0));
	while(que.size()){
		data q=que.top();
		que.pop();
		if(dp[q.vb][q.vg][q.bit]<q.c)continue;
		//printf("%d %d %d %d %d\n",q.vb,q.vg,q.bit,q.c,dp[q.vb][q.vg][q.bit]);
		for(int i=0;i<G[q.vb].size();i++){
			edge ed=G[q.vb][i];
			int nv=dp[q.vb][q.vg][q.bit]+ed.c+d[ed.to];
			int nbit=(e[q.vb]==e[ed.to])?q.bit:0;
			nbit|=1<<id[ed.to];
			if(nv<dp[ed.to][q.vg][nbit]){
				dp[ed.to][q.vg][nbit]=nv;
				//printf("%d %d %d %d\n",ed.to,q.vg,nbit,dp[ed.to][q.vg][nbit]);
				que.push(data(ed.to,q.vg,nbit,nv));
			}
		}
		for(int i=0;i<G2[q.vg].size();i++){
			edge ed=G2[q.vg][i];
			int nv=dp[q.vb][q.vg][q.bit]+ed.c;
			if(e[q.vb]==e[ed.to] && (q.bit>>id[ed.to] & 1));
			else nv+=d[ed.to];
			if(nv<dp[q.vb][ed.to][q.bit]){
				dp[q.vb][ed.to][q.bit]=nv;
				que.push(data(q.vb,ed.to,q.bit,nv));
			}
		}
	}
	if(dp[n-1][n-1][1]==INF)printf("-1\n");
	else printf("%d\n",dp[n-1][n-1][1]);
}

int main(void){
	while(1){
		scanf("%d%d",&n,&m);
		if(n==0 && m==0)break;
		memset(d,0,sizeof(d));
		memset(e,0,sizeof(e));
		memset(id,0,sizeof(id));
		memset(siz,0,sizeof(siz));
		vid.clear();
		e[n-1]=1000;
		vid.push_back(P(0,0));
		vid.push_back(P(10000,0));
		for(int i=1;i<n-1;i++){
			scanf("%d%d",&d[i],&e[i]);
			id[i]=siz[e[i]]++;
			vid.push_back(P(e[i]*10+id[i],i));
		}
		sort(vid.begin(),vid.end());
		for(int i=0;i<vid.size();i++){
			id2[vid[i].second]=i;
		}
		for(int i=0;i<n;i++){
			G[i].clear();
			G2[i].clear();
		}
		for(int i=0;i<m;i++){
			int a,b,c;
			scanf("%d%d%d",&a,&b,&c);
			a--;
			b--;
			if(e[a]<=e[b]){
				G[a].push_back(edge(b,c));
			}
			if(e[a]>=e[b]){
				G2[b].push_back(edge(a,c));
			}
		}
		solve();
	}
	return 0;
}


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

char str[100];
bool used[100];

int main(){
  scanf("%s",str);
  for(int i=0;str[i];i++){
    used[str[i]]=true;
  }
  int len=strlen(str)+1;
  for(int c='z';c>='a';c--){
    if(!used[c]){
      str[len++]=c;
    }
  }
  if(std::next_permutation(str,str+len)){
    printf("%s\n",str);
  }else{
    printf("-1\n");
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner yomi = new Scanner(System.in);
        int[] nyuuryoku = new int[2];
        nyuuryoku[0] = yomi.nextInt();
        nyuuryoku[1] = yomi.nextInt();
        int[] suuzi = new int[3];
        suuzi[0] = nyuuryoku[0] + nyuuryoku[1];
        suuzi[1] = nyuuryoku[0] - nyuuryoku[1];
        suuzi[2] = nyuuryoku[0] * nyuuryoku[1];
        int max =suuzi[0];
        for (byte i=1;i<3;i++){
            max = Math.max(suuzi[i],max);
        }
        System.out.println(max);
        }

    }


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

int main(void){
    int n;
    cin >> n;
    int nf = n/100;
    int nb = n%100;

    bool yymm = true, mmyy = true;
    if(nf>12 || nf==0) mmyy = false;
    if(nb>12 || nb==0) yymm = false;

    if(mmyy && yymm) cout << "AMBIGUOUS" << endl;
    else if(mmyy) cout << "MMYY" << endl;
    else if(yymm) cout << "YYMM" << endl;
    else cout << "NA" << endl;
}

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

int main(){
    string A,B;
    int a;
    cin >> A;
    a =  A.length() - 1;
    B = A.at(a);
    if(B == "3"){
        cout << "bon";
    }else if(B == "0"||B=="1"||B=="6"||B=="8"){
        cout << "pon";
    }else{
        cout <<"hon";
    }
    


}

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

int n, m;
int c[20];
int lp[50005] = {};

int solve(int x){
  if(lp[x] != 0)
    return lp[x];
  int t = INT_MAX;
  for(int i = 0; i < m; i++)
    if(x > c[i])
      t = min(t, solve(x - c[i]) + 1);
  lp[x] = t;
  return t;
}

int main(){
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    cin >> c[i];
    lp[c[i]] = 1;
  }
  cout << solve(n) << endl;
}

Measured memory_bytes: 5592
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
char s[maxn];
int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
    //freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
    cin>>s;
    int len=strlen(s);
    int ans=0;
    rep(i,0,len-1)
    {
        if(s[i]!=s[i+1])
        {
            ans++;
        }
    }
    cout<<ans<<endl;
    
    
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 384
#include<bits/stdc++.h> 
using namespace std; 
//python interactive_runner.py python3 local_testing_tool.py 0 -- ./Code
 
#define x first
#define y second
#define rep(i, a,b) for(int i = int(a); i < int(b); ++i)
#define forn(i,b) for(int i = 0; i < int(b); ++i)
typedef pair<int, int> pii;
int H,W,N,x,y;
const int MAXN = 200000+13;
char S[MAXN],T[MAXN];
const int MAXH = 1000+6;
char grid[MAXH][MAXH];
void solve(){
   
   cin>>H>>W>>N>>x>>y>>S>>T;
   pair<int,int> u = make_pair(0,H-1);
   pair<int,int> r = make_pair(0,W-1);
   for(int j = N-1;j>=0;j--){

   		if(T[j]=='R'){
   		  	r.x = max(0,r.x-1);
		}	
		else if(T[j]=='D'){
   		  	u.x = max(0,u.x-1);
		}
		else if(T[j]=='L'){
   		  	r.y = min(W-1,r.y+1);
		}	
		else if(T[j]=='U'){
   		  	u.y = min(H-1,u.y+1);
		}
		if(S[j]=='R'){
			if(r.y==0) {
				cout<<"NO"<<endl;
				return;
			}
			r.y = r.y-1;
		}	
		else if(S[j]=='D'){
   		  	if(u.y==0) {
				cout<<"NO"<<endl;
				return;
			}
			u.y = u.y-1;
		}
		else if(S[j]=='L'){
   		  	if(r.x==W-1) {
				cout<<"NO"<<endl;
				return;
			}
			r.x = r.x+1;
		}	
		else if(S[j]=='U'){
   		  	if(u.x==H-1) {
				cout<<"NO"<<endl;
				return;
			}
			u.x = u.x+1;
		}	
   }
  // cout<<u.x<<" "<<u.y<<" "<<r.x<<" "<<r.y<<endl;
   if(r.x<= y-1 && r.y>=y-1 && u.x<=x-1 && u.y>=x-1) cout<<"YES"<<endl;
   else cout<<"NO"<<endl;
   
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  String po=sc.nextLine();
  String[]s=po.split("");
  int i,j;
  for(i=0;true;i++){
  if(s[i].equals("A"))break;
  }
  
  for(j=s.length-1;true;j--){
  if(s[j].equals("Z"))break;
  }
  System.out.println(j-i+1);
}
}


Measured memory_bytes: 52960
#include<iostream>
#define ll long long
using namespace std;
ll n,k,t,ans;
int main()
{
	cin>>n>>k;t=n/k,ans+=t*t*t;
	if(!(k&1)&&n>=k/2) t=(n-k/2)/k+1,ans+=t*t*t;
	cout<<ans;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long int ll;
typedef pair<int, int> P;

int a;
string s;

int main(){
  cin >> a >> s;
  if(a >= 3200){
    cout << s << endl;
  }else{
    cout << "red" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n, a, min = 1000000, max = -1000000;
long long sum = 0;

cin >> n;

for(int i = 1; i <= n; i++){

    cin >> a;
    sum = sum + a;

    if(a < min)
    min = a;

    if(a > max)
    max = a;
    }
    
    cout << min << " " << max << " " << sum <<endl;
    
}



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

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;

    if (h == 1 || w == 1) {cout << 1 << '\n'; return 0;}

    int h1,h2,w1,w2;
    if (h%2==0)
    {
        h1 = h/2;
        h2 = h/2;
    }
    else
    {
        h1 = h/2+1;
        h2 = h1-1;
    }

    if (w%2==0)
    {
        w1 = w/2;
        w2 = w/2;
    }
    else
    {
        w1 = w/2+1;
        w2 = w1-1;
    }

    cout << (long long)h1*w1 + (long long)h2*w2 << '\n';

    return 0;
}


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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0)

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }

    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
	int n = ri();
	int a = ri(), b = ri(), c = ri();
	int l[n];
	FOR(i,n) l[i] = ri();

	int x[1<<n] = {0};
	FOR(i,1<<n) FOR(j,n) if (i & (1<<j)) x[i] += l[j];

	int res = INF;
	FOR(i,1<<n) {
		if (!i) continue;
		FOR(j,1<<n) {
			if (i&j) continue;
			if (!j) continue;
			FOR(k,1<<n) {
				if (j&k) continue;
				if (i&k) continue;
				if (!k) continue;
				int cur = (__builtin_popcount(i) + __builtin_popcount(j) + __builtin_popcount(k) - 3)*10;
				cur += abs(a-x[i]);
				cur += abs(b-x[j]);
				cur += abs(c-x[k]);
				res = min(res, cur);
			}
		}
	}
	cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.awt.geom.*;

public class Main{
	
	class State implements Comparable<State>{
		int pos, step;

		public State(int pos, int step) {
			this.pos = pos;
			this.step = step;
		}

		@Override
		public int compareTo(State o) {
			return this.step - o.step;
		}
		
	}

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			if(n == 0) break;
			
			int [] data = new int[n];
			for(int i = 0; i < n; i++){
				data[i] = sc.nextInt();
			}
			
			PriorityQueue<State> open = new PriorityQueue<Main.State>();
			open.add(new State(0, 0));
			int [] close = new int[n];
			int INF = 1 << 24;
			Arrays.fill(close, INF);
			close[0] = 0;
			int ans = -1;
			while(! open.isEmpty()){
				State now = open.poll();
				if(now.pos == n-1){
					ans = now.step;
					break;
				}
				for(int i = 1; i <= 6; i++){
					int npos = now.pos + i;
					while(true){
						if(npos < 0){
							npos = 0;
						}
						if(npos >= n){
							npos = n-1;
						}
						if(close[npos] <= now.step + 1)break;
						close[npos] = now.step + 1;
						if(data[npos] == 0){
							open.add(new State(npos, now.step + 1));
							break;
						}
						npos += data[npos];
					}
				}
			}
			System.out.println(ans);
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

Measured memory_bytes: 64268
#include <iostream>
#include <string>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cmath>

using namespace std;

unsigned int list[] = {3, 5, 7};
unordered_set<int> checker;

bool isValid(unsigned int i)
{
    bool is3 = false, is5 = false, is7 = false;
    int n=i;
    while(0 < n) {
        switch(n%10){
            case 3: is3 = true; break;
            case 5: is5 = true; break;
            case 7: is7 = true; break;
            default: return false;
        }
        n /= 10;
    }

    return (is3 && is5 && is7);
}

int A(unsigned int base, unsigned int N, unsigned int digit)
{
  int count = 0;
  if(base > N) return count;
  if(3 < digit && base <= N && isValid(base) && checker.count(base) <= 0) {
    checker.insert(base);
    count++;
  }
  
  for(auto n : list){
    int X = n * pow(10, digit);
    count += A(base + X, N, digit+1);
  }
  return count;
}

int D(unsigned int base, unsigned int N) { return base <= N; }

int main()
{
  unsigned int N;
  cin >> N;
  
  int count = 0;
  count += D(357, N);
  count += D(375, N);
  count += D(537, N);
  count += D(573, N);
  count += D(735, N);
  count += D(753, N);
  count += A(0, N, 0);
  cout << count << endl;
  return 0;
}


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

int main(void){
    char o[51], e[51];

    scanf("%s%s", o, e);

    if(strlen(o) == strlen(e)){
        for(int i = 0; i < strlen(o); i++){
            printf("%c%c", o[i], e[i]);
        }
    }else{
        for(int i = 0; i < strlen(e); i++){
            printf("%c%c", o[i], e[i]);
        }
        printf("%c", o[strlen(o) - 1]);
    }
    printf("\n");

    return 0;

} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef unsigned long ul;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef set<int> si;
typedef multiset<int> mi;
 
const ll INF = 1e18;
const int MOD = 1e9+7;
 
int main() {
	
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	//ofstream cout ("fileName.txt");
	//ifstream cin ("fileName.txt");
	
	int N, x;
	cin >> N;
	vi v(N);
	
	cin >> v[0];
	x=v[0];

	for(int i=1; i<N; ++i) cin >> v[i], x^=v[i];
	
	for(int i=0; i<N; ++i) {
		cout<<(v[i]^x)<<" ";
	}
	
	return 0;
}



Measured memory_bytes: 3984
// ABC106_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値

int main() {
    // input
    ll N;
    cin >> N;
    
    // calculation
    if (N < 105) {
        cout << 0 << "\n";
    } else if (N == 105) {
        cout << 1 << "\n";
    } else {
        ll res = 1;
        for (ll i = 106; i <= N; ++i) {
            if (i%2 == 1) {
                ll sum = 0;
                for (ll j = 1; j <= i; ++j) {
                    if (i%j == 0) sum++;
                }
                
                if (sum == 8) {
                    res++;
                }
            }
        }
        cout << res << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<deque>
using namespace std;
using ll = long long;

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

int main(){
    int N;
    cin>>N;
    deque<int> deq;
    rep(i,N){
        int a;cin>>a;
        if(((N%2)+i)%2) deq.push_front(a);
        else deq.push_back(a);
    }

    for(auto x : deq) cout<<x<<" ";
}


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

int main(void){

  int x,i,a,b;
    
    scanf("%d", &x);
    
   int *array = malloc(sizeof(int)*x);
    
  
    for(i=0;i<x;i++) {
        scanf("%d", array+i);
    }
    
     a = -1.0e9;
     b = *array;
    
    for(i=1;i<x;i++) {
        if(*(array+i)-b > a) {
            a = *(array+i)-b;
        }
        if(*(array+i) < b) {
            b = *(array+i);
        }
    }
    
    printf("%d\n", a);
    
    free(array);
    
    return 0;
}



Measured memory_bytes: 2292
def dfs(a, b, f):
    if vis[f] == 1: return
    vis[f] = 1
    for t in V[f]:
        if f!=a or t!=b: dfs(a, b, t)

n, m = map(int, input().split())
E = [[*map(lambda x: int(x)-1, input().split())] for _ in range(m)]
V = [[] for _ in range(n)]
for a, b in E: V[a].append(b); V[b].append(a)
ans = 0
for a, b in E:
    vis = [0]*n
    dfs(a, b, a)
    if vis[b] == 0: ans += 1
print(ans)


Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define caseout(i, x) cout << "Case #" << i << ": " << x << endl;

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

    vector<int> x(5);

    rep(i, 3){
        int a, b;
        cin >> a >> b;
        x[a]++;
        x[b]++;
    }

    sort(x.begin(), x.end());

    if (x[0] == 0 && x[1] == 1 && x[2] == 1&&x[3] == 2 && x[4] == 2)
            cout << "YES" << endl;

    else
        cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int x, y;
    cin >> x >> y;
    if (abs(x) < abs(y))
    {
        int ans = 0;
        if (x >= 0)
        {
            ans += abs(y) - abs(x);
        }
        else
        {
            ++ans;
            ans += abs(y) - abs(x);
        }

        if (y < 0)
        {
            ++ans;
        }

        cout << ans << endl;
    }
    else
    {
        int ans = 0;
        if (x > 0)
        {
            ++ans;
        }

        ans += abs(x) - abs(y);

        if (y > 0)
        {
            ++ans;
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int n,x,l,s,ans=1;
int main()
{
	cin>>n>>x;

	for(int i=2;i<=n+1;i++)
	{
		cin>>l;
		s+=l;
		if(s<=x) ans++;
		else break;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a / gcd(a, b) * b ;
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n;cin >> n;
    int l = 1;
    rep(i, n) {
        int a;cin >> a;
        l=lcm(l,a);
    }
    printf("%lld\n",l);
    return 0;
}

Measured memory_bytes: 3684
inpl = lambda: list(map(int,input().split()))
N = int(input())
A = inpl()
ans = 0
xor = plus = A[0]
r = 1
for l in range(N):
    while r < N and xor^A[r] == plus+A[r]:
        xor ^= A[r]
        plus += A[r]
        r += 1
    ans += r-l
    xor ^= A[l]
    plus -= A[l]
print(ans)

Measured memory_bytes: 77900
/*
Problem

Category
全探索：順列全探索

URL:
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_13_A&lang=ja

考察:
再帰でやるか、候補を全列挙するか。


Date: 2020/04/11
*/

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long

/* ==== declarations ====== */
// functions
void solve();
void getInput();

// global variables
int k;
vector<pair<int, int>> Q;


/* ======================== */

signed main(){
    getInput();
    solve();
    return 0;
}

void getInput() {
    cin>>k;
    for(int i=0; i<k; ++i) {
        pair<int, int> p;
        cin>>p.first>>p.second;
        Q.push_back(p);
    }
    
}

bool isValid(vector<int> indices) {
    // print(indices);
    set<int> aSet;
    set<int> bSet;
    for(int x=0; x<8; ++x) {
        int y = indices[x];
        int a = x-y;
        int b = x+y;
        aSet.insert(a);
        bSet.insert(b);
    }
    return aSet.size()==8 and bSet.size() == 8;
}


void solve() {
    vector<int> indices; for(int i=0; i<8; ++i) indices.push_back(i);
    // print(Q);
    do {
        auto r = isValid(indices);
        if (r) {
            bool ok = true;
            for (auto q: Q) {
                int x = q.first;
                int y = q.second;
                if (indices[x] != y) ok=false;
            }
            if(ok) break;
        }
    } while(next_permutation(indices.begin(), indices.end()));

    for(int i=0; i<8; ++i) {
        string s = "........";
        s[indices[i]] = 'Q';
        cout<<s<<endl;
    }
}





Measured memory_bytes: 3236
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse4,avx,avx2")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <chrono>
#include <random>
#include <string>
#include <queue>
#include <tuple>
#include <unordered_map>
#include <sstream>
#include <numeric>
#include <complex>
#include <immintrin.h>
#include <unordered_set>

using namespace std;

using ll = long long;
using ld = long double;
using VectorType = ld;
using ull = unsigned long long;

const ll INF = 1e15;
const ld eps = 1e-7;
const ld pi = atan2(0, -1);
const ll mod = 1e9 + 7;
const ll P = 179, Q = 239;
const ll A = 26;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

ll sign(ll a) {
	if (a < 0) return -1;
	if (a == 0) return 0;
	return 1;
}

bool equal(ld a, ld b) {
	return abs(a - b) < eps;
}

struct query {
	ll l, r, i;

	query(ll l = 0, ll r = 0, ll i = 0) : l(l), r(r), i(i) {};
};

bool mini(ll &a, ll b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

bool maxi(ll &a, ll b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool mini(ld &a, ld b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

ll mmax(ll a, ll b) {
	if (a > b) return a;
	return b;
}

ll mmin(ll a, ll b) {
	if (a < b) return a;
	return b;
}

ld mmax(ld a, ld b) {
	if (a > b) return a;
	return b;
}

ld mmin(ld a, ld b) {
	if (a < b) return a;
	return b;
}

bool maxi(ld &a, ld b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

ll sub(ll a, ll b) {
	a -= b;
	if (a < 0) {
		a += mod;
	}
	return a;
}

ll add(ll a, ll b) {
	a += b;
	if (a > mod) {
		a -= mod;
	}
	return a;
}

ll mul(ll a, ll b) {
	return (a * b) % mod;
}

ll n, m;
ll k;
vector <vector <ll>> vec;
vector <bool> used;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll x;
	cin >> x;
	ll ans = x / 500 * 1000;
	x %= 500;
	ans += x / 5 * 5;
	x %= 5;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll modPow(ll x, ll a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll modInv(ll x) {
    return modPow(x, MOD - 2);
}

ll N, D;
ll X[200010], Y[200010];
ll ans;

int main() {
    cin >> N >> D;
    rep(i, N) cin >> X[i] >> Y[i];

    rep(i, N) {
        if (X[i] * X[i] + Y[i] * Y[i] <= D * D) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 6752
import java.util.Scanner;

class Main{
  public static void main(String[] args) {
    
	  Scanner sc = new Scanner(System.in);
	  
	  int a = sc.nextInt();
	  
	  int b = sc.nextInt();
	  
	  int c = sc.nextInt();
	  
	  int min = 0;
	  int chuu = 0;
	  int max = 0;
	  
	  if(a>=b){
		  if(a>=c){min=a;if(b>=c){chuu=b;max=c;}
		  else{chuu=c;max=b;}
		  }else{min=c;chuu=a;max=b;}
		  }else{if(b>=c){min=b;if(a>=c){chuu=a;max=c;}
		  else{chuu=c;max=a;}
		  }else{min=c;chuu=b;max=a;}
		  }
	
	  System.out.println(max+" "+chuu+" "+min);
	  
  }
}

Measured memory_bytes: 26276
Scanf.scanf "%d" (fun n ->
    let rec loop i score upper downer =
        if i = n then (if score = 0 then Some (upper, downer) else None) else
            let s = Scanf.scanf " %s" (fun s -> s) in
            let sn = String.length s in
            let rec check i cur mi =
                if i = sn then cur, mi else
                    let cur = if s.[i] = '(' then cur + 1 else cur - 1 in
                    check (i + 1) cur (min mi cur)
            in
            let cur, mi = check 0 0 0 in
            let score = score + cur in
            if cur < 0 then loop (i + 1) score upper ((mi, cur) :: downer) else
                            loop (i + 1) score ((mi, cur) :: upper) downer
    in
    let sim u d =
        let u = List.sort (fun a b -> compare b a) u in
        let d = List.sort (fun (am, ah) (bm, bh) -> compare (am - ah, ah) (bm - bh, bh)) d in
        let rec loop cur = function
            | [] -> cur
            | (mi, add) :: tl ->
                    if cur + mi < 0 then -1 else loop (cur + add) tl
        in
        let cur = loop 0 u in
        if cur < 0 then "No" else
            let cur = loop cur d in
            if cur = 0 then "Yes" else "No"
    in
    print_endline @@
        match loop 0 0 [] [] with
        | None -> "No"
        | Some (u, d) -> sim u d
)

Measured memory_bytes: 122484
/*
* @Author: patan
* @Date:   2019-06-29 17:35:14
* @Last Modified by:   patan
* @Last Modified time: 2019-06-29 17:44:12
*/
import java.io.*;
import java.util.*;
 
public class Main {

	public static void main(String[] args)throws IOException {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
		String s = in.next();
		int alpha[] = new int[26];
		Arrays.fill(alpha,0);
		for(char c : s.toCharArray())
		{
			alpha[c-'A']++;
		}
		int count = 0;
		for(int i=0;i<26;i++)
		{
			if(alpha[i]==2)
				count++;
		}
		if(count==2)
			out.println("Yes");
		else
			out.println("No");
		out.close();
	}
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }

}

Measured memory_bytes: 23124
def func(n):
  if n % 2 == 0:
    return (int(n / 2))
  else:
    return (3*n + 1)

s = int(input())
a = [s]

for i in range(1, 1000000):
  a.append(func(a[i - 1]))
  if a[i] in a[:(i-1)]:
    break
print(i + 1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  double n, m, d;
  cin >> n >> m >> d;
  double ans = 0;
  if (d == 0) ans = 1 / n;
  else ans = 2 * (n - d) / (n * n);
  ans *= (m - 1);

  printf("%.9f\n", ans);
}

Measured memory_bytes: 3744
m=998244353
M=1000001
f=[0]*M
g=[0]*M
h=[0]*M
f[0]=g[0]=f[1]=g[1]=h[1]=1
for i in range(2,M):
	f[i]=f[i-1]*i%m
	h[i]=m-h[m%i]*(m//i)%m
	g[i]=g[i-1]*h[i]%m
A,B=map(int,input().split())
if A<B:
	A,B=B,A
b=1
a=0
for j in range(1,B+1):
	a+=b*f[A+B-j]*g[B-j]*g[A]
	b=b*2%m
a=a*f[A]*f[B]*g[A+B]+A
print(a%m)

Measured memory_bytes: 63980
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

int main(){
    int N,M;
    cin>>N>>M;
    if(N == M)cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,i;
  double kotae=0,x,y;
  char u[3];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%lf %s\n",&x,u);
    if(u[0]=='J'&&u[1]=='P'&&u[2]=='Y'){
      y=1;
    }else{
      y=380000;
    }
    kotae+=x*y;
  }
  printf("%lf",kotae);
  return 0;
}
  

Measured memory_bytes: 128
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
count = 0
value = 0
for i in range(N):
  A = list(map(int,input().split()))
  for j in range(len(A)):
    value = value + A[j] * B[j]
  if value + C > 0:
    count += 1
  value = 0
print(count)

Measured memory_bytes: 9168
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

ll dp[100010][15];

ll amari[] = {1, 10, 9, 12, 3, 4};

string s;
int n;

ll rec(int digit, ll sumMod13){
    //cout << digit << " " << sumMod13 << endl;
    
    if(digit == n){
        return sumMod13 == 5;
    }

    int NUM = (n - digit) - 1;
    //cout << NUM << endl;
    ll x = amari[NUM % 6];

    ll &res = dp[digit][sumMod13];

    if(res != 0) return res;

    if(s[digit] == '?'){
        for(ll i=0; i<=9; i++){
            res += rec(digit + 1, (sumMod13 + i * x) % 13);
            //res += MOD;
            res %= MOD;
        }
    }
    else{
        ll num = s[digit] - '0';

        res = 0;

        res += rec(digit + 1, (sumMod13 + num * x) % 13);
        //res += MOD;
        res %= MOD;
    }

    return res;
}

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

    n = s.size();

    memset(dp, 0, sizeof(dp));

    ll ans = rec(0, 0) + MOD;
    cout << ans % MOD << endl;
}


Measured memory_bytes: 45008
#include<stdio.h>
#include<string.h>
   
int main(){
  int S[10000];
  int T[500];
  int n,i,q,j,count=0,flag=0;

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&T[i]);
  }

  for(i = 0; i < q; i++){
    for(j = 0; j < n; j++){
      if(S[j] == T[i]){
	if(flag == 0){
	  flag = 1;
	  count++;
	}
      }
    }
    flag = 0;
  }

  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		if(c-a-b >= 0){
			if(4*a*b < c*c-2*a*c-2*b*c+a*a+2*a*b+b*b){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}else{
			System.out.println("No");
		}
	}
}


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

using namespace std;

int main()
{
    int n,g;
    int res=99999;
    int p[15],c[15];
    scanf("%d%d",&n,&g);
    for(int i=0; i<n; i++)
        scanf("%d%d",&p[i],&c[i]);
    for(int s=0; s<1<<n; s++)
    {
        int cur=0,sum=0;
        for(int i=0; i<n; i++)
        {
            if(1<<i&s)
            {
                sum+=c[i];
                sum+=p[i]*100*(i+1);
                cur+=p[i];
            }
        }
        if(sum<g)
        {
            for(int i=n-1; i>=0; i--)
            {
                if(!(1<<i&s))
                {
                    int rr=0;
                    while(sum<g&&rr<p[i])
                    {
                        sum+=100*(i+1);
                        rr++;
                    }
                    cur+=rr;
                    if(rr==p[i])
                        sum+=c[i];
                }
                if(sum>=g)
                    break;
            }
        }
        if(cur<res)
            res=cur;
    }
    cout<<res<<endl;
}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef long long ll;

void solve() {
  string S;
  cin >> S;
  for (int i = 0; i < S.size(); i++) {
    for (int j = 1; j < S.size(); j++) {
      string tmp = S.substr(0, S.size() - j);
      if (tmp.size() % 2 == 0) {
        if (tmp.substr(0, tmp.size() / 2) ==
            tmp.substr((tmp.size() / 2), tmp.size() / 2)) {
          cout << tmp.size() << endl;
          return;
        }
      }
    }
  }
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
const ll inf = 1e18;
const ll mod = 1e9 + 7;

ll pow (ll x, ll n){
    ll ans = 1;
    while(n>0){
        if(n & 1 == 1){
            ans *= x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}


int main(){
    int n;
    cin >> n;
    set<string> goods;
    rep(i,n){
        string s;
        cin >> s;
        goods.insert(s);
    }
    int ans=goods.size();
    cout << ans << endl;
}


Measured memory_bytes: 19184
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 998244353
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}

int main(){
    string s,t;cin>>s>>t;
    ll ans=0;
    rep(i,s.size()){
        if(s[i]!=t[i]) ans++;
    }

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

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

long long int f(long long int a, long long int b) {
        vector<long long int> index(11);
        iota(index.begin(),index.end(),1);
        long long int c = (a > b ? a : b);
        for (auto& x : index) {
          if (c < pow(10, x)) {
            return x;
          }
        }
        return index.back() + 1;
}
int main(int argc, char const *argv[]) {
        long long int n;
        cin >> n;
        int min = (long long int)(n / 10) + 1;
        for (long long int a = 1; a <= (long long int)sqrt(n); a++) {
                if ((n % a) == 0) {
                        int m = f(a, n / a);
                        if (m < min) {
                                min = m;
                        }
                }
        }
        cout << min << endl;
        return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<utility>
#include<algorithm>
#include<queue>

using namespace std;

int n, d, a, c;
pair<int, int> p[200005];
queue<pair<long long, int>> q;
long long ans;

int main() {
  scanf("%d %d %d", &n, &d, &a);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &p[i].first, &p[i].second);
  }
  sort(p, p + n);
  for (int i = 0; i < n; i++) {
    while (!q.empty() && q.front().first < p[i].first) {
      c -= q.front().second;
      q.pop();
    }
    if ((p[i].second + a - 1) / a > c) {
      q.push({p[i].first + 2 * d, (p[i].second + a - 1) / a - c});
      ans += (p[i].second + a - 1) / a - c;
      c += (p[i].second + a - 1) / a - c;
    }
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 3456
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;   

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

  int n,m,r;
  cin >> n >> m >> r;
  
  vector <int>visit(r);
  REP(i,r){
    cin >> visit[i];
    visit[i]--;
  } 
  
  ll dist[n][n];
  REP(i,n){
    REP(j,n){
      if(i == j) dist[i][j] = 0;
      else       dist[i][j] = MOD;
    }
  }
  
  REP(i,m){
    int a,b,d;
    cin >> a >> b >> d;
    a--;b--;
    dist[a][b] = d;
    dist[b][a] = d;
  }
  
  REP(k,n){
    REP(i,n){
      REP(j,n){
        if(dist[i][j] > dist[i][k] + dist[k][j]) dist[i][j] = dist[i][k] + dist[k][j];
      }
    }
  }
  
  sort(visit.begin(),visit.end());
  
  ll ans = MOD;
  do{
    ll sum = 0;
    REP(i,r-1){
      sum += dist[visit[i]][visit[i+1]];
    }
    ans = min(ans,sum);
  }while(next_permutation(visit.begin(),visit.end()));
        
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	string S;
	cin >> S;
	int cnt[26] = { 0 };
	REP(i, S.size()) {
		int a = S[i] - 'a';
		cnt[a]++;
	}
	int ans = 0;
	REP(i, 26) {
		FOR(j,i+1 ,26) {
			ans += cnt[i] * cnt[j];
		}
	}
	cout << ans + 1 << endl;
	return 0;
}



Measured memory_bytes: 720
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define ll long long
ll INF = 9e17;

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

int main(void) {
	int n; cin >> n;
	ll h[n]{};
	rep(i,n) cin >> h[i];
	ll dp[n]{};

	rep(i,n) dp[i] = INF;
	dp[0] = 0;
	rep(i,n) {
		chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
		chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int[][] route = new int[N][2];
		for(int i = 0;i < N;++i) {
			route[i][0] = sc.nextInt();
			route[i][1] = sc.nextInt();
		}
		sc.close();
		
		int minCost = Integer.MAX_VALUE;
		for(int i = 0;i < N;++i)
			if(route[i][1] <= T && route[i][0] < minCost)
				minCost = route[i][0];
		
		if(minCost == Integer.MAX_VALUE)
			System.out.println("TLE");
		else
			System.out.println(minCost);
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))
 
 // ^^^ Template ^^^ //

int main() {
	in(int, N);
	ll t = -1;
	loop(i, N){
		in(ll, T);
		ll tb = max(1ll, t);
		if(t<0) t = T;
		else t = t/my_gcd(t, T)*T;
	}
	out(t);
}



Measured memory_bytes: 256