akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 505

struct Info{
	Info(int arg_row,int arg_col,ll arg_count){
		row = arg_row;
		col = arg_col;
		count = arg_count;
	}
	int row,col;
	ll count;
};

struct Data{
	Data(){
		row = col = 0;
		sum_cost = 0;
	}

	Data(int arg_row,int arg_col,int arg_sum_cost){
		row = arg_row;
		col = arg_col;
		sum_cost = arg_sum_cost;
	}
	ll row,col,sum_cost;
};

int H,W;
int start_row,start_col,goal_row,goal_col;
int diff_row[4] = {-1,0,0,1},diff_col[4] = {0,-1,1,0};
ll dp[NUM][NUM];
ll min_cost[NUM][NUM];


bool rangeCheck(int row,int col){
	if(row >= 0 && row <= H-1 && col >= 0 && col <= W-1){
		return true;
	}else{
		return false;
	}
}

int find(vector<Info> V,int row,int col){

    int	ret = -1;

	for(int i = 0; i < V.size(); i++){
		if(V[i].row == row && V[i].col == col){
			return i;
		}
	}

	return ret;
}

int main(){

	scanf("%d %d",&H,&W);
	scanf("%d %d %d %d",&start_row,&start_col,&goal_row,&goal_col);

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			min_cost[row][col] = HUGE_NUM; //そのマスに到達する際の最小コスト
			dp[row][col] = 0; //そのマスに到達する経路の総数
		}
	}

	min_cost[start_row][start_col] = 0;
	dp[start_row][start_col] = 1;

	queue<Data> Q;
	Q.push(Data(start_row,start_col,0));

	Data data;
	int adj_row,adj_col,tmp_index;
	vector<Info> V;

	while(!Q.empty()){

		data = Q.front();
		Q.pop();

		//今回のマスから行けるマスと、そこへの経路数を数える
		V.clear();

		//まずは上下左右
		for(int i = 0; i < 4; i++){

			adj_row = data.row+diff_row[i];
			adj_col = data.col+diff_col[i];

			if(!rangeCheck(adj_row,adj_col))continue;

			V.push_back(Info(adj_row,adj_col,1));
		}

		//行の左端(今左端にいるなら、コストがかかるだけ移動は無駄)
		if(data.col != 0){

			tmp_index = find(V,data.row,0);
			if(tmp_index == -1){

				V.push_back(Info(data.row,0,1));
			}else{

				V[tmp_index].count++;
			}
		}

		//行の右端
		if(data.col != W-1){

			tmp_index = find(V,data.row,W-1);
			if(tmp_index == -1){

				V.push_back(Info(data.row,W-1,1));
			}else{

				V[tmp_index].count++;
			}
		}

		//列の上端
		if(data.row != 0){

			tmp_index = find(V,0,data.col);
			if(tmp_index == -1){

				V.push_back(Info(0,data.col,1));
			}else{

				V[tmp_index].count++;
			}
		}

		//列の下端
		if(data.row != H-1){

			tmp_index = find(V,H-1,data.col);
			if(tmp_index == -1){

				V.push_back(Info(H-1,data.col,1));
			}else{

				V[tmp_index].count++;
			}
		}

		for(int i = 0; i < V.size(); i++){

			if(min_cost[V[i].row][V[i].col] > data.sum_cost+1){ //最小値を更新する場合

				min_cost[V[i].row][V[i].col] = data.sum_cost+1;
				dp[V[i].row][V[i].col] = dp[data.row][data.col]*V[i].count;
				dp[V[i].row][V[i].col] %= MOD;
				Q.push(Data(V[i].row,V[i].col,data.sum_cost+1));

			}else if(min_cost[V[i].row][V[i].col] == data.sum_cost+1){ //同点で最小値の場合

				dp[V[i].row][V[i].col] += dp[data.row][data.col]*V[i].count;
				dp[V[i].row][V[i].col] %= MOD;
			}
		}
	}

	printf("%lld %lld\n",min_cost[goal_row][goal_col],dp[goal_row][goal_col]);

	return 0;
}



Measured memory_bytes: 7032
//c++
#include<iostream>
#include<string>
using namespace std;

int main()
{
  int a;
  int b;
  int c;
  int d;
  
  cin >> a;
  cin >> b;
  
  c = a * 3;
  d = (b + c) / 2;
  
  cout<<d<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef pair<int,long long> Edge;
vector<Edge> G[2100];

const long long INF = 1LL<<55;
int N, M;

long long dist[2100];
int main() {
    while (cin >> N >> M) {
        for (int i = 0; i < 2100; ++i) G[i].clear();
        for (int i = 0; i < M; ++i) {
            int a, b;
            long long c;
            cin >> a >> b >> c;
            --a, --b;
            G[a].push_back(Edge(b, c));
        }
        for (int i = 0; i < 2100; ++i) dist[i] = -INF;
        dist[0] = 0;
        bool iscycle = false;
        for (int iter = 0; iter <= N*2; ++iter) {
            for (int v = 0; v < N; ++v) {
                for (auto e : G[v]) {
                    if (chmax(dist[e.first], dist[v] + e.second)) {
                        if (iter >= N && e.first == N-1) {
                            iscycle = true;
                        }
                    }
                }
            }
        }
        if (iscycle) puts("inf");
        else cout << dist[N-1] << endl;
    }
}











Measured memory_bytes: 384
n = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

kanousei = []

yakusuu_list = make_divisors(n)

for i in yakusuu_list[:-(-len(make_divisors(n))//2)]:
    if n%i==0:
        kanousei.append([i, int(n/i)])

saisyou = n + 1
index = 0
        
for i in kanousei:
    if sum(i) < saisyou:
        saisyou = sum(i)

print(saisyou-2)

Measured memory_bytes: 3680
N = int(input())
C0 = 0
C1 = 0
C2 = 0
C3 = 0

for A in range(N) :
    B = input()
    if B == 'AC' :
        C0 += 1
    if B == 'WA' :
        C1 += 1
    if B == 'TLE':
        C2 += 1
    if B == 'RE' :
        C3 += 1

print('AC x ' + str(C0))
print('WA x ' + str(C1))
print('TLE x ' + str(C2))
print('RE x ' + str(C3))


Measured memory_bytes: 9156
#include <bits/stdc++.h>
#define pll pair<ll, ll>
using namespace std;
const int mod = 1e9 + 7;
typedef long long ll;

inline int fsp(int x, int k = mod - 2) {
    int res = 1;
    while (k) {
        if (k & 1)
            res = 1ll * res * x % mod;
        x = 1ll * x * x % mod, k >>= 1;
    }
    return res;
}

int n;
map<pll, int> num;
pll now[200200];

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

    cin >> n;
    int aa = 0, bb = 0, cc = 0;
    for (int i = 1; i <= n; ++i) {
        long long x, y, g;
        scanf("%lld%lld", &x, &y);
        if (!x || !y) {
            if (!x && !y)
                ++cc;
            else if (!x)
                ++aa;
            else if (!y)
                ++bb;
            --i, --n;
            continue;
        }
        g = __gcd(abs(x), abs(y));
        if (x < 0)
            x = -x, y = -y;
        x /= g, y /= g;
        num[now[i] = make_pair(x, y)]++;
    }

    int ans = (fsp(2, aa) + fsp(2, bb) - 1) % mod;
    for (int i = 1; i <= n; ++i) {
        if (!num[now[i]])
            continue;
        pll tmp = make_pair(-now[i].second, now[i].first);
        if (tmp.first < 0)
            tmp.first *= -1, tmp.second *= -1;
        int x = num[now[i]], y = num[tmp];
        num[now[i]] = num[tmp] = 0;
        int t = (fsp(2, x) + fsp(2, y) - 1) % mod;
        ans = 1ll * ans * t % mod;
    }

    ans = (ans - 1 + cc) % mod;
    if (ans < 0)
        ans += mod;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 31760
#include <bits/stdc++.h>
#define LL long long
#define mp make_pair
#define pb push_back
#define INF (1<<29)
using namespace std;
typedef pair<int,int>pii;
int n;
vector<int>G[100010];
int main(){
	cin>>n;
	for(int i=1;i<n;i++){
		int x,y;
		cin>>x>>y;
		G[x].pb(y);
		G[y].pb(x);
	}
	vector<int>color(n+10,-1);
	queue<int>qq;
	qq.push(1);
	qq.push(n);
	color[1]=0;
	color[n]=1;
	while(!qq.empty()){
		int node=qq.front();
		qq.pop();
		for(auto i:G[node]){
			if(color[i]==-1){
				color[i]=color[node];
				qq.push(i);
			}
		}
	}
	int f=0,s=0;
	for(int i=1;i<=n;i++)
		if(color[i]==0)f++;
		else s++;
	if(f>s)cout<<"Fennec\n";
	else cout<<"Snuke\n";
//	cout<<f<<' '<<s<<endl;
//	for(int i=1;i<=n;i++)cout<<color[i]<<' ';
//	puts("");
	return 0;
}


Measured memory_bytes: 6272
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	n <- readInt
	ds <- sort <$> readInts
	let
		lb = last $ take ( n `div` 2 ) ds
		ub = head $ drop ( n `div` 2 ) ds
	print $ ub - lb

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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 1000000007

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    string s;
    cin >> s;
    ll n = s.size();
    vvi dp(n+1, vi(13, 0));
    dp[0][0] = 1;
    int c;
    REP(i, 0, n) {
        if (s[i] == '?') {
            REP(j, 0, 10)
                REP(k, 0, 13) {
                    c = (k*10 + j)%13;
                    dp[i+1][c] = (dp[i+1][c] + dp[i][k])%M;
                }
        }
        else {
            REP(j, 0, 13) {
                c = (j*10 + s[i] - '0')%13;
                dp[i+1][c] = (dp[i+1][c] + dp[i][j])%M;
            }
        }
    }
    cout << dp[n][5] << endl;
    return 0;
}


Measured memory_bytes: 13648
#include <cstdlib>
#include <functional>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>

#define ll long long

using namespace std;

int main(int argc, char *argv[])
{
  ll N, K;

  cin >> N >> K;

  string D[K];

  bool b = false;

  for (ll i = 0; i < K; ++i) {
    cin >> D[i];
  }

  for (ll i = 0; i < 1000000; ++i) {
    b = false;
    string s = to_string(i);
    for (ll j = 0; j < K; j++) {
      if (!b && (s.find(D[j]) != string::npos)) {
        b = true;
      }
    }

    if (b) {
      continue;
    }

    if (atoi(s.c_str()) >= N) {
      cout << s << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <stack>
#include <cstdio>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <iterator>
#include <sstream>
#define popcount(x) __builtin_popcount(x)
#define oddparity(x) __builtin_parity(x)
#define clz(x) __builtin_clz(x)
#define ctz(x) __builtin_ctz(x)
#define sf scanf
#define pf printf
using namespace std;

int i, j, n, a[100], ans, mn, mx;
vector<int>v;

int main()
{
    sf("%d", &n);
    for (i = 0; i < n; i++) {
        sf("%d", &a[i]);
    }
    mn = *min_element(a, a+n);
    mx = *max_element(a, a+n);
    for (j = mn; j <= mx; j++) {
        ans = 0;
        for (i = 0; i < n; i++) {
            ans += abs(a[i]-j) * abs(a[i]-j);
        }
        v.push_back(ans);
    }
    pf("%d\n", *min_element(v.begin(), v.end()));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define fo(i,s,e) for (int i=(s); i < (e); i++)
signed main () {
  int n,m,x;cin>>n>>m>>x;
  vector<vector<int>> v(n,vector<int>(m+1,0));
  rep(i,n) rep(j,m+1) cin>>v[i][j];
  int ans=INT_MAX;
  rep(bit,1<<n){
    bool check_bit=true;
    fo(j,1,m+1){
      int sum_j=0;
      rep(i,n) if((bit>>i)&1) sum_j+=v[i][j];
      if(sum_j<x) check_bit=false;
    }
    if(check_bit){
      int sum_c=0;
      rep(i,n) if((bit>>i)&1) sum_c+=v[i][0];
      ans=min(ans,sum_c);
    }
  }
   cout<< ((ans==INT_MAX) ? -1 : ans);
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    vector<long long>v(n);
    long long s = 0;
    for(auto &x:v)
    {
        cin>>x;
        s^=x;
    }
    for(long long i=0;i<n;i++)
    {
        long long t = s;
        t^=v[i];
        cout<<t<<' ';
    }

    return 0;
}

Measured memory_bytes: 4724
let ans = ref 0
let f g n = let rec f i = if i * i <= n then (if n mod i = 0 then (g i; if i <> n / i then g (n / i)); f (i + 1)) in f 1
let _ = Scanf.scanf "%d %d" @@ fun n m -> f (fun d -> if m / d >= n then ans := max !ans d) m; Printf.printf "%d\n" !ans

Measured memory_bytes: 384
#include<complex>
#include<cmath>
#include<iostream>
#include<cstdio>
#define EPF 1e-10
#define PI 3.14159265358979323846264338
using namespace std;

typedef complex<double> P;

int main(){
  int n,ans;
  double x,y;
  while(cin >> n && n){
    P inf[n];
    ans = 1;
    for(int i=0;i<n;i++){
      scanf("%lf,%lf",&x,&y);
      inf[i] = P(x,y);
    }

    int cnt;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	if(abs(inf[i]-inf[j]) >= 2.0+EPF)continue;
	double MD = sqrt(1-0.25*norm(inf[i]-inf[j]));
	P mid = (inf[i]+inf[j])*0.5;
	P p1 = mid + (inf[i]-inf[j])/abs(inf[i]-inf[j])*polar(MD,M_PI/2);
	P p2 = mid + (inf[i]-inf[j])/abs(inf[i]-inf[j])*polar(MD,-M_PI/2);
	cnt = 0;
	for(int k=0;k<n;k++)if(abs(p1-inf[k]) < EPF+1.0)cnt++;
	
	ans = ans<cnt?cnt:ans;
	cnt = 0;
	for(int k=0;k<n;k++)if(abs(p2-inf[k]) < EPF + 1.0)cnt++;
	ans = ans<cnt?cnt:ans;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
	// your code goes 
	long int n;
	cin>>n;
	string s;
	cin>>s;
	long int l=0,r=n-1;
	long int ans=0;
	while(1)
	{
	    while(r>=0 && s[r]!='R')
	    r--;
	    while(l<n && s[l]!='W')
	    l++;
	    if(l<r)
	    {
	        ans++;
	        swap(s[l],s[r]);
	    }
	    else
	    break ;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3720
#include <stdio.h>
#include <vector>
#include <queue>
#include <set>
using namespace std;

set<int> S[200200],T[200200];
int N,G[200200],D[200200],M[200200];

int main()
{
	scanf ("%d",&N);
	for (int i=1;i<=N;i++){
		scanf ("%d",&G[i]);
		D[G[i]]++;
	}

	queue<int> Q;
	for (int i=1;i<=N;i++) if (D[i] == 0){
		Q.push(i);
	}

	while (!Q.empty()){
		int x = Q.front(); Q.pop();
		for (auto &m : S[x]){
			if (m == M[x]) M[x]++;
			else break;
		}
		S[G[x]].insert(M[x]);
		if (--D[G[x]] == 0) Q.push(G[x]);
	}

	for (int x=1;x<=N;x++) if (D[x] != 0){
		for (auto &m : S[x]){
			if (m == M[x]) M[x]++;
			else break;
		}

		for (int i=1;i<=N;i++) if (D[i] != 2) T[i] = S[i];
		int t = x;
		while (G[t] != x){
			T[G[t]].insert(M[t]);
			t = G[t];
			for (auto &m : T[t]){
				if (m == M[t]) M[t]++;
				else break;
			}
		}

		if (M[x] != M[t]){
			puts("POSSIBLE");
			return 0;
		}

		x = t;
		for (int i=1;i<=N;i++) if (D[i] != 2) T[i] = S[i];
		int o = M[t];
		while (true){
			T[G[t]].insert(M[t]);
			t = G[t];
			M[t] = 0;
			for (auto &m : T[t]){
				if (m == M[t]) M[t]++;
				else break;
			}
			if (t == x) break;
		}

		if (o == M[t]){
			puts("POSSIBLE");
			return 0;
		}
		break;
	}
	puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 38656
import sys
from collections import defaultdict
input = sys.stdin.readline

N, K = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]

k = len(list(set(A)))
d = defaultdict(int)

for a in A:
    d[a] += 1

print(sum(sorted(d.values())[:max(0, k - K)]))

Measured memory_bytes: 37136
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    if (x == 3 || x == 5 || x == 7)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,x;
    char op;
        while(1){
            scanf("%d %c %d" ,&a, &op, &b);
            if( op == '+'){
                x = a + b;
            }
            else if( op == '-'){
                x = a - b;
            }
            else if( op == '*'){
                x = a * b;
            }
            else if( op == '/'){
                x = a / b;
            }
            else{
                break;
            }
            printf("%d\n",x);
        }
return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <math.h>
int isprime(int);
int main(){
  int A[10000];
  int i,n,count=0,st;

  scanf("%d",&n);
  
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  
  for(i=1;i<=n;i++){
    st = isprime(A[i]);
    if(st == 1)count++;
  }

  printf("%d\n",count);
  
  return 0;
}
int isprime(int x){
  int i;
  
  if(x==2) return 1;
  if(x<2||x%2 == 0)return 0;
  
  i=3;
  while(i<=sqrt(x)){
    if(x%i==0)return 0;
    i+=2;
  }
  return 1;
}

Measured memory_bytes: 628
#include<bits/stdc++.h>
#define INF 1e9
using namespace std;

struct Graph{
    Graph(int n):d(n,vector<int>(n,INF)),N(n){
        for(int i=0;i<n;++i)d[i][i]=0;
    }
    vector<vector<int>>d;
    int N;
    void add_edge(int a,int b,int c){
        d[a][b]=c;
    }
    void warshallFloyd(){
        for(int k=0;k<N;++k)
            for(int i=0;i<N;++i)
                for(int j=0;j<N;++j)
                    d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    }
};

main(){
    int n,m,r;
    cin>>n>>m>>r;
    vector<int>R(r);
    for(int i=0;i<r;++i)cin>>R[i];
    sort(R.begin(),R.end());
    Graph E(n);
    int a,b,c;
    for(int i=0;i<m;++i){
        cin>>a>>b>>c;
        E.add_edge(--a,--b,c),E.add_edge(b,a,c);
    }
    E.warshallFloyd();
    int x=1e9;
    do{
        int a=0;
        for(int i=0;i<r-1;++i)
            a+=E.d[R[i]-1][R[i+1]-1];
        x=min(x,a);
    }while(next_permutation(R.begin(),R.end()));
    cout<<x<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k,x;
    cin>>a>>b>>c>>k;
    if(a>=b&&a>=c)
    {
       x=pow(2,k);
       cout<<(x*a)+b+c;
    }
    else if(b>=a&&b>=c)
    {
       x=pow(2,k);
       cout<<(x*b)+a+c;
    }
     else if(c>=a&&c>=b)
    {
       x=pow(2,k);
       cout<<(x*c)+a+b;
    }


    return 0;
}


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

using namespace std ;

int mp[(int)1e5 + 1] ;

int main()
{
    cin.tie(nullptr) ;
    ios_base :: sync_with_stdio(false) ;
    int n , q ;
    cin >> n ;
    memset(mp , 0 , sizeof mp) ;
    long long ans = 0 ;
    int a[n] ;
    for(int &x : a)
    {
        cin >> x;
        ans += x ;
        mp[x] ++ ;
    }
    cin >> q ;
    while (q --)
    {
        int b , c ;
        cin >> b >> c ;
        ans -= 1LL * mp[b] * b ;
        ans += 1LL * mp[b] * c ;
        mp[c] += mp[b] ;
        mp[b] = 0 ;
        cout << ans << '\n' ;
    }
    return 0;
}

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


int main() {
    string s;
    cin >> s;
    int count = 0;
    for (int i = 0; i < s.size() / 2; i++) {
        if (s.at(i) != s.at(s.size()-i-1)) count++;
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ACookieExchanges solver = new ACookieExchanges();
        solver.solve(1, in, out);
        out.close();
    }

    static class ACookieExchanges {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();
            for (int i = 0; ; i++) {
                if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
                    out.println(i);
                    return;
                } else if (a == b && b == c) {
                    out.println(-1);
                    return;
                }
                int na = b + c, nb = c + a, nc = a + b;
                a = na / 2;
                b = nb / 2;
                c = nc / 2;
            }
        }

    }
}



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

int main (){
	int n,i,p[50],ans=0;
	cin >> n;
	for(i=1;i<=n;i++) cin >> p[i];
	for(i=2;i<n;i++){
		if((p[i+1]-p[i])*(p[i]-p[i-1])>0) ans++;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    pre = S[0]
    cnt = 1
    for i in range(1, len(S)):
        si = S[i]
        if pre != si:
            cnt += 1
        pre = si
    print(cnt)


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    i64 a;
    string b;
    cin >> a >> b;

    string s = b.substr(0, 1) + b.substr(2, 2);
    i64 c = stoi(s);

    cout << a * c / 100 << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


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

if(x >= 400 and x <= 599):
    print(8)
elif(x >= 600 and x <= 799):
    print(7)
elif(x >= 800 and x <= 999):
    print(6)
elif(x >= 1000 and x <= 1199):
    print(5)
elif(x >= 1200 and x <= 1399):
    print(4)
elif(x >= 1400 and x <= 1599):
    print(3)
elif(x >= 1600 and x <= 1799):
    print(2)
elif(x >= 1800 and x <= 1999):
    print(1)

Measured memory_bytes: 9200
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;


int main() {
	int H, W, N; cin >> H >> W >> N;
	if (H > W) {
		cout << (N + H - 1) / H << endl;
	}
	else {
		cout << (N + W - 1) / W << endl;
	}
	return 0;
}

Measured memory_bytes: 256
S = input()
List=[0]*(len(S)+1)
i=0
while i<len(S):
    if S[i]=="<":
        List[i+1]=List[i]+1
    i+=1
j=1
while j<=len(S):
    if S[-j]==">":
        List[-(j+1)]=max(List[-j]+1,List[-(j+1)])
    j+=1
print(sum(List))

Measured memory_bytes: 23372
import java.util.*;
class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext()) {
			String[] in = stdIn.nextLine().split(",");
			int[] len = new int[10];
			int sumLen = 0;
			for(int i = 0; i < 10; i++) {
				len[i] = Integer.parseInt(in[i])*1000;
				sumLen += len[i];
			}
			double v1 = Integer.parseInt(in[10])/3600.0*1000.0;
			double v2 = Integer.parseInt(in[11])/3600.0*1000.0;
			
			double t = sumLen/(v1 + v2);
			
			double run = v1 * t;
			int length = 0;
			for(int i = 0; i < 10; i++) {
				length += len[i];
				if(length >= run) {
					System.out.println(i+1);
					break;
				}
				
			}
		}
	}
}

Measured memory_bytes: 17140
fun main(args: Array<String>) {
    studyscheduling()
}

inline fun studyscheduling(){
    val list = readLine()!!.split(" ").map(String::toInt)
    val (h1, m1, h2, m2, k) = list

    val t1 = h1 * 60 + m1
    val t2 = h2 * 60 + m2
    val diff = t2 - t1
    val answer = diff - k
    println(answer)
}


Measured memory_bytes: 36404
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <numeric>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecvec vector<vec>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

ll modpow(ll a,ll b,ll mod){
    if(b==0)return 1;
    if(b%2==0){
        ll d=modpow(a,b/2,mod);
        return d*d%mod;
    }else return modpow(a,b-1,mod)*a%mod;
}
int main(){
    int n = in();
    int p = in();
    string s = stin();
    vec a(n),b(n);
    vecll c(p);
    rep(i,n)a[i] = s[i] - '0';
    b[n-1]=a[n-1]%p;
    rep3(i,n-2,0)b[i] = (b[i+1] + modpow(10,n-i-1,p) * a[i])%p;
    REP(e,b) c[e]++;
    ll ans = 0;
    if(p==2 or p==5){
        vec v;
        rep(i,n)if(a[i]%p==0)v.pb(i+1);
        REP(e,v)ans+=e;
        cout<<ans<<endl;
        return 0;
    }
    rep(i,p)ans += i==0? c[i]*(c[i]+1)/2 : c[i]*(c[i]-1)/2;
    cout << ans << endl;
}

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

int main(void){
    cout<<fixed<<setprecision(12);
    double a,b,C,S,L,h;
    cin>>a>>b>>C;
    S=a*b*sin(M_PI*C/180)/2;
    L=a+b+sqrt(a*a+b*b-2*a*b*cos(M_PI*C/180));
    h=S*2/a;
    cout<<S<<endl<<L<<endl<<h<<endl;
}



Measured memory_bytes: 3640
#include<iostream>

int main() {
	char input;
	int answer = 0;

	for (int i = 0; i < 4; i++) {
		std::cin >> input;
		if (input == '+')
			answer += 1;
		else if (input == '-')
			answer -= 1;
	}

	std::cout << answer << std::endl;

	return 0;
}

Measured memory_bytes: 256
from bisect import bisect as B
LI=lambda:map(int,input().split())
A=0
n,m=LI()
a=sorted(LI())
R=a[::-1]
def Q(x,M):
  w=0
  for i in range(n):
    y=x-R[i]
    c=B(a,y-1)
    w+=n-c
    if w>=M:return 1
  return 0
N=a[-1]*3
O=-1
while N-O>1:
  f=(O+N)//2
  if Q(f,m):O=f
  else:N=f
P=0
for i in range(n):
  e=n-B(a,O-a[i]-1)
  P+=e
  A+=e*a[i]*2
print(A-O*(P-m))


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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer a;
  int i;
  a=nil->next;
  while((a!=nil) && (a->key!=key)){
    a=a->next;
  }
    return a;

}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  //deleteの処理
  t->prev->next=t->next;
  t->next->prev=t->prev;
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil )return;
  //最初をdelete
  deleteNode(t);
}

void deleteLast(){
  NodePointer t=nil->prev;
  if(t==nil)return;
  //最後をdelete
  deleteNode(t);

}

void delete(int key){//Hitしたらdelete
  NodePointer c;
  if((c=listSearch(key))!=NULL){
    if(c==nil) return;
    deleteNode(c);
    }
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next=nil->next;
  
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}

int main(){
  int key, n, i,null;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}

Measured memory_bytes: 34976
#include<stdio.h>
int A[1000000], n;
int binarySearch(int key){
int left = 0;
int right = n;
int mid;
while(left < right){
mid = (left + right) / 2;
if(key == A[mid]) return 1;
if(key > A[mid]) left = mid + 1;
else if(key < A[mid]) right = mid;
}
return 0;
}
int main(){
int i, q, k, sum;
scanf("%d", &n);
for(i = 0; i < n; i++){
scanf("%d", &A[i]);
}
scanf("%d", &q);
for(int i = 0; i < q; i++){
scanf("%d", &k);
if(binarySearch(k)) sum++;
}
printf("%d\n", sum);
return 0;
}


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

int main(){
    
    int r,c;
    cin>>r>>c;
    
    int num[101][101]={};
    
    for(int i=0;i<r;i++)
        for(int j=0;j<c;j++) cin>>num[i][j];
        
         for(int i=0;i<r;i++)
            for(int j=0;j<c;j++) num[r][c] += num[i][j];
        
        for(int i=0;i<r;i++){
          int sum=0;
            for(int j=0;j<c;j++)
             sum += num[i][j];
                num[i][c] = sum;
        }
        
       for(int j=0;j<c;j++){ 
        int sum = 0;
            for(int i=0;i<r;i++)
             sum += num[i][j];
             num[r][j] = sum;
        }
        for(int i=0;i<=r;i++){
           for(int j=0;j<=c;j++){
                if(j) cout<<" ";
                cout<<num[i][j];
            }
            cout<<endl;
        }
        
        
        return 0;
}


Measured memory_bytes: 3112
#include <stdio.h>
#include <iostream>
#include <algorithm>
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
const int MOD=1e9+7;
const int MAXN=1e2;
typedef long long ll;
int dp[2010];
int main()
{
    ios;
    int s;
    cin>>s;
    dp[0]=1;
    for(int i=0;i<=s;i++){
        for(int j=3;i+j<=s;j++){
            dp[i+j]=(dp[i+j]+dp[i])%MOD;
        }
    }
    cout<<dp[s]<<'\n';
    return 0;
}

Measured memory_bytes: 3616
#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<string>
#include<unordered_map>
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,k
#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 sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/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;}
/*float n乗*/ll floatpow(float x,ll n){ll i;float 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;}
double ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
 ll n,k;
 sc(n);sc(k);
 char s[n+1];sc(s);
 s[k-1]-='A'-'a';
 pr(s);
  
return 0;}

Measured memory_bytes: 3620
#include<cstdio>

using namespace std;
int main(void)
{
	int a[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
	int m,n;
	while(scanf("%d%d",&m,&n))
	{
		if(m == 0 && n == 0) break;
		for(int i = 0;i < m;i++)
		{
			n += a[i];
		}
		switch(n%7)
		{
		case 1:
			printf("Thursday\n");
			break;
		case 2:
			printf("Friday\n");
			break;
		case 3:
			printf("Saturday\n");
			break;
		case 4:
			printf("Sunday\n");
			break;
		case 5:
			printf("Monday\n");
			break;
		case 6:
			printf("Tuesday\n");
			break;
		case 0:
			printf("Wednesday\n");
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1012
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <list>
#include <string>
#include <numeric>
#include <utility>
#include <cfloat>
#include <set>

using namespace std;

int T[100];
int P[100];
int X[100];
int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> T[i];
    }
    int M;
    cin >> M;
    for(int i = 0; i < M; i++){
        cin >> P[i] >> X[i];
    }

    long long total_time = 0;
    for(int i = 0; i < N; i++){
        total_time += T[i];
    }

    for(int i = 0; i < M; i++){
        cout << total_time - T[P[i] - 1] + X[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
using namespace std;
int main(){
	int a = 0, b = 0, c=0, d[100000], e[100000],f=0, count = 0;
	char uc[100000];
	cin >> a>>b;
	if (a <= b) {
		cout << 0 << endl;
	}
	else {
		cout << a - b << endl;
	}
	
		return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N=int(input())
a=0
for i in range(9,1,-1):
    if N%i!=0:
        continue
    if 1<=N//i<=9:
        print("Yes")
        a=1
        break
    else:
        print("No")
        a=1
        break
if a==0:
    if N==1:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
} read;

const int maxn = 5050;
ll f[maxn][maxn];
int g[maxn];

int main () {
	int n = read, mod = read;

	for (int i = 1; i < n; i ++)
		g[i] = std::min(i, n - i + 1);

	f[0][0] = 1;
	for (int i = 1; i < n; i ++) {
		for (int j = 0; j < g[i]; j ++)
			f[i][j] = f[i - 1][j];
		for (int j = g[i]; j < n; j ++)
			f[i][j] = (f[i][j - g[i]] + f[i - 1][j]) % mod;
	}

	ll ans = 0;
	for (int j = 0; j < n; j ++)
		(ans += (n - j) * f[n - 1][j]) %= mod;
	printf("%lld\n", ans);
}


Measured memory_bytes: 198784
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    numbers=[]
    number = int(input())
    numbers=[int(input()) for _ in range(number)]
    answers=[-10**9]*number
    buy_point=10**9

    if len(numbers)==2:
        print(numbers[1]-numbers[0])
        exit()

    for idx,value in enumerate(numbers):
        if buy_point==10**9:
            buy_point=value
            continue
        else:
            answers[idx]=value-buy_point
            if buy_point > value:
                buy_point=value
#            print("buy_point={},value={}".format(buy_point,value))
    print(max(answers))
            
if __name__=="__main__":
    main()


Measured memory_bytes: 21516
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int n;
int item[114514];
int main(){
    while(cin>>n){
        int cnt=0,can=0;
        if(n==0)break;
        for(int i=0;i<n;i++){
            cin>>item[i];
            if(item[i]>0)cnt++;
            if(item[i]>1)can=1;
        }
        if(can==1)cout<<cnt+1<<endl;
        else cout<<"NA"<<endl;
    }
return 0;
}

Measured memory_bytes: 1204
n = int(input())
c = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1, n+1):
    s = str(i)
    c[int(s[0])][int(s[-1])] += 1
ans = 0
for i in range(1, n+1):
    s = str(i)
    ans += c[int(s[-1])][int(s[0])]
print(ans)

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int x;
    cin >> x;
    if (x == 5 || x == 3 || x == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
 
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll h,w;
    cin>>h>>w;
  ll ans=10000000000;

  //縦に3つ
  for(int i=1;i<h-1;i++){
    ll a=i*w;
    ll b=(h-i)/2*w;
    ll c=(h-i-(h-i)/2)*w;
    ll now=max({a,b,c})-min({a,b,c});
    chmin(ans,now);
  }
  //横に3つ
  for(int i=1;i<w-1;i++){
    ll a=i*h;
    ll b=(w-i)/2*h;
    ll c=(w-i-(w-i)/2)*h;
    ll now=max({a,b,c})-min({a,b,c});
    chmin(ans,now);
  }

  //T字
  for(int i=1;i<h;i++){
    ll a=i*w;
    ll b=(w/2)*(h-i);
    ll c=(w-w/2)*(h-i); 
    ll now=max({a,b,c})-min({a,b,c});
    chmin(ans,now);
  }

  //ト
  for(int i=1;i<w;i++){
    ll a=i*h;
    ll b=(h/2)*(w-i);
    ll c=(h-h/2)*(w-i);
    ll now=max({a,b,c})-min({a,b,c});
    chmin(ans,now);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <random>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const lint mod = 1e9 + 7, INF = 1e18;
lint dx[8] = { 0, -1, 1, 0, 1, -1, 1, -1 }, dy[8] = { 1, 0, 0, -1, -1, -1, 1, 1 };
typedef pair<double, lint> Pa;

lint R, C, K, r, c, v;

lint dp[3030][3030][4];
lint arr[3000][3000];
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> R >> C >> K;
	REP(i, R + 1) {
		REP(j, C + 1) {
			REP(k, 4) {
				dp[i][j][k] = -INF;
			}
		}
	}
	REP(i, R) {
		REP(j, C) {
			arr[i][j] = 0;
		}
	}
	REP(i, K) {
		cin >> r >> c >> v; r--; c--;
		arr[r][c] = v;
	}
	dp[0][0][0] = 0;
	REP(i, R) {
		REP(j, C) {
			IREP(k, 3) chmax(dp[i][j][k + 1], dp[i][j][k] + arr[i][j]);
			REP(k, 4){
				if (dp[i][j][k] >= 0) {
					chmax(dp[i][j + 1][k], dp[i][j][k]);
					chmax(dp[i + 1][j][0], dp[i][j][k]);
				}
			}
		}
	}
	lint ans = -INF;
	REP(i, 4) chmax(ans, dp[R - 1][C - 1][i]);
	cout << ans << endk;
}


Measured memory_bytes: 358060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=2e5+7;
int base[5005][13];
int n,m;
int x;
int c[15];
int a[15][15];
int tmp[15];
int p[20][20];
void init()
{
    for(int i=1;i<=5000;i++){
        for(int j=0;j<12;j++){
            if((i>>j)&1){
                base[i][j]=1;
            }
        }
    }
}
int main()
{
    init();
    /*for(int i=0;i<10;i++){
        for(int j=0;j<12;j++){
            printf("%d ",base[i][j]);
        }
        printf("\n");
    }*/
    scanf("%d%d",&n,&m);
    scanf("%d",&x);
    for(int i=0;i<n;i++){
        for(int j=0;j<m+1;j++){
            scanf("%d",&p[i][j]);
        }
    }
    for(int i=0;i<n;i++){
        c[i]=p[i][0];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            a[i][j]=p[i][j+1];
        }
    }
    int f=0;
    int res=1e9;
    for(int i=1;i<=(1<<n)-1;i++){
        int pre=0;
        for(int j=0;j<m;j++){
            tmp[j]=0;
        }
        for(int j=0;j<n;j++){
            if(base[i][j]){
                pre+=c[j];
                for(int k=0;k<m;k++){
                    tmp[k]+=a[j][k];
                }
            }
        }
        int ko=0;
        for(int j=0;j<m;j++){
            if(tmp[j]<x){
                ko=1;
                break;
            }
        }
        if(ko==0){
            res=min(res,pre);
            f=1;
        }
    }
    if(f==0){
        printf("-1\n");
    }
    else{
        printf("%d\n",res);
    }
    return 0;
}


Measured memory_bytes: 4072
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    string s,s_moto;
    cin >>s;
    s_moto=s;
    reverse(s.begin(), s.end());
    string mae_s,ato_s;
    int n;
    n=(int)s.length();
    mae_s=s_moto.substr(0, (n-1)/2);
    ato_s=s_moto.substr((n+3)/2-1,n);
    // cout <<n;
    // cout << "mae" << mae_s << endl;
    // cout << "ato " << ato_s << endl;

    string s2,s3;
    s2=mae_s;
    s3=ato_s;
    reverse(mae_s.begin(), mae_s.end());
    reverse(ato_s.begin(), ato_s.end());
    if(s==s_moto){
        if(s2==mae_s){
            if(s3==ato_s){
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
import itertools
n, m, q = map(int, input().split())
Q = [list(map(int, input().split())) for i in range(q)]
m = [i for i in range(1, m+1)]
p = itertools.combinations_with_replacement(m, n)

ans = []
for v in p:
    count = 0
    for i in Q:
        if v[i[1]-1]-v[i[0]-1] == i[2]:
            count += i[3]
    ans.append(count)
print(max(ans))

Measured memory_bytes: 79204
n = int(input())
l = list(map(int,input().split()))
mod = 10**9+7

ones = [0]*60
ans = 0
for i in range(n):
    x = l[i]
    for j in range(60):
        ones[j] += (x>>j)&1
    ans = (ans + (n-1)*x)%mod
# print(ans)

for i in range(60):
    ans = (ans - ones[i]*(ones[i]-1)*2**i)%mod
print(ans)

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

using namespace std;

int main(void){
    long long n, m, k;
    cin >> n >> m >> k;
    
    vector<long long> a(n);
    vector<long long> b(m);
    
    for (int i= 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];
    
    vector<long long> sumA(n+1);
    vector<long long> sumB(m+1);
    
    for (int i = 1; i <= n; i++) sumA[i] = sumA[i-1] + a[i-1];
    for (int i = 1; i <= m; i++) sumB[i] = sumB[i-1] + b[i-1];
    
    int ans = 0;
    
    for (int i = 0; i <= n; i++){
        long long temp = k - sumA[i];
        if (sumA[i] > k) continue;
        
        if (sumA[i] == k) ans = max(ans,i);
        
        int numberOfB = upper_bound(sumB.begin(),sumB.end(),temp) - sumB.begin() - 1;
        ans = max(ans, i+numberOfB);

    }
    
    cout << ans << endl;
}


Measured memory_bytes: 9560