akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define ff(i, n) for (int i = 1; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;





void solve(){
    int a, b, ans = 0;
    cin>>a>>b;
    int k = __gcd(a,b);
    for(int i =2; i <= sqrt(k); i++){
        if(k%i == 0){
            ans++;
            while(k%i == 0)k /= i;
        }
    }
    if(k >= 2)ans++;
    ans++;
    cout<<ans;
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int n,m;
	cin >> n >> m;
	int a[m];
	for(int i=0; i<m; i++) cin >> a[i];

	ll steps[n+1]={0};
	steps[n]=1;
	int p=m-1;
	for(int i=n-1; i>=0; i--){
		if(p>=0 && i == a[p]){
			p--;
			continue;
		}
		if(i==n-1) steps[i] = steps[i+1];
		else steps[i] = (steps[i+1] + steps[i+2])%1000000007;
	}
	cout << steps[0] << endl;

}


Measured memory_bytes: 1408
for t in range(3):
    intlist = input().split(" ")
    int_list = [int(a) for a in intlist]
    h = int_list[3] - int_list[0]
    m = int_list[4] - int_list[1]
    s = int_list[5] - int_list[2]
    if s < 0:
        m -= 1
        s += 60
    if m < 0:
        h -= 1
        m += 60
    print(str(h) + " " + str(m) + " " + str(s)) 


Measured memory_bytes: 5600
#include<stdio.h> 
int main(){ 
    int H,W,m,n;
     for(;;){
         scanf("%d %d",&H,&W);
         if(H==W && H==0) break;
         for(m=0;m<H;m++){ 
            for(n=0;n<W;n++) printf("#");
             printf("\n");
         }
         printf("\n");
     }
 return 0;
 } 

Measured memory_bytes: 572
n=input()

if n=='SUN':
  print(7)
elif n == 'SAT':
  print(1)
elif n == 'FRI':
  print(2)
elif n == 'THU':
  print(3)
elif n == 'WED':
  print(4)
elif n == 'TUE':
  print(5)
elif n=='MON':
  print(6)#, MON, TUE, WED, THU, FRI, or SAT.

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

inline long long read(){
    long long s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}

int main(){
    int a = read(), b = read(), c = read(), d = read();
    for (int i = 1; i >= 1; i++){
        c -= b;
        if (c <= 0){
            puts("Yes");
            return 0;
        }
        a -= d;
        if (a <= 0){
            puts("No");
            return 0;
        }
    }
    return 0;
}
//g++ B.cpp -o B.exe -lm -Wall

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int N = 52, mod = 1000000007;
int n, f[N][N * 2 + 5], c[N][N];
int main() {
  scanf("%d", &n);
  c[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    c[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
    }
  }
  f[1][N + 0] = 1;
  f[1][N + (-2)] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = -n - 1; j <= n + 1; j++) if (!(j & 1) && f[i][N + j]) {
      for (int k1 = 0; k1 <= n - i; k1++) {
        for (int k2 = 0; k1 + k2 <= n - i; k2++) {
          if (!(k1 + k2) || (j / 2 + k2 - k1) & 1 || k1 + k2 < abs(j / 2)) continue;
          (f[i + k1 + k2][N + j / 2 + k2 - k1] += (long long) f[i][N + j] * c[i + k1 + k2][k2] % mod * c[i + k1][k1] % mod) %= mod;
        }
      }
    }
  }
  printf("%d\n", f[n][N]);
}


Measured memory_bytes: 256
//make sure to make new file!
import java.io.*;
import java.util.*;

public class Main{
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      double n = Double.parseDouble(f.readLine());
      
      out.println(n*2.0*Math.PI);
      
      
      
      
      
      
      
      
      out.close();
   }
   
      
}

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

using namespace std;

int main() {
    long n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    long ans = 0;
    for (long i = 0; i < n; ++i) {
        if (i == 0) {
            if (s[0] == 'R' and s[1] == 'R') {
                ++ans;
            }
            continue;
        }
        if (i == n-1) {
            if (s[n-1] == 'L' and s[n-2] == 'L') {
                ++ans;
            }
            continue;
        }

        if (s[i] == 'R' and s[i+1] == 'R') {
            ++ans;
        }
        if (s[i] == 'L' and s[i-1] == 'L') {
            ++ans;
        }
    }

    ans += 2 * k;
    ans = min(ans, n-1);
    cout << ans << endl;
	return 0;
}

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

using namespace std; 

#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(),vec.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fp(i,a,b,p) for(int i=a;i<b;i+=p)
#define SZ(x) (int)x.size()

typedef  vector<string> vs;
typedef  vector<int> vi;
typedef  vector<long long> vl;	


struct data{
	
	int x,y;
	
	int h;
	
};

int main(){
	
	int n;
	
	cin >> n; 
	vector<data> vd(n);
	
	f(i,0,n){
		cin >> vd[i].x >> vd[i].y >> vd[i].h;
	}
	
	int x , y;
	
	int h;
	
	vector<data> ans(n);
	
	f(i,0,101){
		
		f(j,0,101){
			
			bool ok = true;
			
			f(z,0,n){
				if(vd[z].h){
					x = abs(i-vd[z].x);
					y = abs(j-vd[z].y);
					h = vd[z].h + x + y;
				}
			}
			
			f(z,0,n){
			
				if(max(h- abs(i-vd[z].x) - abs(j-vd[z].y),0)!=vd[z].h) ok = false;
			}
			
			if(ok){
				cout << i << " " << j << " " << h << endl;
				return 0;
			}
			
			
		}
		
	}
			

    return 0;
}


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

using namespace std;

const int MaxN = 5005;
const long long oo = 1e18;

int n;
vector<int> Adj[MaxN];
int a[MaxN];
int s[MaxN];
long long dp0[MaxN][MaxN];
bool dp1[MaxN][MaxN];

void DFS(int u, int Pd)
{
    if (a[u] >= 0)
    {
        dp1[u][1] = true;
    }
    dp0[u][1] = a[u];
    s[u] = 1;
    for (auto v : Adj[u])
    {
        if (v != Pd)
        {
            DFS(v, u);
            s[u] += s[v];
            for (int i = s[u]; i > 0; i--)
            {
                bool flag = false;
                long long Min = oo;
                for (int j = max(1, i - s[u] + s[v]); j <= min(i, s[v]); j++)
                {
                    flag |= (dp1[u][i - j + 1] & dp1[v][j]);
                    Min = min(Min, dp0[u][i - j + 1] + dp0[v][j]);
                    if (dp0[v][j] < 0 || dp1[v][j])
                    {
                        flag |= dp1[u][i - j];
                        Min = min(Min, dp0[u][i - j]);
                    }
                }
                dp1[u][i] = flag;
                dp0[u][i] = Min;
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    int u, v;
    for (int i = 1; i < n; i++)
    {
        cin >> u >> v;
        Adj[u].push_back(v);
        Adj[v].push_back(u);
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= n; j++)
        {
            dp0[i][j] = oo;
            dp1[i][j] = false;
        }
    }
    DFS(1, -1);
    for (int i = 1; i <= n; i++)
    {
        if (dp0[1][i] < 0 || dp1[1][i])
        {
            cout << i - 1;
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 221056
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#include<set>
#define ll long long
using namespace std;


int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
	double mod=1.01;
	ll a=100,x;
	cin>>x;
	ll n=0;
	while(a<x){
		a=(ll)a*mod;n++;
		
	}
	cout<<n;
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;

    vector<int>p(n);
    for (int i=0;i<n;i++) {
        cin>>p[i];
    }

    int count =0;

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

    cout <<count<<endl;
}



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

#define ll long long
#define pb push_back
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    int a[5];
    for(int i = 0; i<5; i++) {
        cin >> a[i];
        if(a[i] == 0) {
            cout << i+1;
            return;
        }
    }
}

int main() {_
    int t = 1;
    //cin >> t;
    // Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    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;
    }
}
ll 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;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int A[N+1],B[N+1],C[N+1];
    REP1(i,N){
        cin>>A[i];
    }
    REP1(i,N){
        cin>>B[i];
    }
    REP1(i,N-1){
        cin>>C[i];
    }
    int ANS=0;
    REP1(i,N){
        ANS+=B[A[i]];
        if(i>1&&A[i]-A[i-1]==1){
            ANS+=C[A[i-1]];
        }
    }
    print(ANS);
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sll set<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
using namespace std;

void solve(){
	string s,t;
	cin>>s>>t;
	int n=s.size();

	int ans=0;
	for(int i=0;i<n;i++)
		if(s[i]!=t[i])
			ans++;

	cout<<ans<<endl;
}
 
int main(){
    IOS;
    int q=1;
    //cin>>q;
    while(q--){
        solve();
    }
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    vector<bool> p(100000, true);
    p[0] = p[1] = false;
    for (int i = 2; i < 100000; ++i)
        if (p[i])
            for (int j = 2 * i; j < 100000; j += i)
                p[j] = false;
    int n;
    cin >> n;
    int il = 0;
    for (int i = 6; il < n; i += 5)
    {
        if (p[i])
        {
            cout << i << " ";
            ++il;
        }
    }
    return 0;
}


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

temp = 1
# for i in range(K):
#     temp *= A[i]
# flag = 1
for i in range(K, N):
    # temp2 = temp
    # temp *= A[i]
    # temp //= A[i-K]
    if A[i] <= A[i-K]:
        print("No")
    else:
        print("Yes")


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

H = list(map(int, input().split()))
flg = False
for i in range(1,N+1):
    if flg:
        tmp = H[-i]-1
    else:
        tmp = H[-i]
    flg = False
    if not i==N:
        if tmp < H[-i-1]:
            if tmp == H[-i-1]-1:
                flg = True
            else:
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 20476
#include<iostream>
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  string s ;
  cin >> s ;
  
  int month = stoi(s.substr(5,2)) ;
  //int day = stoi(s.substr(8,2)) ;
  
  if(month<=4)
    cout << "Heisei" << endl ;
  else 
    cout << "TBD" << endl ;
  
  return 0 ;
}


Measured memory_bytes: 256
def main():
    S = input()
    costA = 0
    costB = 0
    for i in range(len(S)):
        if int(S[i]) != (i % 2):
            costA += 1
        else:
            costB += 1
    print(min(costA, costB))


if __name__ == "__main__":
    main()


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

int main() {
	int n;
	while (std::cin >> n && n) {
		std::vector<int> a;
		int minLength = 10000000;

		//????????????????????\???
		for (int i = 0; i < n; i++) {
			int b;
			std::cin >> b;
			a.push_back(b);
		}

		std::sort(a.begin(), a.end());

		//????°???????????±???????
		for (int i = 0; i < a.size() - 1; i++) {
			minLength = std::min(a[i + 1] - a[i], minLength);
		}

		std::cout << minLength << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
#define rep(i, n)  for (int i = 0; i <  (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ll INF = ll(1e18)+1;

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

    ll result = 0;
    rep(i,5){
        ll xi;
        cin >> xi;
        if(xi == 0){
            result = i+1;
        }
    }
    cout << result;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(void){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n-i;j++){
            if(10000*i+5000*j+1000*(n-i-j)==m){cout<<i<<" "<<j<<" "<<n-i-j<<endl;return 0;}
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    vll a(n);
    REP(i,n) cin >> a[i];
    sort(ALL(a));
    if(k==1LL){
        cout << 0 << endl;
        return 0;
    }
    mint ans = mint(0);
    mint nowc = mint(1);
    ans += mint(a[k-1]);
    for(ll i=k;i<n;i++){
        nowc *= mint(i);
        nowc /= mint(i-k+1);
        ans += (mint(a[i])*nowc);
    }
    //cout << ans.x << endl;
    nowc = mint(1);
    ans -= mint(a[n-k]);
    for(ll i=n-k-1;i>=0;i--){
        nowc *= mint(n-1-i);
        nowc /= mint(n-i-k);
        ans -= (mint(a[i])*nowc);
    }
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

int n,l,q;
int a[100000],d[100000][17];
int main() {
	scanf("%d",&n);
	fup(i,0,n-1,1)scanf("%d",a+i);
	scanf("%d%d",&l,&q);
	int j=n-1;
	fdn(i,n-1,0,1)
	{
		while(a[j]-a[i]>l)j--;
		d[i][0]=j;
	}
	fup(j,0,15,1)
	{
		fup(i,0,n-1,1)
		{
			d[i][j+1]=d[d[i][j]][j];
		}
	}
	while(q--)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		if(x==y)
		{
			puts("0");
			continue;
		}
		if(x>y)swap(x,y);
		int ans=0;
		fdn(i,16,0,1)
		{
			if(d[x][i]<y)
			{
				ans+=(1<<i);
				x=d[x][i];
			}
		}
		printf("%d\n",ans+1);
	}
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll sum = 0;
    rep(i,n){
        sum ^= a[i];
    }
    rep(i,n){
        ll x = sum ^ a[i];
        cout << x << " ";
    }
    cout << endl;
}

Measured memory_bytes: 4760
import numpy as np
import math
A, B, H, M = map(int, input().split())

#K = int(input())
#S = input()

def yogen_teiri(A, B, ang):
    lenAB = np.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(ang)))
    return lenAB

angA = H*30+M*0.5
angB = M*6

if angA > angB:
    angAB = min(angA-angB, 360-(angA-angB))
    lenAB = yogen_teiri(A, B, angAB)
elif angB > angA:
    angAB = min(angB-angA, 360-(angB-angA))
    lenAB = yogen_teiri(A, B, angAB)
else:
    lenAB = np.abs(A-B)

print(lenAB)

Measured memory_bytes: 27188
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n;cin >> n;
	vector<vector<int> >  F(n, vector<int>(10));
	rep(i,n)
		rep(j,10)
		cin >> F[i][j];
	vector<vector<int> >  P(n, vector<int>(11));
	rep(i,n)
		rep(j,11)
		cin >> P[i][j];

	//rep(i,10)cout<<P[1][i];
	int ans=INT_MIN;
	for(int bit = 1;bit <(1<<10);++bit)
	{
		int sum=0;
		rep(j,n)
		{
			int cnt=0;
			for(int i=0;i<10;i++)
			{
				if(bit&(1<<i)&&F[j][i]==1)
				{cnt++;}
			}
			//cout<<cnt<<endl;
			//if(bit==1)cout<<cnt<<':'<<P[j][cnt]<<endl;			
			sum+=P[j][cnt];
		}
		//if(bit==1)cout<<sum<<endl;
		ans=max(ans,sum);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var w string
	var maps map[string]int
	maps = map[string]int{}

	fmt.Scan(&w)

	for _, val := range w {
		if _, flag := maps[string(val)]; flag {
			maps[string(val)]++
		} else if !flag {
			maps[string(val)] = 1
		}
	}
	for _, val := range maps {
		if val%2 == 0 {
			continue
		} else {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;

typedef pair<int, int> P;

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

    string s, t;
    cin >> s >> t;
    vector<int> ss(26), tt(26);

    for (char i : s) ss[i - 'a']++;
    for (char i : t) tt[i - 'a']++;

    sort(all(ss));
    sort(all(tt));

    rep (i, 26) {
        if (ss[i] != tt[i]) {
            print("No");
            return 0;
        }
    }
    print("Yes");

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 916
//
//AtCoder Beginner Contest 070
//C
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    vector<ll> t(n);
    REP(i, n) cin >> t[i];

    ll ans = 1;

    REP(i, n){
        ans = lcm(ans, t[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
 
a = ni()
b = ni()
c = ni()
d = ni()
e = ni()
k = ni()
 
if e-a <= k:
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define N 11116
#define mod 1000000007

int n,k;
vector<int> q;
long long f[N],ans;

long long power(long long x,long long y){
	long long t=1;
	for (;y;x=x*x%mod,y/=2)
		if (y&1) t=t*x%mod;
	return t;
}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();k=read();
	for (int i=1;i*i<=n;i++)
		if (n%i==0){
			q.push_back(i);
			if (i*i!=n) q.push_back(n/i);
		}
	sort(q.begin(),q.end());
	for (int i=0;i<(int)q.size();i++){
		f[i]=power(k,(q[i]+1)/2);
		for (int j=0;j<i;j++)
			if (q[i]%q[j]==0)
			f[i]=(f[i]-f[j])%mod;
		if (q[i]%2)
		ans=(ans+f[i]*q[i])%mod;
		else ans=(ans+f[i]*q[i]/2)%mod;
	}
	printf("%lld\n",(ans+mod)%mod);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;

int main()
{
  int n;
  cin >> n;
  string march = "MARCH";
  string s;
  ll d[5];
  fill(d, d + 5, 0);
  REP(i, n) {
    cin >> s;
    REP(k, 5) {
      if (s[0] == march[k]) {
        d[k]++;
        break;
      }
    }
  }
  ll ans = 0LL;
  REP(i, 3) {
    FOR(k, i + 1, 4) {
      FOR(m, k + 1, 5) {
        ans += d[i] * d[k] * d[m];
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, int> PP;

const ll MOD = 998244353;

ll x[200004];
ll y[200004];
P p[200004];
PP pp[200004];
ll c[200004][4];

ll modpow(ll x, ll n){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

template<typename Monoid>
struct SegmentTree {
    using F = function<Monoid(Monoid, Monoid)>;

    int sz;
    vector<Monoid> seg;

    const F f;
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
        sz = 1;
        while(sz < n) sz <<= 1;
        seg.assign(2 * sz, M1);
    }

    void set(int k, const Monoid &x) {
        seg[k + sz] = x;
    }

    void build() {
        for(int k = sz - 1; k > 0; k--) {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }

    void update(int k, const Monoid &x) {
        k += sz;
        seg[k] = x;
        while(k >>= 1) {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }

    Monoid query(int a, int b) {
        Monoid L = M1, R = M1;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if(a & 1) L = f(L, seg[a++]);
            if(b & 1) R = f(seg[--b], R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) const {
        return seg[k + sz];
    }
};

int main()
{
    ll n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
        p[i] = P(y[i], x[i]);
    }
    sort(p, p + n);
    for(int i = 0; i < n; i++) pp[i] = PP(P(p[i].second, p[i].first), i);
    sort(pp, pp + n);
    SegmentTree<ll> seg(n, [](ll a, ll b){return a + b;}, (ll)0);
    for(int i = 0; i < n; i++) seg.set(i, (ll)0);
    seg.build();
    for(int i = 0; i < n; i++){
        c[i][1] = seg.query(pp[i].second, n);
        c[i][2] = i - c[i][1];
        seg.update(pp[i].second, 1);
    }
    for(int i = 0; i < n; i++) seg.set(i, (ll)0);
    seg.build();
    for(int i = n - 1; i >= 0; i--){
        c[i][0] = seg.query(pp[i].second, n);
        c[i][3] = (n - 1 - i) - c[i][0];
        seg.update(pp[i].second, 1);
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans = (ans + MOD * 10 + modpow(2, n) -
               modpow(2, c[i][0] + c[i][1]) - modpow(2, c[i][1] + c[i][2]) - 
               modpow(2, c[i][2] + c[i][3]) - modpow(2, c[i][3] + c[i][0]) +
               modpow(2, c[i][0]) + modpow(2, c[i][1]) + modpow(2, c[i][2]) + modpow(2, c[i][3]) - 1) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 21504
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
typedef pair<int,int> pii;

int main() {
  set<pii> S;
  int n;
  while(cin >> n) {
    REP(i,n) {
      int h,m;
      cin >> h >> m;
      S.insert(pii(h,m));
    }
    int M;
    cin >> M;
    REP(i,M) {
      int h,m;
      cin >> h >> m;
      S.insert(pii(h,m));
    }
    bool f = 0;
    for (pii p : S) {
      if (f) cout << " ";
      printf("%d:%02d", p.first, p.second);
      f = 1;
    }
    cout << endl;

  }
}

Measured memory_bytes: 1232
#include <stdio.h>
#include <limits.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
//typedef pair<int, int> P;


/** Problem1155 : How can I satisfy thee? Let me count the ways... **/
string s;
int P, Q, R, pos;

int formula()
{
	char c = s[pos++];
	
	if (c=='0'||c=='1'||c=='2') return c-'0';
	else if (c=='P') return P;
	else if (c=='Q') return Q;
	else if (c=='R') return R;
	else if (c=='-') return 2-formula();
	else if (c=='(') {
		char a = formula();
		bool multi = (s[pos++]=='*');
		char b = formula();
		pos++;
		
		if (multi) {
			if (a==0 || b==0)
				return 0;
			else if (a==2 && b==2)
				return 2;
			else
				return 1;
		} else {
			if (a==0 && b==0)
				return 0;
			else if (a==2 || b==2)
				return 2;
			else
				return 1;
		}
	}
	return -1;
}

int main()
{
	while (cin>>s, s!=".") {
		int ans=0;
		for(P=0;P<3;P++) {
			for(Q=0;Q<3;Q++) {
				for(R=0;R<3;R++) {
					pos = 0;
					if (formula()==2) {
						//cerr<<"("<<P<<","<<Q<<","<<R<<")"<<endl;
						ans++;
					}
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1188
#include<stdio.h>
int main(void)
{
	int a,b,i;
	while(1){
		scanf("%d",&a);
		if(a==0) break;
		for(i=0;i<9;i++){
			scanf("%d",&b);
			a-=b;
		}
		printf("%d\n",a);
	}
	return 0;
}

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

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(auto &i:A)cin >> i;
	vector<long long> count(N,0);
	vector<long long> ans(N,0);
	
	for(int i=0;i<N;i++){
		A[i]--;
		count[A[i]]++;
	}
	
	for(int i=0;i<N;i++){
		ans[i]=count[i]*(count[i]-1)/2;
	}
	
	long long sum=accumulate(ans.begin(),ans.end(),0LL);
	
	for(int i=0;i<N;i++){
		cout << sum-ans[A[i]]+(count[A[i]]-1)*(count[A[i]]-2)/2 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 6528
// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

char s[1111][1111];
int h,w,q[2000111],fr,rr,dist[1111][1111];
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int main()
{
	get2(h,w);
	memset(dist,-1,sizeof(dist));
	for(int i=1;i<=h;i++)
	{
		scanf("%s",s[i]+1);
		for(int j=1;j<=w;j++)
		{
			if(s[i][j]=='#')
			{
				q[rr++]=i;q[rr++]=j;
				dist[i][j]=0;
			}
		}
	}
	int mx=0;
	for(;fr<rr;fr+=2)
	{
		int x=q[fr],y=q[fr+1];mx=dist[x][y];
		for(int k=0;k<4;k++)
		{
			int nx=x+dx[k],ny=y+dy[k];
			if(nx>=1&&nx<=h&&ny>=1&&ny<=w&&dist[nx][ny]==-1)
			{
				dist[nx][ny]=dist[x][y]+1;
				q[rr++]=nx;q[rr++]=ny;
			}
		}
	}
	printendl(mx);
	return 0;
}

Measured memory_bytes: 13952
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int tyou=0,hisi=0;
	char damy;
	int side[3];
	while(cin>>side[0]>>damy>>side[1]>>damy>>side[2]){
		if(side[0]==side[1]){
			++hisi;
			continue;
		}else if(pow((double)side[0],2)+pow((double)side[1],2)==pow((double)side[2],2))++tyou;
	}
	cout<<tyou<<endl<<hisi<<endl;
	return 0;
}

Measured memory_bytes: 1160
n=int(input())
s=list(input())
cnt=0
def jesus(a,b):
    if (a=='O' and b=='X') or (b=='O' and a=='X'):
        return True
    else:
        return False
i=0
while i+1<n:
    if jesus(s[i],s[i+1]):
        cnt+=1
        i+=1
    i+=1
print(cnt)



Measured memory_bytes: 6508
program aaa
implicit none

character(10) :: s
integer :: y, m, d

read(*,'(a10)') s
read(s(1:4),*) y
read(s(6:7),*) m 
read(s(9:10),*) d 

if(y*1000+m*100+d>2019430) then
write(*,'(a3)') 'TBD'
else
write(*,'(a6)') 'Heisei'
end if

end program

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;
int a[11]={0};
int vis[12]={0};
int n,s,c;
int ans=111111111;
int dis[205][205]={0};
int visit[11]={0};

void search(int step){
	if(step==c+1){
		int minn=0;
		dis[0][a[1]]=0;
		for(int i=1;i<=c;i++){
			minn+=dis[a[i-1]][a[i]];
		}
		ans=min(minn,ans);
	}
	else {
		for(int i=1;i<=c;i++){
			if(vis[i]==0&&(step==1||dis[a[step-1]][visit[i]]!=111111111)){
				a[step]=visit[i];
				vis[i]=1;
				search(step+1);
				vis[i]=0;
			}
		}
	}
}
int main(){
cin>>n>>s>>c;
int x,y,z;
for(int i=1;i<=200;i++){
	for(int j=1;j<=200;j++){
		dis[i][j]=111111111;
	}
	dis[i][i]=0;
}
for(int i=1;i<=c;i++){
	cin>>visit[i];
}
for(int i=1;i<=s;i++){
	scanf("%d%d%d",&x,&y,&z);
	if(dis[x][y]>z)dis[x][y]=z;
	dis[y][x]=dis[x][y];
}
for(int k=1;k<=n;k++){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			dis[i][j]=dis[j][i]=min(dis[i][j],dis[i][k]+dis[k][j]);
		}
	}
}
search(1);
cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 5000
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
PII seq[4];
bool cmp(PII A,PII B)
{
	return A.second-A.first>B.second-B.first;
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=3;i++)
		scanf("%lld",&seq[i].first);
	for(int i=1;i<=3;i++)
		scanf("%lld",&seq[i].second);
	sort(seq+1,seq+1+3,cmp);
	int cnt=0;
	for(int i=1;i<=3;i++)
		if(seq[i].first<seq[i].second)
			cnt++;
	if(cnt==3)
	{
		LL ans=n;
		for(int i=0;i*seq[1].first<=n;i++)
			for(int j=0;i*seq[1].first+j*seq[2].first<=n;j++)
			{
				LL k=(n-(i*seq[1].first+j*seq[2].first))/seq[3].first;
				LL res=(n-(i*seq[1].first+j*seq[2].first))%seq[3].first;
				ans=max(ans,i*seq[1].second+j*seq[2].second+k*seq[3].second+res);
			}
		printf("%lld\n",ans);
		return 0;
	}
	else if(cnt==1)
	{
		n=n%seq[1].first+n/seq[1].first*seq[1].second;
		LL ans=n;
		for(int i=0;i*seq[2].second<=n;i++)
		{
			LL j=(n-i*seq[2].second)/seq[3].second;
			LL res=(n-i*seq[2].second)%seq[3].second;
			ans=max(ans,i*seq[2].first+j*seq[3].first+res);
		}
		printf("%lld\n",ans);
	}
	else if(cnt==2)
	{
		LL ans=n;
		for(int i=0;i*seq[1].first<=n;i++)
		{
			LL j=(n-i*seq[1].first)/seq[2].first;
			LL res=(n-i*seq[1].first)%seq[2].first;
			LL nn=i*seq[1].second+j*seq[2].second+res;
			ans=max(ans,nn%seq[3].second+nn/seq[3].second*seq[3].first);
		}
		printf("%lld\n",ans);
	}
	else if(cnt==0)
	{
		LL ans=n;
		for(int i=0;i*seq[1].second<=n;i++)
			for(int j=0;i*seq[1].second+j*seq[2].second<=n;j++)
			{
				LL k=(n-(i*seq[1].second+j*seq[2].second))/seq[3].second;
				LL res=(n-(i*seq[1].second+j*seq[2].second))%seq[3].second;
				ans=max(ans,i*seq[1].first+j*seq[2].first+k*seq[3].first+res);
			}
		printf("%lld\n",ans);
	}
	return 0;
}

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

#define endl "\n"
typedef unsigned long long uLL;
typedef long long int LL;
typedef pair <int,int> pii;
typedef pair <int,pii> piii;
typedef pair <long long,long long> pll;
typedef pair <long long,pll> plll;
const int N = 55;
const int inf = 1e9;
const long long INF = 1e18;
const double PI = acos(-1.0);
const double EPS = 1e-8;
const int MOD = 1000000007;

int n , x;
int a[ N ];
LL dp[ 55 ][ 55 ][ 3000 ];

LL solve( int idx , int sum , int taken ) {
        if( idx > n ) {
                return taken && sum == taken*x;
        }
        if( dp[idx][taken][sum] != -1 ) return dp[idx][taken][sum];
        LL ret = 0;
        ret += solve( idx + 1 , sum+a[idx] , taken+1 );
        ret += solve( idx + 1 , sum , taken );
        return dp[idx][taken][sum] = ret;
}
int main( int argc , char const *argv[] ) {
        ios_base::sync_with_stdio( false ); cin.tie( nullptr );
        cin >> n >> x;
        for( int i = 1; i <= n; i++ ) cin >> a[i];
        memset( dp , -1 , sizeof( dp ) );
        cout << solve( 1 , 0 , 0 ) << endl;
        return 0;
}












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

//nxt[in][pre][cur]
int nxt[2][2][2]={{{0, 1}, {1, 0}}, {{1, 0}, {0, 1}}};

int main(){
    int N;
    cin>>N;
    vector<int>in(N);
    string s;
    cin>>s;
    for(int i=0;i<N;i++){
        in[i]=(s[i]=='o'?1:0);
    }
    for(int t=3;t>=0;t--){
        vector<int>ans(N, 2);
        ans[0]=(t&1?1:0);
        ans[1]=(t&2?1:0);
        for(int i=1;i+1<N;i++){
            ans[i+1] = nxt[in[i]][ans[i-1]][ans[i]];
        }
        if(nxt[in[0]][ans[N-1]][ans[0]]==ans[1] && nxt[in[N-1]][ans[N-2]][ans[N-1]]==ans[0]){
            for(int i=0;i<N;i++){
                printf("%c",(ans[i]?'S':'W'));
            }
            printf("\n");
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main(){
    ll N, T;
    cin >> N >> T;
    ll t[N];
    REP(i, N)
    {
    	cin >> t[i];
    }

    ll ans = T;
    for (int i = 1; i < N; ++i)
    {
    	ll diff = t[i] - t[i - 1];
    	if (diff >= T)
    	{
    		ans += T;
    	}
    	else {
    		ans += diff;
    	}
    }
 	cout << ans << endl;
}


Measured memory_bytes: 1792
s = input()

s = " " + s

ans = 0

if len(s) % 2 == 0:
    for i in range(1, len(s) // 2 + 1):
        if s[i] != s[i * -1]:
            ans += 1
else:
    for i in range(1, len(s) // 2 + 1):
        if s[i] != s[i * -1]:
            ans += 1

print(ans)

Measured memory_bytes: 9052
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n; cin >> n;
	vector<int> l(n), r(n);
	rep(i, n) {
		cin >> l[i] >> r[i];
	}
	sort(all(l));
	reverse(all(l));
	sort(all(r));
	int ans = 0;
	int res = 0;
	rep(i, n) {
		res += 2 * l[i];
		chmax(ans, res);
		res -= 2 * r[i];
		chmax(ans, res);
	}
	res = 0;
	rep(i, n) {
		res -= 2 * r[i];
		chmax(ans, res);
		res += 2 * l[i];
		chmax(ans, res);
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define f find
#define ub upper_bound
#define lb lower_bound
#define in insert
#define bs binary_search   
#define M_X 1000000007
int main() 
{ 
    int h,w;
    cin>>h>>w;
    char arr[h][w];
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
       cin>>arr[i][j];
    ll dp[h][w];
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
        {
            if(i==0 && j==0)
                dp[i][j]=1;
            else if(i==0)
            {
                if(arr[i][j-1]=='#')
                    dp[i][j]=0;
                else
                    dp[i][j]=dp[i][j-1]%M_X;
            }
            else if(j==0)
            {
                 if(arr[i-1][j]=='#')
                    dp[i][j]=0;
                else
                    dp[i][j]=dp[i-1][j]%M_X;
            }
            else if(arr[i-1][j]=='#' && arr[i][j-1]!='#')
                dp[i][j]=dp[i][j-1]%M_X;
            else if(arr[i-1][j]!='#' && arr[i][j-1]=='#')
                dp[i][j]=dp[i-1][j]%M_X;
            else if(arr[i-1][j]=='#' && arr[i][j-1]=='#')
                dp[i][j]=0;
            else
                dp[i][j]=(dp[i][j-1]%M_X+dp[i-1][j]%M_X)%M_X;
        }
        cout<<dp[h-1][w-1]%M_X;
    return 0; 
} 

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int i,j=0,c=1,a[n],flag=0,temp=1;
    for(i=0; i<n; i++)
        cin>>a[i];
    for(i=1; i<n; i++)
    {
        if(a[i]<=a[i-1])
        {
            c++;
        }
        else
            c=1;
        if(temp<c)
            temp=c;


    }


    cout<<temp-1<<endl;
    return 0;
}


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

int main()
{
    long long n{};
    std::cin >> n;

    std::vector<unsigned long long> A(n);
    std::vector<unsigned long long> B(n);
    std::vector<unsigned long long> C(n);

    for (auto& k : A) {
        std::cin >> k;
    }
    for (auto& k : B) {
        std::cin >> k;
    }
    for (auto& k : C) {
        std::cin >> k;
    }

    std::sort(std::begin(A), std::end(A));
    std::sort(std::begin(B), std::end(B));
    std::sort(std::begin(C), std::end(C));

    std::vector<unsigned long long> x(n);
    std::vector<unsigned long long> y(n);

    for (int i = 0; i < n; ++i) {
        const auto ind = std::lower_bound(std::begin(A), std::end(A), B[i]);
        if (ind != std::end(A))
            x[i] = ind - std::begin(A);
        else
            x[i] = n;
    }
    for (int i = 0; i < n; ++i) {
        const auto ind = std::lower_bound(std::begin(B), std::end(B), C[i]);
        if (ind != std::end(B))
            y[i] = ind - std::begin(B);
        else
            y[i] = n;
    }

    std::vector<unsigned long long> sx(n, 0);
    std::partial_sum(std::begin(x), std::end(x), std::begin(sx));

    unsigned long long r{};
    for (int i = 0; i < n; ++i) {
        if (y[i] > 0) {
            r += sx[y[i]-1];
        }
    }

    std::cout << r << std::endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <iomanip>
using namespace std;
#define rep(k, n)	for (int k; k < n; k++)

int main(){

	double a, b, h, m;
	cin >> a >> b >> h >> m;
	h *= 30;
	h += m / 2;
	m *= 6;
	double ans = sqrt(a*a + b*b - 2*a*b*cos(abs(h - m) / 180 * M_PI));
	cout << setprecision(20) << ans << endl;

	return 0;
} 

Measured memory_bytes: 4232
#include <iostream>

int main(){
	using namespace std;
	string s;
	cin >> s;
		if (s == "Sunny") {
			s = "Cloudy";
		}
		else if (s == "Cloudy") {
			s = "Rainy";
		}
		else {
			s = "Sunny";
		}
	cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using ll=long long;
using namespace std;
int main(){
	ll K;
	ll N;
	cin >> K >> N;
  vector<ll> A(N);
  for(ll i=0;i<N;i++){
    cin >> A[i];
  }
  ll res=-1*(1ll<<60);
  for(ll i=0;i<N-1;i++){
  	res=max(A[i+1]-A[i],res);
  }
  res=max(res,K-A[N-1]+A[0]);
  cout << K-res << endl;
  
}

Measured memory_bytes: 4812