akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class ECrestedIbisVsMonster {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int H, N;
        cin >> H >> N;
        vector<int> A(N), B(N);
        REP(i, N) cin >> A[i] >> B[i];

        vector<int> dp(H+1);
        REP(i, H+1) dp[i] = INF;
        dp[H] = 0;
        REV(i, H, 0) {
            REP(j, N) {
                int nj = max(0LL, i - A[j]);
                dp[nj] = min(dp[nj], dp[i] + B[j]);
            }
        }
        cout << dp[0] << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ECrestedIbisVsMonster solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define d  long double
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define N 200003
#define inf (int)1e18
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int mod=1e9+7;

bool pal(string s,int n)
{
    int f=0;
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
        f=1;
    }
    if(f==1)
    return false;
    return true;
}


 
signed main()
{
    haha
    string s;
    cin>>s;
    int n=s.length();
    string a=s.substr(0,n/2);
   //cout<<a<<endl;
    string b=s.substr(n/2+1,n/2);
   // cout<<b<<endl;
    //cout<<pal(s,n)<<endl;
    if(pal(a,n/2)==true && pal(b,n/2)==true && pal(s,n)==true)
    cout<<"Yes";
    else
    cout<<"No";
    
   
    
   
 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <utility>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S; cin >> S;
  int alp[26];
  for (int i = 0; i < 26; i++)
    alp[i] = 0;
  for (int i = 0; i < S.length(); i++)
    alp[S[i]-'a'] = 1;
  for (int i = 0; i < 26; i++) {
    if (alp[i] == 0) {
      cout << (char)(97+i) << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}


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

int main(int argc, char const *argv[])
{
  int a, b;
  cin >> a >> b;
  if(a==b)
    cout << "a == b" << endl;
  else
    cout << (a > b ? "a > b" : "a < b") << endl;
  return 0;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
int x[110], y[110], h[110];
signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i] >> h[i];
    for (int i = 1; i < N; i++) if (h[i] != 0)swap(x[0], x[i]), swap(y[0], y[i]), swap(h[0], h[i]);
    for (int cx = 0; cx <= 100; cx++) {
        for (int cy = 0; cy <= 100; cy++) {
            int H = h[0] + abs(cx - x[0]) + abs(cy - y[0]);
            for (int i = 1; i < N; i++) {
                if (h[i] != max(0LL, H - abs(cx - x[i]) - abs(cy - y[i])))goto nene;
            }
            cout << cx << " " << cy << " " << H << endl;
            return 0;
nene:;
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 2000001
void CountingSort(int, int);
int A[MAX], B[MAX];
int main(){
        int n, i, k=0;
            scanf("%d", &n);
        for(i= 0; i<n; i++) {
                     scanf("%d", &A[i]);
                if(k<A[i]) k = A[i];
        }

        CountingSort(k, n);

        for(i = 1; i<=n; i++) {
                printf("%d", B[i]);
                if(i<n) printf(" ");
        }
printf("\n");
        return 0;
}
void CountingSort(int k, int n){
        int C[MAX], i;

        for(i = 0; i<=k; i++)   C[i] = 0;
        for(i = 0; i<n; i++)  C[A[i]]++;
        for(i = 1; i<=k; i++) C[i] = C[i] + C[i - 1];
        for(i = n-1; i>=0; i--) {
                B[C[A[i]]] = A[i];
                C[A[i]]--;
        }
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  int N;cin>>N;
  string S;cin>>S;
  vi wn(N),en(N);
  if(S[0]=='W'){wn[0]=1;en[0]=0;}
  else{ wn[0]=0;en[0]=1;}
  f(i,1,N){
    if(S[i]=='W'){
      wn[i]=wn[i-1]+1;
      en[i]=en[i-1];
    }
    else{
      en[i]=en[i-1]+1;
      wn[i]=wn[i-1];
    }
   
  }
  int mi=N+10;
  f(i,0,N){
    
    if(i==0){
      mi=min(en[N-1]-en[i],mi);     
    }
    else{
      mi=min(mi, wn[i-1]+en[N-1]-en[i]);
    }
    
  }
  cout<<mi<<endl;
}





Measured memory_bytes: 3076
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d,x;
    cin>>a>>b>>c>>d;
    while(true)
    {
        c-=b;
        if(c<=0)
        {
            x=1;
            break;
        }
        a-=d;
        if(a<=0)
        {
             x=2;
            break;

        }

    }
    if(x==2)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
}


Measured memory_bytes: 3040
from collections import deque

H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]
directions = [[0,1],[1,0],[0,-1],[-1,0]]

def f(h,w): #スタートが(h,w)
  if S[h][w] == '#':
    return 0
  else:
    d = [[-1]*W for i in range(H)]
    d[h][w] = 0
    
    q = deque([[h,w]])
    
    while q:
      nh,nw = q.pop()
      
      for dh,dw in directions:
        if not (0<=nh+dh<H and 0<=nw+dw<W):
          continue
        if S[nh+dh][nw+dw] == '#':
          continue
        if d[nh+dh][nw+dw] != -1:
          continue
        d[nh+dh][nw+dw] = d[nh][nw]+1
        q.appendleft([nh+dh,nw+dw])
     
    return max([max(i) for i in d])

a = 0
for h in range(H):
  for w in range(W):
    a = max(a,f(h,w))
    
print(a)

Measured memory_bytes: 3316
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
llfor;ll ans=0;////////////////////////////////////////////////////////////
ll n,k,a[300010];

ll f(ll c){//全ての木の高さをc以下にする
 ll x=0;
 rep(i,0,n)x+=(a[i]-1)/c;
return x;}


int main(){
 ll mx=0;
 cin>>n>>k;
 rep(i,0,n){
  cin>>a[i];
  mx=max(a[i],mx);
 }
 map<ll,bool>visited;
 ll now=mx;
 ll b1=0,b2;
 ll ans=llpow(2,30);
 rep(j,0,30){
  ll tmp=29-j;
 // cout<<j<<" "<<ans<<" "<<f(ans)<<" "<<tmp<<endl;
  if(f(ans)==k&&f(ans-1)>k)break;
  else if(f(ans-llpow(2,tmp))<=k)ans-=llpow(2,tmp);
 }
 pr(ans);
 
 return 0;}



Measured memory_bytes: 5132
n = gets.to_i
as = gets.split(nil, n).map(&:to_i)

while as.count != 1 do
  min = as.min
  flg = true
  as = as.map do |a|
    if a == min && flg
      flg = false
      a
    else
      a % min
    end
  end
  as = as.select {|a| a > 0 }
end

puts as.first


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

int main(){
    int a[3],b[3],c[3][3];
    int che = 0;
    
    for(int i = 0;i < 3;i++){
        cin >> c[i][0] >> c[i][1] >> c[i][2];
    }
    for(int i = 0;i < c[0][0]+1;i++,che = 0){
        a[0] = i;
        for(int k = 0;k < 3;k++){
            b[k] = c[0][k] - a[0];
        }
        for(int j = 1;j < 3;j++){
            if((c[j][0]-b[0]) == (c[j][1]-b[1]) && (c[j][1]-b[1]) == (c[j][2]-b[2])){
                a[j] = c[j][0] - b[0];
            } else ++che;
        }
        for(int l = 0;l < 3;l++){
            if(a[l] < 0 && b[l] < 0)++che;
        }
        if(che == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
from functools import lru_cache
import sys
def input():
    return sys.stdin.readline()[:-1]

def solve(N, A, B, C, D):
    @lru_cache(None)
    def f(N):
        if N == 0:
            return 0
        if N == 1:
            return D
        # すべて-1の遷移で0にしたケース
        ret = D * N

        q, r = divmod(N, 2)
        if r == 0:
            # 2で割り算
            ret = min(ret, f(q) + A)
        else:
            # -1して2で割り算、+1して2で割り算
            ret = min(ret, f(q) + A + D, f(q+1) + A + D)

        q, r = divmod(N, 3)
        if r == 0:
            # 3で割り算
            ret = min(ret, f(q) + B)
        elif r == 1:
            # -1して3で割り算
            ret = min(ret, f(q) + B + D)
        else:
            # +1して3で割り算
            ret = min(ret, f(q+1) + B + D)

        q, r = divmod(N, 5)
        if r == 0:
            # 5で割り算
            ret = min(ret, f(q) + C)
        elif r == 1:
            # -1して5で割り算
            ret = min(ret, f(q) + C + D)
        elif r == 2:
            # -2して5で割り算
            ret = min(ret, f(q) + C + D + D)
        elif r == 3:
            # +2して5で割り算
            ret = min(ret, f(q+1) + C + D + D)
        else:
            # +1して5で割り算
            ret = min(ret, f(q+1) + C + D)
        return ret
    return f(N)

T = int(input())
for _ in range(T):
    n,a,b,c,d = map(int, input().split())
    print(solve(n,a,b,c,d))

Measured memory_bytes: 119260
#include<stdio.h>
int main(void){
  int n;
  scanf("%d",&n);
  int a[n];
  long long y=0,z=0;
  long mod=1000000007;
  for(int i=0;i<n;i++){
	scanf("%d",&a[i]);
  }
  long long b=0,sum=0;
  for(int i=1;i<n;i++){
	b=(b+a[i-1])%mod;
    sum=(sum+a[i]*b)%mod;
  }
  printf("%lld",sum);
  
  return 0;
}

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

void solve() 
{
    int n;cin>>n;
    ll a[n];REP(i,n){cin>>a[i];a[i]--;}
    vector<ll>mp(n,0);
    REP(i,n)mp[a[i]]++;
    ll sum=0;
    REP(i,n)if(mp[i])sum+=mp[i]*(mp[i]-1)/2;
    REP(i,n){
        if(mp[a[i]]==0||mp[a[i]]==1)cout<<sum<<endl;
        else{
            ll x=mp[a[i]]-1;
            cout<<sum-mp[a[i]]*(mp[a[i]]-1)/2+x*(x-1)/2<<endl;
        }
    }
}

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

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define maxn 12850
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  int width,height;
  int arr1[82][82];
  int arr2[82][82];
  cin >> height >> width;
  for(int i=0;i<height;i++){
    for(int j=0;j<width;j++){
      cin >> arr1[i][j];
    }
  }
  for(int i=0;i<height;i++){
    for(int j=0;j<width;j++){
      cin >> arr2[i][j];
    }
  }
  bool dp[82][82][maxn+200];
  memset(dp,0,sizeof(dp));
  dp[0][0][0] = 1;
  for(int i=0;i<height;i++){
    for(int j=0;j<width;j++){
      int idk1 = abs((arr1[i][j]-arr2[i][j]));
      for(int k=0;k<maxn;k++){
        if(dp[i][j][k]==0){
          continue;
        }
        //i+1 j
        dp[i+1][j][k+idk1] = 1;
        dp[i+1][j][abs(k-idk1)] = 1;
        //i j+1
        dp[i][j+1][k+idk1] = 1;
        dp[i][j+1][abs(k-idk1)] = 1;
      }
    }
  }
  int diff = abs(arr1[height-1][width-1]-arr2[height-1][width-1]);
  int ans = INT_MAX;
  for(int i=0;i<maxn;i++){
    if(dp[height-1][width-1][i]==1){
      ans = min(ans,abs(i-diff));
      ans = min(ans,abs(i+diff));
    }
  }
  cout << ans;
}

Measured memory_bytes: 86144
a = [int(i) for i in input().split()]
list = []
for i in range(a[0]): list.append([])

for i in range(a[1]):
    cmd = [int(i) for i in input().split()]

    if cmd[0] == 0:
        list[cmd[1]].append(cmd[2])

    elif cmd[0] == 1:
        if list[cmd[1]] != []: print(list[cmd[1]][-1])

    elif cmd[0] == 2:
        if list[cmd[1]] != []: list[cmd[1]].pop()



Measured memory_bytes: 13440
# -*- coding: utf-8 -*-

def main():

    N = int(input())
    W = list(map(int, input().split()))

    absW = []

    for i in range(N):
        absW.append(abs(sum(W[:i + 1]) - sum(W[i + 1:])))

    ans = min(absW)

    print(ans)


if __name__ == "__main__":
    main()

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

int main() {
  int X, i, j;
  int A;
  int max;
  std::vector<int> v;
  std::cin >> X;
  for (i = 1; i <= X; i++) {
    j = 2;
    while(pow(i,j) <= X){
    A = pow(i, j);
    v.push_back(A);
    j++;
    if (i==1)
    break;
  }
  }
  max = *max_element(v.begin(), v.end());
  std::cout << max << endl;
  return 0;
}

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

using namespace std;

char d[]={'L','U','D','R'};

int main(){
    int h,w,n;
    cin >> h >> w >> n;
    int x,y;
    cin >> y >> x;
    int v[]={x,y,y,x};
    int ch[]={-1,-1,1,1};
    int lim[]={w,h,h,w};
    string a,b;
    cin >> a >> b;
    for(int i=0;i<4;i++){
        for(int j=0;j<n;j++){
            //cout << v[i] << endl;
            if(a[j]==d[i]){
                v[i]+=ch[i];
            }
            if(v[i]>lim[i] || v[i]<1){
                cout << "NO" << endl;
                return 0;
            }
            if(b[j]==d[3-i]){
                v[i]+=ch[3-i];
            }
            if(v[i]>lim[i]){
                v[i]--;
            }
            if(v[i]<1){
                v[i]++;
            }
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 776
#include <stdio.h>
#include <string.h>

main(){
	int N;
	int i;
	char str[500];
	char tmp[500];

	scanf("%d",&N);
	scanf("%s",str);

	int k=0;
	int zp=0;

	for(i=0;;i++){
		if(str[i]=='(')
			k++;
		else if(str[i]==')'){
			k--;
			if(k>0){
			}else if(k==0){
					zp=i+1;
			}else{
				zp=0;
				strcpy(tmp,&str[zp]);
				str[zp]='(';
				str[zp+1]='\0';
				strcat(str,tmp);
				k++;
				i++;
			}
		}else if(k){
			strcat(str,")");
			k--;
		}else{
			break;
		}
	}
	puts(str);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	int n, m, v;
	
	int di[1000];
	
	while(true){
		cin >> n >> m;
		if(n == 0 || m == 0){
			break;
		}
		for(int i = 0; i < m; i++){
			di[i] = 0;
		}
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				cin >> v;
				if(v == 1){
					di[j]++;
				}
			}
		}
		bool first = true;
		for(int i = n; i >= 0; i--){
			for(int j = 0; j < m; j++){
				if(di[j] == i){
					if(first){
						printf("%d", j + 1);
						first = false;
					}else{
						printf(" %d", j + 1);
					}
				}
			}
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 1152
#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        h: usize,
        w: usize,
        n: usize
    }
    let m = max(h, w);
    let k = n / m;
    let k1 = if n % m == 0 { 0 } else { 1 };
    println!("{}", k + k1);
}


Measured memory_bytes: 4352
import math
def P(n, r):
    return math.factorial(n)//math.factorial(n-r)
def C(n, r):
    return P(n, r)//math.factorial(r)
N, M = map(int, input().split())
if N > 1:
    ans1 = C(N,2)
else:
    ans1 = 0
if M > 1:
    ans2 = C(M,2)
else:
    ans2 = 0
print(ans1+ans2)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    string str;
    cin>>k>>str;
    if(str.size()<=k){
        cout<<str;
    }else{
    for(int i=0;i<k;i++)
    {
        cout<<str[i];
    }
    cout<<"...";

    }


    return 0;
}




Measured memory_bytes: 3572
n=int(input())
b=list(map(int,input().split()))
a=[0]*(n)
for i in range(n):
  if i == 0:
    a[i] = b[i]
  elif i==n-1:
    a[i] = b[i-1]
  else:
    a[i] = min(b[i],b[i-1])
 
    
print(sum(a))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std ;
#define ll long long 
#define pb push_back
#define in(x) int x; cin>>x;
#define ln(x) long long x; cin>>x;
#define memf(a) memset(a,false,sizeof(a))
#define F first
#define S second
#define endl "\n"
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
int main()
{
	fast
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans;
	ans=max({a*c,a*d,c*b,b*d});
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
const int N = 22;
int n,a[N][N];
int dp[1<<21],cnt[1<<21];
int main(){
	for(int i=0;i<1<<21;i++)for(int j=0;j<21;j++)if(i>>j&1)cnt[i]++;
	scanf("%d",&n);
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)scanf("%d",&a[i][j]);
	dp[0]=1;
	for(int i=0;i<1<<n;i++){
		for(int j=0;j<n;j++)if((i>>j&1)==0 && a[cnt[i]][j]) (dp[i|1<<j]+=dp[i])%=MOD;
	}
	cout << dp[(1<<n)-1] << endl;
}

Measured memory_bytes: 16640
#include<iostream>
#include<vector>
#include<string>
#define REP(i, j) for(int (i)=0; (i)<(j); ++(i))
using namespace std;

int main(){
  int H, W; cin >>H >>W;
  vector<string> v(H); REP(i, H) cin >>v[i];
  for(int i = 0; i < 2 * H; ++i){
    for(int j = 0; j < W; ++j){
      cout <<v[i/2][j];
    }
    cout <<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cassert>
#include <cctype>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <stdexcept>

std::set<int> apply(
    const std::set<int> &lhs, const std::set<int> &rhs, char op) {

  std::set<int> res;
  for (int lx: lhs)
    for (int rx: rhs) {
      if (op == '+') {
        res.insert((lx+rx)&255);
      } else if (op == '-') {
        res.insert((lx-rx)&255);
      } else if (op == '*') {
        res.insert((lx*rx)&255);
      } else if (op == '/') {
        if (rx == 0) throw std::logic_error("division by zero");
        res.insert(lx/rx);
      }
    }

  return res;
}

int main() {
  size_t m;
  scanf("%zu", &m);

  std::map<std::string, std::set<int>> vars;
  for (size_t i=0; i<m; ++i) {
    char buf[32];
    int lb, ub;
    scanf("%s %d %d", buf, &lb, &ub);
    std::string s=buf;
    std::set<int> tmp;
    for (int i=lb; i<=ub; ++i)
      tmp.insert(i);

    vars[s] = std::move(tmp);
  }

  size_t n;
  scanf("%zu", &n);
  std::stack<std::set<int>> st;
  for (size_t i=0; i<n; ++i) {
    char buf[32];
    scanf("%s", buf);
    std::string s=buf;
    if (isdigit(s[0])) {
      st.push({stoi(s)});
    } else if (isalpha(s[0])) {
      st.push(vars.at(s));
    } else {
      std::set<int> b=st.top();
      st.pop();
      std::set<int> a=st.top();
      st.pop();
      try {
        st.push(apply(a, b, s[0]));
      } catch (std::logic_error &e) {
        printf("error\n");
        return 0;
      }
    }
  }
  printf("correct\n");
}



Measured memory_bytes: 3068
#include <stdio.h>
int parent(int i)
{
  return i/2;
}
int left(int i)
{
  return 2*i;
}
int right(int i)
{
  return 2*i+1;
}


main()
{
  int T[250];
  int size,i;

  scanf("%d",&size);
  for(i=1;i<=size;i++)
    {
      scanf("%d",&T[i]);
    }

  for(i=1;i<=size;i++)
    {
      printf("node %d: key = %d, ",i,T[i]);
      if(parent(i)!=0)
	{
	  printf("parent key = %d, ",T[parent(i)]);
	}
      if(left(i)<=size)
	{
	  printf("left key = %d, ",T[left(i)]);
	}
      if(right(i)<=size)
	{
	  printf("right key = %d, ",T[right(i)]);
	}
      printf("\n");
    }
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define FIO {ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);}
#define ll long long int
#define vi vector<ll>
#define vpii vector<pair<ll,ll>>
#define mp make_pair
#define pb emplace_back
#define INF 1000000000000
#define mi map<int>
#define mii unordered_map<ll,ll>
#define line '\n'
#define F first
#define S second
 
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
	if (n & 1)
	  res = (res * x) % mod;
	x = (x * x) % mod;
	n >>= 1;
  }
  return res;
  }
  
  const int N=1e5;
  int parent[N];
  int find_parent(int node)
  {
    if(parent[node]<0)
       return node;

    return parent[node]= find_parent(parent[node]);
  }
   


  void join_them(int x,int y)
  {
    int k1=find_parent(x);
    int k2=find_parent(y);

   if(k1!=k2)
   {
      parent[k1]+=parent[k2];
      parent[k2]=k1;
   }
   else
     return;
  }
  int main()
  {
    //okay This is #665 Div 2 ..i learned how to solve this using DSU 
    //to solve it with DSU we want all to be in a single connected 
    //component and later we will simply check if they belong to same parent or not
    FIO;
    ll n,x,t;
    cin>>n>>x>>t;
    ll t1= ceil((float)n/x);
    cout<<t1*t;
  }

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * Created by hwzheng on 2017/3/26.
 */
public class Main {
    public static void main(String[] args) throws Exception{
        BufferedReader Reader = new BufferedReader (new InputStreamReader(System.in));
        int j=0;
        int N = Integer.parseInt(Reader.readLine());
        String A[] = Reader.readLine().split(" ",0);
        int[] arr = new int[N];
        for (int i=0; i < N; i++){
            arr[i] = Integer.parseInt(A[i]);
        }
        insertionSort(arr,N);
    }

    private static void insertionSort(int[] arr, int n) {
        for (int i = 0; i < n; i++){
            int v = arr[i];
            int j = i - 1;
            while (j >= 0 && arr[j] > v){
                arr[j + 1] = arr[j];
                j--;
            }
            arr[j + 1] = v;
            String s = "";
            for (int anArr : arr) {
                s = s + anArr + " ";
            }
            System.out.println(s.trim());
        }
    }
}

Measured memory_bytes: 43596
var x = require('fs').readFileSync('/dev/stdin', 'utf8');
x = x.toLowerCase();
x = x.replace(/\s+/g, "");
var alphabet = "abcdefghijklmnopqrstuvwxyz";
alphabet = alphabet.split("");
alphabet.forEach((a, i) => {
  	var j = 0;
	for(var k=0; k<x.length;k++)
    {
      if(a === x[k])
      {j++;}
    }
  	console.log(a + " : " + j);
})


Measured memory_bytes: 15320
import java.util.*;


public class Main{
    public static void main(String[] args) throws Exception{
        
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();//3
        int sum_number = 0;

        int[] numbers = {1,0,-1};
        int[] cards = {a,b,c}; //2,1,1

        for(int i = 0; i<=2; i++){
            if(cards[i]<=k){
                sum_number = sum_number + (numbers[i] * cards[i]);
                k = k - cards[i];

            }else{
                sum_number = sum_number + (numbers[i] * k);
                break;
            }
        }
        System.out.println(sum_number);
        return;
    }    
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

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


int main()
{
    int n,m;cin >> n >> m;
    vector<int> a(n);rep(i,n)cin >> a[i];
    map<int, int> amari;
    amari[0] = 1;
    int ruiseki = 0;
    ll ans = 0;
    rep(i,n)
    {
        ruiseki += a[i];
        ruiseki %= m;
        if(amari.count(ruiseki)) 
        {
            ans += (ll)amari[ruiseki];
            amari[ruiseki]++;
            continue;
        }
        amari[ruiseki] = 1;

    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
import java.util.*;

public class Main {
  public static void main(final String[] args) throws Exception {
    final Scanner scanner = new Scanner(System.in);
    try {
      final int n = scanner.nextInt();
      final int h = scanner.nextInt();
      final int w = scanner.nextInt();

      int ans = 0;
      for (int i = 0; i < n; i++) {
        final int a = scanner.nextInt();
        final int b = scanner.nextInt();
        if (h <= a && w <= b) ans++;
      }

      System.out.print(ans);
    } finally {
      scanner.close();
    }
  }
}


Measured memory_bytes: 25800
from collections import deque

class SlideMin:
    """
    スライド最小値\n
    各区間[ai, ai+leng]の最小値を取得する：O(n)\n
    self.que = [(i1, v1), (i2, v2), ..., (ik, vk)]\n
    i1 < ... < ik and v1 < ... < vk
    """
    def __init__(self, leng):
        self.que = deque([])
        self.leng = leng

    def top(self):
        return self.que[0]

    def getQue(self):
        return self.que

    def update(self, index, value):
        while self.que:
            if self.que[-1][1] >= value:
                self.que.pop()
            else:
                break

        self.que.append((index, value))

        if self.que[0][0] == index - self.leng:
            self.que.popleft()

N, X = map(int, input().split())
A = list(map(int, input().split()))

def sol(n):
    # n個前までの最小値
    B = A + A
    que = SlideMin(n + 1)
    ret = [10**18] * N
    for i, a in enumerate(B):
        que.update(i, a)
        ret[i % N] = min(ret[i % N], que.top()[1])
    return sum(ret) + n * X

ans = sum(A)
for i in range(N):
    ans = min(ans, sol(i))
print(ans)


Measured memory_bytes: 73948
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <regex>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

int main() {
	int N;
	int SN = 0;
	string S;

	cin >> S;

	N = stoi(S);
	for (int i = 0; i < S.length(); i++) {
		SN += S[i] - '0';
	}

	if (N % SN == 0)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
H, W = map(int, input().split())
S = [list(input())[: -1] for _ in range(H)]
d = [-1, 0, 1, 0]
for i in range(H):
  for j in range(W):
    if S[i][j] == ".": continue
    t = 0
    for k in range(4):
      y = i + d[k]
      x = j + d[-1 - k]
      if y in range(H) and (x in range(W)):
        t += S[y][x] == "#"
    if t: continue
    print("No")
    exit(0)
print("Yes")

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int n;
	string s;
	cin>>n>>s;
	if(n % 2 == 1){printf("No\n");}
	else{
		string satu = s.substr(0,n/2);
		string dua = s.substr(n/2, n/2);
		if(satu == dua){printf("Yes\n");}
		else{printf("No\n");}
	}
	return 0;
};

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class ETwoCurrencies {
public:

    vector<P> graph[500000];
    vector<P> fare;

    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, m, s; cin >> n >> m >> s;
      rep(i, m) {
        int u, v, a, b; cin >> u >> v >> a >> b;
        u--; v--;
        for(int j=0; j<5000; j++) {
          if (j-a >= 0) {
            graph[u*5000+j].emplace_back(v*5000+j-a, b);
            graph[v*5000+j].emplace_back(u*5000+j-a, b);
          }
        }
      }
      vector<int> c(n), d(n);
      rep(i, n) {
        cin >> c[i] >> d[i];
      }

      rep(i, n) {
        for(int j=0; j<5000; j++) {
          graph[i*5000+j].emplace_back(i*5000+min(j+c[i], 4999), d[i]);
        }
      }

      chmin(s, 4999);
      vector<ll> dp(500000, LLONG_MAX/2);

      priority_queue<P, vector<P>, greater<>> que;
      dp[s] = 0;
      que.emplace(0, s);

      while(!que.empty()) {
        auto pa = que.top(); que.pop();
        auto cost = pa.first;
        auto u = pa.second;
        if (cost > dp[u]) continue;

        for(auto e: graph[u]) {
          if (cost + e.second < dp[e.first]) {
            dp[e.first] = cost + e.second;
            que.emplace(dp[e.first], e.first);
          }
        }
      }

      vector<ll> ans(n, LLONG_MAX);

      for(int i=1; i<n; i++) {
        rep(j, 5000) {
          chmin(ans[i], dp[i*5000+j]);
        }
        cout << ans[i] << '\n';
      }

    }
};

signed main() {
  ETwoCurrencies solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 52232
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    int n, k;
    cin >> n >> k;
    int ans = k;
    rep(i, n - 1) {
        ans *= (k - 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from sys import stdin
K = int(stdin.readline().rstrip())
ans = list(range(1,11))
def f(n):
    if int(n) > 3234566667:
        return
    #elif len(n) > 10:
    #    return
    elif n[0] == "0":
        return

    for i in range(10):
        if abs(int(n[-1])-i) <= 1:
            if int(n+str(i)) > 3234566667:
                return
            ans.append(int(n+str(i)))
            
            f(n+str(i))
    
for i in range(1,10):
    f(str(i))
    
print(sorted(set(ans))[K-1])

Measured memory_bytes: 13252
import java.util.Scanner;

/**
 * @Author oreid
 * @Release 04/12/2016
 */
public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        scanner.next();
        String x = scanner.next();

        scanner.close();

        System.out.println("A"+ x.charAt(0) + "C");
    }
}


Measured memory_bytes: 10068
import java.util.Scanner;

public class Main{


	public static void main(String args[]){

		Scanner s=new Scanner(System.in);

		int d = s.nextInt();
		int n = s.nextInt();

		int[] temp  = new int[d];	//気温
		int[] a = new int[n];		//気温の範囲
		int[] b = new int[n];
		int[] c = new int[n];		//派手さ

		for(int i=0; i<d; i++) {
			temp[i] = s.nextInt();
		}

		for(int i=0; i<n; i++) {
			a[i] = s.nextInt();
			b[i] = s.nextInt();
			c[i] = s.nextInt();
		}

		int[][] dp = new int[d][n];	//初期化
		for(int i=0; i<d; i++) {
			for(int j=0; j<n; j++) {
				dp[i][j] = -1;
			}
		}

		//初日に着れる服
		for(int i=0; i<n; i++) {
			if(a[i] <= temp[0] && b[i] >= temp[0]) dp[0][i]=0;
		}


		for(int i=1; i<d; i++) {
			for(int j=0; j<n; j++) {

				if(a[j]<= temp[i] && b[j] >= temp[i]) {	//着る服
					for(int k=0; k<n; k++) {
						if(dp[i-1][k]<0)continue;		//前日に着た服かどうか
						dp[i][j] = Math.max(dp[i][j], dp[i-1][k]+Math.abs(c[j]-c[k]));	//前日どの服のときが一番最大か
					}
				}
			}
		}

		int ans = 0;
        for (int i = 0; i < n; ++i) {
            ans = Math.max(ans, dp[d - 1][i]);
        }
        System.out.println(ans);
	}
}



Measured memory_bytes: 30208
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = int.Parse(Console.ReadLine());
            while(true)
            {
                if(IsPrime(x) == true)
                {
                    Console.WriteLine(x);
                    break;
                }
                else
                {
                    x++;
                }
            }
        }

        public static bool IsPrime(int num)
        {
            if (num < 2) return false;
            else if (num == 2) return true;
            else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

            double sqrtNum = Math.Sqrt(num);
            for (int i = 3; i <= sqrtNum; i += 2)
            {
                if (num % i == 0)
                {
                    // 素数ではない
                    return false;
                }
            }

            // 素数である
            return true;
        }
    }
}


Measured memory_bytes: 11092
N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

positives = [a for a in A if a > 0]
negatives = [a for a in A if a < 0]
positive_cnt = len(positives)
negative_cnt = len(negatives)
zero_cnt = A.count(0)


if min(2 * (negative_cnt // 2), 2 * (K // 2)) + positive_cnt >= K:
    # 答えが正になる場合
    positives = sorted(positives, reverse=True)
    negatives = sorted(negatives)

    positives_twin = [positives[2 * i] * positives[2 * i + 1] for i in range(positive_cnt // 2)] + [0]
    negatives_twin = [negatives[2 * i] * negatives[2 * i + 1] for i in range(negative_cnt // 2)] + [0]
    positives_twin.sort()
    negatives_twin.sort()

    ans = 1
    positive_select = 0
    for i in range(K // 2):
        if positives_twin[-1] <= negatives_twin[-1]:
            ans *= negatives_twin[-1]
            ans %= MOD
            negatives_twin.pop()
        else:
            ans *= positives_twin[-1]
            ans %= MOD
            positives_twin.pop()
            positive_select += 1

    if K % 2 == 1:
        if K == 1:
            ans = positives[2 * positive_select]
        else:
            ans *= positives[2 * positive_select]
    print(ans % MOD)

elif zero_cnt > 0:
    # 答えが０になる場合
    print(0)
else:
    # 答えが負になる場合
    ans = 1
    A_abs = sorted([abs(a) for a in A])
    for a in A_abs[:K]:
        ans *= a
        ans %= MOD
    ans = -ans % MOD
    print(ans)


Measured memory_bytes: 111216
s = list(input())
n = len(s)
c = 0
ans = "Yes"

for i in range(n):
  for j in range(n):
    if s[i] == s[j]:
      c += 1
  if c%2 != 0:
    ans = "No"
    break
  c = 0

print(ans)


Measured memory_bytes: 64368
#include<bits/stdc++.h>
using namespace std;
string a;
int main()
{
    cin>>a;
    for(register int i=0;i<a.size();i++)
    {
        if(a[i]=='C')
        {
            for(register int j=i+1;j<a.size();j++)
            {
                if(a[j]=='F')
                {
                    printf("Yes");
                    return 0;
                }
            }
        }
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
int n;
int parent[N];
vector < int > v[N];
deque < pair < int , pair < int , int > > > val[N];
int mx;
void merge(int node , int child){
	for(int i = 0 ; i < val[child].size() ; ++i){
		int azero = val[node][i].first;
		int aone = val[node][i].second.first;
		int atwo = val[node][i].second.second;
		int bzero = val[child][i].first;
		int bone = val[child][i].second.first;
		int btwo = val[child][i].second.second;
		int suma = (1LL * azero + aone + 1LL * atwo) % mod;
		int sumb = (1LL * bzero + bone + 1LL * btwo) % mod;
		val[node][i].first = (1LL * azero * bzero) % mod;
		val[node][i].second.first = (1LL * azero * bone + 1LL * aone * bzero) % mod;
		val[node][i].second.second = (((1LL * suma * sumb - val[node][i].first - val[node][i].second.first) % mod) + mod) % mod;
	}
	mx = max(int(val[child].size()) , mx);
}
void dfs(int node){
	for(int next : v[node]){
		dfs(next);
	}
	int big = -1;
	for(int next : v[node]){
		if(big == -1 || val[next].size() > val[big].size()){
			big = next;
		}
	}
	if(big != -1){
		val[node].swap(val[big]);
	}
	mx = 0;
	for(int next : v[node]){
		if(next != big){
			merge(node , next);
		}
	}
	for(int i = 0 ; i < mx ; ++i){
		val[node][i].first = (val[node][i].first + val[node][i].second.second) % mod;
		val[node][i].second.second = 0;
	}
	val[node].push_front(make_pair(1 , make_pair(1 , 0)));
}
int power[N];
int depth[N];
int cnt[N];
int main(){
	scanf("%d" , &n);
	for(int i = 1 ; i <= n ; ++i){
		scanf("%d" , &parent[i]);
		v[parent[i]].emplace_back(i);
	}
	dfs(0);
	int ans = 0;
	power[0] = 1;
	for(int i = 1 ; i <= n ; ++i){
		power[i] = (power[i - 1] << 1) % mod;
	}
	depth[0] = 0;
	for(int i = 1 ; i <= n ; ++i){
		depth[i] = depth[parent[i]] + 1;
	}
	for(int i = 0 ; i <= n ; ++i){
		++cnt[depth[i]];
	}
	for(int i = 0 ; cnt[i] ; ++i){
		ans = (ans + 1LL * val[0][i].second.first * power[n + 1 - cnt[i]]) % mod;
	}
	printf("%d\n" , ans);
}

Measured memory_bytes: 239348
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use std::collections::HashSet;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let x: usize = read!();

    solve(x);
}

fn solve(x: usize) {
    let mut v = HashSet::new();
    v.insert(1);

    for i in 2..=x {
        let mut j = 2;
        while x >= i.pow(j) {
            v.insert(i.pow(j));
            j += 1;
        }
    }

    println!("{}", v.iter().max().unwrap());
}


Measured memory_bytes: 2140
import java.util.*;
import java.text.*;

class Main {
    public static void main(String[]args)throws Exception {
        Scanner sc = new Scanner(System.in);
        String w = sc.next().toLowerCase();
        int c = 0;
        while(sc.hasNext()) {
            String v = sc.next().toLowerCase();
            if(w.equals(v)) c++;
        }
        System.out.println(c);
    }
}

Measured memory_bytes: 18156
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    int N[5], i, a;

    for(i=1; i<=4; i++){
        cin >> N[i];
    }

    sort(N+1, N+5);

    a = N[1]*1000+N[2]*100+N[3]*10+N[4];

    if(a==1479){
        cout << "YES" << endl;
    }

    else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string haha;
  cin >> haha;
  int N = haha.size();
  vector<char> before(ceil(N / 2)), after(ceil(N / 2));
  int M = before.size();
  for (int i = 0; i < M; i++){
    before.at(i) = haha.at(i);
    after.at(i) = haha.at(N - i - 1);
  }
  vector<char> first_quarter(ceil(M / 2)), second_quarter(ceil(M / 2)), third_quarter(ceil(M / 2)),fourth_quarter(ceil(M / 2));
  int L = first_quarter.size();
  for(int i = 0; i <  L; i++){
    first_quarter.at(i) = before.at(i);
    second_quarter.at(i) = before.at(M - i - 1);
    third_quarter.at(i) = after.at(i);
    fourth_quarter.at(i) = after.at(M - i - 1);
  }
 if(after == before && first_quarter == second_quarter && third_quarter == fourth_quarter){
   cout << "Yes";
 }
  else{
    cout << "No";
  }
}


Measured memory_bytes: 256
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

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

@njit((i8[:], ), cache=True)
def build(raw_data):
    bit = raw_data.copy()
    for i in range(len(bit)):
        j = i + (i & (-i))
        if j < len(bit):
            bit[j] += bit[i]
    return bit


@njit((i8[:], i8), cache=True)
def get_sum(bit, i):
    s = 0
    while i:
        s += bit[i]
        i -= i & -i
    return s


@njit((i8[:], i8, i8), cache=True)
def add(bit, i, x):
    while i < len(bit):
        bit[i] += x
        i += i & -i


@njit((i8[:], i8), cache=True)
def find_kth_element(bit, k):
    N = len(bit)
    x, sx = 0, 0
    dx = 1
    while 2 * dx < N:
        dx *= 2
    while dx:
        y = x + dx
        if y < N:
            sy = sx + bit[y]
            if sy < k:
                x, sx = y, sy
        dx //= 2
    return x + 1

@njit((i8[:], i8[:]), cache=True)
def main(X, TAB):
    bit = build(X)
    for i in range(0, len(TAB), 3):
        t, a, b = TAB[i:i + 3]
        if t == 0:
            add(bit, a + 1, b)
        else:
            x = get_sum(bit, b) - get_sum(bit, a)
            print(x)

N, Q = map(int, readline().split())
X = np.array([0] + readline().split(), np.int64)
TAB = np.array(read().split(), np.int64)

main(X, TAB)

Measured memory_bytes: 193128
import java.util.*;
public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt(); 
      int b = sc.nextInt(); 

        
        for(int i = 0; i <= a ; i++ ){
            for(int j = 0; j <= (a-i) ; j++){
                for(int k = 0; k <= (a-i-j) ; k++){
                    if(10000 * i + 5000 * j + 1000 * k == b && i + j + k == a){
                        System.out.println(i+" "+j+" "+k);
                        return;
                    }
                }
            }
        } 
        System.out.println("-1 -1 -1");    
  }    
}

Measured memory_bytes: 39496
#include <bits/stdc++.h>  
#include <memory>
using namespace std;  
#define INF 0x3f3f3f3f  
typedef long long ll;  
const int N =  10005;  
const int M = 101;
#define FI first
#define SE second
typedef pair<int, int>pii;
int mod = 1000000007;
ll rec[N];
int main()  
{  

   // ios::sync_with_stdio(0);
   int n;
   while (~scanf("%d", &n))
   {
      for (int i = 0;i < n; i++)
         cin >> rec[i];
      ll pre = rec[0];
      for (int i = 1; i < n; i++)
      {
         ll tmp = __gcd(pre, rec[i]);
         pre = pre/tmp*rec[i];
      }
      cout<<pre<<endl;
   }
   return 0;
}  

Measured memory_bytes: 256