akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1LL << 60;

string S;
int main() {
    cin >> S;

    map<char, ll> mp;
    rep(i, S.size()) {
        mp[S[i]]++;
    }

    // 左右の動き
    ll w = mp['W'];
    ll e = mp['E'];
    ll n = mp['N'];
    ll s = mp['S'];

    ll judge1 = false;
    if (w == 0 && e == 0) {
        judge1 = true;
    } else if (w > 0 && e > 0) {
        judge1 = true;
    }

    ll judge2 = false;
    if (n == 0 && s == 0) {
        judge2 = true;
    } else if (n > 0 && s > 0) {
        judge2 = true;
    }

    if (judge1 && judge2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
using ll = long long;
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
typedef pair<int, int> pii;
const ll M = 1000000007;
int n,a,b;
//string s;
int main()
{
    cin>>n;
    //vector<bool>vis(n,0);
    int ans=0;
    loop(i,1,n)
    {
        int k=n/i;
        ans+=k-1;
        if(n%i)
        {
            ans++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define all(v) (v).begin(),(v).end()
#define pb push_back
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/
signed main(){
  int n,x,y;
  cin>>n>>x>>y;
  x--;y--;
  vector<vi> d(n,vi (n,0));
  rep(i,n){
    rep(j,n) d[i][j]=abs(i-j);
  }
  rep(i,n){
    rep(j,n){
      chmin(d[i][j],abs(x-i)+abs(j-y)+1);
      chmin(d[i][j],abs(y-i)+abs(j-x)+1);
    }
  }
  vi ans(n+1);
  rep(i,n){
    rep(j,n){
      ans[d[i][j]]++;
    }
  }
  FOR(i,1,n-1) cout<<ans[i]/2<<endl;
  return 0;
}


Measured memory_bytes: 31616
#include<stdio.h>

int main(void){
    int W;
    int H;
    int x;
    int y;
    int r;
    scanf("%d",&W);
    scanf("%d",&H);
    scanf("%d",&x);
    scanf("%d",&y);
    scanf("%d",&r);
    if(x>=r && x<=W-r && y>=r && y<=H-r){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2100
#include <stdio.h>
#include <math.h>

#define N 30

int main(void) {
  int n = 0;
  int dp[N + 1] = {0};

  scanf("%d", &n);

  dp[0] = 1;

  while (n != 0) {
    for (int i = 1; i <= n; i++) {
      if (i == 1) {
	dp[1] = dp[i - 1];
      } else if (i == 2) {
	dp[2] = dp[i - 1] + dp[i - 2];
      } else {
	dp[i] = dp[i - 3] + dp[i - 2] + dp[i - 1];
      }
    }

    int years = (int) ceil((dp[n] / 10.0) / 365.0);

    printf("%d\n", years);

    scanf("%d", &n);    
  }
}

Measured memory_bytes: 1032
#include <stdio.h>

int main(void){
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);

    if(A<C){
        if(A<C && C<B){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    else{
        if(B<C && C<A){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)

const int INF = 100000000;

using namespace std;


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b == c || a + c == b || b + c == a) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC112 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
xyh = [LI() for _ in range(n)]
maxh = 0
for x,y,h in xyh:
    maxh = max(maxh,h)
for H in range(maxh,maxh+201):
    for cx in range(101):
        for cy in range(101):
            for x,y,h in xyh:
                if h != max(H-abs(x-cx)-abs(y-cy),0):
                    break
            else:
                print(cx,cy,H)
                quit()


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

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

using ll = long long;
using P = pair<int,int>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

graph g;
int N;
vector<int> d;

void dfs(int a,int s){
    d[s] = 0;
    for(auto x:g[a]){
        if(d[x]!=-1) continue;
        d[x] = d[a] + 1;
        dfs(x,s);
    }
    return;
}

int main() {
    cin>>N;
    g.resize(N);
    d.assign(N,-1);
    rep(i,N-1) {
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0,0);
    int l = 0;
    int u = 0,v = 0;
    rep(i,N){
        if(chmax(l,d[i])) u = i;
    }
    rep(i,N) d[i] = -1;
    dfs(u,u);
    int L = 0;
    rep(i,N) chmax(L,d[i]);
    if(L%3==1) cout<<"Second"<<endl;
    else cout<<"First"<<endl;
}

Measured memory_bytes: 24132
a,b,k=map(int,input().split())
x=max(a,b)
y=min(a,b)

def lcm(x,y):
    if y==0:
        return x
    else:
        return lcm(y,x%y)
yaku=[]
mx=lcm(x,y)
for i in range(1,mx):
    if mx%i==0:
        yaku.append(i)
yaku.append(mx)
print(yaku[-k])


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct sptyp {char s[11]; int p,o;};

int asbc(const void *x, const void *y) {
  int i;

  if ((i=strcmp((*(struct sptyp *)x).s,(*(struct sptyp *)y).s))==0)
     return (*(struct sptyp *)y).p - (*(struct sptyp *)x).p;
  else
     return i;
}

int main(){
   int i,n;
   struct sptyp sp[100];
    
   scanf("%d",&n);
   for (i=0;i<n;i++) {
      scanf("%s %d",sp[i].s,&(sp[i].p));
      sp[i].o=i+1;
   }
   qsort(sp,n,sizeof(struct sptyp),asbc);
   for (i=0;i<n;i++) printf("%d\n",sp[i].o);
   return 0;
}


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

int main(void){
    long long int i, j, k, n, q, ans=0, po=0, x[5];
    scanf("%lld", &n);
    long long int a[n];
    for(i=0; i<n; i++) scanf("%lld", &a[i]);
    scanf("%lld", &q);
    long long int b[q], c[q], s[q+1];
    for(i=0; i<q; i++) scanf("%lld %lld", &b[i], &c[i]);
    for(i=0; i<q+1; i++) s[i] = 0;
    for(i=0; i<n; i++) s[0] += a[i];
    long long int aa[100001];
    for(i=0; i<100001; i++) aa[i] = 0;
    for(i=0; i<n; i++) aa[a[i]]++;

    for(i=0; i<q; i++){
        s[i+1] = s[i] + c[i]*aa[b[i]] -b[i]*aa[b[i]];
        aa[c[i]] += aa[b[i]];
        aa[b[i]] = 0;
        //for(j=0; j<n; j++) printf("%lld ", aa[j]);
        //printf("\n");
    }
    for(i=0; i<q; i++)printf("%lld\n", s[i+1]);

    
}

Measured memory_bytes: 5612
import javax.swing.*;
import java.io.*;
import java.sql.Struct;
import java.util.*;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[][] board = new boolean[n][m];
        for(int i = 0; i < n; i++) {
            board[i] = new boolean[m];
            String s = sc.next();
            for(int j = 0; j < m; j++) {
                board[i][j] = s.charAt(j) != '#';
            }
        }
        long[][] res = new long[n][m];
        res[n - 1][m - 1] = 1;
        int rem = 1000000007;
        for(int i = n - 1; i >= 0; i--) {
            for (int j = m - 1; j >= 0; j--) {
                if( i == n - 1 && j == m - 1) {
                    continue;
                }
                int curRes = 0;
                if(i + 1 < n && board[i + 1][j]) {
                    curRes += res[i + 1][j];
                }
                if(j + 1 < m && board[i][j + 1]) {
                    curRes += res[i][j + 1];
                }
                res[i][j] = curRes % rem;
            }
        }
        System.out.println(res[0][0]);
    }
}

Measured memory_bytes: 39204
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 1e6 + 5;
struct node
{
    int x,i;
} N[100005];
bool cmp(node a,node b)
{
    return a.x<b.x;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%d",&N[i].x);
        N[i].i=i+1;
    }
    sort(N,N+n,cmp);
    for(int i=0; i<n-1; i++)
        printf("%d ",N[i].i);
    printf("%d\n",N[n-1].i);
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
long long n,a,b,ans;
int main(){
	scanf("%lld%lld%lld",&n,&a,&b);
	ans+=n/(a+b)*a;
	ans+=n%(a+b)>a?a:n%(a+b);
	printf("%lld",ans);
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    string s;
    cin >> s;
    string target = "CODEFESTIVAL2016";

    int count = 0;
    for (int i = 0; i < target.size(); i++)
    {
        count += (target[i] != s[i]);
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    string s;cin>>s;
    int l=0;int r=n;int m=(l+r)/2;bool can;string tmp;
    while(r-l>1){
        m=(l+r)/2;
        if(n<2*m){
            r=m;
            continue;
        }
        can=false;
        set<string> ss;
        queue<string> q;
        rep(i,m)q.push(s.substr(i,m));
        for(int i=m;i+m-1<n;i++){
            ss.insert(q.front());q.pop();
            tmp=s.substr(i,m);
            if(ss.count(tmp)){
                can=true;
                break;
            }
            q.push(tmp);
        }
        if(can)l=m;
        else r=m;
    }
    cout<<l<<endl;
}

Measured memory_bytes: 9704
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 998244353;
const double pi = 3.141592653589793;

ll mypow(ll a, ll b)
{
	ll r = 1ll;
	while(b != 0){
		if(b&1) r = r * a % MOD;
		a = a * a % MOD;
		b /= 2;
	}
	return r;
}

vector<ll> fac;
vector<ll> ifac;

void factorial_init(ll n)
{
	fac.resize(n+1);
	ifac.resize(n+1);
	fac[0] = 1;
	ifac[0] = 1;
	REP(i,n) {
		fac[i+1] = fac[i] * (i + 1) % MOD;
		ifac[i+1] = ifac[i] * mypow(i + 1, MOD - 2) % MOD;
	}
}

ll Combination(ll a, ll b)
{
	if(a == 0 && b == 0) return 1;
	if(a < b || a < 0) return 0;
	ll r = ifac[a-b] * ifac[b] % MOD;
	return r * fac[a] % MOD;
}

int main()
{
	int n, m, k;
	ll ans = 0ll;
	cin>>n>>m>>k;

	factorial_init(max(n,m)+1);

	REP(i,k+1) {
		ll tmp;
		tmp = (mypow(m-1, n-i-1) * m) % MOD;
		tmp *= Combination(n-1,i);
		ans += tmp;
		ans %= MOD;
		//cout<<i<<" "<<Combination(n-1,i)<<endl;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 6336
/*
गिरते हैं शहसवार ही मैदान-ए-जंग में ।
वो तिफ़्ल क्या गिरे जो घुटनों के बल चले ।।
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define int     long long int
#define ull     unsigned int
#define ld      long double
#define pb      push_back
#define pa      pair<int,int>
#define ppa     pair<pair<int,int>,int>
#define pap     pair<int,pair<int,int>>
#define v1d     vector<int>
#define v2d     vector<vector<int> >
#define vpa     vector<pair<int,int>>
#define M       1000000007
#define MN      LLONG_MIN
#define MX      LLONG_MAX
#define ff      first
#define ss      second
#define endl    "\n"
#define v1s     vector<string>
#define all(v)  v.begin(),v.end()
#define S(v)    sort(v.begin(),v.end())
#define RS(v)   sort(v.rbegin(),v.rend())
#define R(v)    reverse(v.begin(),v.end())
#define mxpq(T)    priority_queue <T>
#define mnpq(T)    priority_queue<T,vector<T>,greater<T>>
#define T       int tc;cin>>tc;while(tc--)
#define p2d(v)     for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)      for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)      for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define sz(v)       (int)(v.size())
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define qqq 400005


void Weapons19(){
    int n;cin>>n;
    string s;cin>>s;
    int ans=0;
    map<int,int>m;
    for(auto a:s)m[a]++;
    if(sz(m)<3){cout<<0;return;}
    ans=1;
    for(auto a:m)ans*=a.ss;
    for(int i=0;i<n;i++){
        for(int j=1;j<n;j++){
            if(i-j>=0&&i+j<n&&s[i]!=s[i-j]&&s[i]!=s[i+j]&&s[i-j]!=s[i+j])ans--;
        }
    }
    cout<<ans;















}

int32_t main(){

    /*
    त्यक्तवाधर्मं च लोभं च
    मोहंचो द्यमास्थिता।
    युद्ध्यध्वमनहंकारा
    यतो धर्मस्ततो जयः।।
    */

    cout<<fixed<<setprecision(16);
    cin.sync_with_stdio(false);
    cin.tie(0);cout.tie(0);



    Weapons19();
    
}


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

int main(){
    int p,q,r;
    cin >> p >> q >> r;
    int sum_a = p+q;
    int sum_b = q+r;
    int sum_c = r+p;
    cout << min(min(sum_a,sum_b),sum_c) << endl;
}

Measured memory_bytes: 256
using System.Collections.Generic;
using static System.Console;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = ReadLine().ToCharArray().Select(i => (int)i).ToArray();
            var t = ReadLine().ToCharArray().Select(i => (int)i).ToArray();

            var buffer = new List<int>();
            var l = s.Count();
            var result = true;

            for (int i = 0; i < l; i++)
            {
                if (s[i] == t[i])
                {
                    buffer.Add(s[i]);
                    continue;
                }
                else
                {
                    if (buffer.Contains(s[i]))
                    {
                        result = false;
                        break;
                    }
                    else
                    {
                        if (buffer.Contains(t[i]))
                        {
                            result = false;
                            break;
                        }


                        var asciiOfTargetChar = s[i];

                        for (int j = 0; j < l; j++)
                        {
                            if (s[j] == asciiOfTargetChar)
                            {
                                s[j] = t[i];
                            }
                            else
                            {
                                if (s[j] == t[i])
                                {
                                    s[j] = asciiOfTargetChar;
                                }
                            }
                        }

                        buffer.Add(t[i]);
                        continue;
                    }
                }
            }

            WriteLine(result ? "Yes" : "No");

        }
    }
}

Measured memory_bytes: 20832
#include <stdio.h>

int main(void) {
    int i,N;
    int a[150];
    
    scanf("%d",&N);
    
    for(i=0;i<N;i++){
        scanf("%d",&a[i]);    
    }
    
    for(i=N-1;i>=0;i--){
        printf("%d",a[i]);
        if(i != 0) printf(" ");
    }
    
    printf("\n");
    
	return 0;
}



Measured memory_bytes: 2032
import sys
readline = sys.stdin.readline

N = int(readline().strip())
l = list(map(int, readline().split()))

L = {}
S = []
for i in range(N):
  if l[i] not in L:
    L[l[i]] = 1
    S.append(l[i])
  else:
    L[l[i]] += 1
S.sort()

n = len(S)
ans = 0

if n < 3:
  print(ans)
  exit()

for i in range(n):
  for j in range(i+1, n):
    for k in range(j+1, n):
      if S[k] < S[i] + S[j]:
        ans += L[S[i]] * L[S[j]] * L[S[k]]
print(ans)

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

int main()
{
  int n;
  ll k;
  cin >> n >> k;
  int bit_ctr[M] = {};
  ll a[n];
  rep(i, n) {
    cin >> a[i];
    rep(j, M) {
      bit_ctr[j] += (int)((a[i] >> j) & 1LL);
    }
  }
  ll x = 0;
  for (int i = M-1; i >= 0; --i) {
    if (bit_ctr[i] > n/2) continue;
    ll tmp = 1LL << i;
    if (x + tmp  <= k) {
      x += tmp;
    }
  }

  ll ans = 0;
  rep(i, n) {
    ans += x ^ a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include "algorithm"
#include "vector"
#include "string"
#include "iostream"
using namespace std;

int main(){
    int H,W;
    while(1){
        cin>>H>>W;
        if(H==0&&W==0) break;
        int count =0;
        while(1){
            for(int i =0;i<W/2;i++){
                cout<<"#.";
            }
            if(W%2!=0) cout<<"#";
            count++;
            if (count==H) break;
            cout<<endl;
            for(int i =0;i<W/2;i++){
                cout<<".#";
            }
            if(W%2!=0) cout<<".";
            count++;
            if (count==H) break;
            cout<<endl;
        }
        cout<<endl<<endl;
    }
}




Measured memory_bytes: 3096
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<list>
#include<map>
#include<iomanip>
#include<iostream>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
#include<memory.h>
using namespace std;
int main(){
	long long q,h,s,d,n,sum=0,m,mm,mom;
	cin>>q>>h>>s>>d>>n;
	long long a[5];
	memset(a,0,sizeof(a));
	a[1]=4*q;
	a[2]=2*h;
	a[3]=s;
	a[4]=d/2;
	long long mo=min(a[1],min(a[2],min(a[3],a[4])));
	for(int i=1;i<=4;i++)
		if(a[i]==mo)
		m=i;
	if(m==1){
		cout<<n*4*q<<endl;
		return 0;
	}
	if(m==2){
		cout<<n*2*h<<endl;
		return 0;
	}
	if(m==3){
		cout<<n*s<<endl;
		return 0;
	}
	else{
		if(n==1){
			mom=min(a[1],min(a[2],a[3]));
			for(int i=1;i<=3;i++)
				if(mom==a[i])
					mm=i;
			if(mm==1)
				sum=sum+4*q;
			if(mm==2)
				sum=sum+2*h;
			if(mm==3)
				sum=sum+s;
		}
		else{
			sum+=n/2*d;
			if(n%2==1){
				a[1]=4*q;
				a[2]=2*h;
				a[3]=s;
				mom=min(a[1],min(a[2],a[3]));
				for(int i=1;i<=3;i++)
					if(mom==a[i])
						mm=i;
				if(mm==1)
					sum+=4*q;
				if(mm==2)
					sum=sum+h+h;
				if(mm==3)
					sum+=s;
			}
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int N;
  cin >> N;
  if(N%2==0){
    cout << 0.5 << endl;
  }else{
    double m=N;
    cout << (m+1)/2/m << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
       

template <typename T>
class Grid {
  struct Pos {
    int i, j;
    Pos(int i, int j) : i(i), j(j) {}
  };

  int H, W;
  vector<vector<T>> G;

  vector<int> di8 = {1, 1, 0, -1, -1, -1, 0, 1},
              dj8 = {0, 1, 1, 1, 0, -1, -1, -1};
  vector<int> di4 = {1, 0, -1, 0}, dj4 = {0, 1, 0, -1};

  vector<Pos> neighbor(int i, int j, const vector<int>& dis,
                       const vector<int>& djs) const {
    vector<Pos> res;
    for (int k = 0; k < dis.size(); ++k) {
      if (in(i + dis[k], j + djs[k])) res.emplace_back(i + dis[k], j + djs[k]);
    }
    return res;
  }

 public:
  static bool in(int H, int W, int i, int j) {
    return 0 <= i && i < H && 0 <= j && j < W;
  }

  Grid(int H, int W) : H(H), W(W) { G.resize(H, vector<T>(W)); }

  vector<T>& operator[](int i) { return G[i]; }

  bool in(int i, int j) const { return (0 <= i && i < H && 0 <= j && j < W); }

  vector<Pos> neighbor8(int i, int j) const { return neighbor(i, j, di8, dj8); }

  vector<Pos> neighbor4(int i, int j) const { return neighbor(i, j, di4, dj4); }

  void scanFrom(istream& strm) { for (int i = 0; i < (int)(H); ++i) for (int j = 0; j < (int)(W); ++j) strm >> G[i][j]; }

  void outputTo(ostream& strm) {
    for (int i = 0; i < (int)(H); ++i) {
      for (int j = 0; j < (int)(W); ++j) cout << G[i][j];
      strm << endl;
    }
  }
};

template <typename T>
inline istream& operator>>(istream& strm, Grid<T>& g) {
  g.scanFrom(strm);
  return strm;
}

template <typename T>
inline ostream& operator<<(ostream& strm, Grid<T>& g) {
  g.outputTo(strm);
  return strm;
}

int main() {
  int w, h;
  while (true) {
    cin >> w >> h;
    if (w == 0 && h == 0) break;
    Grid<int> grid(h, w);
    cin >> grid;

    function<void(int, int)> dfs = [&](int i, int j) {
      grid[i][j] = 0;
      for (auto& p : grid.neighbor8(i, j)) {
        if (grid[p.i][p.j]) dfs(p.i, p.j);
      };
    };

    int ans = 0;
    for (int i = 0; i < (int)(h); ++i) for (int j = 0; j < (int)(w); ++j) {
      if (grid[i][j]) {
        dfs(i, j);
        ++ans;
      }
    }
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3424
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define nfs ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,a,b) for(i=a;i>=b;i--)
#define m_p make_pair
#define p_b push_back
#define MOD 1000000007
#define pl pair<ll,ll>
int main()
{
	nfs;
	int t;
	t=1;
//	cin >> t;

	while(t--)
	{
		ll h,w;
		cin >> h >> w;
		string s[h];
		ll i;
		F(i,0,h)
		{
			cin >> s[i];
		}
		
		ll marked[h][w];
		
		ll j;
		for(i=0;i<h;i++)
		{
			for(j=0;j<w;j++)
			{
				marked[i][j] = 0;
				
			}
		}
		ll count = 0;
		for(i=0;i<h;i++)
		{
			for(j=0;j<w;j++)
			{
				
				if(marked[i][j]==1)
				{
					continue;
				}
				marked[i][j]=1;
				ll white=0,black = 0;
				stack <pl> st;
				st.push(m_p(i,j));
				while(!st.empty())
				{
					 
					pl temp = st.top();
					st.pop();
					
					
				//	char y =(char)( '.'+'#' + 0);
					ll f = temp.first;
					ll sn = temp.second;
					marked[f][sn] = 1;
					char x = s[f][sn];
					if(x=='.')
					{
						white++;
					}
					else
					{
						black++;
					}
				//	cout << f << " " << sn << endl;
					
					if(f+1<h)
					{
						if(s[f+1][sn]!=s[f][sn]&&marked[f+1][sn]==0)
						{
							st.push(m_p(f+1,sn));
							marked[f+1][sn] = 1;
						}
					}
					if(f-1>=0)
					{
						if(s[f-1][sn]!=s[f][sn]&&marked[f-1][sn]==0)
						{
							st.push(m_p(f-1,sn));
							marked[f-1][sn] = 1;
						}
					}
					if(sn+1<w)
					{
					//	cout << "LOL" << endl;
					//	cout << s[f][sn] << s[f][sn+1] << marked[f][sn+1];
						
						if(s[f][sn+1]!=s[f][sn]&&marked[f][sn+1]==0)
						{
							st.push(m_p(f,sn+1));
							marked[f][sn+1] = 1;
						}
					}
					if(sn-1>=0)
					{
						if(s[f][sn-1]!=s[f][sn]&&marked[f][sn-1]==0)
						{
							st.push(m_p(f,sn-1));
							marked[f][sn-1] = 1;
						}
					}
					
				}
			//	cout << black << " " << white << endl;
				
				count += (white)*(black);
				
			}
		}
		cout << count << endl;
			
	}
	return 0;

}



Measured memory_bytes: 2944
import copy
import math

N,X = map(int,raw_input().split())
S = map(int,raw_input().split())
MOD = 10**9 + 7

S.sort()

dp = [[0 for i in range(X+1)] for j in range(N+1)]

for i in range(X+1):
  dp[1][i] = i % S[0]

for n in range(2,N+1):
  for x in range(X+1):
    #print n,x
    dp[n][x] =  dp[n-1][x] * (n-1) 
    dp[n][x] += dp[n-1][x%S[n-1]]
    dp[n][x] %= MOD

print dp[N][X]


Measured memory_bytes: 188652
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;
use proconio::marker::Usize1;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

#[fastout]
fn main() {
    input! {
        b: char,
    }

    let ans = match b {
        'A' => 'T',
        'T' => 'A',
        'C' => 'G',
        'G' => 'C',
        _ => 'X',
    };

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


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  string S;
  cin >> N >> K >> S;
  vector<int> cnt(100010,0);
  cnt[0]=1;
  int cur=0;
  for (int i=1;i<N;i++){
    if (S[i]==S[i-1]){
      cnt[cur]++;
    }
    else {
      cur++;
      cnt[cur]++;
    }
  }
  vector<int> sum(100010,0);
  sum[0]=0;
  for (int i=0;i<100010;i++){
    sum[i+1]=sum[i]+cnt[i];
  }
  int ans=0;
  if (S[0]=='1'){
    int x=(cur+1)/2;
    if (x<=K){
      ans=N;
    }
    else {
      for (int i=0;i<=cur-2*K+1;i+=2){
        ans=max(ans,sum[min(cur+1,i+2*K+1)]-sum[i]);
      }
    }
  }
  else {
    int x=(cur+2)/2;
    if (x<=K){
      ans=N;
    }
    else {
      for (int i=1;i<=cur-2*K+1;i+=2){
        ans=max(ans,sum[min(cur+1,i+2*K+1)]-sum[i]);
      }
      ans=max(ans,sum[min(cur+1,2*K)]-sum[0]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1280
import java.io.*;

class Main
{
	public static void main(String args[]) throws IOException
	{
		BufferedReader br =
			new BufferedReader(new InputStreamReader(System.in));
		
		String str = br.readLine();
		
		int x = Integer.parseInt(str);
		
		System.out.println(x*x*x);
	}
}

Measured memory_bytes: 24236
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == 0){
				break;
			}
			double mbi = 0;
			String mStr = "";
			for(int i = 0;i < n;i++){
				String str = scan.next();
				double h = scan.nextDouble() / 100;
				double w = scan.nextDouble();
				double t = 22.0 - w / (h*h);
				t *= (t < 0)?-1:1;
				if(mStr.equals("") || mbi > t){
					mStr = str;
					mbi = t;
				}
			}
			System.out.println(mStr);
		}
	}
}

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

typedef long long ll;
const int NMAX = 2e5 + 10;
const int MOD = 1e9 + 7;

int pre[NMAX],a[NMAX];
inline int find(int x){
	return pre[x] = (x == pre[x]? x : find(pre[x]));
}
int main(int argc, char const *argv[])
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(register int i = 1;i <= n;i++)
		pre[i] = i;
	int u,v;
	while(m--)
	{
		scanf("%d%d",&u,&v);
		int u_pre = find(u) , v_pre = find(v);
		if(u_pre == v_pre)	continue;
		pre[u_pre] = v_pre; 
	}
	int ans = 0;
	for(register int i = 1;i <= n;i++)
		a[find(i)] += 1 , ans = max(ans,a[find(i)]);
	printf("%d\n",ans );
	return 0;
}

Measured memory_bytes: 10836
N = int(input())
A=list(map(int,input().split()))
Q = int(input())
BC = [map(int, input().split()) for _ in range(Q)]
B, C = [list(i) for i in zip(*BC)]
sum=0
D=[0]*(10**5+1)
for i in range(N):
    sum+=A[i]
    D[A[i]]+=1
for i in range(Q):
    D[C[i]]+=D[B[i]]
    sum+=D[B[i]]*(C[i]-B[i])
    D[B[i]]=0
    print(sum)

Measured memory_bytes: 66780
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int s = 0;
        String n = String.valueOf(N);
        for(int i = 0; i < n.length(); i++){
            s += Character.getNumericValue(n.charAt(i));
        }
        if (N%s == 0) {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21840
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll mypow(ll a, ll b) {
    ll ret = 1;
    while (b--) {
        ret *= a;
    }
    return ret;
}

int main() {
    ll a, b;
    cin >> a >> b;
    if (a + b >= 10) {
        cout << "error\n";
    } else {
        cout << a + b << "\n";
    }
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		String s = sc.next();
		String t = sc.next();
		sc.close();
		out.println(s.equals(t.substring(0,s.length()))?"Yes":"No");
	}
}


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

using namespace std;

int main() {
    int V, E;
    cin >> V >> E;

    int g[10][50];
    for (int i = 0; i < V; ++i) {
        for (int j = 0; j < V; ++j) {
            g[i][j] = 0;
        }
    }

    while (E--) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a][b] = 1;
        g[b][a] = 1;
    }

    vector<int> vt;
    for (int i = 1; i < V; ++i) {
        vt.push_back(i);
    }

    int ans = 0;
    do {
        bool flag = true;
        if (g[0][vt[0]] == 0) flag = false;
        for (int i = 0; i < vt.size() - 1; ++i) {
            if (g[vt[i]][vt[i + 1]] == 0) {
                flag = false;
            }
        }
        if (flag) ans++;
    } while (next_permutation(vt.begin(), vt.end()));

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
*/

//#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 510031;

long long a,b;

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	cin>>a>>b;
	long long ans=1;
	while (a*2<=b){
		ans++;
		a*=2;
	}
	cout<<ans<<endl;

	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize,
        av: [usize; n]
    };

    let set = av.into_iter().collect::<HashSet<_>>();
    let res = if set.len() == n { "YES" } else { "NO" };
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 6764
/*
  comparator(?)を使用するパターン
  サンプル3はlong型使わないと答えがintの最大値になってしまう。
  参考①
   site:雑草SEの備忘録
   page:JavaのComparatorを使って配列を並び替える
   --そのまま実装するとサンプル3が通せない
  参考②
   page:Java Collections - Comparator.comparingLong() Examples
*/

import java.util.*;
public class Main{
  public static void main(String[] args){
    Main r = new Main();
    r.run();
  }
  private void run() {
    //入力
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();

    //自前クラス(構造体？)を配列に格納する
    Drink[] dr = new Drink[n];
    for(int i=0; i<n; ++i)
      dr[i] = new Drink(sc.nextLong(), sc.nextInt());

    //なんか並び替えてくれる呪文
    Arrays.sort(dr, Comparator.comparingLong(Drink::geta));

    //M本まで数える
    int cnt=0;
    long ans=0;
    for(int i=0; i<n; ++i) {
      if(dr[i].getb()+cnt <= m) {
        cnt += dr[i].getb();
        ans += dr[i].geta() * dr[i].getb();
      }
      else {
        ans += dr[i].geta() * (m-cnt);
        break;
      }
    }
    System.out.println(ans);

  }
  //自前クラス(構造体？)
  private class Drink {
    private long a; //単価
    private int b;  //本数
    public Drink(long a, int b){
      this.a=a;
      this.b=b;
    }
    public long geta(){ return a;}
    public int getb(){ return b;}
  }
}
/*作業用

//試し出力用
for(int i=0; i<n; ++i)
  System.out.println(dr[i].geta() +" "+dr[i].getb());

*/


Measured memory_bytes: 94756
def koch(n, left, right):
	vector = [(right[0] - left[0])/3, (right[1] - left[1])/3]
	vector_up = [-vector[1]*(3**0.5)/2, vector[0]*(3**0.5)/2]
	point1 = [left[0] + vector[0], left[1] + vector[1]]
	point2 = [left[0] + 2*vector[0], left[1] + 2*vector[1]]
	middle = [left[0] + vector[0]*3/2 + vector_up[0],
			  left[1] + vector[1]*3/2 + vector_up[1]]

	if n == 0:
		return [right]

	if n == 1:
		return [point1, middle, point2, right]

	return koch(n-1, left, point1) + koch(n-1, point1, middle)\
			+ koch(n-1, middle, point2) + koch(n-1, point2, right)

if __name__ == "__main__":
	for point in [[0,0]] + koch(int(input()), [0,0], [100,0]):
		print(*point)


Measured memory_bytes: 6264
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n];
    a[0] = sc.nextInt();
    int max = a[0];
    String s = "Yes";
    for(int i = 1;i<n;i++){
      a[i] = sc.nextInt();
      if(a[i]>max){
        max = a[i];
      }
      if(max-1>a[i]){
        s = "No";
        break;
      }
    }
    System.out.println(s);    
  } 
}

Measured memory_bytes: 48792
using System;
using static System.Math;
public class hello
{
	public static void Main()
	{
		var n = int.Parse(Console.ReadLine().Trim());
		var h = new int[n];
		for (int i = 0; i < n; i++) h[i] = int.Parse(Console.ReadLine().Trim());
		Array.Sort(h);
		Array.Reverse(h);
		var ans = getAns(h, n);
		Console.WriteLine(ans);
	}
	static long getAns(int[] h, int n)
	{
		var d = 0;
		var p = 0;
		var count = 1L;
		while (true)
		{
			for (int i = 0; i < 4; i++)
			{
				count += Max(0, h[p++] - d);
				if (p == n) return count;
			}
			d++;
		}
	}
}



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

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


Measured memory_bytes: 256
x = int(input())


def is_prime(n):
    if n < 2: return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True


def next_prime(n):
    if n <= 1:
        return 2
    prime = n
    found = False
    while not found:
        prime = prime + 1
        if is_prime(prime):
            found = True

    return prime


if is_prime(x):
    print(x)
else:
    print(next_prime(x))


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, t, l, r;
ll ans;

int main() {
	cin >> n >> t;
	cin >> l;
	ans += t;
	rep(i,n-1) {
		cin >> r;
		ans += t;
		if (l+t>r) ans -= l+t-r;
		l = r;
	}
	cout << ans << ln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr first
#define sc second
#define ll  long long
#define mp make_pair
#define mod 1000000007

using namespace std;

bool v[100100];
int del[100100];
int main()  {
    ll n,k;
    cin>>n>>k;
    ll res =0;

    int i =0 ;

    for(ll b=k+1 ;b <=n ;b ++){
        ll r1 =0 ;
        ll en= -1;
        for(ll j=k ; j<=n ;j+=b){
            if(en >= j){
                r1 += max(min(j+i,n) - max(en,0LL),0LL);
            }
            else
                r1 += min(j+i,n) - max(j,1LL)+1;
            en = j+i;
        }
        i++;
        res += r1;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
"use strict";
function main(input) {
    var line = input.split(/\r?\n/g);
    var arr = line[0].split(" ");
    const S = arr[0], T = arr[1];
    arr = line[1].split(" ")
    var A = parseInt(arr[0]), B = parseInt(arr[1]);
    const U = line[2];
    if (S === U) A--;
    else B--;
    console.log(A + " " + B);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#from functools import lru_cache
#@lru_cache(maxsize=None)
def is_prime(x):
    if x==1:
        return False
    for i in range(2,int(x**0.5)+1):
        if x%i==0:
            return False
    return True

# @lru_cache(maxsize=None)
def like2017(x):
    return is_prime(i) and is_prime((i+1)//2)
    
table=[0,0]
for i in range(2,10**5):
    table+=table[i-1]+like2017(i),
        
n=int(input())
for _ in range(n):
    a,b=map(int,input().split())
    print(table[b]-table[a-1])
# print(table)


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

using namespace std;

const int N = 100205;
int n, k, dp[N], h[N];
int cal(int x) {
  if (x > n) return 2e9;
  if (x == n) {
    return 0;
  }
  int &ret = dp[x];
  if (ret < 2e9) {
    return ret;
  }
  for (int i = 1; i <= k; i++) {
    ret = min(ret, cal(x+i) + abs(h[x] - h[x+i]));
  }
  return ret;
}

int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i <= n + 200; i++) {
    dp[i] = 2e9;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &h[i]);
  }
  printf("%d", cal(1));
  return 0;
}


Measured memory_bytes: 5760
def submit():
    n = int(input())
    count = {}

    for _ in range(n):
        s = input().strip()
        if s not in count.keys():
            count[s] = 1
        else:
            count[s] += 1

    # 最大回数を求める
    max_count = max(count.values())

    # 最大回数投票された文字列を求める
    max_votes = []
    for s, c in count.items():
        if max_count == c:
            max_votes.append(s)
    
    max_votes.sort()
    for v in max_votes:
        print(v)


if __name__ == "__main__":
    submit()

Measured memory_bytes: 32096
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 double long double
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 101415
#define  vi vector<int>
#define  v  vector
#define die exit(0)
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 
gp_hash_table<int, int> table;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash {
    int operator()(int x) const { return x ^ RANDOM; }
};


int seive[N];


void solve()
{
    for(int i = 2 ; i*i <= N-20 ; i++)
    {
    	if(seive[i] == 1)continue;
    	for(int j = i+i ; j<=N-10 ; j+=i)seive[j] = 1;
    }
	
	int x;
	cin>>x;
	forn(i,x,N-10)
	{
		if(seive[i] == 0)
		{
			cout<<i;
			die;
		}
	}
}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        solve();
        nl;
    }



    return 0;

}

//       g++ -g c.cpp ; timeout 2s ./a.out

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

int main() {
  double A,B,C,D,E,F;
  cin >> A >> B >> C >> D >> E >> F;
  double max_per = E/(100+E);
  double ans = 0.0;
  double ans_sug_wat = 0;
  double ans_sug = 0;
  
  for(int i=0; i<100; i++){
    if(100*i*A > F){
      break;
    }
    for(int j=0; j<100; j++){
      if(100*i*A + 100*j*B > F){
        break;
      }
      for(int k=0; k<=3000; k++){
        if(100*i*A + 100*j*B + k*C> F){
          break;
        }
        for(int l=0; l<=3000; l++){
          if(100*i*A + 100*j*B + k*C + l*D> F){
            break;
          }
          if((k*C+l*D)/(100*i*A + 100*j*B + k*C + l*D) >= ans && (k*C+l*D)/(100*i*A + 100*j*B + k*C + l*D) <= max_per){
            ans = (k*C+l*D)/(100*i*A + 100*j*B + k*C + l*D);
            ans_sug_wat = 100*i*A + 100*j*B + k*C + l*D;
            ans_sug = k*C+l*D;
          }
        }
      }
    }
  }
  
  cout << ans_sug_wat << endl;
  cout << ans_sug << endl;

}

Measured memory_bytes: 256
n = int(input())
t = list(map(int, input().split()))
m = int(input())
pm = [list(map(int, input().split())) for _ in range(m)]

for p, m in pm:
    ans = 0
    for i in range(len(t)):
        if p-1 == i:
            ans += m
        else:
            ans += t[i]
    print(ans)


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

using namespace std;

int main() {
            int n; cin>>n;
            int b[n+5]; for(int i=0;i<n-1;i++) cin>>b[i];
            
            int a[n+5];
            
            int sum  = 0;
            a[0] = b[0];
            a[n-1] = b[n-2];
            
            for(int i = 1 ;i<n-1; ++i){
                a[i] = min(b[i],b[i-1]);
            } 
            
            for(int i=0;i<n;++i)
            {
                sum += a[i];
            }
            
            
            cout<<sum;
  return 0;      
}

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

const int64_t c = 1e9 + 7;
// const int64_t c = 13;

int64_t modinv(int64_t n) {
    int m = c - 2;
    int64_t res = 1;
    while (m > 0) {
        if (m & 1) {
            res = res * n % c;
        }
        n = n * n % c;
        m >>= 1;
    }
    return res;
}

int main() {
    int x, y;
    cin >> x >> y;
    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    int n = (2 * y - x) / 3;
    int m = (2 * x - y) / 3;
    if (n < 0 || m < 0) {
        cout << 0 << endl;
        return 0;
    }
    int64_t ans = 1;
    for (int i = max(n, m) + 1; i <= n + m; i++) {
        ans = (ans * i) % c;
    }
    for (int i = 1; i <= min(n, m); i++) {
        ans = (ans * modinv(i)) % c;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

long long const MOD = 1000000007LL;

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

    cout << max(0, c - (a - b)) << endl;
}


Measured memory_bytes: 256
# 右に(N-1)回移動、下に1回移動
# 合計値は上の段は下に降りるまでの累積和、下の段は降りてからの累積和

N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
 
cum1, cum2 = [0]*(N+1), [0]*(N+1)
for i in range(N):
  cum1[i+1] = cum1[i] + A1[i]
  cum2[i+1] = cum2[i] + A2[i]
print(max([cum1[i+1] + cum2[-1] - cum2[i] for i in range(N)]))

Measured memory_bytes: 3064