akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <stdlib.h>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector <int> tab(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> tab[i];
	}
	vector <int> dp(n, 2147483647);
	dp[0] = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = i + 1; j < i + 3; j++)
		{
			if (j < n)
			{
				dp[j] = min(dp[j], dp[i] + abs(tab[i] - tab[j]));
			}
		}
	}
	cout << dp[n - 1];
}

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

using namespace std;

int main()
{
    string a,b;
    long long sum=0;
    cin>>a>>b;
    for(int i=0 ; i<a.size(); i++){
        if(a[i]!=b[i]){
            sum++;
        }
    }

      
        cout<<sum;
      

}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[101010],B[101010],C[101010];
ll pat[101010];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i];
	FOR(i,N) cin>>B[i];
	FOR(i,N) cin>>C[i];
	sort(A,A+N);
	sort(B,B+N);
	x=0;
	FOR(i,N) {
		while(x<N && A[x]<B[i]) x++;
		pat[i]=x;
	}
	sort(C,C+N);
	x=0;
	ll ret=0,sum=0;
	FOR(i,N) {
		while(x<N && B[x]<C[i]) sum+=pat[x],x++;
		ret+=sum;
	}
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;


int main(){
  ll n;
  cin >> n;

  ll a,b,sum=0;
  std::vector<pair<ll,ll>> task(n);
  rep(i,n){
    cin >> a;
    cin >> b;
    task.at(i)=make_pair(b,a);
  }

  sort(all(task));

  for(auto i:task){
    sum+=i.second;
    if(i.first<sum){
      cout << "No" << endl;
      return 0;
    }


  }

  cout << "Yes" << endl ;


  }


Measured memory_bytes: 6412
#include <stdio.h>


int main() {
	int W, H, x, y;
	scanf("%d %d %d %d", &W, &H, &x, &y);
	double ans = (double)W*H / 2;
	if (x * 2 == W && y * 2 == H) {
		printf("%f %d\n", ans, 1);
	}
	else {
		printf("%f %d\n", ans, 0);
	}

	return 0;
	

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, pii> pip;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
typedef pair<pair<lint, int>, pair<int, int>> ppp;
typedef complex<double> xy_t;
typedef vector<lint> poly;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

const lint mod = 1e9 + 7;
const int INF = mod;
const int MAX = 100010;

template<class T> struct  SegTree{
    typedef  function<T(T, T)> F;
    int n = 1;
    vector<T> node;
    T et;
    F f, g;

    SegTree(int n_, T et_, F f_, F g_):
    et(et_), f(f_), g(g_){
        while(n < n_) n *= 2;
        node.resize(n*2-1, et);
    }

    void update(int i, T x){
        i += n-1;
        node[i] = g(node[i], x);
        while(i){
            i = (i-1) / 2;
            node[i] = f(node[i*2+1], node[i*2+2]);
        }
    }

    T query(int a, int b){
        T vl = et, vr = et;
        for(a+=n-1, b+=n-1; a<b; a=(a-1)/2, b=(b-1)/2){
            if(!(a&1)) vl = f(vl, node[a++]);
            if(!(b&1)) vr = f(node[--b], vr);
        }
        return f(vl, vr);
    }
};

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    string s;
    cin >> s;

    auto f=[&](pii p, pii q){
        if(p.fi==INF) return q;
        else if(q.fi==INF) return p;
        else if(p.fi==q.fi) return p;
        else return min(p, q);
    };
    SegTree<pii> st(n+1, make_pair(INF, MAX), f, f);
    rep(i, n+1) st.update(i, make_pair(INF, i));
    st.update(0, make_pair(0, 0));

    int prev[n+1];
    For(i, 1, n+1)if(s[i]=='0'){
        pii tmp=st.query(max(0, i-m), i);
        if(tmp.fi==INF){
            printf("-1\n");
            return 0;
        }
        st.update(i, make_pair(tmp.fi+1, i));
        prev[i]=tmp.se;
    }

    vector<int> ans;
    int cur=n;
    while(cur){
        ans.push_back(cur-prev[cur]);
        cur=prev[cur];
    }
    reverse(ans.begin(), ans.end());
    for(int x: ans) printf("%d ", x);
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#include<vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MOD 1000000007
#define MAX 200005
#define PMAX 55
#define PRECISION 0.00000000001
#define INF 2000000000
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
char s[MAX];
int main()
{
    int n,i;
    scanf("%d ",&n);
    for(i=0;i<n;i++)
    {
        scanf("%c",&s[i]);
    }
    int cnt[2]={0};
    for(i=0;i<n;i++)
    {
        if(s[i]=='R') cnt[0]++;
        else cnt[1]++;
    }
    int c=cnt[0];
    for(i=0;i<cnt[0];i++)
    {
        if(s[i]=='R') c--;
    }
    c=min(c,cnt[1]);
    printf("%d",min(c,cnt[1]));
    return 0;
}


Measured memory_bytes: 3944
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a,vector<vector<ll>> b,int n){
	int i,j,k,t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k]*b[k][j] % M)%M;
			c[i].push_back(t);
		}
	}
	return c;
}
int main() {
	ll x, y, z, k, a[1111], b[1111], c[1111],i,j,t;
	cin >> x >> y >> z >> k;
	vector<ll> v;
	for (i = 0; i < x; i++)
		cin >> a[i];
	for (i = 0; i < y; i++)
		cin >> b[i];
	for (i = 0; i < z; i++)
		cin >> c[i];
	sort(a, a + x,greater<ll>());
	sort(b, b + y, greater<ll>());
	sort(c, c + z, greater<ll>());
	for (i = 0; i < k&&i<x; i++)
		for (j = 0; i*j < k&&j<y; j++)
			for (t = 0; i*j*t < k&&t<z; t++)
				v.push_back(a[i] + b[j] + c[t]);
	sort(v.rbegin(), v.rend());
	for (i = 0; i < k; i++)
		cout << v[i] << endl;
}

Measured memory_bytes: 39908
#include<stdio.h>
int left[262144],right[262144];
int num=0;
int val[262144];
long long ans=0;
int n,l;
int sl[262144],sr[262144];
void dec()
{
	int now;
	for(now=num-1;now>0;now--)
	{
		if(val[now]!=val[now-1])
		{
			break;
		}
	}
	int d=num-now;
	int v=val[now];
	long long s=0;
	for(int i=now;i<num;i++)
	{
		ans+=(long long)left[i]*right[i];
		if(i-l+1>=now)
		{
			s+=left[i-l+1];
		}
		ans+=s*right[i];
	}
	if(d<l)
	{
		num=now;
		while(num)
		{
			dec();
		}
		return;
	}
	int dd=d/l;
	for(int i=0;i<=dd;i++)
	{
		sl[i]=0;
		sr[i]=0;
	}
	for(int i=now;i<num;i++)
	{
		sl[(i-now+1)/l]+=right[i];
		sr[(num-i)/l]+=left[i];
	}
	num=now+dd;
	for(int i=1;i<=dd;i++)
	{
		right[now+i-1]=sl[i];
		left[num-i]=sr[i];
	}
	s=0;
	for(int i=now;i<num;i++)
	{
		val[i]=v+1;
		ans-=(long long)left[i]*right[i];
		if(i-l+1>=now)
		{
			s+=left[i-l+1];
		}
		ans-=s*right[i];
	}
}
int main()
{
	scanf("%d%d",&n,&l);
	while(n--)
	{
		int a;
		scanf("%d",&a);
		while(num>0)
		{
			if(val[num-1]>=a)
			{
				break;
			}
			dec();
		}
		left[num]=1;
		right[num]=1;
		val[num]=a;
		num++;
	}
	while(num)
	{
		dec();
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3328
n = int(input())
s = list(map(int,input().split()))
q = int(input())
r = list(map(int,input().split()))
cou = 0

for i in range(q):
    for j in range(n):
        if(s[j] == r[i]):
            cou += 1
            break
print(cou)


Measured memory_bytes: 6316
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
        

fast();
//ll t;cin>>t;while(t--)
{
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
       cin>>a[i]; 
       
     
    }
    vi v;
    sort(a,a+n,greater<ll>());
  
  ll flag=0,c=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                 if(a[i]<a[j]+a[k]&&a[j]<a[i]+a[k]&&a[k]<a[i]+a[j])
                    c++;
            }
        }
         
    }
    cout<<c<<endl;
    
}
return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;

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

        int rest = 0;
        int senyen = 0;
        if(n % 1000 == 0) {
            senyen = n % 1000;
            System.out.println(senyen);
        } else {
            rest = n % 1000;
            System.out.println(1000 - rest);
        }
    }
}


Measured memory_bytes: 35716
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

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

    int n;
    cin >> n;
    int x[n], y[n];
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }

    double ans = 1000;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            double rx = (x[i] + x[j]) / 2.0, ry = (y[i] + y[j]) / 2.0;
            double r2 = pow(x[i] - rx, 2) + pow(y[i] - ry, 2);

            bool f = true;
            for (int k = 0; k < n; k++) {
                if (pow(x[k] - rx, 2) + pow(y[k] - ry, 2) > r2 + 1e-10) {
                    f = false;
                }
            }

            if (f) {
                ans = min(ans, sqrt(r2));
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                double a1 = x[j] - x[i], b1 = y[j] - y[i], c1 = (x[j] * x[j] - x[i] * x[i] + y[j] * y[j] - y[i] * y[i]) / 2.0;
                double a2 = x[k] - x[i], b2 = y[k] - y[i], c2 = (x[k] * x[k] - x[i] * x[i] + y[k] * y[k] - y[i] * y[i]) / 2.0;
                double rx = (c1 * b2 - c2 * b1) / (a1 * b2 - a2 * b1);
                double ry = (c1 * a2 - c2 * a1) / (b1 * a2 - b2 * a1);
                double r2 = pow(x[i] - rx, 2) + pow(y[i] - ry, 2);

                bool f = true;
                for (int p = 0; p < n; p++) {
                    if (pow(x[p] - rx, 2) + pow(y[p] - ry, 2) > r2 + 1e-10) {
                        f = false;
                    }
                }

                if (f) {
                    ans = min(ans, sqrt(r2));
                }
            }
        }
    }

    cout << fixed << setprecision(7) << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{ int n,x=0,i,max=0;
cin>>n;
int b[n+2]={0};
char a[n+1];
cin>>a;
for(i=0; i<n; i++)
{
  
    if(a[i]=='I')
    {
    x++;
    b[i]=x;
    }
    if(a[i]=='D')
    {
    x--;
    b[i]=x;
    }
    
}
for(i=0; i<n+2; i++)
{
    if(b[i]>max)
    max=b[i];
    
}
cout<<max;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;
int arr[333][333];
int xu[333][333];
bool mark[333];
int num[333];
bool sol(int a){
    memset(mark,0,sizeof(mark));
    int ma=0;
    int cnt=m;
    do{
        memset(num,0,sizeof(num));
        cnt=0;
        for(int i=1;i<=m;i++){
            if(!mark[i])cnt++;
        }
        if(cnt==0)return 0;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(!mark[arr[i][j]]){
                    num[arr[i][j]]++;
                    //cout<<i<<':'<<arr[i][j]<<endl;
                    break;
                }
            }
        }
        ma=0;
        for(int i=1;i<=m;i++){
            ma=max(ma,num[i]);
            //cout<<num[i]<<'&';
        }
        //cout<<endl;
        if(ma>a){
            for(int i=1;i<=m;i++){
                if(num[i]>a)mark[i]=1;
            }
        }
        //cout<<ma<<' '<<a<<' '<<cnt<<endl;
    }while(ma>a&&a*cnt>=n);
    //for(int i=1;i<=m;i++)cout<<mark[i]<<'*';cout<<endl;
    //cout<<ma<<','<<a<<endl;
    return ma<=a;
}
int main(){
    int a,b,c,d,e,f,g,h;
    ios::sync_with_stdio(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>arr[i][j];
            xu[i][arr[i][j]]=j;
        }
    }
    if(sol(1)){
        cout<<1<<endl;
        return 0;
    }
    int l=1,r=n;
    while(r-l>1){
        int mid=(l+r)>>1;
        if(sol(mid)){
            r=mid;
        }
        else{
            l=mid;
        }
    }
    cout<<r<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(){
    int a[4]={};
    int b[4]={};
    int d=0,e=0;;
    for(int i=0;i<4;i++)
        scanf("%d",&a[i]);
    if(a[0]<=a[2]){
        d=a[2]-a[0];
        e=a[3]-a[1];
        b[0]=a[2]-e;
        b[1]=a[3]+d;
        b[2]=a[0]-e;
        b[3]=a[1]+d;
        
    }
    if(a[0]>a[2]){
        d=a[0]-a[2];
        e=a[1]-a[3];
        b[0]=a[2]+e;
        b[1]=a[3]-d;
        b[2]=a[0]+e;
        b[3]=a[1]-d;
        
    }
   for(int i=0;i<4;i++)
       printf("%d ",b[i]);
    return 0;
}



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

static int cmp_int(const void* v1, const void* v2)
{
  const long long _v1 = *((const long long*)v1);
  const long long _v2 = *((const long long*)v2);

  if ( _v1 > _v2 ) {
    return -1;
  } else if ( _v1 < _v2 ) {
    return 1;
  } else {
    return 0;
  }
}
int main(void)
{
  long long a[100002], m[2]={0};
  int n, i, j, c;
  c = 1; j = 0;
  scanf("%d", &n);

  for(i = 0; i < n; i++)
    scanf("%lld", &a[i]);

  qsort(a, n, sizeof(long long), cmp_int);
  
  i = 0;
  do{
    while(a[i] == a[i+1]){
      c++;
      i++;
    }
    if(2 <= c && c < 4){
      m[j] = a[i];
      j++;
      c = 1;
    }else if(4 <= c){
      if(j==0){
      m[0] = a[i];
      m[1] = a[i];
      j=2;
      }else{
	m[j] = a[i];
	j++;
      }
    }
    i++;
    if(i == n) break;
  }while(j != 2);

  printf("%llu\n", m[0]*m[1]);

  return 0;
}


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define inf 0x7fffffff
#define RG register
#define maxn 100005
#define maxm 205
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
inline ll read(){
    ll x = 0, f = 1;
    char ch = getchar();
    while(ch > '9' || ch < '0') {if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x *10 + ch -'0';ch = getchar();}
    return x * f;
}

int n, m, a[maxn], x;
ll sum, st;
int main(){
	int i, j, k;
	n = read(), x = read(); 
	for(i = 1;i <= n;i++) a[i] = read();
	if(a[1] > x) sum += a[1] - x, a[1] = x;
	for(i = 1;i < n;i++)
		if(a[i] + a[i + 1] > x) sum += a[i] + a[i + 1] - x, a[i + 1] = x - a[i];
	printf("%lld\n", sum);
	return 0;
}


Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){
  int H,N;
  cin >>H>>N;
  vector<int> A(N);
  vector<int> B(N);
  
  int max_check = 0;
  
  rep(i,N){
    int a;
    cin >>a;
    A[i] = a;
    max_check = max(a,max_check);
    cin >> B[i];
  }
  
  const int INF = 1000000007;
  vector<int> dp(200000,INF);
  dp[100000+H] = 0;
  for(int i=100000+H-1;i>100000-max_check;i--){
    vector<int> candidates = {};
    rep(j,N) candidates.push_back(dp[i+A[j]] + B[j]);
    sort(candidates);
    dp[i] = candidates[0];
  }
  int ans = INF;
  for(int i=100000-max_check;i<100001;i++){
    ans = min(ans,dp[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
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 gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//##############################CODE_START
	
	int n;cin>>n;
	set<pair<char,int>> Map;
	rep(i,n){
	    char a;int b;
	    cin>>a>>b;
	    pair<char,int> p=MP(a,b);
	    Map.insert(p);
	}
	vector<char> words={'S','H','C','D'};
	
	rep(i,4){
	    rep(j,13){
	        pair<char,int> p=MP(words[i],j+1);
	        if(!Map.count(p)){
	            cout<<p.first<<" "<<p.second<<endl;
	        }
	    }
	}
	
	//##############################CODE_END
	return 0;
}



Measured memory_bytes: 3152
import java.io.*;
import java.util.*;
class Main{
  static Node root = null;
  static StringBuilder bl = new StringBuilder();
  public static void main(String args[])throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    String [] s = new String[2];
    for(int i = 0; i<n; i++){

      s = br.readLine().split("\\s+");

      if(s[0].charAt(0) == 'i'){
        Insert( Integer.parseInt(s[1]));
      }
      else if(s[0].charAt(0) == 'p'){
        inorder(root);
        bl.append("\n");
        preorder(root);
        bl.append("\n");
      }
    }
    System.out.print(bl);
  }
  static void Insert (int k){
    Node y = null;
    Node x = root;
    Node z = new Node();
    z.key = k;
    z.left = null;
    z.right = null;

    while(x != null){
      y = x;
      if(z.key < x.key){
        x = x.left;
      }else{
        x = x.right;
      }
    }
    z.parent = y;

    if( y == null){
      root = z;
    }else if( z.key < y.key){
      y.left = z;
    }else{
      y.right = z;
    }
  }

  static void preorder(Node u){
    if( u == null) return;
    bl.append(" ").append(u.key);
    preorder(u.left);
    preorder(u.right);
  }

  static void inorder(Node u){
    if(u == null) return;
    inorder(u.left);
    bl.append(" ").append(u.key);
    inorder(u.right);
  }

}

class Node{
  int key;
  Node parent;
  Node right;
  Node left;
  Node(){};
}


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

#define F first
#define S second
#define llong long long
#define ullong unsigned long long
#define mp make_pair
#define pb push_back
#define sz(v) (int)v.size()

using namespace std;

const int MXN = (int)1e6 + 10;
const int INF = (int)1e9 + 7;
const llong LINF = (llong)1e18 + 10;
const double EPS = (double)1e-9;
const double PI = (double)acos(-1.0);

vector <pair <int, int> > g[MXN];
vector <pair <int, int> > gr[MXN];
int n, m;
vector <int> order;
bool cycles;
int used[MXN];
int x[MXN];
bool b[MXN];
bool no_ans;

void dfs1(int v){
	used[v] = 1;
	for(auto it : g[v]){
		int to = it.F;
		if(used[to] == 1){
			cycles = true;
			return;
		}
		else if(!used[to]){
			dfs1(to);
		}
	} 
	used[v] = 2;
}

void topsort(int v){
	used[v] = true;
	for(auto it : g[v]){
		int to = it.F;
		if(!used[to])
			topsort(to);
	}
	order.pb(v);
}

int main(){
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif 
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; ++i){
		int x, y, w;
		scanf("%d%d%d", &x, &y, &w);
		g[x].pb(mp(y, w));
		gr[y].pb(mp(x, w));
	}
	for(int i = 1; i <= n; ++i){
		if(!used[i])
			topsort(i);
	}
	reverse(order.begin(), order.end());
	fill(used + 1, used + n + 1, false);
	for(int i = 0; i < n; ++i){
		int v = order[i];
		if(!used[v])
			dfs1(v);
		if(cycles)
			break;
	}
	if(cycles){
		printf("No");
		return 0;
	}
	b[order[0]] = true;
	for(int i = 1; i < n; ++i){
		int v = order[i];
		if(!b[v]){
			for(auto it : gr[v]){
				int to = it.F;
				if(b[to]){
					x[v] = x[to] + it.S; 		
					break;
				}
			}
		}
		for(auto it : gr[v]){
			int to = it.F;
			if(x[to] + it.S != x[v]){
				printf("No");
				return 0;
			}
		}
		for(auto it : g[v]){
			int to = it.F;
			if(!b[to])
				x[to] = x[v] + it.S;
			else {
				if(x[to] != x[v] + it.S){
					printf("No");
					return 0;
				}
			} 		
		}		
	}
	printf("Yes");
	return 0;
}


Measured memory_bytes: 61436
#include<cstdio>
#include<cstring>

using namespace std;

int main(){
	char s[205];
	char s1[205];
	int a[205];
	int b[205];
	int flag = 0;
	scanf("%s%s",s,s1);
	int len = strlen(s);
	int len1 = strlen(s1);
	if(len > len1) printf("GREATER\n");
	else if(len < len1) printf("LESS\n");
	else if(len == len1){
		for(int i = 0; i < len; i++){
			a[i] = s[i] - '0';
			}
		for(int i = 0; i< len1; i++){
			b[i] = s1[i] - '0';
			}
		for(int i =0; i < len; i++){
			if(a[i] > b[i]){
				flag = 1;
				printf("GREATER\n");
				break;
			}			
			else if(a[i] < b[i]){
				flag = 1;
				printf("LESS\n");
				break;
				}
		}
		if(flag == 0) printf("EQUAL\n");
	}
}

Measured memory_bytes: 128
#include <stdio.h>

int gcd(long a, long b);
int lcm(long a, long b);

int main(){
    long x,y,answer_gcd,answer_lcm;
    int r;

    while(1){
        x=-1;
        scanf("%ld %ld",&x,&y);
        if(x<0)break;
        
        answer_gcd=gcd(x,y);
        answer_lcm=lcm(x,y);
    
        printf("%ld %ld\n",answer_gcd,answer_lcm);
    }
    return 0;
}

int gcd(long a, long b){
    int tmp;
    while (b)
    {
        tmp=a%b;
        a=b;
        b=tmp;
    }
    return a;
}

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

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
const int sz=1e5+9;
char b[sz],a[sz];
int n;
long long v[sz];
long long dp[sz][14];
long long m=1e9+7;
long long mul(long long a,long long b){return (a%m*b%m)%m;}
long long add(long long a,long long b){return (a%m+b%m)%m;}
vector<int> q;
int N;

long long solve(int idx,int my){
    long long &ret=dp[idx][my];
    if(~ret) return ret;
    if(idx==N) return ret=(my==5);
    //if(a[idx]!='?') return ret=solve(idx+1,add(my,mul(v[idx],a[idx]-'0'))%13);
    ret=0;
    for(int i=0;i<10;i++){
        int nmy=(my+v[q[idx]]*i)%13;
        ret=add(ret,solve(idx+1,nmy));
    }
    return ret;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%s",b);
    n=strlen(b);
    for(int i=0;i<n;i++) a[i]=b[n-1-i];
    v[0]=1;
    for(int i=1;i<n;i++) v[i]=(v[i-1]*10)%13;
    long long my=0;
    for(int i=0;i<n;i++){
        if(a[i]=='?') q.push_back(i);
        else my=(my+v[i]*(a[i]-'0'))%13;
    }
    N=q.size();
    memset(dp,-1,sizeof(dp));
    printf("%I64d",solve(0,my));
    return 0;
}


Measured memory_bytes: 18936
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define rep(i, a, n) for (int i = a; i < n; ++i)

int main() {
    int d, n;
    cin >> d >> n;

    if (n == 100) n++;
    int ans = 1;
    rep(i, 0, d) ans *= 100;
    cout << ans * n << endl;

    return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
int A,B,C,D;
int main(void){
    scanf("%c",&A); A=A-'0';
    scanf("%c",&B); B=B-'0';
    scanf("%c",&C); C=C-'0';
    scanf("%c",&D); D=D-'0';

    if      (A+B+C+D==7){
        printf("%d+%d+%d+%d=7\n",A,B,C,D);
    }else if(A+B+C-D==7){
        printf("%d+%d+%d-%d=7\n",A,B,C,D);
    }else if(A+B-C+D==7){
        printf("%d+%d-%d+%d=7\n",A,B,C,D);
    }else if(A+B-C-D==7){
        printf("%d+%d-%d-%d=7\n",A,B,C,D);
    }else if(A-B+C+D==7){
        printf("%d-%d+%d+%d=7\n",A,B,C,D);
    }else if(A-B+C-D==7){
        printf("%d-%d+%d-%d=7\n",A,B,C,D);
    }else if(A-B-C+D==7){
        printf("%d-%d-%d+%d=7\n",A,B,C,D);
    }else if(A-B-C-D==7){
        printf("%d-%d-%d-%d=7\n",A,B,C,D);
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int S,a,b,c,d;
	cin>>S;
	a=S%10;
	S/=10;
	b=S%10;
	S/=10;
	c=S%10;
	S/=10;
	d=S%10;
	if(a==b||b==c||c==d)
	cout<<"Bad"<<endl;
	else
	cout<<"Good";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  string S, T;
  cin >> S >> T;
  rep(i,S.size()){
    if(S[i] != T[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  
  return 0;
}


Measured memory_bytes: 3600
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0,m=0,l=0,r=0,lmax=0,rmin=INT_MAX;
    cin>>n>>m;
    for(int i=0;i<m;++i)
    {
        cin>>l>>r;
        lmax=max(lmax,l);
        rmin=min(rmin,r);
    }
    if(lmax<=rmin)
        cout<<(rmin-lmax+1);
    else
        cout<<"0";
    cout<<endl;
}

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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  int n; read(n);
  map<int, int> m;
  rep(i, 0, n) {
    int t; read(t);
    m[t]++;
  }
  int v = 0;
  for (auto p : m) {
    v += max(0, p.second - 1);
  }
  write(n - (v + 1) / 2 * 2);
}


Measured memory_bytes: 8160
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9
#define f first
#define s second

typedef long long ll;

using namespace std;

int main()

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

    string s;

    cin >> s;

    if (s.size() == 2) cout << s;
    else {

        reverse(s.begin(), s.end());
        cout << s;
    }

    return 0;
}


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

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  int x = N * A;
  int y = B;
  if (x > y){
  	cout << y << endl;
  }
  else if (x < y){
  	cout << x << endl;
  }
  else {
  	cout << y << endl;
  }
}


Measured memory_bytes: 3632
if __name__ == "__main__":
    input_str = list(input())
    op_num = int(input())
    for _ in range(op_num):
        operations = input().split()
        op_name = operations[0]
        beg_idx = int(operations[1])
        end_idx = int(operations[2]) + 1
        if "replace" == op_name:
            replace_str = list(operations[3])
            input_str[beg_idx:end_idx] = replace_str
        elif "reverse" == op_name:
            input_str[beg_idx:end_idx] = reversed(input_str[beg_idx:end_idx])
        else:
            print("".join(input_str[beg_idx:end_idx]))



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


signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    int n;
    cin >> n;
    string x;
    cin >> x;
    int d;
    cin >> d;
    int cnt = 0;
    vector<bool> changed(n);

    for (int i = 0; i < n; i++){
        if (cnt >= d){
            cout << x << endl;
            return 0;
        }
        if (x[i] == '0'){
            x[i] = '1';
            cnt++;
            changed[i] = true;
        }
    }

    for (int i = n - 1; i >= 0; i--){
        if (cnt >= d)
            break;
        if (!changed[i] and x[i] == '1'){
            x[i] = '0';
            cnt++;
        }
    }
    cout << x << endl;
}


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

int main() {
	int A,B,C;
  cin >>A>>B>>C;
  int m,n;
  if(A>B){m=A;n=B;}
  else{m=B;n=A;}

    if(C>n&&C<m){
        cout << "Yes" << endl; }
    else {cout <<"No"<<endl;}
	return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Data.List

main = do
  n <- read <$> getLine :: IO Int
  xs <- (map read).words <$> getLine :: IO [Int]
  let n' = n `div` 2
  let xs' = sort xs
  let s = (xs' !! n') - (xs' !! pred n')
  putStrLn $ show s


Measured memory_bytes: 29052
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  int ret = 0;
  rep(i,S.size()){
    if(S[i] != T[i]) ret++;
  }

  cout << ret << endl;
  
  return 0;
}


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll n, m, x, y; cin >> n >> m >> x >> y;
  vll X(n), Y(m); rep(i, n) cin >> X[i]; rep(i, m) cin >> Y[i];
  bool ans = false;
  for(ll z = x + 1;z <= y;z++)
  {
    ll flag = 0;
    rep(i, n)
    {
      if(X[i] >= z) flag++;
    }
    rep(i, m)
    {
      if(Y[i] < z) flag++;
    }
    if(flag == 0) ans = true;
  }
  if(ans) fin("No War")
  else fin("War")
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<utility>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
typedef long long ll;

using namespace std;



int main() {
    int D;
    cin>>D;
    vector<int>c(27);
    rrep(i,26)cin>>c[i];
    vector<vector<int>>s(D+1,vector<int>(27));
    rrep(d,D){
        rrep(i,26)cin>>s[d][i];
    }
    vector<vector<int>>last(D+1,vector<int>(27));
    vector<int>C(D+1);
    vector<int>v(D+1);
    vector<int>t(D+1);
    vector<int>S(D+1);
    rrep(d,D){
        pair<int,int> ans = make_pair(-2e9,0);
        //Tを全部試して一番満足度の高いタイプを実施
        rrep(T,26){
            C[d] = 0;
            last[d][T] = d;
            rrep(i,26){
                C[d] += c[i]*(d-last[d][i]);
            }
            v[d] = S[d-1]+s[d][T]-C[d];
            ans = max(ans, pair<int,int>(v[d],T));
            last[d][T] = last[d-1][T];
        }
        S[d] = ans.first;
        t[d] = ans.second;
        srep(i,d,D+1){
            last[i][t[d]] = d;
        }
    }
    rrep(d,D){
        cout<<t[d]<<endl;
    }

    return 0;
}

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

using namespace std;
using ll = long long;
const ll md = 1e9 + 7;

namespace mod {
template <class T, int M>
class MInt;

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp);

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n);

template <class T, int M>
class MInt {
  T n_;

 public:
  MInt() : n_(0) {}
  MInt(T n) : n_((n % M + M) % M) {}

  MInt &operator+=(const MInt &rhs) {
    n_ += rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator-=(const MInt &rhs) {
    n_ += M - rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator*=(const MInt &rhs) {
    n_ = n_ * rhs.n_ % M;
    return *this;
  }

  MInt &operator/=(const MInt &rhs) { return (*this) *= Inv(rhs); }

  T Get() { return n_; }
};

template <class T, int M>
MInt<T, M> operator-(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res -= rhs;
}

template <class T, int M>
MInt<T, M> operator+(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res += rhs;
}

template <class T, int M>
MInt<T, M> operator*(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res *= rhs;
}

template <class T, int M>
MInt<T, M> operator/(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res /= rhs;
}

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp) {
  if (exp == 0) {
    return 1;
  }

  auto a = Pow(base, exp / 2);
  a *= a;
  if (exp % 2 == 1) {
    a *= base;
  }

  return a;
}

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n) {
  return Pow(n, static_cast<T>(M - 2));
}
}  // namespace mod

using MInt = mod::MInt<long long, md>;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  map<pair<ll, ll>, ll> m;
  MInt z_cnt(0);
  for (int i = 0; i < n; ++i) {
    ll a, b;
    cin >> a >> b;

    if (a == 0 && b == 0) {
      z_cnt += 1;
      continue;
    }

    if (a == 0) {
      m[make_pair(0, 1)]++;
      continue;
    } else if (b == 0) {
      m[make_pair(1, 0)]++;
      continue;
    }

    // a, bはどちらも0でない
    if (b < 0) {
      a *= -1;
      b *= -1;
    }

    ll ab_gcd = gcd(abs(a), abs(b));
    auto key = make_pair(a / ab_gcd, b / ab_gcd);
    m[key]++;
  }

  MInt ans(1), m2(2);
  set<pair<ll, ll>> used;
  for (auto [ab, ab_cnt] : m) {
    if (used.count(ab) > 0) {
      continue;
    }

    auto [a, b] = ab;
    pair<ll, ll> p;
    if (a == 0 || b == 0) {
      p.first = b;
      p.second = a;
    } else if (a < 0) {
      // ex.
      // -3, 1
      // -1, 3
      p.first = b;
      p.second = -a;
    } else {
      // ex.
      // 3, 1
      // -1, 3
      p.first = -b;
      p.second = a;
    }

    ans *= mod::Pow(m2, ab_cnt) + mod::Pow(m2, m[p]) - MInt(1);

    used.insert(p);
    used.insert(ab);
  }

  ans += z_cnt;
  ans -= 1;
  cout << ans.Get() << '\n';

  return 0;
}

Measured memory_bytes: 53596
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long x,n=100,c=0,y;
  cin>>x;
  y=100;
  while(x>n)
  {
    n+=(y/100);
    c++;
    y=n;
   
  }
  cout<<c<<endl;

}

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

int main(){

    int N, M;
    std::vector<int> d, t;

    std::cin >> N;
    for(int i = 0; i < N; ++i){
        int input;
        std::cin >> input;
        d.push_back(input);
    }

    std::cin >> M;
    for(int i = 0; i < M; ++i){
        int input;
        std::cin >> input;
        t.push_back(input);
    }

    std::sort(d.begin(), d.end());
    std::sort(t.begin(), t.end());

    int di = 0, ti = 0;
    while(true){
        if(ti >= t.size()){
             std::cout << "YES" << std::endl;
             break;
        }

        if(t[ti] < d[di]){
            std::cout << "NO" << std::endl;
            break;
        }

        if(d[di] == t[ti]){
            ++di, ++ti;
        }
        else {
            ++di;
        }
    }

    return 0;
}


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

int maze[12][12];
static const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

void printTable(int a[12][12]) {
	for (int i = 0; i < 12; i++) {
		for (int j = 0; j < 12; j++) {
			cout << a[i][j];
		}
		cout << endl;
	}
}

void dfs(int y, int x) {
	maze[y][x] = 0;
	for (int i = 0; i < 4; i++) {
		if (0 <= dx[i] + x && dx[i] + x < 12 && 0 <= dy[i] + y && dy[i] + y < 12 && maze[y + dy[i]][x + dx[i]] == 1) {
			dfs(y + dy[i], x + dx[i]);
		}
	}
}


int main()
{
	string s;
	while (cin>>s) {
		//memset(maze, 0, sizeof(maze));
		if(cin.eof())break;
		//1 line 
		for (int i = 0; i < 12; i++) {
			maze[0][i] = s[i] - '0';
		}
		//2-12 line
		for (int i = 1; i < 12; i++) {
			cin >> s;
			for (int j = 0; j < 12; j++) {
				maze[i][j] = s[j] - '0';
			}
		}
		int ans = 0;
		//cout << "=======dfs???=======" << endl;
		//printTable(maze);
		//cout << "===================" << endl;
		//dfs
		for (int y = 0; y < 12; y++) {
			for (int x = 0; x < 12; x++) {
				if (maze[y][x] == 1) {
					dfs(y, x);
					ans++;
				}
			}
		}
		cout << ans << endl;
		//cout << "=======dfs???=======" << endl;
		//printTable(maze);
		//cout << "===================" << endl;
	}



	return 0;
}

Measured memory_bytes: 3156
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
 
#include <bits/stdc++.h>
 
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
#define PI 3.1415926535
 
using namespace std;
        
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;

/*
const ll MAX_MEM = 25e7;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/
        
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
        
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
        
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
        
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
        
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("lol.in", "r", stdin);
    //freopen("lol.out", "w", stdout);
}
signed main()
{
    Start();
    int n;
    string s;
    cin >> n;
    set <string> q;
    for (int i = 0; i < n; ++i)
        cin >> s, q.emplace(s);
    cout << q.size();
    return 0;
}



Measured memory_bytes: 19140
size = int(input())
waters = list(map(int, input().split()))

# 奇数の場合のみ、たとえば size = 5 なら、
# m1 = d1 - d2 + d3 - d4 + d5 のように求められる

# 各山に振った水量を、mとする
m = [0]*size
m[0] = str(sum(waters[::2]) - sum(waters[1::2]))

for i in range(1, size):
    m[i] = str(2 * (waters[i-1]) - int(m[i - 1]))


print(" ".join(m))

Measured memory_bytes: 85092
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0) break;
		vi a(m);
		for(auto &i:a) cin>>i;
		vi dp(256,inf);
		dp[128]=0;
		for(int i=0;i<n;i++){
			int x;
			cin>>x;
			vi DP(256,inf);
			for(int j=0;j<256;j++) if(dp[j]<inf){
				for(int k=0;k<m;k++){
					int t=j+a[k];
					if(t<0) t=0;
					if(t>=256) t=255;
					DP[t]=min(DP[t],dp[j]+(t-x)*(t-x));
				}
			}
			dp=DP;
		}
		int res=inf;
		for(auto i:dp) res=min(res,i);
		cout<<res<<endl;
	}
}


Measured memory_bytes: 3120
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int x = sc.nextInt();
			if (n == 0 && a == 0 && b == 0 && c == 0 && x == 0)
				break;
			int[] y = new int[n];
			for (int i = 0; i < n; i++)
				y[i] = sc.nextInt();
			int f = 0;
			for (int i = 0; i < n; i++) {
				while (x != y[i] && f < 10001) {
					x = (a * x + b) % c;
					f++;
				}
				if (f > 10000) {
					f = -1;
					break;
				}
				if (i < n - 1 && x == y[i + 1]) {
					x = (a * x + b) % c;
					f++;
				}
			}
			System.out.println(f);
		}
		sc.close();
	}
}

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

using namespace std;
typedef long long ll;
typedef double ld;

ll n;
ll a[200010];
ll gap;

int main(void)
{
	scanf("%lld", &n);
	
	for(ll i = 1 ; i <= n ; i++)
	{
		scanf("%lld", &a[i]);
		gap ^= a[i];
	}
	
	for(ll i = 1 ; i <= n ; i++)
		printf("%lld ", gap ^ a[i]);
	
	return 0;
}

Measured memory_bytes: 5316
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>

using namespace std;

int hoge[1000][10][20];

void Ini(){
	int cnt = 196470;
	for(int i=1;i<1000;i++){
		for(int j=1;j<=10;j++){
			int day = 19;
			if(i%3 == 0 || j%2 == 1) day = 20;
			for(int k=1;k<=day;k++){
				hoge[i-1][j-1][k-1] = cnt;
				cnt--;
			}
		}
	}
}

bool solve(){
	Ini();
	int n;
	cin>> n;
	for(int i=0;i<n;i++){
		int y, m ,d;
		cin>> y>> m>> d;
		cout<< hoge[y-1][m-1][d-1]<< endl;
	}
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

 

Measured memory_bytes: 1940
n, m, l = map(int, input().split())
A = []
B = []
for _ in range(n):
    A.append(list(map(int, input().split())))
for _ in range(m):
    B.append(list(map(int, input().split())))
    
C = [[0 for _ in range(l)] for _ in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):    
            C[i][j] += A[i][k] * B[k][j]

for c in C:
    print(*c)


Measured memory_bytes: 7068
from scipy.sparse import*
(n,m,s,*D),*t=[map(int,t.split())for t in open(0)]
x=51
r=range(x*x)
for u,v,a,b in t[:m]:
 for i in r:k=(i+a)*x;D+=k+u,i*x+v,b,k+v,i*x+u,b
i=0
for c,d in t[m:]:
 i+=1
 for j in r:D+=j*x+i,(j+c)*x+i,d
d=csgraph.dijkstra(csr_matrix((D[2::3],(D[::3],D[1::3])),[8**6]*2),1,min(j,s)*x+1)
for i in range(2,n+1):print(int(min(d[i::x])))

Measured memory_bytes: 126896
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, A):
    A.sort()
    B = [A[i // 2] if i & 1 == 0 else A[-1 - i // 2] for i in range(N)]
    C = [A[i // 2] if i & 1 == 1 else A[-1 - i // 2] for i in range(N)]

    print(max(f(B), f(C)))

def f(L):
    res = 0
    for i in range(len(L) - 1):
        res += abs(L[i] - L[i - 1])
    return res

if __name__ == '__main__':
    input = sys.stdin.readline
    N = int(input())
    A = [int(input()) for _ in range(N)]
    main(N, A)


Measured memory_bytes: 89368