akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

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

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 2e5;
int h, w, k;
bool b[6][6];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> h >> w >> k;
  FOR(i, 0, h){
    string s;
    cin >> s;
    FOR(j, 0, w) b[i][j] = s[j]=='#';
  }
  int ans = 0;
  FOR(bh, 0, bit(h)) FOR(bw, 0, bit(w)){
    int c = 0;
    FOR(i, 0, h)if(bh&bit(i))FOR(j, 0, w)if(bw&bit(j)) if(b[i][j]) c++;
    if(c==k) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

int score[3][100001]={};

int tf(char c){
  switch(c){
    case 'r':return 0;
    case 's':return 1;
    case 'p':return 2;
    default: return -1;
  }
}

bool win(int my,int opp){
  if(my - opp == -1){
    return true;
  }if(my - opp == 2){
    return true;
  }else{
    return false;
  }
}

int ma(int i, int disc = -1){
  int hi = -1;
  LOOP(j,3){
    if(j==disc) continue;
    hi = max(hi, score[j][i]);
    // cerr << score[j][i] << "-";
  }//cerr << " ";
  return hi;
}

signed main(){
  int n,k;
  int sc[3]={};
  cin >> n >> k;
  cin >> sc[0] >> sc[1] >> sc[2];
  string s;
  cin >> s;

  LOOP(i,n){
    if(i<k){
      //
      LOOP(j,3){
        //出す手を選ぶ
        // score[j][i+1] = ma(i);
        if( win(j, tf(s[i]) ) ){
          //win
          score[j][i] = sc[j];
        }
      }
    }else{
      LOOP(j,3){
        score[j][i] = ma(i-k, j);
        // cerr << ma(i-k, j) << " ";

        if( win(j, tf(s[i]) ) ){
          //win
          score[j][i] += sc[j];
        }
      }
    }//cerr << endl;
  }

  // LOOP(j,3){
  //   LOOP(i,n){
  //     // cerr << score[j][i] << " ";
  //   }//cerr << endl;
  // }
  int score = 0;
  LOOP(i,k){
    score += ma(n-i-1);
  }cout << score << endl;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define N 1010
#define ll long long
const ll mod=1e9+7;

int n,m,s1,s2,cnt;
int a[N],b[N],h[N*N],l[N*N];
ll ans=1;

int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		if (h[a[i]]) return puts("0"),0;
		h[a[i]]=i;
	}
	for (int i=1;i<=m;i++) {
		scanf("%d",&b[i]);
		if (l[b[i]]) return puts("0"),0;
		l[b[i]]=i;
	}
	
	for (int i=n*m;i;i--) {
		if (h[i] && l[i]) s1++,s2++; else
		if (h[i] || l[i]) {
			if (h[i]) ans=ans*s2%mod,s1++;
			else ans=ans*s1%mod,s2++;
		} else
		ans=ans*(s1*s2-(n*m-i))%mod,cnt++;
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;
using ll = long long;

vector<pair<int,int>> dir{{1,1},{1,0},{0,1},{-1,-1},{0,-1},{-1,0},{1,-1},{-1,1}};
int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<char>> mp(h + 2, vector<char>(w + 2)) ;
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++)cin >> mp[i][j];
    }

    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            int cnt = 0;
            if(mp[i][j] == '#')continue;
            for(auto k : dir){
                if(mp[i + k.first][j + k.second] == '#')cnt++;
            }
            mp[i][j] = cnt + '0';
        }
    }

    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++)cout << mp[i][j];
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
using namespace std;
const int INF = 1e18;

#define A 0
#define B 1
#define C 2

void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int a[n], b[n], c[n];
    rep(i, n)
    {
        cin >> a[i] >> b[i] >> c[i];
    }

    int dp[3][100010];
    memset(dp, 0, sizeof(dp));

    for (int i = 0; i < n; i++)
    {
        if (i == 0)
        {
            dp[A][i] = a[i];
            dp[B][i] = b[i];
            dp[C][i] = c[i];
        }
        else
        {
            dp[A][i] = max(dp[B][i - 1] + a[i], dp[C][i - 1] + a[i]);
            dp[B][i] = max(dp[A][i - 1] + b[i], dp[C][i - 1] + b[i]);
            dp[C][i] = max(dp[A][i - 1] + c[i], dp[B][i - 1] + c[i]);
        }
    }

    cout << max({dp[0][n - 1], dp[1][n - 1], dp[2][n - 1]}) << endl;
}

signed main()
{
    solve();
    return 0;
}


Measured memory_bytes: 4992
/*
Author: QAQ-Automaton
LANG: C++
PROG: a.cpp
Mail: cnyalilk@vip.qq.com
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define all(x) x.begin(),x.end()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const signed inf=0x3f3f3f3f;
const double eps=1e-8;
const double pi=acos(-1.0);
template<class T>int chkmin(T &a,T b){return a>b?a=b,1:0;}
template<class T>int chkmax(T &a,T b){return a<b?a=b,1:0;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
template<class T>int dcmp(T a,T b){return a>b;}
template<int *a>int cmp_a(int x,int y){return a[x]<a[y];}
#define min mmin
#define max mmax
#define abs aabs
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	inline void read (signed &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
	}

	inline void read (long long &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
	}
	inline void read (char &x) {
		x=gc();
	}
	inline void read(char *x){
		while((*x=gc())=='\n' || *x==' '||*x=='\r');
		while(!(*x=='\n'||*x==' '||*x=='\r'))*(++x)=gc();
		*x=0;
	}
	template<typename A,typename ...B>
	inline void read(A &x,B &...y){
		read(x);read(y...);
	}
	// print a signed integer
	inline void write (signed x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}

	inline void write (long long x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	inline void write (char x) {
		putc(x);
	}
	inline void write(const char *x){
		while(*x){putc(*x);++x;}
	}
	inline void write(char *x){
		while(*x){putc(*x);++x;}
	}
	template<typename A,typename ...B>
	inline void write(A x,B ...y){
		write(x);write(y...);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: read;
using io :: putc;
using io :: write;
int main(){
#ifdef QAQAutoMaton 
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
#endif
	int a,b,c;
	read(a,b,c);
	chkmin(c,a+b+1);
	write(b+c,'\n');
	return 0;
}



Measured memory_bytes: 2304
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc159/tasks/abc159_f>
 問題文============================================================
 F - Knapsack for All Segments
 =================================================================
 解説=============================================================
 ================================================================
 */

constexpr ll MOD = 998244353;
template<class Type>
Type solve(Type res = Type()){
    int N,S; cin >> N >> S;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    
    auto dp = make_v<ll>(N+1,S+1,3);
    dp[0][0][0] = 1;
    auto update = [&](ll& l,ll r){
        r %= MOD;
        l += r;
        l %= MOD;
    };
    for(int i = 0; i < N;i++){
        for(int j = 0; j <= S; j++){
            update(dp[i+1][j][0],dp[i][j][0]);
            update(dp[i+1][j][1],dp[i][j][0] + dp[i][j][1]);
            update(dp[i+1][j][2],dp[i][j][0] + dp[i][j][1] + dp[i][j][2]);
            
            if(j + A[i] <= S){
                update(dp[i+1][j+A[i]][1],dp[i][j][0] + dp[i][j][1]);
                update(dp[i+1][j+A[i]][2],dp[i][j][0] + dp[i][j][1]);
            }
        }
    }
    res = dp[N][S][2];
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

int main(){
  long long n; cin >> n;
  
  long long i = 0;
  for(long long j = 1; j <= sqrt(n); j++) i++;
  bool flag = false;
  //cout << i << endl;
  while(!flag){
  
  	if(n%i==0) flag = true;
  
    if(flag) break;
  	i--;
  
  }
  
  cout << i-1 + n/i -1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	int N,M;
	cin >> N >> M;
	int X[M];
	REP(i,M){
		cin >> X[i];
	}
	sort(X,X+M);
	int d[M-1];
	REP(i,M-1){
		d[i] = X[i+1]-X[i];
	}
	sort(d,d+M-1);
	int sum = 0;
	FOR(i,0,M-N-1){
		sum += d[i];
	}
	println(sum);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<pair<int, int> > >edge(n + 3);
    vector<vector<int> >rails(n + 3);
    for(int i = 1; i <= m; i++){
        int u, v, c;
        cin >> u >> v >> c;
        edge[u].push_back({c, v});
        edge[v].push_back({c, u});
        rails[u].push_back(c);
        rails[v].push_back(c);
    }
    for(int i = 1; i <= n; i++){
        sort(edge[i].begin(), edge[i].end());
    }
    deque<pair<int, pair<int, int> > >dq;
    vector<map<int, int> >mp(n + 3);
    mp[1][0] = 0;
    dq.push_back({0, {1, 0}});
    while(!dq.empty()){
        int d = dq.front().first;
        int now = dq.front().second.first;
        int rail = dq.front().second.second;
        dq.pop_front();
        if(rail == 0){
            for(int i = 0; i < rails[now].size(); i++){
                int nrail = rails[now][i];
                if(mp[now].find(nrail) != mp[now].end() && mp[now][nrail] <= d + 1){
                    continue;
                }
                mp[now][nrail] = d + 1;
                dq.push_back({d + 1, {now, nrail}});
            }
        }
        else{
            pair<int, int>p = make_pair(rail, 0);
            int x = lower_bound(edge[now].begin(), edge[now].end(), p) - edge[now].begin();
            while(x != edge[now].size() && edge[now][x].first == rail){
                int nxt = edge[now][x].second;
                if(mp[nxt].find(rail) != mp[nxt].end() && mp[nxt][rail] <= d){
                    x++;
                    continue;
                }
                mp[nxt][rail] = d;
                dq.push_front({d, {nxt, rail}});
                x++;
            }
            if(mp[now].find(0) != mp[now].end() && mp[now][0] <= d){
                continue;
            }
            mp[now][0] = d;
            dq.push_front({d, {now, 0}});
        }
    }
    if(mp[n].empty()){
        cout << "-1";
        return 0;
    }
    int ans = 1e8;
    for(int i = 0; i < rails[n].size(); i++){
        int x = rails[n][i];
        ans = min(ans, mp[n][x]);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 47288
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x, y;
	cin >> x >> y;

	string ans="No";
	if(y%2==1) ans="No";
	else if(4*x-y>=0 && -2*x+y>=0) ans="Yes";

	cout << ans << endl;

}

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


int main(){
  ll N, M;
  cin >> N >> M;
  
  vector<ll> A(N);
  rep(i,N) cin >> A.at(i);
  
  vector<ll> B(M); vector<ll> C(M);
  rep(i,M) cin >> B.at(i) >> C.at(i);
  
  //sort(A.begin(), A.end(), greater<int>());
  //sort(CB.begin(), CB.end(), greater<int>());
  
  vector<pair<ll, ll>> AC;
  rep(i, M) AC.push_back(make_pair(C.at(i), B.at(i)));
  rep(i, N) AC.push_back(make_pair(A.at(i), 1));
  sort(AC.begin(), AC.end());
  
  ll i = N;
  ll j = AC.size() - 1;
  ll res = 0;
  
  while(i >= 0){
    if(i >= AC.at(j).second){
      res += AC.at(j).first * AC.at(j).second;
      i -= AC.at(j).second;
      j--;
    }else{
      res += AC.at(j).first * i;
      i = 0;
    }
  if(i <= 0) break;
    //cout << i << " " << res << endl;
  }
  
  //rep(i, AC.size()) cout << AC.at(i).first << " " << AC.at(i).second << endl;
  cout << res;  
  
  
  
  
  
  
}

Measured memory_bytes: 8816
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = a[::-1]

ans = 0
for left in range(n+1):
    for right in range(n+1):
        if left + right > k or left+right > n:
            break
        operate = k - left - right
        v = a[:left] + b[:right]
        v.sort(reverse=True)
        for _ in range(operate):
            if len(v) == 0 or v[-1] >= 0:
                break
            v.pop()
        ans = max(ans, sum(v))

print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		System.out.println(n % 2 == 0 ? n / 2 : n / 2 + 1);
	}
}


Measured memory_bytes: 35592
h,w=map(int,input().split())
a=['.'*(w+2)]
for i in range(h):
  a.append('.'+input()+'.')
a.extend(['.'*(w+2)])
flg=0
for i in range(1,h+1):
  for j in range(1,w+1):
    if a[i][j] == '#':
      if a[i-1][j] == '.' and a[i][j-1] == '.' and a[i+1][j] == '.' and a[i][j+1] == '.':
        flg = 1
if flg == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;



template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();
void solution();
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

void solution(){
    set<int> nums;
    int mat[3][3];
    from(i, 3){
        from(j, 3){
            cin >> mat[i][j];
        }
    }

    int n;
    cin >> n;
    from(i, n){
        int tmp;
        cin >> tmp;
        nums.insert(tmp);
    }

    bool ans = false;
    from(i, 3){
        int cnt = 0;
        from(j, 3){
            if(nums.count(mat[i][j])){
                mat[i][j] = 0;
                cnt++;
            }
        }

        if(cnt == 3) ans = true;
    }

    from(j, 3){
        int cnt = 0;
        from(i, 3){
            if(mat[i][j] == 0){
                cnt++;
            }
        }
        if(cnt == 3) ans = true;
    }

    if(mat[0][0] == 0 && mat[1][1] == 0 && mat[2][2] == 0) ans = true;
    if(mat[0][2] == 0 && mat[1][1] == 0 && mat[2][0] == 0) ans = true;

    if(ans) cout << "Yes"<< endl;
    else cout << "No" << endl;
}   

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
vector<int> T[100010];
int N, K;
int dfs(int u, int p) {
    int ret = 1;
    int cnt = K - 2;
    if(p == -1) cnt++;
    for(auto to: T[u]) {
        if(to == p) continue;
        ret = (ret * dfs(to, u)) % mod;
        ret = (ret * cnt) % mod;
        cnt = max(cnt - 1, 0LL);
    }
    //cout << u << " " << ret << endl;
    return ret;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        T[a].push_back(b);
        T[b].push_back(a);
    }
    cout << (dfs(0, -1) * K) % mod << endl;

    return 0;
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<int,int> p;

int n;
int a[200200];

int main(){
  cin >> n;
  rep(i,0,n)cin >> a[i];
  int b[n];
  if(n%2==0){
    rep(i,0,n){
      int k = i/2;
      if(i%2==0)b[n/2 + k] = a[i];
      else b[n/2 - (k+1)] = a[i];
    }
  }else{
    rep(i,0,n){
      int k= i/2;
      if(i%2==0)b[n/2 - k] = a[i];
      else b[n/2 + (k+1)] = a[i];
    }
  }
  rep(i,0,n)cout << b[i] << ' ';
  cout << endl;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
  int n;
  string s;
  cin >> n >> s;

  if (n % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }
  
  n /= 2;
  string a = s.substr(0, n);
  string b = s.substr(n, n);

  if (a == b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
} 

Measured memory_bytes: 256
//2018-1-26
//miaomiao
//
#include <bits/stdc++.h>
using namespace std;
 
#define LL long long
#define pb push_back
#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
 
#define N (100000+5)
 
int rt, dig[N];
LL f[N], a[N];
vector<int> G[N];
 
#define v G[now][i]
 
LL Dfs(int now, int F){
	if(G[now].size() == 1) return a[now];

	LL sum = 0, mx = 0;
	For(i, 0, G[now].size() - 1){
		if(v == F) continue;

		LL res = Dfs(v, now);
		if(res < 0) return -1;

		sum += res; mx = max(mx, res);
	}

	if(sum - a[now] < 0) return -1;
	if(sum - a[now] <= min(sum >> 1, sum - mx)) return (a[now] << 1) - sum;
	return -1;
}
 
#undef v
 
int main(){
	int n, u, v;
 
	scanf("%d", &n);
	For(i, 1, n) scanf("%lld", &a[i]);
 
	For(i, 1, n-1){
		scanf("%d%d", &u, &v);
		G[u].pb(v); G[v].pb(u);
		++dig[u]; ++dig[v];
	}
	
	if(n == 2){
		if(a[1] == a[2]) puts("YES"); else puts("NO");
		return 0;
	}

	For(i, 1, n-1) if(dig[i] > 1) rt = i;
	printf("%s", Dfs(rt, 0) == 0? "YES": "NO");
 
	return 0;
}

Measured memory_bytes: 14720
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << ele << endl
#define print10(ele) cout << fixed << setprecision(10) << ele << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  int n, d, x;
  cin >> n >> d >> x;
  ivec a(n);
  REP(i, n) cin >> a[i];
  int ans = 0;
  REP(i, n) {
    int D = 1;
    REP(j, d) {
      D = j * a[i] + 1;
      if (D <= d) ans++;
    }
  }
  ans += x;
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

typedef long long ll;

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

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

int main() {
    ll n, ans = 1, t;
    scanf("%lld", &n);
    for (ll i = 0; i < n; ++i) {
        scanf("%lld", &t);
        ans = lcm(ans, t);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream> 
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#define N 1000005
#define int long long

using namespace std;

int a, b, c, d;

signed main(void) {
	cin >> a >> b>> c >> d;
	cout << max(max(a*c, b*c), max(d*a, b*d));
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(void){
  int n, minj, buffa;
  int count = 0;
  int MAX = 100;
  int R[MAX], i , j, k, flag;
  scanf("%d", &n);

  for(k=0;k<n;k++) scanf("%d", &R[k]);

  for(i=0;i<n-1;i++){
    minj = i;
    flag = 0;
    for(j=i;j<n;j++){
      if(R[minj]>R[j]){ 
        minj = j;
        flag = 1;
      } 
    }
    if(flag == 1){
    buffa = R[minj];
    R[minj] = R[i];
    R[i] = buffa;
    count = count + 1;

    }}

  for(i=0;i<n-1;i++) printf("%d ", R[i]);
  printf("%d\n", R[n-1]);
  printf("%d\n", count);
  return 0;
}





Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
const int N = 204721;
using namespace std;
typedef long long ll;
int mod = 1e9 + 7;

int main()
{
#ifndef ONLINE_JUDGE  
  //  freopen("in.txt","r" ,stdin);
    // freopen("out.txt", "w", stdout);
#endif 
    string a, b, c;
    while (cin >> a >> b >> c)
    {
        printf("%c%c%c\n", a[0] - 32, b[0] - 32, c[0] - 32);
    }
    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=[0]*101
count=0
for i in range(1,N+1):
    T = str(i)
    K = len(T) - 1
    if i<10:
        A[i*10+i]+=1
    else:
        X=i%10
        Y=i//(10**K)
        if X!=0:
            A[Y*10+X]+=1

#print(A)

for i in range(1,N+1):
    T = str(i)
    K = len(T) - 1
    if i<10:
        count+=A[i*10+i]
    else:
        X=i%10
        Y=i//(10**K)
        if X!=0:
            count+=A[X*10+Y]
print(count)

Measured memory_bytes: 40428
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;


int main(){
  int N; cin >> N;
  vector <int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];

  ll ans = 1;
  int now[3] = {0, 0, 0};

  for (int i = 0; i < N; i++){
    ll cnt = 0;

    for (int j = 0; j < 3; j++){
      if (now[j] == A[i]){
        if (cnt == 0) now[j]++;
        cnt++;
      }
    }
    
    ans *= cnt;
    ans %= nmax;

  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <cmath>
#include <map>

int main()
{
    int N;
    std::cin >> N;
    std::vector<std::string> S(N);
    for (int i = 0; i < N; i++)
    {
        std::cin >> S[i];
    }

    int a = 0, b = 0;
    int cnt = 0;
    int cnt2 = 0;
    for (int i = 0; i < N; i++)
    {
        bool bb = S[i][0] == 'B';
        bool ba = S[i].back() == 'A';
        if (bb)b++;
        if (ba)a++;
        if (bb && ba)
        {
            cnt2++;
        }
        int pos = 0;
        while ((pos = S[i].find("AB", pos)), pos != std::string::npos)
        {
            pos += 2;
            cnt++;
        }
    }
    if (a == b && b == cnt2  && cnt2 > 0) { a--; }
    int min = std::min(a, b);
    std::cout << cnt + min << std::endl;

    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

signed main() {

    string s;
    int ans = 1000;
    int tmp = 0;
    cin >> s;
    for(int i = 0; i < s.length()-2; i ++){
        tmp = 0;
        tmp += ((int)(s[i]-'0'))*100;
        tmp += ((int)(s[i+1]-'0'))*10;
        tmp += ((int)(s[i+2]-'0'));
        ans = min(ans,abs(tmp-753));
    }

    cout << ans;


    return 0;
}

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

int main() {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int time = H2 * 60 + M2 - H1 * 60 - M1;
    cout << time - K << endl;
    return 0;
}

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

bool isleapyear(int year){
	if(year%400==0){
		return true;
	}else if(year%100==0){
		return false;
	}else if(year%4==0){
		return true;
	}
	return false;
}

int main(void){
	int a,b;
	bool f = false;
	while(cin >> a >> b){
		if(a==0&&b==0)break;
		if(f) cout << "\n";
		f = true;
		bool na = false;
		for(int i=a;i<=b;i++){
			if(isleapyear(i)){
				cout << i << "\n";
				na = true;
			}
		}
		if(!na)cout << "NA\n";
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535897932;

int main()
{
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double a_rad = 2.0 * PI * (h + m / 60.0) / 12.0;
    double b_rad = 2.0 * PI * m / 60.0;
    double C = fabs(a_rad - b_rad);
    double ans = sqrt(a * a + b * b - 2.0 * a * b * cos(C));
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}

Measured memory_bytes: 4160
from collections import defaultdict
s = input()
k = int(input())
dd = {}
if len(s) == 1:
    print(s)
    exit()
for i in range(len(s)):
    dd[s[i]] = 1
for i in range(len(s)-1):
    for j in range(i+1, len(s)):
        if j-i+1 <= k:
            dd[s[i:j+1]] = 1
li = []
for key in dd:
    li.append(key)
li.sort()
print(li[k-1])

Measured memory_bytes: 10904
#include <cstdio>
#include <algorithm>
using namespace std;
int N,M;
int a[1010];

int main () {
	while(1) {
		int pri = -1;
		scanf("%d%d",&N,&M);
		if(N == 0 && M == 0) break;
		for(int i = 1;i <= N;++i) {
            scanf("%d",&a[i]);
		}
		sort(a + 1,a + 1 + N);
		for(int i = 1;i < N;++i) {
            int t = upper_bound(a + i + 1,a + N + 1,M - a[i]) - a;
			if(t == i || t == i + 1)
				break;
			if(a[i] + a[t - 1] > pri)
				pri = a[i] + a[t - 1];
		}
		if(pri != -1)
			printf("%d\n",pri);
		else printf("NONE\n");
	}
}



Measured memory_bytes: 2784
n = int(input())
if n>=64:
    print('64')
elif n >= 32:
    print('32')
elif n >= 16:
    print('16')
elif n >= 8:
    print('8')
elif n >=4:
    print('4')
elif n >= 2:
    print('2')
else :
    print('{}'.format(n))
    

Measured memory_bytes: 2940
a , b = map(int , input().split())
if a > 0 and b > 0:
  print('Positive')
elif (a <= 0 and b > 0) or (a > 0 and b <= 0):
  print('Zero')
else:
  if abs(a - b) % 2 == 1:
    print('Positive')
  else:
    print('Negative')

Measured memory_bytes: 3060
// Winners don't quit and Quitters don't win
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 998244353
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll m,n,i,j,s=0,x;
    cin>>n>>m;
    for(i=0;i<m;++i){
    	cin>>x;
    	s+=x;
	}
	if(s>n){
		cout<<"-1";
	}
	else{
		cout<<(n-s);
	}
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

long long dp[100001];

int main(){

    int N, W;
    cin >> N >> W;
    vector<pair<int ,int>> wv(N);

    int w, v;
    for(int i = 0; i < N; i++){
        cin >> w >> v;
        wv[i] = (make_pair(w, v));
    }

    memset(dp, 0, sizeof(dp));

    for(int i = 0; i < N; i++){
        auto temp = wv[i];
        int tempW = temp.first;
        int tempV = temp.second;
        for(int j = W; j >= tempW; j--){
            dp[j] = max(dp[j], dp[j - tempW] + tempV);
        }
    }

    cout << dp[W] << endl;

    return 0;
}

Measured memory_bytes: 1024
// Problem : D - I hate Factorization
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
int f[105], cnt;
signed main() {
  int x; std::cin >> x;
  for (int i = 1; i * i <= x; ++i)
    if (x % i == 0) f[++cnt] = i, f[++cnt] = x / i;
  for (int i = 1; i <= cnt; ++i) {
    for (int b = -10000; b <= 10000; ++b) {
      int a = b + f[i];
      int ans = (a*a*a*a + a*a*a*b + a*a*b*b + a*b*b*b + b*b*b*b);
      if (ans == x / f[i]) {
        printf("%lld %lld\n", a, b); return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3696
/*
spade = 1 ~ 13, hart = 14 ~ 26, crub = 27 ~ 39, dia = 39 ~ 52
*/

#include <iostream>
#define MAX 52
using namespace std;

int main(void)
{
    int n, cn;
    int cflag[MAX] = {0}; // input 1~52
    char d;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> d >> cn;
        switch (d)
        {
        case 'S':
            cflag[cn - 1] = 1;
            break;
        case 'H':
            cflag[cn - 1 + 13] = 1;
            break;
        case 'C':
            cflag[cn - 1 + 26] = 1;
            break;
        case 'D':
            cflag[cn - 1 + 39] = 1;
            break;
        }
    }
    for (int i = 0; i < MAX; i++)
    {
        if (cflag[i] != 1)
        {
            switch (i / 13)
            {
            case 0:
                cout << 'S' << " " << i + 1 << endl;
                break;
            case 1:
                cout << 'H' << " " << i + 1 - 13 << endl;
                break;
            case 2:
                cout << 'C' << " " << i + 1 - 26 << endl;
                break;
            case 3:
                cout << 'D' << " " << i + 1 - 39 << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 3092
Q, H, S, D = map(int, input().split())
N = int(input())


one_cost = min(4*Q, 2*H, S)
two_cost = min(2*one_cost, D)

if N % 2 == 0:
    print(two_cost * (N // 2))
else:
    print(two_cost * (N // 2) + one_cost)

Measured memory_bytes: 3060
#include<cstdio>
#include<map>
#include<algorithm>
using namespace std;
int fa[200005],fb[200005];
map<int,map<int,int> >mp;
inline int find(int x)
{
	if(fa[x]==x)
		return x;
	return fa[x]=find(fa[x]);
}
inline int fd(int x)
{
	if(fb[x]==x)
		return x;
	return fb[x]=fd(fb[x]);
}
inline void U(int x,int y)
{
	fa[find(x)]=find(y);
}
inline void U1(int x,int y)
{
	fb[fd(x)]=fd(y);
}
int main()
{
	int n,k,l;
	scanf("%d%d%d",&n,&k,&l);
	for(int i=1;i<=n;i++)
		fa[i]=fb[i]=i;
	for(int i=1;i<=k;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		U(x,y);
	}
	for(int i=1;i<=l;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		U1(x,y);
	}
	for(int i=1;i<=n;i++)
		mp[find(i)][fd(i)]++;
	for(int i=1;i<n;i++)
		printf("%d ",mp[find(i)][fd(i)]);
	printf("%d\n",mp[find(n)][fd(n)]);
	return 0;
}

Measured memory_bytes: 27776
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
long long Read() {
	long long x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') {
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
	return x*f;
}
int main() {
	int a=Read(),b=Read();
	if (a > 0 && b > 0) {
		cout << "Positive" << endl;
	} else if (max(a, b) >= 0 && min(a, b) <= 0 || a == 0 || b == 0) {
		cout << "Zero" << endl;
	} else {
		if ((abs(min(a, b)) - abs(max(a, b))) % 2 == 0) {
			cout << "Negative" << endl;
		} else {
			cout << "Positive" << endl;
		}
	}
	return 0;
}

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

void remove_row(vector<vector<char>> &table, int row){
  int height = table.size();
  for (int i=row;i<height-1;i++) {
    table.at(i) = table.at(i+1);
  }
  table.pop_back();
  
  return;
}

void remove_col(vector<vector<char>> &table, int col){
  int height = table.size();
  int width = table.at(0).size();
  
  for (int i=0;i<height;i++) {
    for (int j=col;j<width-1;j++) {
      table.at(i).at(j) = table.at(i).at(j+1);
    }
    table.at(i).pop_back();
  }
  
  return;
}

int main() {
  int H, W;
  cin >> H >> W;
 
  vector<vector<char>> grid(H,vector<char>(W));
  
  for (int row=0;row<H;row++) {
    for (int col=0;col<W;col++) {
      cin >> grid.at(row).at(col);
    }
  }
  
  int num_black = 0;
  
    
  //行のチェック
  for (int row=0;row<grid.size();row++) {
    num_black = 0;
    for (int col=0;col<grid.at(0).size();col++) {
      if (grid.at(row).at(col) == '#') {
        num_black++;
      }
    }
    
    if (num_black == 0) {
      remove_row(grid, row);
      row--;
    }
  }
  
   //列のチェック
  for (int col=0;col<grid.at(0).size();col++) {
    num_black = 0;
    for (int row=0;row<grid.size();row++) {
      if (grid.at(row).at(col) == '#') {
        num_black++;
      }
    }
    
    if (num_black == 0) {
      remove_col(grid, col);
      col--;
    }
  }
  
  // 出力
  H = grid.size();
  W = grid.at(0).size();  
  for (int row=0;row<H;row++) {
    for (int col=0;col<W;col++) {
      cout << grid.at(row).at(col);
      
      if (col == W-1){
        cout << endl;
      } 
    }
  }
  
  
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math


def main():
    S = list(input())
    for abc in 'abcdefghijklmnopqrstuvwxyz':
        if not abc in set(S):
            print(abc)
            exit(0)
    print('None')


if __name__ == "__main__":
    main()


Measured memory_bytes: 3956
#include<iostream>
#include <string>
using namespace std;
int main()
{
  string y,N;
  double x,ans=0;
  x,ans=0;
  cin>> N;
  while(cin>> x>>y){
    if(y=="BTC"){
      ans+=x*380000;
    }else{
      ans+=x;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;


// Eratosthenes
vector<int> eratTable;

vector<ll> eratosthenes(ll n) {
    eratTable.assign(n + 1, 1);
    eratTable[0] = 0;
    eratTable[1] = 0;
    for (ll i = 2; i <= n; i++) {
        if (eratTable[i] == 1) {
            for (ll j = 2; i * j <= n; j++) {
                eratTable[i * j] = 0;
            }
        }
    }

    vector<ll> primes;
    rep(i, eratTable.size()) {
        if (eratTable[i] >= 1) {
            primes.push_back(i);
        }
    }

    return primes;
}

void Main()
{
    ll Q;
    cin >> Q;
    vector<ll> l(Q), r(Q);
    rep(i, Q) cin >> l[i] >> r[i];

    auto primes = eratosthenes(100001);

    vector<ll> S(100001);
    ll cnt = 0;
    rep(i, 100001) {
        if (2 == i) {
            continue;
        }
        if (eratTable[i] == 1) {
            ll v = (i + 1) / 2;
            if (eratTable[v] == 1) {
                cnt++;
            }
        }

        S[i] = cnt;
    }

    rep(i, Q) {
        put(S[r[i]] - S[l[i] - 1]);
    }

}
signed main(){ Main();return 0;}

Measured memory_bytes: 6224
#include <iostream>
using namespace std;
void func(int,int);
char ans[12];
int d[12],f,w;

int main(){
  cin>>w;
  d[0]=1,d[1]=3;
  for(int i=2;i<12;i++) d[i]=d[i-1]*3;
  func(0,0);
  return 0;
}

void func(int x,int n){
  if(f) return ;
  if(x==12){
    if(n==w){
      f=1;
      int ff=0;
      for(int i=11;i>=0;i--){
	if(ff==0&&ans[i]!='0') ff=1;
	if(ff) cout<<ans[i];
      }
      cout<<endl;
    }
  }else{
    ans[x]='-';
    func(x+1,n-d[x]);
    ans[x]='0';
    func(x+1,n);
    ans[x]='+';
    func(x+1,n+d[x]);
  }
}

Measured memory_bytes: 1156
def main():
    N = int(input())
    S = input()
    left = [set() for _ in range(N-2)]
    right = [set() for _ in range(N-2)]
    left[0] = set(S[0])
    right[0] = set(S[-1])
    for i in range(1, N-2):
        left[i] = set([S[i]] + list(left[i-1]))
        right[i] = set([S[N-1-i]] + list(right[i-1]))
    pattern = set()
    for i in range(1, N-1):
        for l in left[i-1]:
            for r in right[N-2-i]:
                pattern.add(l*100 + S[i] * 10 + r)
    print(len(pattern))


if __name__ == "__main__":
    main()


Measured memory_bytes: 82780
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 1000005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 998244353;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    set<ll>fac;
    int sq = (int)sqrt(n);
    for (int i = 1 ; i <= sq ; i++) {
        if (n % i == 0) {
            fac.insert(i);
            fac.insert(n / i);
        }
        if ((n - 1) % i == 0) {
            fac.insert(i);
            fac.insert((n-1) / i);
        }
    }
    fac.erase(1);
    set<ll>ans;
    
    for (auto i:fac) {
        ll t = n;
        while (t % i == 0) {
            t /= i;
        }
        t %= i;
        if (t == 1) {
            ans.insert(i);
        }
    }
    cout << ans.size() << '\n';
}
    



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

int n;

int main(){
  cin >> n;
  int res = 0;
  for(int i = 1; i <= n; i += 2){
    int num = i;
    map<int, int> mp;
    for(int j = 2; j <= 15; j++){
      while(num % j == 0){
        num /= j;
        mp[j]++;
      }
    }
    if(num != 1) mp[num]++;
    int cnt = 1;
    for(P x : mp){
      cnt *= x.second + 1;
    }
    if(cnt == 8){
      cerr << i << endl;
      res++;
    }
  }
  cout << res << endl;
  return 0;
}

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

vector<string> S;

int main(){
  int N;
  cin >> N;
  string s;
  rep(i, N){
    cin >> s;
    S.push_back(s);
  }
  sort(S.begin(), S.end());
  S.erase(unique(S.begin(), S.end()), S.end());
  cout << S.size() << endl;
}


Measured memory_bytes: 11596
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, clock()*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

char s[210000];

int main() {
#ifdef LOCAL
  freopen("b.in", "r", stdin);
  freopen("b.out", "w", stdout);
#endif

  while (scanf("%s", s) == 1) {
    vector<int> cnt(26);
    ll ans = 1;
    for (int i = 0; s[i]; i++) {
      int id = s[i] - 'a';
      ans += i - cnt[id];
      cnt[id]++;
    }
    printf("%lld\n", ans);
  }

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <vector>
    #include <string>
    #include <string.h>
     
    typedef long long ll;
    using namespace std;
    const ll INF = 1000000000000000000ll;
    const ll MOD = 1000000007ll;
     
    const double EPS = 1e-8;
     
    int main()
    {
   		char A[19];

		cin >> A ;

		for(int i=0;i<19;i++){
			if(A[i]==','){A[i]=32;}
		}

		cout << A << endl;

		return 0;
    }

Measured memory_bytes: 256
# 整数の入力
a = int(input())
# 数値のリスト化
xList = [int(i) for i in input().split()]
cList = [int(i) for i in input().split()]
kati = 0
for i in range(a):
    if(xList[i] > cList[i]):
        kati = kati + (xList[i] - cList[i])

print(kati)

Measured memory_bytes: 3060
from collections import Counter

n = int(input())
a = list(map(int,input().split()))
q = int(input())
bc = [list(map(int,input().split()))for _ in range(q)]

g = [0] * (10**5 + 3)
for i in a:
    g[i] += 1

ans = sum(a)
for i,j in bc:
    ans -= g[i]*i 
    ans += g[i]*j
    g[j] += g[i]
    g[i] = 0
    print(ans)

Measured memory_bytes: 32484
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int inf = 1001001001;
const int MOD = 1000000007;

ll modpow(ll x, ll n) {
    x = x%MOD;
    if(n==0) return 1;  //再帰の終了条件

    else if(n%2==1) {
        return (x*modpow(x, n-1))%MOD;  //nが奇数ならnを1ずらす
    }
    else return modpow((x*x)%MOD, n/2)%MOD;  //nが偶数ならnが半分になる
}

ll com(ll n, ll k) {
    ll x = 1;
    for(int i=n-k+1; i<=n; i++) {
        x = x*i%MOD;
    }

    ll y = 1;
    for(int i=1; i<=k; i++) {
        y = y*i%MOD;
    }
    y = modpow(y, MOD-2);

    return x*y%MOD;
}

int main() {
    
    ll n,a,b;
    cin >> n >> a >> b;

    ll all=modpow(2,n)-1;
    ll muri=com(n,a)+com(n,b);

    ll ans=all-muri;
    while(ans<0) {
        ans+=MOD;
    }

    cout << ans << endl;

}

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

int main()
{
	int m, f, r;
	
	while(1){
		cin >> m >> f >> r;
		if(m == -1 && f == -1 && r == -1){
			break;
		}
		if(m == -1 || f == -1){
			cout << 'F' << endl;
		}else if(m + f >= 80){
			cout << 'A' << endl;
		}else if(m + f >= 65){
			cout << 'B' << endl;
		}else if(m + f >= 50){
			cout << 'C' << endl;
		}else if(m + f >= 30){
			if(r >= 50){
				cout << 'C' << endl;
			}else{
				cout << 'D' << endl;
			}
		}else{
				cout << 'F' << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3104