akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; ++i) {
        cin >> s[i];
    }
    vector<vector<int>> flip(h, vector<int>(w, 1000000));
    flip[0][0] = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (i != h - 1) {
                if (s[i + 1][j] != s[i][j])
                    chmin(flip[i + 1][j], flip[i][j] + 1);
                else
                    chmin(flip[i + 1][j], flip[i][j]);
            }
            if (j != w - 1) {
                if (s[i][j + 1] != s[i][j])
                    chmin(flip[i][j + 1], flip[i][j] + 1);
                else
                    chmin(flip[i][j + 1], flip[i][j]);
            }
        }
    }
    int ret = flip[h - 1][w - 1];
    if (s[0][0] != s[h - 1][w - 1])
        ret++;
    else if (s[0][0] == '#' && s[h - 1][w - 1] == '#')
        ret += 2;
    cout << ret / 2 << "\n";
    return 0;
}

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

using ll = long long int;

const int MAX_N = (int)(1e5 + 5);

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


int n;
ll x;

ll ans;

int main(void){
  scanf("%d %lld", &n, &x);
  for (int i = 0; i < n; ++i) {
    ll tmp;
    scanf("%lld", &tmp);
    ans = gcd(ans, abs(x - tmp));
  }

  printf("%lld\n", ans);

  return 0;
}

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

using namespace std;

int main()
{
    int t;
    int n;
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int l = a+b;
    int r = c+d;
    if (l > r)
        cout << "Left\n";
    else if (l < r)
        cout << "Right\n";
    else
        cout << "Balanced\n";
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))

MOD = 10 ** 9 + 7
ans = 1

#全部取る
if n == k:
    for x in a:
        ans *= x
        ans %= MOD
    print(ans % MOD)

#全部負かつ奇数個取る
elif max(a) < 0 and k % 2:
    a.sort()
    for i in range(1, k+1):
        ans *= a[-i]
        ans %= MOD
    print(ans % MOD)

else:
    pos = []
    neg = []
    
    for x in a:
        if x >= 0:
            pos.append(x)
        else:
            neg.append(x)
    
    pos.sort(reverse=True)
    neg.sort()
    
    
    if k % 2:
        ans *= pos.pop(0)
        k -= 1
     
    #2個ずつ取る
    num = []
    for x, y in zip(pos[::2], pos[1::2]):
        num.append(x * y)
    for x, y in zip(neg[::2], neg[1::2]):
        num.append(x * y)

    num.sort(reverse=True)

    for i in range(k // 2):
        ans *= num[i]
        ans %= MOD
    
    print(ans % MOD)
    

Measured memory_bytes: 32056
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> NP;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main() {
	int H, W; cin >> H >> W;
	string c[50];
	for (int i = 0; i < H; i++)
		cin >> c[i];

	// count #
	int black = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (c[i][j] == '#') black++;
		}
	}

	// set start
	queue<NP> Q;
	Q.push(NP(P(0, 0), 0));

	// bfs
	int white = 0;
	bool is_goal = false;
	while (!Q.empty()) {
		int y = Q.front().first.first;
		int x = Q.front().first.second;
		int lv = Q.front().second;
		Q.pop();

		for (int i = 0; i < 4; i++) {
			int ny = y + dy[i];
			int nx = x + dx[i];
			if (ny < 0 || H <= ny || nx < 0 || W <= nx) continue;
			if (ny == H - 1 && nx == W - 1) {
				white = lv + 2;
				is_goal = true;
				break;
			}
			if (c[ny][nx] == '.') {
				Q.push(NP(P(ny, nx), lv + 1));
				c[ny][nx] = 'V';
			}
		}
		if (is_goal) break;
	}

	int res = H * W - black - white;
	if (!is_goal) res = -1;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[15][15];
pair<int,int> par[15][15];
int sz[15][15];
int now[15][15];
int v[15][15];
int tr,tc;
int H,W;
void dfs0(int a,int b){
	par[a][b]=make_pair(tr,tc);
	sz[tr][tc]++;
	v[a][b]=1;
	if(a&&str[a-1][b]=='X'&&!v[a-1][b])dfs0(a-1,b);
	if(b&&str[a][b-1]=='X'&&!v[a][b-1])dfs0(a,b-1);
	if(a<H-1&&str[a+1][b]=='X'&&!v[a+1][b])dfs0(a+1,b);
	if(b<W-1&&str[a][b+1]=='X'&&!v[a][b+1])dfs0(a,b+1);
}
int res;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int used[15][15];
int gr,gc;
int ABS(int a){return max(a,-a);}
int dfs(int a,int b,int c){
	if(str[a][b]=='G'){
		return 1;
	}
	if(c==0)return 0;
	if(ABS(gr-a)+ABS(gc-b)>c)return 0;
	for(int i=0;i<4;i++){
		int nr=a+dx[i];
		int nc=b+dy[i];
		if(nr<0||nr>=H||nc<0||nc>=W)continue;
		if(used[nr][nc])continue;
		if(str[nr][nc]=='#')continue;
		if(nr&&nc&&used[nr-1][nc-1]&&used[nr-1][nc]&&used[nr][nc-1])continue;
		if(nr&&nc<W-1&&used[nr-1][nc]&&used[nr-1][nc+1]&&used[nr][nc+1])continue;
		if(nr<H-1&&nc&&used[nr][nc-1]&&used[nr+1][nc]&&used[nr+1][nc-1])continue;
		if(nr<H-1&&nc<W-1&&used[nr][nc+1]&&used[nr+1][nc]&&used[nr+1][nc+1])continue;
		if(str[nr][nc]=='X'){
			int row=par[nr][nc].first;
			int col=par[nr][nc].second;
			if((now[row][col]+1)*2>sz[row][col])continue;
			now[row][col]++;
			used[nr][nc]=1;
			if(dfs(nr,nc,c-1))return 1;
			used[nr][nc]=0;
			now[row][col]--;
		}else{
			used[nr][nc]=1;
			if(dfs(nr,nc,c-1))return 1;
			used[nr][nc]=0;
		}
	}
	return 0;
}
int main(){
	int a,b;
	while(scanf("%d%d",&b,&a),a){
		H=a;W=b;
		for(int i=0;i<a;i++)scanf("%s",str[i]);
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)v[i][j]=now[i][j]=sz[i][j]=used[i][j]=0;
		for(int i=0;i<a;i++)for(int j=0;j<b;j++){
			if(str[i][j]=='X'&&!v[i][j]){
				tr=i;tc=j;
				dfs0(i,j);
			}
		}
		res=99999;
	//	int ret;
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)if(str[i][j]=='G'){gr=i;gc=j;}
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)if(str[i][j]=='S'){
			for(int k=0;;k++){
				//res=0;
				res=dfs(i,j,k);
				if(res){
					printf("%d\n",k);
					break;
				}
			}
		}
	//	printf("%d\n",res);
	}
}

Measured memory_bytes: 1036
#pragma GCC optimize("O3")

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

# include <stdio.h>
# include <bits/stdc++.h>


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace __gnu_pbds;
using namespace std;
 
typedef
tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s[N];
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;

int main () {
	SpeedForce;
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> s[i];
		sort(every(s[i]));
	} 
	ll ans = 0;
	sort(s + 1, s + n + 1);
	for (int i = 1, j; i <= n; i = j) {
		j = i;
		while (j <= n && s[i]==s[j]) j ++;
		ans += (j - i) * (ll)(j - i - 1) / 2;
	}
	cout << ans;

	return Accepted;
}

// B...a

Measured memory_bytes: 27520
def cmb(n,r,mod):
  if r<0 or r>n:
    return 0
  r=min(r,n-r)
  return g1[n]*g2[r]*g2[n-r]%mod

k=int(input())
s=list(input())
n=len(s)
mod=10**9+7

g1=[1,1]
g2=[1,1]
inverse=[0,1]

for i in range(2,2*10**6+1):
  g1.append((g1[-1]*i)%mod)
  inverse.append((-inverse[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inverse[-1])%mod)

pow25=[1]
for i in range(n+k+1):
  pow25.append((pow25[-1]*25)%mod)

pow26=[1]
for i in range(n+k+1):
  pow26.append((pow26[-1]*26)%mod)

ans=0
for i in range(n,n+k+1):
  ans+=cmb(i-1,n-1,mod)*pow25[i-n]*pow26[n+k-i]
  ans%=mod
print(ans)

Measured memory_bytes: 324056
#include <bits/stdc++.h>
using namespace std;
int zeta(int t){
  if(t<0)t*=-1;
  return t;
}
 
int main() {
  long K,A,B;
  cin>>K>>A>>B;
  
  long count=0;
  if(B-A<2||A>=K){
    count=K+1;
  }
  else{
    long t=K-A+1;
    count=B+(t/2-1)*(B-A)+t%2;
  }
  
  cout<<count<<endl;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pa pair<int,int>
#define ld long double
#define BOOST ios_base::sync_with_stdio(false)
#define pb push_back
#define st first
#define nd second
#define dokladnosc cout<<fixed<<setprecision(10);
using namespace std;
const int MAX=3005;
  ld tab[MAX];
  ld dp[MAX];
int main()
{
    BOOST;
    dokladnosc;
    int n;
    cin>>n;

    for (int i=0;i<n;i++)
    {
        cin>>tab[i];
    }
    dp[0]=1;
    for (int i=0;i<n;i++)
    {
         for (int j=i+1;j>=0;j--)
         {
             if (j==0)dp[j]=dp[j]*((ld)1-tab[i]);
             else dp[j]=dp[j-1]*tab[i]+dp[j]*((ld)1-tab[i]);
         }
    }
    ld wynik=0;
    for (int i=1;i<=n;i++)
    {
        if (i>n-i)wynik+=dp[i];
    }
    cout<<wynik;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	clock_t begin = clock();
	vector<int>v(5);
	for (int i = 0; i < 6; i++) {
		int x;
		cin >> x;
		v[x]++;
	}
	bool ok = false;
	for (int i = 0; i < 5; i++) {
		if (v[i] >= 3) {
			ok = true;
			break;
		}
	}
	if (ok)
		cout << "NO" << endl;
	else
		cout << "YES" << endl;
	clock_t end = clock();
	cerr << "Time run: " << (float)(end - begin) / CLOCKS_PER_SEC << " s" << endl;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
int n,a[10010];
int main(){
    scanf("%d",&n);
    int cnt = 0;
    for(int i=0;i<n;i++){
        int tmp;scanf("%d",&tmp);
        while(1){
            if(tmp%2) break;
            cnt++; tmp /= 2;
        }
    }
    cout<<cnt<<'\n';
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

int n;
signed main(){
  cin>>n;
  int a=abs(n-9);
  if(n>=9){
    if(a%7==0){
      cout<<"sat"<<en;
    }else if(a%7==1){
      cout<<"sun"<<en;
    }else if(a%7==2){
      cout<<"mon"<<en;
    }else if(a%7==3){
      cout<<"tue"<<en;
    }else if(a%7==4){
      cout<<"wed"<<en;
    }else if(a%7==5){
      cout<<"thu"<<en;
    }else{
      cout<<"fri"<<en;
    }
  }else{
    if(a%7==0){
      cout<<"sat"<<en;
    }else if(a%7==6){
      cout<<"sun"<<en;
    }else if(a%7==5){
      cout<<"mon"<<en;
    }else if(a%7==4){
      cout<<"tue"<<en;
    }else if(a%7==3){
      cout<<"wed"<<en;
    }else if(a%7==2){
      cout<<"thu"<<en;
    }else{
      cout<<"fri"<<en;
    }
  }
  RE;
}





Measured memory_bytes: 3104
#include<cstdio>
#include<algorithm>
using namespace std;
#define LL long long
#define maxn 1005
int n,m;
LL a[maxn],b[maxn],c[maxn],d[maxn],w,ans;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)scanf("%lld%lld%lld",a+i,b+i,c+i);
	for(int i=0;i<8;i++){
		for(int j=0;j<n;j++){
			d[j]=((i&1)?1:-1)*a[j]+((i&2)?1:-1)*b[j]+((i&4)?1:-1)*c[j];
		}
		sort(d,d+n);w=0;
		for(int j=0;j<m;j++){
			w-=d[j];
		}
		ans=max(ans,w);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] c = new int[n];
		int[] s = new int[n];
		int[] f = new int[n];
		for (int i = 0; i < n - 1; i++) {
			c[i] = sc.nextInt();
			s[i] = sc.nextInt();
			f[i] = sc.nextInt();
		}
		sc.close();

		for (int i = 0; i < n; i++) {
			int now = s[i] + c[i];
			for (int j = i + 1; j < n - 1; j++) {
				if (now <= s[j]) {
					now = s[j];
				} else {
					int mod = Math.floorMod(now, f[j]);
					if (mod > 0) {
						now += f[j] - mod;
					}
				}
				now += c[j];
			}
			System.out.println(now);
		}
	}
}


Measured memory_bytes: 28224
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;
char a[10][10];
int main() {
    int N,C,K;
    cin>>N>>C>>K;
    vector<int>T(N);
    for(int i=0;i<N;i++){
      cin>>T[i];
    }
    sort(T.begin(),T.end());
    int count=0;
    for(int i=0;i<N;){
      int start=i;
      int sum=0;
      while(i<N&&T[i]-T[start]<=K&&sum<C){i++;sum++;}
      count++;
    }
    cout<<count<<endl;
return 0;}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	long long x,y;
	cin >> x >> y;
	rep(i,2,10000){
		long long a = x * i;
		if(a % y != 0){
			P(a);
			ret 0;
		}
	}
	
	P(-1);

	ret 0;
}

Measured memory_bytes: 256
//#pragma GCC target ("avx2,sse2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <queue>

using namespace std;

const int N = 2e6 + 14;
const int INF = 1e9;
const int mod = 1e9;
const int SZ = (1 << 17) - 1;
const int K = 320;

#define eb emplace_back
#define sz(s) (int)(s.size())
#define ppb pop_back

#define ll long long

#define int ll

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> m >> n;
	int sum = 0;
	while (n--) {
		int x;
		cin >> x;
		sum += x;
	}
	cout << (sum >= m ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, k;
    string s, t, z;
    char c = 'z';
    cin >> n >> k >> s;
    for (int i = 0; i < n; i++) z += 'z';
    for (int i = 0; i < n; i++) c = min(c, s[i]);
    if (k >= 15) {
        for (int i = 0; i < n; i++) cout << c;
        return 0;
    }
    t = s;
    reverse(t.begin(), t.end());
    t = s + t;
    for (int i = 0; i <= n; i++) {
        string u = t.substr(i, n);
        //cout << u << ' ';
        for (int j = 2; j < k; j++) {
            string v = u;
            reverse(v.begin(), v.end());
            v = u + v;
            int d = 0, e = 0, f = 0;
            for (int l = n; l < n + n; l++) {
                if (v[l] == c) d++;
                else d = 0;
                if (d > e) e = d, f = l;
            }
            //cout << f << ' ' << v << '\n';
            if (!f) break;
            u = v.substr(f - n + 1, n);
        }
        //cout << u << '\n';
        if (k > 1) {
            string v = u;
            reverse(v.begin(), v.end());
            v = u + v;
            int d = 0, e = 0, f = -1;
            for (int l = n - 1; l >= 0; l--) {
                if (v[l] == c) d++;
                else d = 0;
                if (d > e) e = d, f = l;
            }
            //cout << f << ' ' << v << '\n';
            if (f != -1) u = v.substr(f, n);
        }
        z = min(z, u);
    }
    cout << z;
}


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

//mod
#define MOD 1000000007

vector<int> stepMemo(110000, -1);
bool isDanger[100100];

int getStep(int x){
    if(stepMemo[x] == -1){
        if(x==1){
            if(isDanger[1]){
                stepMemo[1] = 0;
            }else{
                stepMemo[1] = 1;
            }
        }else if(x==2){
            if(isDanger[2]){
                stepMemo[2] = 0;
            }else{
                stepMemo[2] = stepMemo[1] + 1;
            }
        }else{
            if(isDanger[x]){
                stepMemo[x] = 0;
            }else{
                stepMemo[x] = (stepMemo[x-1] + stepMemo[x-2]) % MOD;
            }
        }
    }
    
    return stepMemo[x];
}

int main(){
    int n, m;
    cin >> n >> m;
    for(int i=0; i<100100; i++){
        isDanger[i] = false;
    }
    for(int i=0; i<m; i++){
        int a;
        cin >> a;
        isDanger[a] = true;
    }
  for(int i=1; i<=n; i++){
    int aaa = getStep(i) % MOD;
  }
  cout << getStep(n) % MOD << endl;
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
using namespace std;
int main()
{
  int n;
  while(cin >> n){
    if(n == 0) break;
    int ret = 0;
    while(n != 1){
      if(n % 3 == 0){
        n /= 3;
      }else{
        n /= 3;
        n++;
      }
      ret++;
    }
    cout << ret << endl;
  }
  return 0;
}

Measured memory_bytes: 1164
//Littleboy123 Template 1.2

#include <bits/stdc++.h>
using namespace std;

//pragmas
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define FOR(a,b,c) for(ll (a)=(b);(a)<(c);++(a))
#define FORE(a,b,c) for(ll (a)=(b);(a)<=(c);++(a))
#define FORN(a,b,c) for(ll (a)=(b);(a)>(c);--(a))
#define FORNE(a,b,c) for(ll (a)=(b);(a)>=(c);--(a))
#define COUT(a) cout << (a) << '\n'
#define MEM(a,b) memset((a), (b), sizeof((a)))
#define MAX(a,b) (a) = max((a), (b))
#define MIN(a,b) (a) = min((a), (b))
#define nl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)

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

void infile(){
	ifstream in("input.in");
	streambuf *cinbuf = std::cin.rdbuf();
	cin.rdbuf(in.rdbuf());
}

void outfile(){
	ofstream out("out.txt");
	streambuf *coutbuf = std::cout.rdbuf();
	cout.rdbuf(out.rdbuf());
}

//End of template

int main(){
	init();
	//infile();
	//outfile();
	
	int n;
	cin >> n;
	int arr[n];
	FOR(i, 0, n){
		cin >> arr[i];
	}
	int len = 0;
	int cnt = 0;
	for(int i = 1; i < n; i++){
		if(arr[i] <= arr[i-1]){
			cnt++;
		}
		else{
			cnt = 0;
		}
		len = max(len, cnt);
	}
	len = max(len, cnt);
	cout << len << nl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll gcd(ll x, ll y) { return (y ? gcd(y, x % y) : x); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main() {
	init();

	int N, K; cin >> N >> K;
	vector<ll>vec(N);
	rep(i, 0, N) {
		cin >> vec[i];
		if (K == vec[i]) {
			cout << "POSSIBLE" << "\n";
			return 0;
		}
	}
	int g = vec[0];
	rep(i, 0, N) {
		g = gcd(g, vec[i]);
	}
	rep(i, 0, N) {
		if (vec[i] > K && (vec[i] - K) % g == 0) {
			cout << "POSSIBLE" << "\n";
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << "\n";


	return 0;
}

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

int main() {
  unsigned H, W;
  std::cin >> H >> W;
  std::vector<std::vector<char>> a(H, std::vector<char>(W));
  for (unsigned i = 0; i < H; ++i) {
    for (unsigned j = 0; j < W; ++j) {
      std::cin >> a[i][j];
    }
  }
  std::vector<unsigned> max(H, 0);
  std::vector<unsigned> min(H, UINT32_MAX);
  for (unsigned i = 0; i < H; ++i) {
    for (unsigned j = 0; j < W; ++j) {
      if (a[i][j] == '#') {
        max[i] = j;
        if (min[i] > j) {
          min[i] = j;
        }
      }
    }
  }
  for (unsigned i = 0; i < H - 1; ++i) {
    if (max[i] != min[i + 1]) {
      std::cout << "Impossible";
      return 0;
    }
  }
  std::cout << "Possible";
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
void shuffle(string& s, int h) {
    string t = s.substr(0, h);
    s.erase(0, h);
    s.append(t);
}
int main() {
    string s;
    int m, h;
    while(true) {
        cin >> s;
        if(s == "-") break;
        cin >> m;
        for(int i = 0; i < m; ++i) {
            cin >> h;
            shuffle(s, h);
        }
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <string>

using namespace std;

int main() {
	string S;
	cin >> S;
	int N = S.size();
	int ans = 0;
	for (int i = 0; i < N / 2 - 1; i++) {
		string str = S.substr(0, i + 1);
		str += str;
		if (S.find(str) != string::npos) {
			ans = (i + 1)*2;
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
int n;
cin >> n;
if(n>=195) cout << 5 << endl;
else if(n>=189) cout << 4 << endl;
else if(n>=165) cout << 3 << endl;
else if(n>=135) cout << 2 << endl;
else if(n>=105) cout << 1 << endl;
else cout << 0 << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
a = []
for _ in range(N):
  x, y = map(int, input().split())
  a.append((x, y))
a.sort(reverse = True)
res = 0
while True:
  x, y = a.pop()
  if M <= y:
    res += x * M
    break
  else:
    res += x * y
    M -= y
print(res)

Measured memory_bytes: 48732
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  sort(L.begin(), L.end());
  reverse(L.begin(), L.end());
  int ans = 0;
  for (int i = 0; i < N - 2; i++) {
    for (int j = i + 1; j < N - 1; j++) {
      for (int k = j + 1; k < N; k++) {
        if (L.at(i) < L.at(j) + L.at(k)) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
N,K = map(int,input().split())
A = list(map(int,input().split()))

def f(x):
    ret = 0
    for i in range(N):
        ret += A[i] ^ x
    return ret

###2**(num-1)<=K<2**numなるnumを求める
P = bin(K)
num = len(list(map(int,P[2:])))

best = 0

for i in range(num):
    count = 0###2**iの位が1になるAの個数
    for j in range(N):
        if A[j] > A[j]^(2**i):
            count += 1
    
    if count <= N - count:
        best += 2**i

#print(best)
can = [0]*40

for i in range(40):
    if K & 2**i == 0:
        continue
    for j in range(0,i):
        can[i] += best & 2**j
    for j in range(i+1,40):
        can[i] += K & 2**j

can.append(K)

print(max(list(map(f,can))))

Measured memory_bytes: 69264
/*
 *Author - Abhas Jain
 */
 
#include <bits/stdc++.h>
 
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define endl '\n'
#define pb push_back
 
 
typedef long long ll;
typedef long double ld;
 
using namespace std;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
 
const ld PI = 3.141592653589793;
const ll INF = 9223372036854775807ll;
const ll mod = 1e9 + 7;
 
void solve() 
{
    int n;
    cin >> n;
    vector<int> orig(n), srt(n);
    for (int i = 0; i < n; ++i) {
    	cin >> orig[i];
    	srt[i] = orig[i];
    }
    sort(all(srt));
    if (orig == srt) {
    	cout << "YES" << endl;
    }	else {
    	for (int i = 0; i < n; ++i) {
    		for (int j = i + 1; j < n; ++j) {
    			vector<int> temp = orig;
    			swap(temp[i], temp[j]);
    			if (temp == srt) {
    				cout << "YES" << endl;
    				exit(0);
    			}
    		}
    	}
    	cout << "NO" << endl;
    }
}
 
int main( )
{   
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const ll INF=1e18L+5;
const ll maxi=200000;
vector<ll>wt;
vector<ll>val;


int main(){
    ll n,w;
    cin>>n>>w;
    vector<ll> dp(maxi+1,INF);
    dp[0] = 0;
    for(ll i = 0; i < n; i++){
        ll we,va;
        scanf("%lld%lld",&we,&va);

        for(ll x = maxi - va; x >= 0; x--){
            dp[x+va] = min(dp[x+va],dp[x] + we);

        }
    }
    ll answer = 0;
    for(ll i = 0; i <= maxi; i++){

        if(dp[i] <= w)
            answer = i;
    }
    printf("%lld",answer);
    return 0;
}


Measured memory_bytes: 1792
from math import factorial

N,M=list(map(int, input().split()))
C=10**9+7
def factorization(n):
    if n==1:
        return [[1,1]]
    temp=n
    ans=[]
    for i in range(2, int(n**0.5+1.01)):
        if temp % i ==0:
            ct=0
            while temp % i == 0:
                temp //= i
                ct += 1
            ans.append([i, ct])
    if temp != 1:
        ans.append([temp, 1])
    return ans

L=factorization(M)
# print(L)
# n種類のモノから重複を許してk個選ぶ重複組合せは
# モノk個と仕切りn-1個の順列だから
# (n+k-1)!/k!(n-1)!

ans=1
for i in L:
    if i[0]!=1:
        tmp=(factorial(i[1]+N-1) // (factorial(i[1])*factorial(N-1)))
        # print(tmp)
        ans*=tmp
        ans%=C
print(ans)

Measured memory_bytes: 135460
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;

int main() {
    int n, m; cin >> n >> m;
    vector<bool> broken(n, false);
    for (int i=0; i<m; ++i) {
        int num; cin >> num;
        broken[num] = true;
    }
    vector<long long> dp(n + 10, 0);
    dp[0] = 1;
    for (int i=0; i<n; ++i) {
        if (!broken[i+1]) {
            dp[i+1] += dp[i];
            dp[i+1] %= mod;
        }
        if (!broken[i+2]) {
            dp[i+2] += dp[i];
            dp[i+2] %= mod;
        }
    }
    cout << dp[n]%mod << endl;
}

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

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;

const int N = 1e5 + 10;
int a[N];

int main() {
  #ifdef LOCAL
  freopen("in", "r", stdin);
  #endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin >> n;
  if (n == 1) cout << 0;
  else {
    ll ans = n * (n - 1) / 2;
    cout << ans;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, A, B; 
  cin >> N >> A >> B;

  if(abs(A-B)%2 == 0){
    cout << abs(A-B)/2 << "\n";
    return 0;
  }

  cout << min(min(A, B)-1, N-max(A, B))+(abs(A-B)+1)/2 << "\n";

  return 0;
}

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

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

using namespace std;

const int INF=1<<29;

int main(){
	int n; scanf("%d",&n);
	vector<int> v(n),w(n);
	rep(i,n) scanf("%d%d",&v[i],&w[i]);

	vector<vector<int>> dp(min(1<<9,n),vector<int>(100001,-INF));
	rep(i,min(1<<9,n)){
		if(i==0){
			dp[i][0]=0;
		}
		else{
			dp[i]=dp[(i-1)/2];
		}
		for(int a=100000;a>=w[i];a--) dp[i][a]=max(dp[i][a],dp[i][a-w[i]]+v[i]);
		rep(a,100000) dp[i][a+1]=max(dp[i][a+1],dp[i][a]);
	}

	int q; scanf("%d",&q);
	rep(_,q){
		int u,W; scanf("%d%d",&u,&W); u--;

		vector<int> V;
		while(u>=min(1<<9,n)){
			V.emplace_back(u);
			u=(u-1)/2;
		}

		int ans=0;
		int m=V.size();
		rep(S,1<<m){
			int wsum=0,vsum=0;
			rep(i,m) if(S>>i&1) {
				wsum+=w[V[i]];
				vsum+=v[V[i]];
			}
			if(wsum>W) continue;

			ans=max(ans,dp[u][W-wsum]+vsum);
		}
		printf("%d\n",ans);
	}

	return 0;
}


Measured memory_bytes: 206544
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define int long long
int n,l,r,a[100001],b[100001];
main(){
  cin>>n;
  r(i,n)cin>>a[n-1-i]>>b[n-1-i];
  int c=0,ans=0;
  r(i,n){
    if((a[i]+c)%b[i]!=0)c+=b[i]-(a[i]+c)%b[i];
  }
  cout<<c<<endl;
}

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

typedef vector <long long> vi;
typedef vector <vi> vvi;
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define ll long long

int main(void)
{
    ll n, k;
    cin >> n >> k;

    ll h[n];
    for (int i = 0; i < n; i++)
        cin >> h[i];
    
    ll dp[n];
    dp[0] = 0;

    for (ll i = 1; i < n; i++)
    {
        dp[i] = LLONG_MAX;
        ll limit = min(k , i);
        for (int j = 1; j <= limit; j++)
            dp[i] = min(dp[i], dp[i - j] + llabs(h[i] - h[i - j]));
    }

    cout << dp[n - 1] << "\n";
}


Measured memory_bytes: 1792
s = str(input())
a,b,c = 0,0,0

for i in s:
    if i == "a":
        a += 1
    if i == "b":
        b += 1
    if i == "c":
        c += 1

if a == 1 and b == 1 and c == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
use proconio::{fastout, input};
use std::collections::VecDeque;

#[derive(Debug, Clone, Default)]
struct Cell {
    wait: usize,
    cost: usize,
    neighbors: Vec<usize>,
}

#[fastout]
fn main() {
    input! {in_n: usize};
    input! {in_ps: [usize; in_n * in_n]};

    let width = in_n + 2;
    let height = in_n + 2;
    let mut cells = Vec::new();

    for i in 0..(width * height) {
        let x = i % width;
        let y = i / width;
        let mut cell = Cell::default();

        if 0 < x && x < width - 1 && 0 < y && y < height - 1 {
            cell.wait = 1;
            cell.cost = *[x, width - x - 1, y, height - y - 1].iter().min().unwrap();
            cell.neighbors.push(i + 1);
            cell.neighbors.push(i - 1);
            cell.neighbors.push(i + width);
            cell.neighbors.push(i - width);
        }

        cells.push(cell);
    }

    let mut cost = 0;

    for in_p in in_ps {
        let x = (in_p - 1) % in_n + 1;
        let y = (in_p - 1) / in_n + 1;
        let i = x + y * width;

        cells[i].cost -= 1;
        cells[i].wait = 0;
        cost += cells[i].cost;

        let mut queue = VecDeque::new();

        queue.push_front(i);

        while !queue.is_empty() {
            let i = queue.pop_back().unwrap();

            for n in cells[i].neighbors.clone().iter() {
                let c = cells[i].cost + cells[*n].wait;

                if cells[*n].cost > c {
                    cells[*n].cost = c;
                    queue.push_front(*n);
                }
            }
        }
    }

    println!("{}", cost);
}


Measured memory_bytes: 27192
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
readString = map BS.unpack . BS.words

getIntList = readIntList <$> BS.getLine
getNString n = map readString <$> replicateM n BS.getLine

display (cs : css) = do
  putStrLn $cs
  putStrLn $cs
  when (css /= []) $ display css

main = do
  [h, w] <- getIntList
  css <- getNString h
  let css' = map head css
  display css'


Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
const ll maxn = 2e6+100;
const ll mod=1e9+7;

ll gt[maxn];
ll gt1[maxn];
ll tich[maxn];
ll nck(ll n,ll k)
{
    return ((gt[n]*gt1[n-k])%mod*gt1[k])%mod;
}
ll mu(ll a,ll n)
{
    if (n==1) return a;
    if (n==0) return 1;
    ll h=mu(a,n/2);
    if (n%2==0)
    {
        return (h*h)%mod;
    }
    return ((h*h)%mod*a)%mod;

}
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // freopen("test.txt", "r", stdin);
    if (fopen("pump.in","r"))
    {
        freopen("pump.in","r", stdin);
        freopen("pump.out", "w",stdout);
    }
    ll n;
    cin>>n ;
    if (n==1)
    {
        cout <<0;
        return 0;
    }
   ll ans=0;
   tich[0]=1;
   gt[0]=1;
   for (int i=1;i<maxn;i++)
   {
       gt[i]=(gt[i-1]*i)%mod;
   }
   gt1[maxn-1]=mu(gt[maxn-1],mod-2);
   for (int i=maxn-2;i>=0;i--)
   {
       gt1[i]=(gt1[i+1]*(i+1))%mod;
   }
   for (int i=1;i<=n;i++)
   {
       ll cl= n-(2*i);
       if (cl<i) break;
       //cout <<nck(cl-1,i-1)<<endl;
       ans=ans+nck(cl-1,i-1);
       ans%=mod;
   }
   cout <<ans;








}


Measured memory_bytes: 34872
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>

long long gcd(const long long &a, const long long &b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}

int main() {
    int n; long long m; std::cin >> n >> m;
    std::vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        a[i] /= 2;
    }
    long long lcm = 1;
    for (int i = 0; i < n; i++) {
        lcm *= a[i] / gcd(lcm, a[i]);
    }
    bool flag = true;
    for (int i = 0; i < n; i++) {
        flag &= (lcm / a[i]) & 1;
    }
    if (!flag) {
        std::cout << 0 << std::endl;
        return 0;
    }
    std::cout << (m / lcm + 1) / 2 << std::endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <climits>

using namespace std;
#define ll long long
#define ve vector
#define umap unordered_map

int main() {
    int n, a;
    cin>>n>>a;
    ve<int> x(55);
    ve<ve<ll> > dp(55,ve<ll>(5555));
    for(int i=1;i<=n;i++) cin>>x[i];
    dp[0][0]=1;
    int sum=0;
    for(int i=1;i<=n;i++) {
        for(int j=i-1;j>=0;j--) {
            for(int k=sum;k>=0;k--) {
                dp[j+1][k+x[i]] += dp[j][k];
            }
        }
        sum += x[i];
    }
    ll ans=0;
    for(int i=1;i<=n;i++) ans+=dp[i][i*a];
    cout<<ans<<endl;
}

Measured memory_bytes: 2688
N = int(input())
l = [0]*(10**5+1)
A = list(map(int,input().split()))
Q = int(input())
for a in A:
  l[a] += a
suml = sum(l)
for _ in range(Q):
  b,c = map(int,input().split())
  suml += ((l[b]//b)*c - l[b])
  l[c] += (l[b]//b)*c
  l[b] = 0
  print(suml)

Measured memory_bytes: 21656
#include <stdio.h>
#include <string.h>
 
int i,j,k,flag=0,t;
int x[6],y[6],z[6];
 
void input(){
    for(i = 0;i < 6;i++) scanf("%d",&x[i]);
    for(i = 0;i < 6;i++) scanf("%d",&y[i]);
}
 
void N(int w[]){
    t = w[0];
    w[0] = w[1];
    w[1] = w[5];
    w[5] = w[4];
    w[4] = t;
}
  
void S(int w[]){
    t = w[0];
    w[0] = w[4];
    w[4] = w[5];
    w[5] = w[1];
    w[1] = t;
}
  
void W(int w[]){
    t = w[0];
    w[0] = w[2];
    w[2] = w[5];
    w[5] = w[3];
    w[3] = t;
}
  
void E(int w[]){
    t = w[0];
    w[0] = w[3];
    w[3] = w[5];
    w[5] = w[2];
    w[2] = t;
}
 
void turn(int w[]){
    t = w[1];
    w[1] = w[2];
    w[2] = w[4];
    w[4] = w[3];
    w[3] = t;
}
 
int main(void){
    input();
    for(i=0;i<6;i++){
        if(x[0]==y[i]){
            memcpy(z,y,sizeof(int)*6);
            switch(i){
                case 0:
                break;
                case 1:
                N(z);
                break;
                case 2:
                W(z);
                break;
                case 3:
                E(z);
                break;
                case 4:
                S(z);
                break;
                case 5:
                N(z);
                N(z);
                break;
            }
            for(j=0;j<4;j++){
                if(x[0]==z[0] && x[1]==z[1] && x[2]==z[2] && x[3]==z[3] && x[4]==z[4] && x[5]==z[5]){
                flag=1;
                break;
                }else turn(z);
            }
        }
        if(flag==1) break;
    }
    if(flag==1) printf("Yes\n");
    else printf("No\n");
     
}


Measured memory_bytes: 1804
import math

def calc_digit(data1, data2):
    if(data1 == 0):
        data_size2 = int(len(str(data2)))
        data_size1 = 1
    elif(data2 == 0):
        data_size1 = int(len(str(data2)))
        data_size2 = 1
    else:
        data_size1 = int(len(str(data1)))
        data_size2 = int(len(str(data2)))
    return(data_size1, data_size2)

def two_number_sum(data1, data2):
    result = data1 + data2
    if int(len(str(result))) > 80:
        print("overflow")
    else:
        print(result)

def main():
    a = []
    N = int(input())
    for i in range(N*2):
        a.append(input())
    for i in range(0, N*2):
        if i % 2 == 0:
            continue
        else:
            data1 = int(a[i-1])
            data2 = int(a[i])
            if(data1 == None):
                data1 = 0
            elif(data2 == None):
                data2 = 0
            x, y = calc_digit(data1, data2)
            if(x > 80 or y > 80):
                print("overflow")
                continue
            two_number_sum(data1, data2)

if __name__ == '__main__':
    main()



Measured memory_bytes: 5668
import java.awt.List;
import java.util.*;
public class Main {
	static int modNum = 1000000007;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		long a = sc.nextLong();
		int ans = 0;
		ArrayList<Integer> list = new ArrayList<Integer>();
		
		for(int i=1;i<=a*2;i++){
			int b = sc.nextInt();
			list.add(b);
		}
		Collections.sort(list);

		for(int i = 0;i<list.size();i++){
			if(i%2==0){
				ans += list.get(i);				
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int X,A,B;
    cin >> X>>A>>B;
    cout<<(X-A)%B<<endl;



}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        char[][] map = new char[h][w];
        int[][] dp = new int[h][w];
        for(int i = 0; i < h; i++){
            map[i] = sc.next().toCharArray();
        }
        dp[0][0] = map[0][0] == '#' ? 1 : 0;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                int ic = 1000000;
                int jc = 1000000;
                if(i == 0 && j == 0){
                    continue;
                }
                if(i > 0){
                    ic = dp[i-1][j];
                    if(map[i-1][j] == '.' && map[i][j] == '#'){
                        ic++;
                    }
                }
                if(j > 0){
                    jc = dp[i][j-1];
                    if(map[i][j-1] == '.' && map[i][j] == '#'){
                        jc++;
                    }
                }
                dp[i][j] = Math.min(ic,jc);
            }
        }
        /*
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                System.out.print(dp[i][j]);
            }
            System.out.println();
        }
        */
        System.out.println(dp[h-1][w-1]);
    }
}


Measured memory_bytes: 22996
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  auto n=scanElem;
  writeln(n*800-n/15*200);
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <numeric>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rept(i,k,n) for(long long i = (k); i < (long long)(n); i++)
#define All(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Rsort(v) sort(v.begin(),v.end(),[](auto a, auto b) { return a > b; })
#define Reverse(v) reverse(v.begin(),v.end())
#define MAX 1000000007
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;
typedef tuple<int,int,int> Tii;

template <typename T>
ostream& operator<<(ostream& s, const vector<T> &vec){
    for(int i=0;i<vec.size();i++){
        if(i) s << ',';
        else s << '{';
        s <<setw(2)<< vec[i];
    }
    s << '}' << endl;
    return s;
}


int main(){
    ll s;
    cin>>s;
    ll mod = 1000000007;
    vector<ll> dp(s+1,0);
    ll sum = 0;
    rept(i,3,s+1){
        dp[i]=(dp[i-3]+1+dp[i-1])%mod;
    }
    cout<<((dp[s]+mod)-dp[s-1])%mod<<endl;
    return 0;
}

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

int main() {
int N;
cin >> N;
vector<int> vec(N);
for (int i = 0; i < N; i++) {
   cin >> vec.at(i);
 }

double ans = 0.0;

 for (int i = 0; i < N; i++) {
    ans += 1.0 / vec.at(i); 
  }

cout << 1.0 / ans << endl;

}

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

int lim=1,f[600001],n,nl,top,fin[1000001];
char T[1000001],ope[1000001];
void write(int x){
	if(x>9)write(x/10);
	putchar((x%10)+'0');
}
int main(){
	scanf("%d",&n);
	int v1=1,v2=1;
	for(int i=1;i<=n;i++)lim*=3;
	for(int i=1;i<=(n>>1);i++)v1*=3;
	for(int i=1+(n>>1);i<=n;i++)v2*=3;
	for(int i=0;i<lim;i++)f[i]=f[i/3]*3+(3-i%3)%3;
	scanf("%s",T+1);
	nl=strlen(T+1);
	for(int i=0;i<v1;i++){
		int tem=i;
		top=0;
		for(int j=1;j<=nl;j++)
			if(T[j]=='S'){
				tem=f[tem];
				(ope[top]=='S')?--top:ope[++top]='S';
			}
			else{
				++tem;
				if(tem==v1)ope[++top]='R',tem=0;
			}
		for(int j=0;j<v2;j++){
			int tem2=j;
			for(int k=1;k<=top;k++)
				if(ope[k]=='S')tem2=f[tem2];
				else if(ope[k]=='R')
					if((++tem2)==v2)tem2=0;
			fin[i+j*v1]=tem2*v1+tem;
		}
	}
	for(int i=0;i<lim;i++)write(fin[i]),putchar(' ');
}

Measured memory_bytes: 8376