akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for(int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for(int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for(auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef priority_queue<ll, vl> decendingQueue;              //降順
typedef priority_queue<ll, vl, greater<ll>> ascendingQueue; //昇順
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 9 * 1e18;
const ll MOD = 1e9 + 7;

void solve(long long N, long long X, std::vector<long long> L) {
    ll d = 0;

    vl D;
    D.push_back(d);
    rep(i, 0, N) {
        d += L[i];
        D.push_back(d);
    }

    ll index = upper_bound(all(D), X) - D.begin();
    print(index);
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long X;
    scanf("%lld", &X);
    std::vector<long long> L(N);
    for(int i = 0; i < N; i++) {
        scanf("%lld", &L[i]);
    }
    solve(N, X, std::move(L));
    return 0;
}


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


bool isok(int a , int b)
{
    //mmyy

    if(a>=1 && a<=12)
        return true;
    return false;
}

int main()
{
    int t , n;

    int k;

    string s;

    cin >> s;

    int a = (s[0]-'0')*10+(s[1]-'0');
    int b = (s[2]-'0')*10+(s[3]-'0');

    if(isok(a , b) && isok(b , a))
        cout << "AMBIGUOUS";
    else if(isok(a , b))
        cout << "MMYY";
    else if(isok(b , a))
        cout << "YYMM";
    else
        cout << "NA";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int makeList(int x)
{
	int ans=1;
	for(int i=2;i<=sqrt(x);i++)
	{
		int j=i;
		while((j*=i)<=x)
		  ans=max(ans,j); 
	}
	return ans;
} 

int main()
{
	int a;
	cin>>a;
	cout<<makeList(a)<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    string s;
    cin>>s;
    int a,b;
    for(a=0;a<s.size();a++)
        if(s[a]=='C')
            break;
    for(b=s.size()-1;b>=0;b--)
        if(s[b]=='F')
            break;
    if(a<b)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX_N 200001
#define mod 1000000007
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll n;

signed main(){
    cin >> n;
    REP(i, n){
        ll a; cin >> a;
        if(a % 2 == 0){
            if(a % 3 != 0 && a % 5 != 0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;

    return 0;
}

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

typedef int32_t i32;
typedef int64_t i64;

static i64 read_int(void){int prev='\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}

typedef i32  radix_type;

#define RADIX_WIDTH 9
const uint32_t radix_type_max = 18;
const uint32_t radix_type_begin = 0;
const uint32_t radix_width = RADIX_WIDTH;
const uint32_t radix_mask = (1 << RADIX_WIDTH) - 1;
#undef RADIX_WIDTH

static inline uint32_t radix_get_bit (radix_type v, uint32_t shift) {
  return v >> shift & radix_mask;
}

void radix_sort (radix_type *a, uint32_t n) {
  radix_type * const array = (radix_type *) calloc (4 * n, sizeof (radix_type));
  radix_type **bucket = (radix_type **) calloc (1 << radix_width, sizeof (radix_type *));
  uint32_t *len = (uint32_t *) calloc (2 << radix_width, sizeof (uint32_t));
  uint32_t *max_len = len + (1 << radix_width);
  for (uint32_t shift = radix_type_begin; shift < radix_type_max; shift += radix_width) {
    radix_type *p = array;
    memset (len, 0, sizeof (uint32_t) << (radix_width + 1));
    for (uint32_t i = 0; i < n; ++i) {
      uint32_t bit = radix_get_bit (a[i], shift);
      if (len[bit] == max_len[bit]) {
	for (uint32_t j = 0; j < len[bit]; ++j) {
	  p[j] = bucket[bit][j];
	}
	max_len[bit] = 2 * max_len[bit] + 1;
	bucket[bit] = p;
	p += max_len[bit];
      }
      bucket[bit][len[bit]++] = a[i];
    }
    for (uint32_t bit = 0, i = 0; bit < (1 << radix_width); ++bit) {
      for (uint32_t j = 0; j < len[bit]; ++j, ++i) {
	a[i] = bucket[bit][j];
      }
    }
  }
  free (array);
  free (bucket);
  free (len);
}

void run (void) {
  i32 n = read_int();
  i32 m = read_int();
  i32 *x = (i32 *) calloc (m, sizeof (i32));
  for (i32 i = 0; i < m; ++i) {
    x[i] = read_int() + 100000;
  }
  radix_sort (x, m);
  for (i32 i = 0; i < m - 1; ++i) {
    x[i] = x[i + 1] - x[i];
  }
  radix_sort (x, m - 1);
  i32 ans = 0;
  for (i32 i = 0; i < m - n; ++i) {
    ans += x[i];
  }
  printf("%" PRIi32 "\n", ans);
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int n,m,a[52][52];
char c;
int main() {
	cin>>n>>m;
	for(int i=1; i<=n; i++) 
		for(int j=1; j<=m; j++) {
			cin>>c;
			if(c=='#') { 
				a[i][j]=-10000000;
				a[i-1][j-1]++;
				a[i-1][j]++;
				a[i-1][j+1]++;
				a[i][j-1]++;
				a[i][j+1]++;
				a[i+1][j-1]++;
				a[i+1][j]++;
				a[i+1][j+1]++;
			}
		}
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=m; j++)
			if(a[i][j]<0)cout<<"#";
			else cout<<a[i][j];
		cout<<endl;
	}
	return 0;
}
/*
*全国青少年计算机程序设计大赛究竟何时创办?
*前缀与后缀为何混淆不清?
*Catalan数到底表示什么?
*是什么让一台只有红蓝两色球的抽奖机如此火爆?
*关机的手机究竟能否带进考场?
*负权回路与Dijkstra算法有什么不为人知的关系?
*图灵奖到底是哪方设立?
*四人郊游为何只有两人如约?
*是什么让＋＋cnt陷入无意义的循环?
*双向链表究竟是何方神圣?
*小猪又为何在两家商店间因巨额消费徘徊不定?
*欢迎来到第二十四届NOIp!
*/

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
A - Happy Birthday!
https://abc100.contest.atcoder.jp/tasks/abc100_a

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    A, B = map(int, input().split())
    if A <= 8 and B <= 8:
        print('Yay!')
    else:
        print(':(')


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    ll N;
    cin >> N;
    vector<ll> X(N),Y(N),h(N);
    for(int i=0;i<N;i++){
        cin >> X[i] >> Y[i] >> h[i];
    }
    for(int Cx=0;Cx<=100;Cx++){
        for(int Cy=0;Cy<=100;Cy++){
            bool jg=true;
            ll H = 0;
            ll mi = INF;
            for(int i=0;i<N;i++){
                if(h[i]>0) {
                    H = h[i]+llabs(X[i]-Cx)+llabs(Y[i]-Cy);
                    break;
                }
                else{
                    mi = min(mi,llabs(X[i]-Cx)+llabs(Y[i]-Cy));
                }
            }
            if(H==0) H = mi;
            for(int i=0;i<N;i++){
                if(h[i]!=max(H-llabs(X[i]-Cx)-llabs(Y[i]-Cy),(ll)0)){
                    jg = false;
                    break;
                }
            }
            if(jg){
                cout << Cx << " " << Cy << " " << H << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
using PP = pair<int, int>;
int n, m, s, t;
vector<int> G[300000];

int bfs() {
  vector<int> dist(3 * n, INF);
  queue<PP> Q;
  Q.push(PP(0, s));
  while (!Q.empty()) {
    PP p = Q.front(); Q.pop();
    int d = p.first;
    int from = p.second;
    if (dist[from] != INF) continue;
    dist[from] = d;
    for (int to : G[from]) {
      Q.push(PP(d + 1, to));
    }
  }
  return dist[t];
}

int main() {
  cin >> n >> m;
  for (int j = 0; j < m; ++j) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    for (int k = 0; k < 3; ++k) {
      G[a + k * n].push_back(b + (k + 1) % 3 * n);
    }
  }
  cin >> s >> t;
  --s; --t;
  int ans = bfs();
  cout << (ans == INF ? -1 : ans / 3) << endl;
}

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


int main() {
	
	int N;
	cin >> N;
	for (int i=N; i>0; i--){
		if ((int)sqrt(i)*(int)sqrt(i) == i) {
			cout << i << endl;
			break;
		}
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1e9+7;

int main() {
  int abc[3];
  rep(i,3) cin>>abc[i];
  sort(abc,abc+3);
  if(abc[0]==5 && abc[1]==5 && abc[2]==7)
    cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin>>n;
    ll ans = 0;
    for(ll i = 1;i<=n;i++){
        ans+=i*(n-i+1);
    }
    ll a,b;
    for(int i = 0;i<n-1;i++){
        cin>>a>>b;
        if(b<a)swap(a,b);
        ans-=a*(n-b+1);
    }
    cout<<ans;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,x,y;
    cin >> n >> x >> y;
    --x, --y;
    vector<int> ans(n);
    for(int i=0; i<n; i++){
        vector<int> dist(n,-1);
        queue<int> q;
        // if distance of v is d, do push
        // lambda def.
        auto push = [&](int v, int d){
            if(dist[v] != -1) return;// if distance is already known, skip
            dist[v] = d;
            q.push(v);
        };
        push(i,0);// initial step
        
        // start BFS
        while(!q.empty()){
            int v = q.front(); q.pop();
            int d = dist[v];
            // if sent. is for out-of range reference error
            if(v-1>=0) push(v-1,d+1); // you can go to v-1 by d+1
            if(v+1<=n) push(v+1,d+1); // you can go to v+1 by d+1
            // connected case
            if(v==x) push(y,d+1);
            if(v==y) push(x,d+1);
        }
        for(int j=0; j<n; j++) ans[dist[j]]++;
    }
    // for duplication
    // e.g. (1,2), (2,1)
    for(int i=0; i<n; i++) ans[i]/=2;
    for(int i=1; i<=n-1; i++){
        cout << ans[i] << endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	int k=1;
	if(a==b&&b==c)
	k=0;
	if(a!=b&&b!=c&&c!=a)
	k=0; 
	if(k==1)
	printf("Yes");
	else
	printf("No");
	return 0;
}


Measured memory_bytes: 128
n = int(input())
s = [int(input()) for _ in range(n)]
k = []
k1 = []

for i in range(n):
    k.append(s[i])
    if s[i]%10!=0:
        k1.append(s[i])

if sum(k)%10!=0:
    print(sum(k))
else:
    if len(k1)==0:
        print(0)
    else:
        k1.sort()
        print(sum(k)-k1[0])


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

int main() {
    int n; cin >> n;
    vector<int> p(n);
    rep(i, n){
        cin >> p[i];
    }

    int ans = 0;
    for (int i = 1; i < n-1; i++){
        if(p[i] > p[i-1] && p[i] < p[i+1])ans++;
        if(p[i] < p[i-1] && p[i] > p[i+1])ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

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

bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int abs(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int fiv(int n){
  if(n==0){
    return 0;
  }
  else if(n==1){
    return 1;
  }
  return fiv(n-1)+fiv(n-2);
}
ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}
int main(){
  int n;
  cin >>n;
  vector<ll> a(n);
  rep(i,n){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  bool res=true;
  for(int i=0; i<n-1;i++){
    if(a[i]==a[i+1]){
      res =false;
      break;
    }
  }
  if(res){
    cout <<"YES"<<endl;
  }
  else{
    cout<< "NO"<<endl;
  }

  
}



Measured memory_bytes: 1792
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;
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; }

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

vvecllong edge;
vecllong ans;

void calc(llong now, llong parent){
    if(parent != -1){
        ans[now] += ans[parent];
    }
    for_each(edge[now].begin(), edge[now].end(), [&](llong to) {
        if(to != parent){
            calc(to, now);
        }
    });
    return;
};

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

    llong N, Q;
    cin >> N >> Q;

    edge.resize(N, vecllong(0));
    FOR(i, N - 1){
        llong a, b;
        cin >> a >> b;
        a--;
        b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    ans.resize(N, 0);
    FOR(i, Q) {
        llong p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }

    calc(0, -1);
    FOR(i, N) {
        cout << ans[i] << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 24320
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

bool is_prime(int x){
    if(x <= 1) return false;
    for(int i=2; i*i <= x; i++)
        if(x % i == 0) return false;
    return true;
}


int main(){
    int p; cin >> p;
    while(!is_prime(p)){
        p++;
    }

    cout << p;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s,t; cin>>s>>t;
    int res = 1000;
    for (int i=0; i<s.size(); i++) {
        if (i+t.size() > s.size()) break;
        int tmp = 0;
        for (int j=0; j<t.size(); j++) {
            if (s[i+j] != t[j]) tmp++;
        }
        res = min(res, tmp);
    }
    cout << res;
    return 0;
}

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

int main() {
    int X;
    cin >> X;
    if(X <= 599) cout << 8 << endl;
    else if(600 <= X && X <= 799) cout << 7 << endl;
    else if(800 <= X && X <= 999) cout << 6 << endl;
    else if(1000 <= X && X <= 1199) cout << 5 << endl;
    else if(1200 <= X && X <= 1399) cout << 4 << endl;
    else if(1400 <= X && X <= 1599) cout << 3 << endl;
    else if(1600 <= X && X <= 1799) cout << 2 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
//#define MOD 1000000007
#define MOD 998244353
#define INF 2305843009213693951
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define all1(i) begin(i),end(i)
#define GOODBYE do { cout << "-1" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

class segmenttree{
    /*
    Copyright (c) 2020 0214sh7
    https://github.com/0214sh7/library/
    */
    private:
    int n;
    long long identity = 0;//単位元
    std::vector<long long> dat;
    public:
    
    void init(int N){
        n=1;
        while(n<N)n*=2;
        dat.clear();
        for(int i=0;i<2*n-1;++i){
            dat.push_back(identity);
        }
    }
    
    long long calc();
    
    void update(int k,long long a){
        k+=n-1;
        dat[k]=a;
        while(k>0){
            k=(k-1)/2;
            dat[k]=calc(dat[2*k+1],dat[2*k+2]);
        }
    }
    
    long long query(long long a,long long b){
        a+=n;
        b+=n;
        long long R=0;
        while(a < b){
            if(a % 2 == 1){
                R = calc(R, dat[a - 1]);
                a += 1;
            }
            a /= 2;
            if(b % 2 == 1){
                b -= 1;
                R = calc(R, dat[b - 1]);
            }
            b /= 2;
        }
        return R;
    }
    
    long long calc(long long a,long long b){
        //your monoid here
        return max(a,b);
    }
    
};

int main(void){
    
    ll N,K,a;
    vector<ll> A;
    cin >> N >> K;
    REP(i,N){
        cin >> a;
        A.push_back(a);
    }
    
    segmenttree seg;
    seg.init(314514);
    
    REP(i,N){
        a = A[i];
        ll l = max(0ll,a-K);
        ll r = min(314514ll,a+K+1);
        
        ll D = seg.query(l,r);
        seg.update(a,D+1);
    }
    
    ll Ans = seg.query(0,314514ll);
    cout << Ans << endl;
    
    return 0;
}



Measured memory_bytes: 13992
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl

//ここからAtCoder向けdefine
#define yes cout << "Yes" << endl
#define no cout << "No" << endl

using namespace std;

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using pint = pair<int,int>;

const int INF = ~(1 << 31);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int i;
    for(i = 1;;i *= 10){
        if(b % i == b) break;
    }
    int c = a * i + b;
    float f = sqrt(c) * 10.0;
    if((int)f % 10 == 0){ yes; }
    else { no; }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    
    int N;
    string S;
    cin >> N;
    cin >> S;
    
    for(int i = 0; i < S.size(); i++){
        int int_S = (int)(S[i]) + N;
        if(int_S > 90) cout << (char)(int_S - 26);
        else cout << (char)(int_S);
    }cout << endl;
    
}


Measured memory_bytes: 256
import sys
x, n = map(int, input().split())
p = list(map(int, input().split()))

if n == 0 or not x in p:
    print(x)
    sys.exit()
c = 1
while True:
    if not x-c in p:
        print(x-c)
        sys.exit()
    if not x+c in p:
        print(x+c)
        sys.exit()
    c+=1

Measured memory_bytes: 9184
#include<iostream>
#include <bits/stdc++.h>
#include<string>
#include<algorithm>
#include <utility>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)


int main(){
    char S[3];
    cin >> S;
    if(S[0]==S[1]&&S[1]==S[2]){
        cout << "No"<< endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

	int sum = 0;
	int koka[] = {1,5,10,50,100,500};
	
	for (int i = 0; i < 6; i++){
		int c;
		cin >> c;
		sum += c * koka[i];
	}

	cout << (sum >= 1000 ? "1" : "0") <<endl;

	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <tuple>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

using T = tuple<ll,ll>;
using Graph = vector<vector<T>>;

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

    string s;
    cin >> s;
    ll num (0);
    for (auto c : s)
        if (c=='+')
            ++num;
        else if (c=='-')
            --num;

    cout << num << endl;
    return 0;
}


Measured memory_bytes: 256
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

s,t = input().split()
a,b = inm()
u = ins()
if u==s:
    print("{} {}".format(a-1,b))
else:
    print("{} {}".format(a,b-1))


Measured memory_bytes: 38384
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#undef LOCAL
#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#ifdef LOCAL
struct PrettyOS {
    ostream& os;
    bool first;
    template <class T> auto operator<<(T&& x) {
        if (!first) os << ", ";
        first = false;
        os << x;
        return *this;
    }
};
template <class... T> void dbg0(T&&... t) {
    (PrettyOS{cerr, true} << ... << t);
}
#define dbg(...)                                            \
    do {                                                    \
        cerr << __LINE__ << " : " << #__VA_ARGS__ << " = "; \
        dbg0(__VA_ARGS__);                                  \
        cerr << endl;                                       \
    } while (false);
#else
#define dbg(...)
#endif

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

struct Scanner {
    FILE* fp = nullptr;
    char line[1 << 15];
    size_t st = 0, ed = 0;
    void reread() {
        memmove(line, line + st, ed - st);
        ed -= st;
        st = 0;
        ed += fread(line + ed, 1, (1 << 15) - ed, fp);
    }
    bool succ() {
        while (true) {
            if (st == ed) {
                reread();
                if (st == ed) return false;
            }
            while (st != ed && isspace(line[st])) st++;
            if (st != ed) break;
        }
        if (ed - st <= 50) reread();
        return true;
    }
    template <class T, enable_if_t<is_same<T, string>::value, int> = 0>
    bool read_single(T& ref) {
        if (!succ()) return false;
        while (true) {
            succ();
            while (st != ed && !isspace(line[st])) ref += line[st++];
            if (st != ed) break;
        }
        return true;
    }
    template <class T, enable_if_t<is_integral<T>::value, int> = 0>
    bool read_single(T& ref) {
        if (!succ()) return false;
        bool neg = false;
        if (line[st] == '-') {
            neg = true;
            st++;
        }
        ref = T(0);
        while (isdigit(line[st])) {
            ref = 10 * ref + (line[st++] - '0');
        }
        if (neg) ref = -ref;
        return true;
    }
    void read() {}
    template <class H, class... T> void read(H& h, T&... t) {
        bool f = read_single(h);
        assert(f);
        read(t...);
    }
    Scanner(FILE* _fp) : fp(_fp) {}
};

int main() {
    Scanner sc(stdin);
    int n;
    string s;
    sc.read(n, s);
    string t;
    for (char c: s) {
        if (t.empty() || t.back() != c) t.push_back(c);
    }
    cout << t.size() << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>

int main(){
  int x;
  std::cin >> x;
  bool enable = false;
  for (int i = 1; i < 10; i++){
    int div = x / i;
    int mod = x % i;
    if (0 < div && div < 10 && mod == 0){
      enable = true;
      break;
    }
  }
  if (enable){
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
}

Measured memory_bytes: 256
function print(data){
  process.stdout.write(data+'\n')
}

const cube = x => x*x*x

const readLine = require('readline')

const rl = readLine.createInterface({
input:process.stdin,
output:process.stdout
})

rl.on('line', (line) => {
  print(cube(parseInt(line)))
})


Measured memory_bytes: 16388
n, k = input().split()
N = int(n)
K = int(k)
A = [int(a) for a in input().split()]
countAList = []
countBList = []
for j in range(N):
    countA = 0
    countB = 0
    for i in range(N):
        if A[i] < A[j]:
            countB += 1
            if i > j:
                countA += 1
    countAList.append(countA)
    countBList.append(countB)
result = 0

for a, b in zip(countAList, countBList):
    result += int(K * a) + int(b * K * (K - 1) // 2)
    result %= 10 ** 9 + 7
print(result)


Measured memory_bytes: 3188
/*
    nah nah nah
*/
#include <bits/stdc++.h>
#define ll long long
#define fir first
#define sed second
#define i64 int64_t
#define pii pair< int,int >
using namespace std;
ifstream fi("");
ofstream fo("");

int main(){
//cout<<(int)'A'<<" "<<(int)'Z'<<endl;
string s;
int x;
cin>>x;
cin>>s;
for (int i=0;i<s.size();i++) s[i]=char((s[i]-65+x)%26 + 65);
cout<<s;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int i,j,k;
	int u[10];

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

	for(j=0;j<9;j++)
	{
		for(k=0;k<9-j;k++)
		{
			if(u[k]<u[k+1])
			{
				i=u[k];
				u[k]=u[k+1];
				u[k+1]=i;
			}
		}
	}
	for(i=0;i<3;i++)
	{
		printf("%d\n",u[i]);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000003
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

//AGC034
signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    
    string s; cin>>s;
    if(s.size()<=2){cout<<0<<endl; return 0;}

    int ans=0;
    int acnt=0;
    rep(i,s.size()){
        bool b=true;
        if(s[i]=='A'){
            acnt++;
            b=false;
        }
        if(i<s.size()-1 and s[i]=='B' and s[i+1]=='C' and acnt>0){
            ans+=acnt;
            b=false;
            i++;
        }
        if(i<s.size()-2 and s[i]=='A' and s[i+1]=='B' and s[i+2]=='C'){
            ans+=acnt;
            b=false;
            i+=2;
        }
        if(b)acnt=0;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n - 1); 0 <= i; --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

namespace My
{
template <typename ArrayT>
static void DumpArray(const ArrayT &arr)
{
#if defined(HOME)
	for (auto it = std::begin(arr); it != std::end(arr); ++it) {
		cerr << *it << " ";
	}
	cerr << endl;
#endif
}
template<typename T>
static void DumpGrid(const vector<vector<T>> &grid){
#if defined(HOME)
	REP (i, grid.size()) {
		REP (j, grid[i].size()) {
			cerr << grid[i][j] << " ";
		}
		cerr << endl;
	}
#endif
}
template <class ArrayT, typename T>
static void InitArray(ArrayT &arr, T initValue){
	for (auto &v : arr){
		v = initValue;
	}
}
template <typename T>
static bool ReplaceIfSmaller(T &target, T value)
{
	if (value < target) {
		target = value;
		return true;
	} else {
		return false;
	}
}
template <typename T>
static bool ReplaceIfBigger(T &target, T value)
{
	if (target < value) {
		target = value;
		return true;
	} else {
		return false;
	}
}

class Solver
{
  public:
	Solver() {}
	void Solve(istream &cin, ostream &cout)
	{
		int A, B, C, D;
		cin >> A >> B >> C >> D;

		if (A * B < C * D){
			cout << C * D << endl;
		}else{
			cout << A * B << endl;
		}
	}
};
} // namespace My

#if !defined(BOOST_TEST_MODULE)
#if !defined(GTEST_INCLUDE_GTEST_GTEST_H_)
int main()
{
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);

	My::Solver solver;
	solver.Solve(std::cin, std::cout);

	return 0;
}
#endif
#endif


Measured memory_bytes: 256
#include<stdio.h>

  int main(void)
  {
    int a, b, c;
    double k;

    scanf("%d", &a);
    scanf("%d", &b);

    k = (a+b)/2.0;
    c = (int)k;
    if (k-c == 0) {
      printf("%d\n", (int)k);
    } else {
      printf("IMPOSSIBLE");
    }

    return 0;
  }


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,c;
	cin>>a>>b>>c;
	if(4*a*b<a*a+b*b+c*c+2*a*b-2*a*c-2*b*c &&(c-a-b)>0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


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


void solve() {
  int N, K;
  scanf("%d %d", &N, &K);
  int arr[N];
  for (size_t i = 0; i < N; i++) {
    scanf("%d", &arr[i]);
  }
  int ans = 0;
  for (size_t i = 0; i < N; i++) {
    if (arr[i] >= K) {
      ans++;
    }
  }

  cout << ans << "\n";
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
struct pp
{
	int	a,b;
}p[50];
bool cmp(const pp &a,const pp &b)
{
	return a.b<b.b;
}

using namespace std;
int main()
{
	int n;
	while(cin>>n)
	{
		if(n==0) break;
		bool f=true;
		for(int i=0;i<n;i++)
		{
			cin>>p[i].a>>p[i].b;
			if(p[i].a>p[i].b) {
				f=false;
			}
		}
		if(!f) cout<<"No"<<endl;
		else {
			sort(&p[0],&p[n],cmp);
			int bag=p[0].a;
			for(int i=1;i<n;i++)
			{
				bag=p[i].a+bag;
				if(bag>p[i].b) {
					f=false;
					break;
				}
			}
			if(f) cout<<"Yes"<<endl;
			else cout<<"No"<<endl;	
		}
	}
	return 0;
} 

Measured memory_bytes: 1172
/*---> praveenojha33 <---> 01 September 2019 <--- > 17:36:57 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

int32_t main(){__
	int a,b;
	cin>>a>>b;
	for(int i=0;;i++){
		if((a-1)*(i-1)+a>=b){
			return cout<<i<<"\n",0;
		}
	}
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int X = scanner.nextInt();
        int Y = scanner.nextInt();
        int Z = scanner.nextInt();
        int N;

        N = X;
        X = Y;
        Y = N;

        N = X;
        X = Z;
        Z = N;

        System.out.println(X + " " + Y + " " + Z);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string s;
    cin>>s;
    bool j=true;
    //cout<<s.size()<<endl;
    if(s.size()%2==1){
        cout<<"No"<<endl;
        return 0;
    }
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s.at(i)=='h'){
                continue;
            }
            else{
                j=false;
            }
        }
        else{
            if(s.at(i)=='i'){
                continue;
            }
            else{
                j=false;
            }
        }
    }
    if(j==true){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}

Measured memory_bytes: 256
# 約数の数 = 素因数分解して、各素因数の(指数 + 1)をかけ合わせたもの
# 例：12 = 2^2 * 3^1 -> 3 * 2 = 6 (1,2,3,4,6,12)
# これが75になるためには、以下のペアを作れる必要がある。この組み合わせを数える
# 75 : 指数が74
# 3 * 25 : 指数が2 , 24
# 5 * 15 : 指数が4 , 14
# 3 * 5 * 5 : 指数が2,4,4

import sys
readline = sys.stdin.readline

N = int(readline())

def factorization(n):
  res = []
  temp = n
  for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
    if temp % i == 0:
      cnt = 0
      while temp % i == 0:
        cnt += 1
        temp //= i
      res.append([i,cnt])
  if temp != 1:
    res.append([temp, 1])
  if res == []:
    res.append([n, 1])
  return res

from collections import defaultdict
dic = defaultdict(int)
for i in range(1, N + 1):
  res = factorization(i)
  for r in res:
    dic[r[0]] += r[1]

ans = 0

vals = dic.values()
# 74以上のものを探す
i74 = 0
for v in vals:
  if v >= 74:
    i74 += 1
ans += i74

i2 = 0
i24 = 0
# 2,24以上のものを探す
for v in vals:
  if v >= 24:
    i24 += 1
  elif v >= 2:
    i2 += 1
ans += (i24 * (i24 - 1))
ans += i24 * i2
  
# 5,15以上のものを探す
i4 = 0
i14 = 0
for v in vals:
  if v >= 14:
    i14 += 1
  elif v >= 4:
    i4 += 1
ans += (i14 * (i14 - 1))
ans += i14 * i4

# 2,4,4を探す
i4 = 0
i2 = 0
for v in vals:
  if v >= 4:
    i4 += 1
  elif v >= 2:
    i2 += 1
if i4 >= 3:
  ans += ((i4 * (i4 - 1)) // 2) * (i4 - 2)
ans += ((i4 * (i4 - 1)) // 2) * i2

print(ans)

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();
		int[][]A = new int[n][m];
		int[][]B = new int[m][l];
		long[][]C = new long[n][l];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				A[i][j] = scan.nextInt();
			}
		}
		for(int i = 0; i < m; i++) {
			for(int j = 0; j < l; j++) {
				B[i][j] = scan.nextInt();
			}
		}
		scan.close();
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < l; j++) {
				long sum = 0;
				for(int k = 0; k < m; k++) {
					sum += A[i][k] * B[k][j];
				}
				C[i][j] = sum;
			}
		}
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < l; j++) {
				if(j == l - 1) {
					System.out.println(C[i][j]);
				}else {
					System.out.print(C[i][j] + " ");
				}
			}
		}
	}
}


Measured memory_bytes: 52704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    string A,B,C;
    cin >> A >> B >> C;
    reverse(ALL(A));
    reverse(ALL(B));
    reverse(ALL(C));
    char turn = 'a';
    char ans = 'a';
    while(1){
        if(turn == 'a'){
            if(A.size() == 0){
                ans = 'A';
                break;
            }
            turn = *A.rbegin();
            A.pop_back();
        }else if(turn == 'b'){
            if(B.size() == 0){
                ans = 'B';
                break;
            }
            turn = *B.rbegin();
            B.pop_back();
        }else if(turn == 'c'){
            if(C.size() == 0){
                ans = 'C';
                break;
            }
            turn = *C.rbegin();
            C.pop_back();
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int fa1[200009];
int fa2[200009];
int findset1(int u)
{
    return fa1[u]==u?u:fa1[u]=findset1(fa1[u]);
}
int findset2(int u)
{
   return fa2[u]==u?u:fa2[u]=findset2(fa2[u]);
}
int main()
{
    int n,k,r;
    cin>>n>>k>>r;
    for(int i=1;i<=n;i++)
    {
        fa1[i]=i;
        fa2[i]=i;
    }
    int u,v;
    for(int i=1;i<=k;i++)
    {
        cin>>u>>v;
        int fu=findset1(u);
        int fv=findset1(v);
        if(fu!=fv)
        {
            fa1[fu]=fv;
        }
    }
    for(int i=1;i<=r;i++)
    {
        cin>>u>>v;
        int fu=findset2(u);
        int fv=findset2(v);
        if(fu!=fv)
        {
            fa2[fu]=fv;
        }
    }
    map<pair<int,int>,int>mp;
    for(int i=1;i<=n;i++)
    {
        findset1(i);
        findset2(i);
    }
    for(int i=1;i<=n;i++)
    {
        mp[make_pair(fa1[i],fa2[i])]++;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<mp[make_pair(fa1[i],fa2[i])]<<" ";
    }

}


Measured memory_bytes: 13568
N,M,X,Y = map(int, input().split())
list_x = list(map(float, input().split()))
list_y = list(map(float, input().split()))
if X<Y:
	if max(list_x)<min(list_y) and X<min(list_y) and Y>max(list_x):
	  print("No War")
	
	else:
		print("War")
      
    
else:
	if max(list_x)>min(list_y) and Y<min(list_x):
	  print("No War")
    
	else:
	  print("War")
   


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

int main()
{
    int n;
    cin >> n;
    int start = 0;
    int ans = 0;
    bool flag = false;
    for(int i=1; i<=n; i++){
        int t;
        cin >> t;
        if(t == i){
            if(!flag) start = i;
            if(i == n) ans += (i-start+2)/2;
            flag = true;
        }else{
            if(flag) ans += (i-start+1)/2;
            flag = false;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define faf ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define ll long long
#define pb push_back
#define mp make_pair
#define For(i,k,n) for(i=k;i<=n;i++)


const  ll modo=1e9+7;

int nod(int n)
{
    int i=0;
    while(n>0)
    {
        i++;
        n/=10;
    }
    return  i;
}



int main()
{
    faf;
    int n;
    cin>>n;
    int i;
    int ans=0;
    int pp;
    for(i=1;i<=n;i++)
    {
        pp=nod(i);
        if(pp%2)ans++;
    }
    cout<<ans;



    return 0;
}

Measured memory_bytes: 256
"use strict"

function main(input) {
  input = input.split("").map(v => ~~v)
  let ops = [
    ["+", "+", "+"],
    ["+", "+", "-"],
    ["+", "-", "-"],
    ["-", "-", "+"],
    ["-", "+", "-"],
    ["+", "-", "+"],
    ["-", "+", "+"],
    ["-", "-", "-"]
  ]
  // console.log(input)
  for (let i = 0; i < ops.length; i++) {
    let tmp = input[0]
    tmp += ops[i][0] == "+" ? input[1] : -1 * input[1]
    tmp += ops[i][1] == "+" ? input[2] : -1 * input[2]
    tmp += ops[i][2] == "+" ? input[3] : -1 * input[3]
    if (tmp == 7) {
      console.log(
        input[0] +
          ops[i][0] +
          input[1] +
          ops[i][1] +
          input[2] +
          ops[i][2] +
          input[3] +
          "=7"
      )
      return false
    }
  }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int n;cin>>n;
    vector<int>v(n);
    rep(i,n)cin>>v[i];
    vector<int>dp(n);
    rep(i,n){
        if(i==0)dp[i]=abs(0-v[i]);
        else dp[i]=abs(v[i-1]-v[i])+dp[i-1];
    }
    rep(i,n){
        int ans=0;
        if(i==n-1){
            ans+=dp[n-2]+abs(v[n-2]);
        }else if(i==0){
            ans+=dp[n-1]-dp[1]+abs(v[n-1])+abs(v[1]);
        }else{
            ans+=dp[i-1]+dp[n-1]-dp[i+1]+abs(v[i+1]-v[i-1])+abs(v[n-1]);
        }
        
        cout<<ans<<endl;
    }
}


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

using namespace std;

const int MAXN = 1e3 + 5, MOD = 1e9 + 7;
int H, W;
char grid[MAXN][MAXN];
int dp[MAXN][MAXN];

int calcDp(int r, int c) {
    if (r < 0 || c < 0 || grid[r][c] == '#')
        return 0;
    if (dp[r][c] != -1)
        return dp[r][c];
    if (r == 0 && c == 0)
        dp[r][c] = 1;
    else
        dp[r][c] = (calcDp(r - 1, c) + calcDp(r, c - 1)) % MOD;
    return dp[r][c];
}

signed main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++) {
            cin >> grid[i][j];
            // dp[i][j] = -1;
        }

    dp[0][0] = 1;
    for (int r = 0; r < MAXN; r++)
        for (int c = 0; c < MAXN; c++) {
            if (grid[r][c] == '#')
                continue;
            if (r > 0)
                dp[r][c] += dp[r - 1][c];
            if (c > 0)
                dp[r][c] += dp[r][c - 1];
            dp[r][c] %= MOD;
        }
    cout << dp[H - 1][W - 1] << endl;
}
// cout << calcDp(H - 1, W - 1) << endl;

Measured memory_bytes: 5248
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;

// to container
template <class C>
void input(C &c)
{
    for_each(c.begin(), c.end(), [](auto &i) { cin >> i; });
}

// to number, string
template <class T>
T input()
{
    T data;
    cin >> data;
    return data;
}

int main()
{
    int N;
    cin >> N;

    bool res = false;
    for (int i = 1; i <= 9; i++)
    {
        for (int j = 1; j <= 9; j++)
        {
            if (i * j == N)
            {
                res = true;
                break;
            }
        }
    }

    cout << (res ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const double eps = 1e-8;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
	ll H, W, N;
	cin >> W >> H >> N;
	vector<set<ll>> sets(H);
	for (int i = 0;i < N;i++) {
		ll x, y;
		cin >> x >> y;
		x--;
		y--;
		sets[y].insert(x);
	}
	for (int y = 0;y < H;y++)
		sets[y].insert(W);
	ll answer = INF;
	ll y = 0;
	ll x = 0;
	while (true) {
		if (sets[y].lower_bound(x) == sets[y].end())
			break;
		ll near = *sets[y].lower_bound(x);
		answer = min(answer, near);
		x++;
		if (x >= W)
			break;
		if (sets[y].find(x) != sets[y].end())
			break;
		if (y >= H - 1)
			break;
		if (sets[y + 1].find(x) == sets[y + 1].end())
			y++;
		if (y >= H || x >= W)
			break;
	}
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int i = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int i = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int i = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).begin(),(v).end(),greater<>()
#define debug(x) cerr << #x << ':' << x << '\n'
#define Pi 3.1415926535
#define MOD 1000000007
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}
void yes(){cout << "Yes" << '\n';}
void no(){cout << "No" << '\n';}

int solve(){
    ll x, k, d; cin >> x >> k >> d;
    x = abs(x);
    if(x/d>=k){
        cout << x-k*d << endl;
        return 0;
    }

    k -= x/d;
    //x -= (x/d)*d;
    x = x%d;

    if(k%2 == 0) cout << x << endl;
    else cout << d-x << endl;

    return 0;
}

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


Measured memory_bytes: 3652