akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define V vector<int>
#define Vc vector<char>
#define VV(v, n, m) vector<V> v(n, V(m));
#define VVc(v, n, m) vector<Vc> v(n, Vc(m));
#define _4(i, n) for(int i = 0; i < n; i++)
#define g_arr(arr, n) _4(i, n) cin >> arr[i];
#define p_vec(vec) _4(i, (int)vec.size()) cout << vec[i] << ' '; cout << endl;

typedef long long ll;

using namespace std;

#define MOD 1000000007

int main(int argc, char * argv[]) {
    ios::sync_with_stdio(0);
    cin.tie(NULL);

    int h, w;
    cin >> h >> w;

    VVc(grid, h, w);
    VV(dp, h, w);

    dp[0][0] = 1;

    _4(i, h) {
        _4(j, w) {
            cin >> grid[i][j];
            if(grid[i][j] == '#')
                dp[i][j] = -1;
        }
    }

    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(dp[i][j] < 0)
                continue;

            if(i == 0 && j == 0)
                continue;

            if(i == 0) {
                if(dp[i][j - 1] < 0)
                    continue;

                dp[i][j] = dp[i][j - 1];
            } else if (j == 0) {
                if(dp[i - 1][j] < 0)
                    continue;

                dp[i][j] = dp[i - 1][j];
            } else {
                if(dp[i - 1][j] >= 0)
                    dp[i][j] = (dp[i - 1][j] + dp[i][j]) % MOD;
                if(dp[i][j - 1] >= 0)
                    dp[i][j] = (dp [i][j] + dp[i][j - 1]) % MOD;
            }
        }
    }

    cout << dp[h - 1][w - 1];

    return 0;
}



Measured memory_bytes: 5248
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
#define ll long long
#define INFTY 1 << 21
int x[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int y[8] = {1, 0, -1, 1, -1, 1, 0, -1};

int main() {
  int r;
  cin >> r;
  cout << 3 * r * r << endl;
}


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

int n, f[100][10], p[100][11], ans = 10e8*(-1);
int main(){
    cin >> n;

    for(int i=0; i<n; ++i)
        for(int k=0; k<10; ++k) cin >> f[i][k];

    for(int i=0; i<n; ++i)
        for(int k=0; k<11; ++k) cin >> p[i][k];

    for(int i=1; i<1024; ++i){
        int w=0;
        for(int l = 0; l < n; ++l){
            int w2 = 0;
            for(int k=0; k<10; ++k){
                if(i >> k & 0b1 == 1 && f[l][9 - k] == 1)
                    ++w2;
            }
            w += p[l][w2];
        }

        ans = max(ans, w);
    }

    cout << ans << endl;
}




Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
class UnionFind:
    #ノード番号は0-indexである
    def __init__(self, n):
        self.parents = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.length = [1 for _ in range(n)] 
        self.numberOfElements = n
    #UnionFindを初期化する関数
    def makeSet(self, n):
        self.parents = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.length = [1 for _ in range(n)]
        self.numberOfElements = n

    #ノードxのrootを探して返す関数
    def findRoot(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.findRoot(self.parents[x])
            return self.parents[x]

    #ノードxとノードyを連結する関数
    def uniteNode(self, x, y):
        x = self.findRoot(x)
        y = self.findRoot(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parents[x] = y
            self.length[y] += self.length[x]
        else:
            self.parents[y] = x
            self.length[x] += self.length[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    #ノードxが含まれるグループの要素数を返す関数
    def getLength(self, x):
        x = self.findRoot(x)
        return self.length[x]        

    #ノードxとノードyが同じグループであるかを返す関数
    def isSameGroup(self, x, y):
        return self.findRoot(x) == self.findRoot(y)

    #グループの数を返す関数
    def getNumberOfGroup(self):
        s = set()
        for i in range(self.numberOfElements):
            s.add(self.findRoot(i))
        return len(s)

def main():
    n, m = map(int, readline().split())
    uf = UnionFind(n)
    for _ in range(m):
        x, y, z = map(int, readline().split())
        uf.uniteNode(x-1, y-1)
    print(uf.getNumberOfGroup())
if __name__ == '__main__':
    main()


Measured memory_bytes: 17576
#include <iostream>
using namespace std;
int main(){
    string S;
    cin >> S;
    int N = S.size(), MOD = 1000000007;
 
    long long dp[100010][4] = {};
    for(int i = N; i >= 0; --i){
        for(int j = 3; j >= 0; --j){
            if(i == N){
                dp[i][j] = (j == 3 ? 1 : 0);
            }else{
                dp[i][j] = dp[i+1][j] * (S[i] == '?' ? 3LL : 1LL);
                if(j < 3 && (S[i] == '?' || S[i] == "ABC"[j])){
                    dp[i][j] += dp[i+1][j+1];
                }
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[0][0] << endl;
  //cout << "ABC"[2] << endl;
}

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

typedef unsigned long long int ull;
typedef long double ldb;
typedef long long int ll;

#define MOD1        1000000007
#define MOD2        998244353
#define PI          3.1415926535897932384626433832795
#define FILL(a, value) memset(a, value, sizeof(a))
#define BOOST       ios_base::sync_with_stdio(false); cin.tie(NULL)
#define what_is(x)  cerr << #x << " is " << x << endl;
#define ASSERT(left,operator,right) { if(!((left) operator (right))){ std::cerr << "ASSERT FAILED: " << #left << #operator << #right << " @ " << __FILE__ << " (" << __LINE__ << "). " << #left << "=" << (left) << "; " << #right << "=" << (right) << std::endl; } }

#define rep01(k,n)      for (ll i=k; i<n; i++)
#define rep02(k,n)      for (ll j=k; j<n; j++)
#define rep03(k,n)      for (ll k=k; k<n; k++)
#define rep11(k,n)      for (ll i=k; i<=n; i++)
#define rep12(k,n)      for (ll j=k; j<=n; j++)
#define rep13(k,n)      for (ll k=k; k<=n; k++)
#define repIT(c,it)     for(typeof(c.begin()) it = c.begin(); it != c.end(); ++it)
#define all(c)      c.begin(), c.end()

using namespace std;

const double pi = acos(-1.0);
const double epsilon = 1e-9;        // Add epsilon when casting double to int to avoid rounding pitfall issues, eg, 0.94*8178 in int
const int maxn = 1e6+10;

void solve()
{
    ll n;
    cin >> n;

    vector<ll> d(n);
    for(auto &i: d)
        cin >> i;

    sort(d.begin(), d.end());
    cout << d[d.size()/2] - d[d.size()/2-1];
}

int main()
{
    

    int t = 1;
    //cin >> t;
    while(t--)
        solve();

    cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 3984
//This is getting accepted!
#include<bits/stdc++.h>
#define ll long long
#define oo 1000000009
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define INA(a,n) for (int i = 1; i <= (n); ++i) cin >> a[i];
#define ITE(x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define isset(x, i) (((x)>>(i))&1)
#define setbit(x, i) ((x)^(1ll<<(i)))
#define clearbit(x, i) ((x)&(~(1ll<<(i))))
#define twoexp(i) (1ll<<(i))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) >= 0 ? (a) : -(a))
#define FI first
#define SE second
#define son1 (id*2)
#define son2 (id*2+1)

using namespace std;

const int MOD = 1000000007;
const double EPS = 1e-8;
const double PI = 2 * acos(0);
const int MAXN = 1e6 + 6;

int n, k;
vector< pair<int, int> > p;

void input() {
	int u, v, w, x, y, qtype;
	
	cin >> n >> k;
	
}


void preprocess() {
	
	if (k > (n-1)*(n-2)/2) {
		cout << -1 << endl;
		exit(0);
	}
	
}

void process(int itest) {
	int u, v, w, x, y, qtype;
	
	FOR(i, 2, n)
		p.push_back({1, i});
	
	int cnt = (n-1)*(n-2)/2;
	
	FOR(i, 2, n) {
		FOR(j, i+1, n) {
			if (cnt > k) {
				cnt--;
				p.push_back({i, j});
			}
		}
	}
	
	cout << p.size() << "\n";
	for(auto each : p) {
		cout << each.FI << " " << each.SE << "\n";
	}
	
}

void oneTest() {
	
	input();
	preprocess();
	process(0);
	
}

void multiTest() {
	
	int t;
	cin >> t;
	
	for (int it = 1; it <= t; ++it) {
		input();
		preprocess();
		process(it);
	}
}

int main(){
    #ifndef ONLINE_JUDGE
//    freopen("../out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	oneTest();
//	multiTest();

    return 0;

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main() {
    vector<long long> a(87);
    a[0] = 2;
    a[1] = 1;
    for (int i = 2; i < 87; i++)
        a[i] = a[i-1]+a[i-2];
    int n;
    cin >> n;
    cout << a[n]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
ll gyaku(ll n){
  ll mo=mod-2;
  ll now=n;
  ll ret=1;
  while(mo>0){
    if(mo&1)ret*=now;
    ret%=mod;
    now*=now;
    now%=mod;
    mo/=2;
  }
  return ret;
}
ll nck(ll n,ll k){
  if(2*k>n)k=n-k;
  ll ret=1;
  for(ll i=0;i<k;i++){
    ret*=n-i;
    ret%=mod;
    ret*=gyaku(i+1);
    ret%=mod;
  }
  return ret;
}
int main(){
  ll n,m;cin>>n>>m;
  vector<ll>v;
  for(ll i=2;;i++){
    ll sum=0;
    while(m%i==0){
      sum++;
      m/=i;
    }
    if(sum>0)v.push_back(sum);
    if(m==1)break;
  }
  ll ans=1;
  for(ll i=0;i<v.size();i++){
    ans*=nck(n+v[i]-1,v[i]);
    ans%=mod;
  }
  cout<<ans<<endl;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, g;
    cin >> n >> g;
    g /= 100;
    vector<int> p(n), c(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i] >> c[i];
        c[i] /= 100;
    }
    int ans = INT_MAX;
    for (int i = 0; i < (1 << n); i++) {
        int t = g, cnt = 0;
        for (int j = 0; j < n; j++) {
            if ((1 << j) & i) {
                t -= c[j] + (j + 1) * p[j];
                cnt += p[j];
            }
        }
        for (int j = n - 1; j >= 0; j--) {
            if (!((1 << j) & i)) {
                for (int k = 0; k < p[j] - 1 && t > 0; k++) {
                    t -= j + 1;
                    cnt++;
                }
            }
        }
        if (t <= 0) {
            ans = min(cnt, ans);
        }

    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#define PI 3.14159265359
typedef long long ll;
const int MOD = 1e9+7;
const ll LLINF = 7e18;
using namespace std;

int w[4];
vector<int> v[4];
vector<ll> sum[4];

int main(){
	ll n, w_max, w1, v1;
	cin >> n >> w_max;
	cin >> w1 >> v1;
	w[0]++;
	v[0].push_back(v1);
	for (int i = 1; i < n; i++){
		int temp;
		cin >> temp >> v1;
		w[temp-w1]++;
		v[temp-w1].push_back(v1);
	}
	
	for (int i = 0; i < 4; i++){
		sort(v[i].begin(), v[i].end(), greater<int>());
	}

	for (int i = 0; i < 4; i++){
		sum[i].push_back(0);
	}
	for (int i = 0; i < 4; i++){
		for (int j = 0; j < v[i].size(); j++){
			sum[i].push_back(sum[i][j] + v[i][j]);
		}
	}
	ll ans = 0;
	for (int i = 0; i <= w[0]; i++){
		for (int j = 0; j <= w[1]; j++){
			for (int k = 0; k <= w[2]; k++){
				for (int l = 0; l <= w[3]; l++){
					ll tmp = j + 2*k + 3*l + w1*(i+j+k+l);
					if (tmp <= w_max){
						ans = max(ans, sum[0][i] + sum[1][j] + sum[2][k] + sum[3][l]);
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3168
a1, a2, a3 = map(int, input().split(' '))


c123 = abs(a3 - a2) + abs(a2 - a1)
c132 = abs(a2 - a3) + abs(a3 - a1)
c213 = abs(a3 - a1) + abs(a1 - a2)
c231 = abs(a1 - a3) + abs(a3 - a2)
c312 = abs(a2 - a1) + abs(a1 - a3)
c321 = abs(a1 - a2) + abs(a2 - a3)

print(min([c123, c132, c213, c231, c312, c321]))


Measured memory_bytes: 3060
N, Q = map(int, input().split())
S = input()

t = [0] * N
t[0] = 0
for i in range(1,N):
    if S[i-1] == 'A' and S[i] == 'C':
        t[i] = t[i-1] + 1
    else:
        t[i] = t[i-1]

for _ in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Measured memory_bytes: 6188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using p = pair<int,int>;

int main(){
  char a, b, c;
  cin >> a >> b >> c;
  if( a == '7' || b == '7' || c == '7' ) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main() {
  int s1s2s3;
  cin >> s1s2s3;
  cout << (s1s2s3/100)%2 + 
    (s1s2s3/10 - (s1s2s3/100)*10)%2 +
    (s1s2s3 - (s1s2s3/10 - (s1s2s3/100)*10)*10 - (s1s2s3/100)*100)%2 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
int x[100005], y[100005];
std::vector<int>need[1005];
int fixX[1005], fixY[1005];
int tag[1005];
long long pair[1005][1005];

long long getNumber(long long l,long long r,long long d,long long left){
    if(l%d<=left) l = l-l%d+left;
    else l = l+d-l%d+left;
    return (r-l+d)/d;
}

int isValid(long long lx,long long rx,long long ly,long long ry,long long d){
    for(int i = 0; i < d; i++){
        for(int j = 0; j < d; j++){
            long long have = getNumber(lx,rx,d,i)*getNumber(ly,ry,d,j);
            //printf("i = %d, j = %d: %lld\n",i,j,have);
            if(have<pair[i][j]) return 0;
        }
    }
    return 1;
}
//length that can't cover 
int isGood(int len,int d){
    int find = 0;
    for(int i = 0; i<d; i++){
        int ok = 1;
        for(int j = 0; j < d; j++){
            if(fixY[j]!=-1) tag[j] = 1;
            else tag[j] = 0;
        }
        for(int j = 0; j < len; j++){ 
            int p = (j+i)%d;
            if(fixX[p]!=-1) ok = 0;
            if(need[p].size()!=0){ 
                for(int k = 0; k < (int)need[p].size(); k++) tag[need[p][k]] = 1;
            }
        }
        if(!ok) continue;
        else{
            int sum = 0;
            for(int j = 0; j < len; j++) sum += tag[j];
            if(sum==0) find = 1;
            //printf("sum = %d\n",sum);
            for(int j = 1; j<d; j++){
                sum -= tag[j-1];
                int p = (j+len-1)%d;
                sum += tag[p];
                if(sum==0){ 
                    //printf("i = %d, j = %d\n",i,j);
                    find = 1;
                }
            }
        }
    }
    return find;
}

int main(){
    int n,d;
    scanf("%d%d",&n,&d);
    for(int i = 1; i <= n; i++){ 
        scanf("%d%d",&x[i],&y[i]);
        pair[x[i]%d][y[i]%d]++;
    }
    /*for(int i = 0; i < d; i++){
        for(int j = 0; j < d; j++) printf("pair[%d][%d] = %lld\n",i,j,pair[i][j]);
    }*/
    long long L = 1, R = n*d;
    long long res = -1;
    while(L<=R){
        long long M = (L+R)/2;
        long long cnt = (M+1)/d;
        int ok = 1;
        for(int i = 0; i < d; i++) fixX[i] = fixY[i] = -1, need[i].clear();
        for(int i = 0; i < d; i++){
            for(int j = 0; j < d; j++){
                if(pair[i][j]>cnt*cnt){
                    if(pair[i][j]<=cnt*(cnt+1ll)){ 
                        need[i].push_back(j);
                    }
                    else if(pair[i][j]<=(cnt+1ll)*(cnt+1ll)) fixX[i] = fixY[j] = 1;
                    else ok = 0;
                }
            }
        }
        if(!ok) L = M+1;
        else{
            //for(int i = 0; i < d; i++) printf("fx[%d] = %d, fy[%d] = %d\n",i,fixX[i],i,fixY[i]);
            int len = d-(M+1)%d;
            //printf("len = %d\n",len);
            if(isGood(len,d)){
                res = M;
                R = M-1;
            }
            else L = M+1;
        }
    }
    printf("%lld\n",res);
    return 0;
}


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

std::priority_queue<int> que;
int n;
int a, b;

int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        int x;
        scanf("%d", &x);
        que.push(x);
    }
    for(int i = 0; i < n; i++){
        int x = que.top();
        que.pop();
        if(i % 2 == 0){
            a += x;
        }else{
            b += x;
        }
    }
    printf("%d\n", a-b);
    return 0;
}

Measured memory_bytes: 256
//----------ACCIDENTAL COMPETITIVE PROGRAMMER---------------------

#include<bits/stdc++.h>

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

#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair


const LL MOD = (1e9) + 7 ;
const LD EPS = 0.0000001 ;
const int N = 100000 + 50;

LL cache[N];
LL height[N];
int n, k;

LL solve(int idx)
{
	if (idx == n)
		return 0;
	LL &ans = cache[idx];
	if (ans != -1)
		return ans;
	ans = solve(idx + 1) + abs(height[idx] - height[idx + 1]);
	for (int i = 2; i <= k; i++){
		if (idx + i > n)
			break;
		ans = min(ans, solve(idx + i) + abs(height[idx] - height[idx + i]));
	}
	return ans;
}


int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    for (int i = 0 ; i < N; i++)
    	cache[i] = -1;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    	cin >> height[i];

    cout << solve(1) << endl;

	return 0;
}

Measured memory_bytes: 4992
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

template<int MOD>
class ModInt {
public:
    ModInt() :value(0) {}
    ModInt(long long val) :value((int)(val<0 ? MOD + val % MOD : val % MOD)) { }

    ModInt& operator+=(ModInt that) {
        value = value + that.value;
        if (value >= MOD)value -= MOD;
        return *this;
    }
    ModInt& operator-=(ModInt that) {
        value -= that.value;
        if (value<0)value += MOD;
        return *this;
    }
    ModInt& operator*=(ModInt that) {
        value = (int)((long long)value * that.value % MOD);
        return *this;
    }
    ModInt &operator/=(ModInt that) {
        return *this *= that.inverse();
    }
    ModInt operator+(ModInt that) const {
        return ModInt(*this) += that;
    }
    ModInt operator-(ModInt that) const {
        return ModInt(*this) -= that;
    }
    ModInt operator*(ModInt that) const {
        return ModInt(*this) *= that;
    }
    ModInt operator/(ModInt that) const {
        return ModInt(*this) /= that;
    }
    ModInt pow(long long k) const {
        ModInt n = *this, res = 1;
        while (k) {
            if (k & 1)res *= n;
            n *= n;
            k >>= 1;
        }
        return res;
    }
    ModInt inverse() const {
        long long a = value, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }
    int toi() const { return value; }

private:
    int value;
};
typedef ModInt<1000000007> mint;
ostream& operator<<(ostream& os, const mint& x) {
    os << x.toi();
    return os;
}

int N, A[21][21];

void solve() {
    cin >> N;
    rep(i, N)rep(j, N)cin >> A[i][j];
    vector<mint> cu(1 << N), ne(1 << N);
    cu[0] = 1;

    rep(i, N) {
        fill(all(ne), 0);
        rep(j, N) {
            if (!A[i][j])continue;
            int S = ((1 << N) - 1) ^ (1 << j);
            int T = S;
            do {
                ne[T | 1 << j] += cu[T];
                T = (T - 1)&S;
            } while (T != S);
        }
        swap(cu, ne);
    }
    cout << cu.back() << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,j,i,k,l,a[100],b[100];
    vector<int>v1,v2;
    cin>>n;
    for(i=0;i<n;i++){cin>>a[i];}
    for(i=0;i<n;i++){v1.push_back(a[i]);}
    for(i=0;i<n;i++){b[i]=a[i];}
    sort(b,b+n);sort(v1.begin(),v1.end());
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            if(b[i]==a[j]){k=j;break;}
        }
        if(i!=k){swap(a[i],a[k]);break;}
    }
    for(l=0;l<n;l++){v2.push_back(a[l]);}
    if(i==n){cout<<"YES\n";}
    else{
        if(v1==v2){cout<<"YES\n";}
        else{cout<<"NO\n";}
        }
    }

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;

int main(){

ll A,B,C,K;

cin >> A >> B >> C;
cin >> K;


for(ll i = 0;i < K;++i){

    if(A >= B) B = B + B;
    else if(B >= C) C = C + C;

}

if(A < B && B < C) cout << "Yes" << endl;
else cout << "No" << endl;

return 0;

}


Measured memory_bytes: 3668
#include<iostream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include <algorithm>
#include <set>
#include<math.h>
#include<cmath>
#include<vector>
#include<map>
#include<random>
using namespace std;

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


}

Measured memory_bytes: 256
import java.util.Map.Entry;
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		long N = sc.nextLong();
		long P = sc.nextLong();
		long ans = 1;
		
		if(N == 1){
			System.out.println(P);
			return;
		}
		
		for(int i = 2; i <= Math.sqrt(P); i++){
			if(P % i == 0){
				int count = 0;
				while(P % i == 0){
					P /= i;
					count++;
				}
				//System.out.println(i + " ^ " + count);
				if(count >= N){
					int num = (int)(count / N);
					ans *= Math.pow(i, num);
				}
			}
		}
		
		
		System.out.println(ans);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22740
N = int(input())
a = sorted(map(int, input().split()))[::-1]

a_p = 0
b_p = 0

for i in range(N):
    if i % 2 == 0:
        a_p += a[i]
    else:
        b_p += a[i]

print(a_p - b_p)


Measured memory_bytes: 2940
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 2e5 + 5;
const ll linf = 0x3f3f3f3f3f3f3f3f;

struct Node
{
	int x,y;
}p[MAXN];

inline bool cmp(const Node &p,const Node &q){ return p.x < q.x;}

int main(void)
{
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; ++i)
		scanf("%d%d",&p[i].x,&p[i].y);
	
	sort(p+1,p+n+1,cmp);
	
	ll mx1 = -linf, mx2 = -linf;
	
	ll ans = -linf;
	for(int i=1; i<=n; ++i)
	{
		ans = max(ans, mx1 + p[i].x + p[i].y);
		ans = max(ans, mx2 + p[i].x - p[i].y);
		
		mx1 = max(mx1, (ll)-p[i].x - p[i].y);
		mx2 = max(mx2, (ll)-p[i].x + p[i].y);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)

int main() {
  int k; cin>>k;
  if (k&1==1) {
    cout << k/2 * (k/2+1) << endl;
  } else {
    cout << k*k/4 << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 10000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,pair<int,int>> P;

int H,W,ans=0;
char C[1100][1100];
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
queue<P> que;


void bfs(){
  
  while(que.size()){
    P p=que.front(); que.pop();
    ans=max(ans,p.first);
    //cout<<p.second.first<<" "<<p.second.second<<endl;
    for(int i=0;i<4;i++){
      int ny=p.second.first+dy[i],nx=p.second.second+dx[i];
      //cout<<ny<<" "<<nx<<" "<<"nyとnx"<<endl;
      if(0<=nx && nx<W && ny>=0 && ny<H && C[ny][nx]=='.'){
        //cout<<"unk"<<endl;
        C[ny][nx]='#';
        que.push(make_pair(ans+1,make_pair(ny,nx)));
      }
    }
  }
}

int main(){
  int count=0;
  cin>>H>>W;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>C[i][j];
      if(C[i][j]=='#')   que.push(make_pair(0,make_pair(i,j)));
    }
  }

  bfs();
  //cout<<C[0][0]<<endl;
  cout<<ans<<endl;
}


Measured memory_bytes: 13184
s = input()
sum = 0
max = 0
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T':
        sum += 1
    else: sum = 0
    if sum >= max: max = sum
print(max)

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

const int maxn=505;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0}; 
int n,ql,qr,ans;
int dist[maxn][maxn];
bool occ[maxn][maxn];
pair<int,int>que[maxn*maxn];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)
		dist[i][j]=min(min(i,j),min(n-i+1,n-j+1)),occ[i][j]=true;
	for(int i=1;i<=n*n;i++){
		int p;scanf("%d",&p);
		int x=(p-1)/n+1,y=(p-1)%n+1;
		occ[x][y]=false;
		dist[x][y]--;
		ans+=dist[x][y];
		ql=1;qr=0;
		que[++qr]=make_pair(x,y);
		while(ql<=qr){
			x=que[ql].first;y=que[ql].second;
			ql++;
			for(int d=0;d<4;d++){
				int nx=x+dx[d],ny=y+dy[d];
				if(nx>=1&&nx<=n&&ny>=1&&ny<=n&&dist[nx][ny]>dist[x][y]+occ[nx][ny]){
					dist[nx][ny]=dist[x][y]+occ[nx][ny];
					que[++qr]=make_pair(nx,ny);
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6856
module String = struct
  include String
  let to_list s =
    let rec loop acc = function
      | 0 -> acc
      | n -> loop (s.[n - 1] :: acc) (n - 1) in
    loop [] (String.length s)
end

let () =
  read_line ()
  |> String.to_list
  |> List.map2 ( <> ) (String.to_list "CODEFESTIVAL2016")
  |> List.filter (fun x -> x)
  |> List.length
  |> Printf.printf "%d\n"

Measured memory_bytes: 384
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	[ a, b, c ] <- readInts
	-- b, a, c
	-- c, a, b
	printf "%d %d %d\n" c a b

Measured memory_bytes: 380
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll n;
	cin>>n;
	double p[n+1];
	lp(i,1,n)
		cin>>p[i];
	double dp[n+1][n+1];
	dp[0][0]=1;
	for(ll i=1 ; i<=n; i++){
		dp[0][i]=(1-p[i])*dp[0][i-1];
		for(ll j=1; j<=i; j++){
			dp[j][i]=p[i]*dp[j-1][i-1]+(1-p[i])*dp[j][i-1];
		}
	}
	ld ans=0;
	for(ll i=(n+1)/2; i<=n; i++ )
		ans+=dp[i][n];
	cout<<setprecision(15)<<ans<<endl;

	return 0;	
}


Measured memory_bytes: 49920
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,ans;
string s;
int32_t main(){
CODE_START;
cin>>s;
n=s.size();
for(ll i=0;i<n;i++)
if(s[i]=='o'){
    ans++;
}
cout<<700+100*ans;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{

  public static void main(String[] args){

	Scanner scan = new Scanner(System.in);
	
	  int a = scan.nextInt();
	  int b = scan.nextInt();
	
	  System.out.println((a * b) + " " + ((a + b) * 2));
  }
}

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

int main(){

    string S;
    cin >> S;
    int need_hug_time = 0;
    
    for(int i = 0; i < S.size() / 2; i++){
        if(S[i] != S[S.size()-1-i]){
            need_hug_time++;
        }
    }

    int ans = need_hug_time;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll N, K;
ll dp[102][20001];

ll beki(ll a, ll b) {
    if(b == 0) return 1;
    ll ret = beki(a, b / 2);
    ret = ret * ret % mod;
    if(b & 1) ret = ret *a % mod;
    return ret;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    dp[N+1][0] = 1;
    for(ll i = N; i >= 1; i--) {
        ll Over = K - i;
        chmax(Over, 0LL);
        for(ll before = 0; before <= 10000; before++) {
            if(dp[i+1][before] == 0) continue;
            dp[i][before] += Over * dp[i+1][before];
            dp[i][before] %= mod;
            ll under = (i * 10000 - before) % i;
            ll carry = before / i;
            if(under == 0) under = i;
            chmin(under, min(i, K) + 1);
            //cerr << i << " " << before << " " << under << endl;
            dp[i][before+carry] += under * dp[i+1][before];
            dp[i][before+carry] %= mod;
            for(ll delta = 1; ; delta++) {
                ll New = under + delta * i;
                chmin(New, min(i, K) + 1);
                //cerr << i << " " << before << " " << delta << " " << New << " " << New - (under + (delta-1)*i) << endl;
                dp[i][before+carry+delta] += (New - (under + (delta - 1) * i)) * dp[i+1][before];
                dp[i][before+carry+delta] %= mod;
                if(New != under + delta * i) break;
            }
        }
    }
    /*
    for(int i = 1; i <= N; i++) {
        for(int j = 0; j <= N * K; j++) {
            cerr << i << " " << j << " " << dp[i][j] << endl;
        }
    }
    */
    ll ans = beki(K + 1, N - 1) * K;
    ans %= mod;
    ans *= (K + 1);
    ans %= mod;
    ans *= beki(2, mod - 2);
    ans %= mod;
    ans *= N;
    ans %= mod;
    //cerr << ans << endl;
    for(int i = 0; i <= 10000; i++) {
        ans -= dp[1][i] * i;
        ans %= mod;
        ans += mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12672
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1000000000000000000
#define MOD 998244353 

void func()
{
    ll n;
    cin>>n;
    ll a[n];
    loop(i,0,n) cin>>a[i];
    ll ans=1000;
    loop(i,0,n-1){
        if(a[i]<a[i+1]){
            ll t=ans/a[i];
            ans+=t*(a[i+1]-a[i]);
        }
    }
    cout<<ans<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif
 
    ll t=1;
    //cin>>t;
    while(t--)
    {
        func();
    }

}

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

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

int main(){
  ll a,b;
  cin>>a>>b;
  cout<<a/gcd(a,b)*b<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main(){
    int V, E, S; cin >> V >> E >> S;
    struct edge {
        int from, to, cost;
    };

    vector<edge> es(E);
    vector<int> d(V, INF);
    
    for(edge &e:es){
        int f, t, c; cin >> f >> t >> c;
        e.from = f;
        e.to = t;
        e.cost = c;
    }
    
    d[S] = 0;
    bool negativ_cycle = false;
    for(int i=0; i<V; i++){
        bool updated = false;
        for(int i=0; i<E; i++){
            edge e = es[i];
            if(d[e.from]!=INF && d[e.to] > d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
                updated = true;
            }
        }
        if(!updated) break;
        if(i==V-1) negativ_cycle = true;
    }
    
    if(negativ_cycle){
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }
    for(int i=0; i<V; i++){
        if(d[i]==INF) cout << "INF" << endl;
        else cout << d[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a)
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;

inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=205;
//i_am_noob
int t,n,a[maxn],pos[63];
string str;
vector<int> vec;
set<int> st;
bool flag;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> t;
    while(t--){
        cin >> n;
        rep(n) cin >> a[i];
        cin >> str;
        reverse(a,a+n);
        reverse(all(str));
        if(str[0]=='1'){
            print1(1);
            continue;
        }
        vec.clear();
        flag=false;
        rep(n){
            vec.pb(a[i]);
            st.clear();
            rep3(j,62,0){
                rep1(k,sz(vec)){
                    if((vec[k]&pow2(j))&&st.count(k)==0){
                        rep1(l,sz(vec)) if((vec[l]&pow2(j))&&l!=k) vec[l]^=vec[k];
                        st.insert(k);
                        break;
                    }
                }
            }
            if(str[i]=='1') if(vec.back()){
                print1(1);
                flag=true;
                break;
            }
            if(!vec.back()) vec.pop_back();
        }
        if(!flag) print1(0);
    }
	return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n;
vector<pair<long,int> >a;
int cnt[1<<17];
main()
{
	cin>>n;
	for(int i=0;i<2*n;i++)
	{
		int x;cin>>x;
		a.push_back(make_pair(x,i));
	}
	int f=3,u=0;
	sort(a.begin(),a.end());
	long ans=0;
	for(int i=0;i<n;i++)
	{
		ans+=a[i].first;
		u+=cnt[a[i].second/2]++;
		f&=2-a[i].second%2;
	}
	if(f)cout<<ans<<endl;
	else if(u)cout<<ans<<endl;
	else
	{
		if(a[n-1].second/2!=a[n].second/2)
		{
			cout<<ans-a[n-1].first+a[n].first<<endl;
		}
		else
		{
			cout<<ans+min(a[n+1].first-a[n-1].first,a[n].first-a[n-2].first)<<endl;
		}
	}
}

Measured memory_bytes: 6512
H, W = map(int, input().split())
mas = []
deltags = []
for x in range(H):
    try:
        temp = list(input())
    except:
        pass
    if "#" in temp:
        mas.append(temp)

for x in range(len(mas[0])):
    deltag = False
    for y in range(len(mas)):
        if mas[y][x] == "#":
            break
        if y == len(mas)-1:
            deltag = True
    deltags.append(deltag)

for x in range(len(mas)):
    for y in range(len(mas[x])):
      if deltags[y]:
        mas[x][y] = "A"

try:
    x = 0
    while True:
        while "A" in mas[x]:
            mas[x].remove("A")
        print("".join(mas[x]))
        x += 1
except:
    pass


Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

bool che(string p){
		int lnt=p.length();
		for(int i=0;i<lnt/2;i++){
			if(p[i]!=p[lnt-1-i])return false;
		}
		return true;
}

int main(){
		
		string s;
		cin>>s;
		
		int lnth=s.length();
		if (s.substr(0,lnth/2)!=s.substr(lnth/2+1,lnth/2)){
			cout<<"No"<<endl;
			return 0;
		}
		
		if(!che(s.substr(0,lnth/2))){
			cout<<"No"<<endl;
		}else cout<<"Yes"<<endl;
			
		
		

	
		return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdtr1c++.h>
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
const int N = 100005;
const int MOD = 1000000007;
int mi(int a,int b){
    if(a<b) return a;
    return b;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin >> n >> k;
    int h[n+1];
    for(int i=1;i<=n;i++){
        cin >> h[i];
    }
    int minu[n+1];
    minu[1]=0;
    
    for(int i=2;i<=n;i++){
        minu[i]=INT_MAX;
        for(int j=1;j<=k && j<i;j++){
            minu[i]=mi(minu[i],minu[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout << minu[n];


    
    return 0;
}


Measured memory_bytes: 4380
N, Q = map(int, input().split())
S = list(input())
t = [0] * (N+1)
cnt = 0
for i in range(1,N):
    if S[i-1] == 'A' and S[i] == 'C':
        cnt += 1
    t[i] = cnt
t[-1] = t[-2]
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])


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

using namespace std;

int main() {
  	int MAX_N = 200000;
  	int n = 0;
	int buka_array[MAX_N] = {};
    int buka = 0;
  	
  	cin >> n;
  	while (cin >> buka) {
    	buka_array[buka-1]++;
    }
  
  	for (int i = 0; i < n; i++) {
    	cout << buka_array[i] << endl;
    }
}

Measured memory_bytes: 4420
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
typedef pair<lint,pint> tint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint dp[3010][3010];
int a[3010];
lint mo=1000000007,ha=500000004;
int main()
{
	int n,q,x,y;
	cin>>n>>q;
	memset(dp,0,sizeof(dp));
	rep(i,n) cin>>a[i];
	rep(i,n) rep(j,n){
		if(i!=j && a[i]>a[j]) dp[i][j]++;
	}
	rep(i,q){
		cin>>x>>y;x--;y--;
		vector<tint> v;
		lint t=dp[x][y]+dp[y][x];
		t*=ha;t%=mo;
		v.pb(mp(t,mp(x,y)));v.pb(mp(t,mp(y,x)));
		rep(j,n){
			if(j==x || j==y) continue;
			lint t1=(dp[j][x]+dp[j][y])*ha%mo,t2=(dp[x][j]+dp[y][j])*ha%mo;
			v.pb(mp(t1,mp(j,x)));v.pb(mp(t1,mp(j,y)));
			v.pb(mp(t2,mp(x,j)));v.pb(mp(t2,mp(y,j)));
		}
		rep(j,v.size()) dp[v[j].se.fi][v[j].se.se]=v[j].fi;
	}
	lint out=0;
	rep(i,n) REP(j,i+1,n){
		out+=dp[i][j];out%=mo;
	}
	rep(i,q){
		out*=2;out%=mo;
	}
	cout<<out<<endl;
}


Measured memory_bytes: 71488
#include<bits/stdc++.h>
using namespace std;
#define i64 long long int
int n,k;
pair<i64,int> a[1111];int top;
void pus(i64 x){
  int r = 0;
  for(i64 y = x; y; y/=10)
    r += y%10;
  while(top > 0 && a[top-1].first * r > a[top-1].second * x)
    --top;
  a[top++] = make_pair(x,r);
}
int main(){
  for(int i=1; i<1000000; i++){
    pus(i);
  }
  i64 cur = 10;
  for(int k=7; k<=15; k++,cur*=10){
    for(int i=100000; i<1000000; i++)
      pus((i+1)*cur-1);
  }
//  k=top;
  scanf("%d",&k);
  for(int i=0; i<k; i++)
    printf("%lld\n",a[i].first);
  return 0;
}

Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
//#include <vector>
//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int countSwitch(int sw[],int status[][10],int N, int ni,int P[],int M){
    if(ni >= N){
//        cout << "count:" << ni << endl;
        for( int mi = 0 ; mi < M ; mi++ ){
            int sumv = 0;
            for( int nni = 0 ; nni < N ; nni++ ){
                sumv+= status[mi][nni] * sw[nni];
//                cout << sw[nni];
            }
//            cout << endl;
//            cout << sumv << endl;
            if(sumv%2!=P[mi]){
                return 0;
            }
        }
        return 1;
    }else{
        int count;
        sw[ni]=0;
        count = countSwitch(sw,status,N,ni+1,P,M);
        sw[ni]=1;
        count += countSwitch(sw,status,N,ni+1,P,M);
        return count;
    }
}

int main(){

    int N;

    cin >> N;

    int M;
    cin >> M;
    int k[M];
    int status[10][10]={};

    for( int mi = 0 ; mi < M ; mi++ ){
        cin >> k[mi];
        int val;
        for( int si = 0 ; si < k[mi] ; si++ ){
            cin >> val;
            status[mi][val-1]=1;
        }
    }

    int P[M];
    for( int pi = 0 ; pi < M ; pi++ ){
        cin >> P[pi];
    }

    int count=0;
    int sw[N];

    cout << countSwitch(sw,status,N,0,P,M);
    



    


}

Measured memory_bytes: 256
#include <cmath>
#include <iomanip>
#include <iostream>

using namespace std;
int main() {
  double a, b, c, d, e, f;
  while (cin >> a >> b >> c >> d >> e >> f) {
    double x = (c * e - b * f) / (a * e - b * d);
    double y = (c * d - a * f) / (b * d - a * e);
    x = floor(x * 10000 + .5) / 10000;
    y = floor(y * 10000 + .5) / 10000;
    cout << fixed << setprecision(3) << x << " " << y << endl;
  }
}

Measured memory_bytes: 1284
#include<stdio.h>

int main(void)
{
  int N,num=1;
  int i;
  
  scanf("%d",&N);
  
  for(i=0;i<7;i++){
    num=num*2;
    if(num>N){
      printf("%d",num/2);break;
    }
    if(num==N){
      printf("%d",num);break;
    }
  }
    
  return 0;
}

Measured memory_bytes: 128
n,a,b = map(int, input().split())
def f(x):
  ret = 0
  while(x > 0):
    ret += x % 10
    x //= 10
  return ret
nums = filter(lambda x: f(x) >= a and f(x) <= b, range(1, n + 1))
print(sum(nums))

Measured memory_bytes: 3060