akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

const int MOD1=1000000007;
const int MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const int dx[]={0,1,0,-1,1,-1,1,-1};
const int dy[]={1,0,-1,0,1,1,-1,-1};

#define lint boost::multiprecision::cpp_int;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<long long,long long>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define eb emplace_back

#define unless(a) if(!(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(n);i++)
#define bitrep(i,s,n) for(int i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}
long long cutup(long long a,long long b){return (a+b-1)/b;}
long long popcnt(long long a){return __builtin_popcountll(a);}
template<class T,class U> inline bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template<class T,class U> inline bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}

template<typename t>
constexpr t mpow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
    }
    return x;
}

template<typename t>
constexpr t nCr(t n,int r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(int i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b;
    cin>>a>>b;
    if(a>b)cout<<a-1<<endl;
    else cout<<a<<endl;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
typedef long long ll;

int main() {
    ll a, b, x;
    cin >> a >> b >> x;
    if(a == 0LL) {
        cout << b / x + 1 << endl;
    } else {
        cout << b / x - (a - 1LL) / x << endl;
    }
    return 0;
}

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

int main() {
    int n;
    int result = 0;
    int current, next;

    cin >> n;

    for (int i = 0; ; i ++) {
        current = ((i > 0) ? (current * 10) : 1);
        next = current * 10;

        if ((current <= n) && (next > n)) {
            if ((i % 2) == 0) {
                result += n - current + 1;
            }

            break;
        }

        if ((i % 2) == 0) {
            result += next - current;
        }
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = map(int, readline().split())
    x = list(map(int, readline().split()))
    y = list(map(int, readline().split()))

    s = 0

    for i in range(1, m):
        s += i * (m - i) * (y[i] - y[i - 1])
        s %= MOD

    ans = 0

    for i in range(1, n):
        t = s * (x[i] - x[i - 1])
        t %= MOD
        t *= i * (n - i)
        t %= MOD
        ans += t
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()


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

int main(){

    string s;
    vector<int> ans(26);
    while(getline(cin, s)){
        for(auto c : s){
            if('A' <= c && c <= 'Z'){
                c = (char) (c + 0x20);
            }
            if('a' <= c && c <= 'z'){
                ans[c - 'a']++;
            }
        }
    }


    for(int i = 0; i < 26; ++i){
        cout << (char) ('a' + i) << " : " << ans[i] << endl;
    }

    return 0;
}


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

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

    int A[N];
    rep(i,N){
        cin >> A[i];
    }

    int B[N]={0};
    rep(i,N){
        B[A[i]-1] = i+1;
    }

    rep(i,N){
        printf("%d ",B[i]);
    }
    printf("\n");

    return 0;
}

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

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<int>> V0(H, vector<int>(W, 0));
  char D;
  char B = '#';
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> D;
      if (D == B) {
        V0.at(i).at(j) = 1;
      }
      else {
        V0.at(i).at(j) = 0;
      }
    }
  }

  int C = 0;
  
  for (int i = 0; i < pow(2, H + W); i++) {
    vector<vector<int>> V = V0;
    int I = i;
    vector<int> E(H + W, 1);
    for (int j = H + W - 1; j >= 0; j--) {
      int p = pow(2, j);
      if (I >= p) {
        I -= p;
        E.at(j) = 0;
      }
    }
    
    /*
    for (int ll = 0; ll < H + W; ll++) {
      cout << E.at(ll) << " ";
    }
    cout << endl;
    */
    
    for (int k = 0; k < H + W; k++) {
      if (E.at(k) == 1) {continue;}
      if (k < H) {
        for (int l = 0; l < W; l++) {
          V.at(k).at(l) *= 0;
        }
      }
      else {
        for (int l = 0; l < H; l++) {
          V.at(l).at(k - H) *= 0;
        }
      }
    }
  
    int sum = 0;
    for (int k = 0; k < H; k++) {
      for (int j = 0; j < W; j++) {
        sum += V.at(k).at(j);
      }
    }
    //cout << sum << endl;
    if (sum == K) {
      C++;
    }
  }
  cout << C << endl;
}


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

int c, ans;
string a;
int main()
{
	int i;
	cin >> a;
	for (i = 0; i < a.size(); i++) {
		if (a[i] == 'S') c++;
		else ans += (c == 0), c = max(0, c - 1);
	}
    cout << c + ans << endl;
    return 0;
}

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for(int i = m; i < (int)(n); ++i)
#define pb(e) push_back(e)

typedef long long ll;

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

int r, c;
bool memo[20][20][4][16];
string prog[20];

bool dfs(int x, int y, int dir, int mem)
{
    x = (x + c) % c, y = (y + r) % r;
    while(true) {
        if(memo[x][y][dir][mem]) return false;
        memo[x][y][dir][mem] = true;
        switch(prog[y][x]) {
            case '<': dir = 2; break;
            case '>': dir = 0; break;
            case '^': dir = 3; break;
            case 'v': dir = 1; break;
            case '_': dir = (mem == 0 ? 0 : 2); break;
            case '|': dir = (mem == 0 ? 1 : 3); break;
            case '.': break;
            case '+': mem = (mem + 1) & 15; break;
            case '-': mem = (mem - 1) & 15; break;
            case '@': return true;
            case '?':
                rep(i, 4)
                    if(dfs(x+dx[i], y+dy[i], i, mem))
                        return true;
                return false;
            default:  mem = prog[y][x] - '0'; break;
        }
        x = (x + dx[dir] + c) % c;
        y = (y + dy[dir] + r) % r;
    }
}

int main()
{
    cin >> r >> c;
    rep(i, r) cin >> prog[i];
    cout << (dfs(0, 0, 0, 0) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 2748
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
using P = pair<int, int>;
const long long INF = 1LL << 60;

int main(){
  ll N,A,B; cin >> N >> A >> B;
  ll ans,tmp,tmp2;
  if(N%(A+B) > A) tmp = A;
  else tmp = N%(A+B);
  tmp2 = N/(A+B);
  ans = A*tmp2 + tmp;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <iomanip>

typedef long long ll;
typedef long double ld;

using namespace std;
using Graph = vector<vector<ll>>;

#define rep(i, N) for (ll i = 0; i < (ll)(N); ++i)
#define ALL(a) (a).begin(),(a).end()

const ll inf = 1e18+7;
const ll mod = 1e9+7;

ll GetDigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int n;
vector<int> g[1010];
int x[5050];
#define INF 1e9
int dp[1010][2][5050];

int dfs(int now){
  int t=0;
  for(int j=0;j<g[now].size();j++){
    int u=g[now][j];
    int tmp=dfs(u);
    if(tmp<0) return -1;
    fill(dp[now][(t+1)%2],dp[now][(t+1)%2]+5050,INF);

    for(int k=x[now];k>=0;k--){
      /*if(k+x[u]<=x[now]) dp[now][k+x[u]]=min(dp[now][k+x[u]],dp[u][k]+tmp);
      if(k+tmp<=x[now]) dp[now][k+tmp]=min(dp[now][k+tmp],dp[u][k]+x[u]);*/
      if(k+x[u]<=x[now]) dp[now][(t+1)%2][k+x[u]]=min(dp[now][(t+1)%2][k+x[u]],dp[now][t][k]+tmp);
      if(k+tmp<=x[now]) dp[now][(t+1)%2][k+tmp]=min(dp[now][(t+1)%2][k+tmp],dp[now][t][k]+x[u]);
    }

    t^=1;
  }

  int res=INF;
  for(int k=0;k<=x[now];k++){
    res=min(res,dp[now][t][k]);
  }
  if(res==INF) return -1;
  else return res;
}

int main(){
  cin>>n;
  for(int i=1;i<n;i++){
    int p;
    cin>>p;
    p--;
    g[p].push_back(i);
  }
  for(int i=0;i<n;i++){
    cin>>x[i];
  }

  for(int i=0;i<=n;i++){
    dp[i][0][0]=0;
    for(int j=1;j<=5000;j++){
      dp[i][0][j]=INF;
      dp[i][1][j]=INF;
    }
  }
  int ans=dfs(0);
  if(ans<0) cout<<"IMPOSSIBLE"<<endl;
  else cout<<"POSSIBLE"<<endl;

  return 0;
}


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

long long N, A;

int main() {
	cin >> N;
	cin >> A;
	
	long long tmp = N % 500;
	if (tmp <= A) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


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

#define int long long
#define ci(m)     for(int i=0;i<m;i++)
#define cj(m)     for(int j=0;j<m;j++)
#define ck(m)     for(int k=0;k<m;k++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;
vector<int>v[2000];
int dp[2000][2000];
int32_t main() {
    nitin;
    int n,x,y;
    for(auto &a:dp) for(auto &b:a) b=INT_MAX;
    cin>>n>>x>>y;
    --x;
    --y;
    dp[0][0]=0;
    for(int i=1;i<n;i++)
    {
        dp[i][i]=0;
        v[i].push_back(i-1);
        v[i-1].push_back(i);
    }
    v[x].push_back(y);
    v[y].push_back(x);
    for(int i=0;i<n;i++)
    {
        queue<int>q;
        unordered_map<int,int>visited;
        int node=i;
        q.push(node);
        visited[i]=1;
        while(!q.empty())
        {
            int vert=q.front();
            q.pop();
            for(auto c:v[vert])
            {
                if(!visited[c])
                {
                    dp[node][c]=dp[node][vert]+1;
                    q.push(c);
                    visited[c]=1;
                }
            }
        }
    }
    vector<int>cnt(n+1,0);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
            cnt[dp[i][j]]++;
    }
    for(int i=1;i<=n-1;i++)
        cout<<cnt[i]/2<<endl;
    return 0;
}

Measured memory_bytes: 35072
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()

int main(){
	const long mod=1e9+7;
	int N,M;cin>>N>>M;
	int S[N],T[M];
	rep(i,0,N) cin>>S[i];
	rep(i,0,M) cin>>T[i];
	long dp[N][M]={};long sum[N][M]={};long temp=0;
	rep(i,0,M){
		if(S[0]==T[i]){
			dp[0][i]=1;
		}
        temp+=dp[0][i];
		sum[0][i]=temp;
	}temp=0;
	rep(i,0,N){
		if(S[i]==T[0]){
			dp[i][0]=1;
		}
        temp+=dp[i][0];
		sum[i][0]=temp;
	}
	rep(i,1,N){
		rep(j,1,M){
			if(S[i]==T[j]){
				dp[i][j]=sum[i-1][j-1]+1;
			}sum[i][j]=(sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+dp[i][j]+mod)%mod;
		}
	}cout<<(sum[N-1][M-1]+1)%mod<<endl;
}

Measured memory_bytes: 62720
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int arr[105],dp[100005][2],n,k;
int rek(int k1,int x) {
	//if(k1<=10000) cout <<k1<<" "<<x<<" "<<dp[k1][x]<<endl;
	//if(k1==0 or k1<arr[0]) return (1 xor x);
	if(dp[k1][x]!=-1) return dp[k1][x];
	int b1=0;
	for(int i=0;i<n;i++) {
		if(k1>=arr[i] && rek(k1-arr[i],(1 xor x))==x) b1+=1;
	}
	int ret;
	if(b1>0) ret=x;
	else ret=(1 xor x);
	dp[k1][x]=ret;
	return ret;
}
int main()
{
	cin >> n >> k;
	for(int i=0;i<n;i++) {
		cin >> arr[i];
	}
	memset(dp,-1,sizeof(dp));
	if(rek(k,0)==0) cout <<"First";
	else cout <<"Second";
	return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int main() {
	int n,k; long long ans=0;
	string s;
	cin>>k;
	for(int i=1;i<=k;i++){
	    for(int i2=1;i2<=k;i2++){
	        for(int i3=1;i3<=k;i3++){
	            ans+=gcd(i,gcd(i2,i3));
	        }
	    }
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<int, int>
#define vint vector<int>
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;
//const int MOD=998244353;

int main(){
	ll n,p; cin>>n>>p;
	if(n==1){
		co(p);
		return 0;
	}else if(n>40){
		co(1);
		return 0;
	}else{
		ll k=2;
		ll ans=1;
		while(1){
			ll t=1;
			FOR(i,0,n) t*=k;
			if(p%t==0) ans=k;
			if(p<t) break;
			k++;
		}
		co(ans);
	}

}


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

signed main() {
    int N; cin >> N;
    vector<vector<int>> v(N, vector<int>(N));
    int sum = 0;
    rep(i, N) rep(j, N) cin >> v[i][j];
    
    bool ok = true;
    auto vv = v;
    rep(k, N) rep(i, N) rep(j, N) {
        if (i == k || j == k) continue;
        if (v[i][j] > v[i][k] + v[k][j]) ok = false;
        if (v[i][j] == v[i][k] + v[k][j]) vv[i][j] = 0;
    }
    rep(i, N) rep(j, N) sum += vv[i][j];
    
    cout << (!ok ? -1ll : sum/2) << endl;
}

Measured memory_bytes: 1788
N = int(input())

d = {}
for _ in range(N):
    S = input()
    if S in d:
        d[S] += 1
    else:
        d[S] = 1

m = max(d.values())
l = []
for k in d:
    v = d[k]
    if v != m:
        continue
    l.append(k)

for s in sorted(l):
    print(s)


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	bool four = false;
	FOR(i,0,n){
		char s;
		cin >> s;
		if(s == 'Y'){
			four = true;
			break;
		}
	}
	if(four){
		ANS("Four");
	}else{
		ANS("Three");
	}
	return 0;
}


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

string hugo(int i)
{
    if (i == 0)
        return "+";
    else if (i == 1)
        return "-";
    else
        return "*";
}

int calc(int i, int a, int b)
{
    if (i == 0)
        return a + b;
    else if (i == 1)
        return a - b;
    else
        return a * b;
}

bool hoge(int a, int b, int c, int d)
{
    for(int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                int x = calc(i, a, b);
                int y = calc(j, c, d);
                int z = calc(k, x, y);
                if (z == 10) {
                    cout << "(" << a << hugo(i) << b <<")";
                    cout << hugo(k);
                    cout << "(" << c << hugo(j) << d << ")" << endl;
                    return true;
                }
            }
        }
    }
    return false;
}

bool fuge(int a, int b, int c, int d)
{
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                int x = calc(i, a, b);
                int y = calc(j, x, c);
                int z = calc(k, y, d);
                if (z == 10) {
                    cout << "(" << a << hugo(i) << b << ")";
                    cout << hugo(j) << c;
                    cout << hugo(k) << d << endl;
                    return true;
                }
            }
        }
    }
    return false;
}

int main(int argc, char const* argv[])
{
    int a[4];
    while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
        bool flag = false;
        if (accumulate(a, a+4, 0) == 0)
            break;
        for (int i = 0; i < 4 && !flag; ++i) {
            for (int j = 0; j < 4 && !flag; ++j) {
                for (int k = 0; k < 4 && !flag; ++k) {
                    for (int l = 0; l < 4 && !flag; ++l) {
                        if (i == j || i == k || j == k ||
                            i == l || j == l || k == l )
                            continue;
                        if (hoge(a[i], a[j], a[k], a[l]) ||
                            fuge(a[i], a[j], a[k], a[l]) )
                            flag = true;
                    }
                }
            }
        }
        if (!flag)
            cout << 0 << endl;
    }
    return 0;
}



Measured memory_bytes: 3120
#include<stdio.h>
#include<string.h>
int main()
{  int i,l,f=1;
   char s[11],t[12];
   gets(s);
   gets(t);
   l=strlen(s);
   for(i=0;i<l;i++)
   if(s[i]!=t[i]) f=0;
   if(f) printf("Yes");
   else printf("No");
} 

Measured memory_bytes: 1608
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <chrono>

using namespace std;

unsigned int xor32(){
    static unsigned int y = 2463534242;
    y = y ^ (y << 13); y = y ^ (y >> 17);
    return y = y ^ (y << 5);
}

int main(){
    int D; cin >> D;
    vector<int> c(26, 0);
    for(auto& t : c) cin >> t;
    vector s(D, vector(26, 0));
    for(auto& v : s){
        for(auto& t : v) cin >> t;
    }
    vector<int> last(26, 0);
    vector<set<int>> days(26);
    for(int i=0;i<26;i++){
        days[i].insert(0);
        days[i].insert(D+1);
    }
    vector<int> select(D+1, -1);
    long long score = 0;
    for(int i=1;i<=D;i++){
        int t = -1;
        long long best = 0;
        for(int j=0;j<26;j++){
            long long cur = s[i-1][j];
            for(int k=0;k<26;k++){
                if(j==k) continue;
                cur -= c[k] * (i - last[k]);
            }
            if(t == -1 || best < cur){
                t = j;
                best = cur;
            }
        }
        days[t].insert(i);
        select[i] = t;
        last[t] = i;
        score += best;
    }
    const double startTemp = 100;
    const double endTemp = 10;
    auto res = select;
    double bestScore = score;
    auto start = chrono::system_clock::now();
    const double tl = 1900;
    while(true){
        auto cur = chrono::system_clock::now();
        auto time = chrono::duration_cast<chrono::milliseconds>(cur-start).count();
        if(time > tl) break;
        const double temp = time/tl * (endTemp - startTemp) + startTemp;
        for(int i=0;i<100000;i++){
            int d = xor32()%D + 1;
            int q = xor32()%26;
            long long sub = 0;
            sub -= s[d-1][select[d]];
            auto it = days[select[d]].find(d);
            --it;
            auto pre = *it;
            ++it; ++it;
            auto next = *it;
            sub += ((d-pre)*(d-pre-1)/2 + (next-d)*(next-d-1)/2) * c[select[d]];
            sub -= (next-pre)*(next-pre-1)/2 * c[select[d]];
            q = -1;
            long long sub2 = 0;
            int q2 = xor32()%26;
            while(q2 == select[d]) q2 = xor32()%26;
            for(int j=0;j<26;j++){
                if(j == select[d]) continue;
                it = days[j].lower_bound(d);
                next = *it;
                --it;
                pre = *it;
                long long curSub = s[d-1][j];
                curSub -= ((d-pre)*(d-pre-1)/2 + (next-d)*(next-d-1)/2) * c[j];
                curSub += (next-pre)*(next-pre-1)/2 * c[j];
                if(q == -1 || sub2 < curSub){
                    q = j;
                    sub2 = curSub;
                }
            }
            sub += sub2;
            if(sub > 0 || exp(0.01*sub)/temp > rand()%10000000*1e-7){
                days[select[d]].erase(d);
                days[q].insert(d);
                select[d] = q;
                score += sub;
                if(score > bestScore){
                    bestScore = score;
                    res = select;
                }
            }
        }
    }
    for(int i=1;i<=D;i++) cout << res[i]+1 << endl;
}

Measured memory_bytes: 4388
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {

        Action abort = () => { Console.WriteLine(-1); Environment.Exit(0); };

        const int INF = (int)1e9;

        var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];
        var d = Console.ReadLine().Split().Select(int.Parse).ToArray();

        char[] color = Enumerable.Repeat(' ', n).ToArray();
        int[] weights = new int[m];

        var wXorb = 'W' ^ 'B';

        Stack<int> stack = new Stack<int>();

        List<Edge>[] graph = Enumerable.Repeat(0, n).Select(_ => new List<Edge>()).ToArray();
        for (int i = 0; i < m; i++)
        {
            var st = Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToArray();
            var s = st[0];
            var t = st[1];
            graph[st[0]].Add(new Edge() { ID = i, To = st[1] });
            graph[st[1]].Add(new Edge() { ID = i, To = st[0] });

            if (d[s] == d[t])
            {
                if (color[s] == ' ' && color[t] == ' ')
                {
                    color[s] = 'B';
                    color[t] = 'W';
                    stack.Push(s);
                    stack.Push(t);
                }
                else if (color[s] == ' ')
                {
                    color[s] = (char)(color[t] ^ wXorb);
                    stack.Push(s);
                }
                else if (color[t] == ' ')
                {
                    color[t] = (char)(color[s] ^ wXorb);
                    stack.Push(t);
                }
                else { }
                weights[i] = d[s];
            }
        }

        while (stack.Count > 0)
        {
            var elem = stack.Pop();
            var curCost = d[elem];
            foreach (var edge in graph[elem])
            {
                if (weights[edge.ID] != 0) continue;
                if (color[edge.To] != ' ' || d[edge.To] < curCost)
                {
                    weights[edge.ID] = INF;
                    continue;
                }
                weights[edge.ID] = d[edge.To] - curCost;
                color[edge.To] = color[elem];
                stack.Push(edge.To);
            }
        }

        if (color.Any(x => x == ' ') || weights.Any(x => x == 0))
        {
            abort();
        }

        Console.WriteLine(string.Join("", color));
        Console.WriteLine(string.Join("\n", weights));
    }
}

struct Edge
{
    public int ID;
    public int To;
}


Measured memory_bytes: 46768
N = int(input())
h_list = list(map(int,input().split()))

max_cnt = 0
tmp_cnt = 0
for i in range(N-1):
    if h_list[i] < h_list[i+1]:
        if max_cnt < tmp_cnt:
            max_cnt = tmp_cnt
        tmp_cnt = 0
    else:
        tmp_cnt += 1
        
if max_cnt < tmp_cnt:
    max_cnt = tmp_cnt

print(max_cnt)

Measured memory_bytes: 63856
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int ms = 1e3+9;
ll X[ms], Y[ms], Z[ms];


int main(){
	int n,m;
	cin >> n >> m;
	for(int i = 0;i<n;i++) cin >> X[i] >>Y[i] >> Z[i];
	ll ans = 0;
	
	for(int i = -1;i<=1;i+=2){
		for(int j = -1;j<=1;j+=2){
			for(int k =-1;k<=1;k+=2){
				vector<ll> vet;
				
				for(int l = 0;l<n;l++){
					vet.push_back(X[l]*i + Y[l]*j + Z[l]*k);
				}
				sort(vet.rbegin(), vet.rend());
				ll soma =0 ;
				for(int i = 0;i<m;i++){
					soma += vet[i];
				}	
				ans = max(ans, soma);
			}
		}
	}
	cout<<ans;


}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  double kei,kpt;
  int now;
  for(int i = 1;i <= N;i++){
    now = i;
    kpt = 1.0/N;
    while(now < K){
      now = now * 2;
      kpt = 0.5 * kpt;
    }
    kei += kpt;
    //cout << kpt << endl;
  }
  cout << fixed << setprecision(12) << kei << endl;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int n; cin>>n;
    vector<int> A(n+1),B(n);
    rep(i,n+1)cin>>A[i];
    rep(i,n)cin>>B[i];
    ll cnt = 0;
    rep(i,n){
        if(B[i]>=A[i]){
            cnt+=A[i];
            B[i] -= A[i];
            cnt += min(B[i],A[i+1]);
            A[i+1] = max(A[i+1]-B[i],0);
        }
        else cnt += B[i];
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 1152
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
A = [input() for _ in range(H)]

cnt = 0
for a in A:
	cnt += a.count("#")
if cnt == H+W-1:
	print("Possible")
else:
	print("Impossible")


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

void Main()
{
	int N, K; cin >> N >> K;
	string S; cin >> S;
	int s = 0, t = 0;
	int res = 0;
	int zero_sum = 0;
	int sum = 0;
	bool flg = false;
	while (true) {
		while (t < N && zero_sum <= K) {
			if (!flg && S[t] == '0') {
				++zero_sum;
				flg = true;
				if (zero_sum > K) break;
			}
			if (flg && S[t] == '1') flg = false;
			++sum;
			++t;
		}
		res = max(res, sum);
		if (S[s++] == '0' && s < N && S[s] == '1') --zero_sum;
		--sum;
		if (t >= N) break;
	}
	cout << res << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
/********************************************************************************************************************************/
/* main *************************************************************************************************************************/
/********************************************************************************************************************************/
int DEBUG = 0;										/* デバッグプリント 提出時は0 */
int main()
{
	double		a,b,c,i=0,ans=0;

	scanf("%lf", &a);

	if (DEBUG) printf("%lf %f\n",a,M_PI);

	printf("%lf %lf\n",M_PI*a*a, M_PI*2*a);
	
	return 0;
}



Measured memory_bytes: 2040
from sys import stdin
N = int(stdin.readline().rstrip())
data = [int(x) for x in stdin.readline().rstrip().split()]
data = sorted(data)
if len(data) == 1:
    print(data[0])
else:
    while len(data) > 2:
        data.append(((data[0] + data[1]) / 2))
        data = sorted(data)
        data.remove(data[0])
        data.remove(data[1])
    print(sum(data)/2)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#define MOD 1000000007
#define MAX 100005

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit(void) {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
};

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
};

int int_sort( const void * a , const void * b ) {
  return *(long *)a - *(long *)b;
};


int main(void){
    int long long ans=0,cmb;
    int n,k,i;
    int long a[MAX];
    scanf("%d %d",&n,&k);
    for(i=1;i<=n;i++){
        scanf("%ld",&a[i]);
    };
    qsort(&a[1],n,sizeof(long),int_sort);
    /*for(i=1;i<=n;i++){
        printf("%d ",a[i]);
    };*/
    //putchar('\n');
    COMinit();
    for(i=k;i<=n;i++){
        cmb=COM(i-1,k-1);
        ans+=(a[i]*cmb)% MOD;
        ans%=MOD;
        //printf("a[%d]=%d, a[%d]=%d, f=%d, cmb=%lld, ans=%lld\n",i,a[i],j,a[j],f,cmb,ans);
    };
    for(i=1;i<=n-k+1;i++){
        cmb=COM(n-i,k-1);
        ans-=(a[i]*cmb)% MOD;
        ans%=MOD;
    };
    while(ans<0)ans+=MOD;
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 3312
#include<bits/stdc++.h>
#include<iostream>
#include<set>
#define ll long long
using namespace std;
ll a[10000005]={0};
ll b[10000005]={0};
int main(){
    ll t ;
    cin>>t;
    for(ll i=0;i<=t;i++){
        cin >>a[i];
    }
    for(ll i=0;i<t;i++){
        cin >>b[i];
    }
    ll num=0;
    for(ll i=0;i<t;i++)
    {
          if(b[i]>=a[i]){
            b[i]-=a[i];
            num+=a[i];
            if(b[i]>=a[i+1]){
                 num+=a[i+1];
                 a[i+1]=0;
            }
            else {
               // cout<<b[i]<<endl;
                a[i+1] -= b[i];
                num+=b[i];
            }
        }
        else if(b[i]<a[i]){
            num+=b[i];
        }
    }
    cout<<num<<endl;
     return 0;
}


Measured memory_bytes: 3072
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 10000000000000000
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
#define SIZE 1000000
map<int,int> hoge;
int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		hoge[a[i]]++;
	}
	
	sort(all(a));
	int mi=a[0],ma=a[n-1];
	bool flag=false,check=true;
	if(hoge[mi]==1){
		if(mi*2==ma){
			for(int j=mi+1;j<=ma;j++){
				if(hoge[j]<2)check=false;
			}
				flag=check;
		}
	}else if(hoge[mi]==2){
		if(mi*2-1==ma&&mi!=1){
			for(int j=mi+1;j<=ma;j++){
				if(hoge[j]<2)check=false;
			}
			flag=check;
		}
		if(mi==1&&n==2)flag=true;
	}
	if(flag)cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
}

Measured memory_bytes: 256
import sys, os
import bisect

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n,m,x = f()
    a = f()

    idx = bisect.bisect_left(a, x)
    print(min(idx, m - idx))

solve()


Measured memory_bytes: 3060
#include <iostream>

int main(){
	int area;
	int d = 0;
	int sum_area = 0;
	while(std::cin >> d){
		sum_area = 0;
		for(int i = d; i <= 600 - d; i += d){
			area = i * i;
			sum_area += d * area;
		}
		std::cout << sum_area << std::endl;
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int n,t,mmax,mmax1,ans,anss;
int a[100010];
int main()
{
	cin>>n>>t;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=n;i>=1;i--){mmax=max(a[i],mmax);ans=max(mmax-a[i],ans);}
	for(int i=n;i>=1;i--){mmax1=max(a[i],mmax1);if(mmax1-a[i]==ans)anss++;}
	cout<<anss<<endl;
	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

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

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  string S;
  cin >> S;
  ll w;cin >> w;
  for(ll i=0;i<S.size();i+=w){
    cout << S[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>d1(n),d2(n);
  int flag=0;
  for(int i=0;i<n;i++){
    cin>>d1.at(i);
    cin>>d2.at(i);
    if(d1.at(i)==d2.at(i)){
      if(flag!=0)flag++;
      else flag=1;
      if(flag==3){cout<<"Yes"<<endl;return 0;}
    }
    else flag=0;
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    ll n, k;    cin >> n >> k;
    vector<ll> a(n);
    REP(i, n)   cin >> a[i];
    sort(ALL(a));
    ll res=0;
    REP(i, k) res += a[i];
    cout << res << endl;
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<algorithm>


using namespace std;

int main()
{
	char a ,b,c;
	cin >> a >> b ; 

	if (a=='H') {
		if (b == 'H') {
			c = 'H';
		}
		else {
			c = 'D';
		}

	}else {
		if (b == 'H') {
			c = 'D';
		}
		else {
			c = 'H';
		}
	}


	cout << c << endl;
    
	return 0;
}

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

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)
typedef long long ll;

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);
int gcd(int a, int b);

int main() {
    int n;
    string s;
    int k;
    cin >> n >> s >> k;

    char k_c = s[k-1];
    for(int i=0; i<n; i++) {
        if(s[i] != k_c) {
            s[i] = '*';
        }
    }
    cout << s << endl;

    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

int sum_digits(int num) {
    int rtn = 0;
    while(num != 0) {
        int tmp = num % 10; 
        rtn += tmp;
        num /= 10; 
    }   
    return rtn;
}
//int sum_digits(int num) {
//    int rtn = 0;
//    string num_str = to_string(num);
//    for(int i=0; i<num_str.size(); i++) {
//        rtn += num_str[i] - '0';
//    }   
//    return rtn;
//}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}

// ユークリウッドの互除法
int gcd(int a, int b) {
    if(b==0) return a;
    else return gcd(b, a % b);
}



Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
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);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

int digit(int x) {
    int res = 0;
    while (x > 0) {
        res++;
        x /= 10;
    }
    return res;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    int A = sqrt(N);
    while (N % A != 0) {
        A--;
    }
    cout << digit(N / A) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define ll long long
using namespace std;
const int MOD = 1000000007;
const long long INF = 1LL << 60;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  vector<int> start(26, -1);
  vector<int> goal(26, -1);
  for (ll i = 0; i < s.size(); i++) {
    int a = s[i] - 'a';
    int b = t[i] - 'a';
    if (start[a] != -1 || goal[b] != -1) {
      if (start[a] != b || goal[b] != a) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      start[a] = b;
      goal[b] = a;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3808
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


mod = 10**9 + 7


def main():
    L = in_s()
    N = len(L)

    dp1 = [0] * N
    dp2 = [0] * N

    dp1[0] = 2
    dp2[0] = 1

    for i in range(1, N):
        if L[i] == "0":
            dp1[i] = dp1[i - 1]
            dp2[i] = dp2[i - 1] * 3
        else:
            dp1[i] = dp1[i - 1] * 2
            dp2[i] = dp2[i - 1] * 3 + dp1[i - 1]
        dp1[i] %= mod
        dp2[i] %= mod

    ans = dp1[-1] + dp2[-1]
    ans %= mod

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 67772
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS

int main(int argc, char const *argv[])
{
  int str[100] = {'\0'};
  scanf("AtCoder %s Contest",str);
  printf("A%cC",str[0]);
  return 0;
}


Measured memory_bytes: 128
#include<algorithm>
#include<cmath>
#include<climits>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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 pair<int, int> P;

int N, M;
vector<int> d;
vector<int> prevv;

vector<vector<int>> G;

void dijkstra(int s)
{
	priority_queue<P, vector<P>, greater<P>> q;

	d.resize(N, 1000000000);
	prevv.resize(N, -1);
	d[s] = 0;
	q.emplace(0, s);

	while (!q.empty())
	{
		auto p = q.top(); q.pop();
		int v = p.second;

		if (d[v] < p.first) continue;

		if (v == -1) break;

		for (auto u : G[v])
		{
			if (d[u] > d[v] + 1)
			{
				d[u] = d[v] + 1;
				q.emplace(d[u], u);
				prevv[u] = v;
			}
		}
	}
}

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

	G.resize(N, vector<int>());

	rep(i, M)
	{
		int a, b;
		cin >> a >> b;

		--a;
		--b;

		G[a].push_back(b);
		G[b].push_back(a);
	}

	dijkstra(0);

	bool flg = true;

	repl(i, 1, N)
	{
		if (prevv[i] == -1)
		{
			flg = false;
			break;
		}
	}


	if (flg)
	{
		cout << "Yes" << endl;

		repl(i, 1, N)
		{
			cout << prevv[i] + 1 << endl;
		}
	}
	else
	{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 11172
#include<bits/stdc++.h>
using ll = long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTIONS ......................*/



/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__

	int N;
	cin>>N;
	VI A(N+1,0);
	FOR(i,1,N)cin>>A[i];
	A.PB(0);
	
	int sum=0;
	REP(i,N+1) sum+=abs(A[i+1]-A[i]);


	FOR(i,1,N){
		int ans=sum-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]);
		cout<<ans<<endl;
	}



	return 0;
}


Measured memory_bytes: 3976