akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(ll i=0;i<(n);++i)
#define Fr(i,n) for(long long i=1;i<=(n);++i)
#define ifr(i,n) for(long long i=(n)-1;i>=0;--i)
#define iFr(i,n) for(long long i=(n);i>0;--i)

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n,mm,mmm;
  string s;
  cin>>n>>s;
  mm=-48+s[0];
  if(s.size()>2){
    if(s.size()>3){
      mmm=(-48+s[2])*10-48+s[3];
    }
    else{
      mmm=(-48+s[2])*10;
    }
  }
  
  cout<<n*mm+(mmm*n)/100;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, K;
int white[1000][1000];
int black[1000][1000];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> K;
  rep(i, N) {
    int x, y; char ch;
    cin >> x >> y >> ch;
    int c = ch == 'B';
    c ^= (x/K)&1;
    c ^= (y/K)&1;
    x %= K;
    y %= K;
    if (c == 0) white[x][y]++;
    else black[x][y]++;
  }
  rep(x, K-1) rep(y, K) white[x+1][y] += white[x][y];
  rep(x, K) rep(y, K-1) white[x][y+1] += white[x][y];

  rep(x, K-1) rep(y, K) black[x+1][y] += black[x][y];
  rep(x, K) rep(y, K-1) black[x][y+1] += black[x][y];
  int m = 0;
  rep(x, K) {
    rep(y, K) {
      int match = 0;
      if (x>0&&y>0) match += 2*black[x-1][y-1];
      match += black[K-1][K-1];
      if (x>0) match -= black[x-1][K-1];
      if (y>0) match -= black[K-1][y-1];

      if (x>0) match += white[x-1][K-1];
      if (y>0) match += white[K-1][y-1];
      if (x>0&&y>0) match -= 2*white[x-1][y-1];
      m = max(m, match);
      m = max(m, N-match);
    }
  }
  cout << m << "\n";
  return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=2e5+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
}
int n,m;
vector<int>E[N];
#define pb push_back
void input()
{
	int x,y;
	n=read<int>();
	For(i,1,n<<1)
	{
		x=read<int>(),y=read<int>()+n;
		E[x].pb(y),E[y].pb(x);
	}
}
const int mo=1e9+7;
int ans,inv[N];
int vis[N],edge;
int node[N],cnt;
int c[N],top;
int fa[N];
int stk[N],tp;
void dfs1(int u,int pre)
{
	//cerr<<u<<endl;
	node[++cnt]=u;stk[++tp]=u,vis[u]=1,stk[tp+1]=0;
	//cerr<<cnt<<endl;
	edge+=(int)E[u].size();
	for(int v:E[u])if(v^pre)
	{
		if(!vis[v])dfs1(v,u);
		else if(!top)
		{
			while(stk[tp+1]!=v)vis[c[++top]=stk[tp--]]=2;
			c[0]=v;
		}
	}
	if(!top)--tp;
}
void dfs2(int u,int pre)
{
	for(int v:E[u])if(v^pre&&vis[v]<2)
	{
		fa[v]=u;
		dfs2(v,u);
	}
}
vector<int>G[N];
int d[N],sz[N];
void dfs3(int u,int &res)
{
	sz[u]=1;
	for(int v:G[u])
	{
		dfs3(v,res);
		sz[u]+=sz[v];
	}
	res=1ll*res*inv[sz[u]]%mo;
}
int cal()
{
	int res=1;
	For(i,1,cnt)
	{
		res=1ll*res*i%mo;
		d[node[i]]=0;
		G[node[i]].clear();
	}
	For(i,1,cnt)
	{
		for(int v:E[node[i]])if(v<fa[node[i]])
		{
			G[node[i]].pb(v);d[v]++;
		}
	}
	For(i,1,cnt)if(!d[node[i]])dfs3(node[i],res);
	return res;
}
void init(int st)
{
	int res=0;
	cnt=top=tp=edge=0;	
	dfs1(st,0);	
	if(edge!=(cnt<<1)){puts("0");exit(0);}
	For(i,1,top)dfs2(c[i],0);	
	For(i,1,top)fa[c[i-1]]=c[i];
	res=cal();
	For(i,1,top)fa[c[i]]=c[i-1];
	res=(res+cal())%mo;
	ans=1ll*ans*res%mo;
	For(i,1,cnt)ans=1ll*ans*inv[i]%mo;
	//cerr<<cnt<<endl;
}
void work()
{
	ans=1;
	inv[0]=inv[1]=1;
	For(i,2,n<<1)ans=1ll*ans*i%mo,inv[i]=1ll*inv[mo%i]*(mo-mo/i)%mo;
	For(i,1,n<<1)if(!vis[i])init(i);
	write(ans,'\n');
}
int main()
{

	input();
	work();
	return 0;
}



Measured memory_bytes: 27520
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
int main()
{
  int n;
  cin>>n;
  if(n%1000==0)
  cout<<0;
  else
  {
  	int k=n%1000;
  	cout<<1000-k;
  }
  
}


Measured memory_bytes: 3604
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < ll >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < ll , ll >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 
const ll inf=1e18+1e17;
const ll moda =29;
const ll modb =34483;
//const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
/*ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}*/
const ll N =2e5+5;
int arr[N],brr[N];
void init(){
	for ( int i=0;i<N;i++){
		arr[i]=i;
		brr[i]=1;
	}
}
int root( int pos){
	if ( arr[pos]==pos)
		return pos;
	return arr[pos]=root( arr[pos]);
}
void join ( int x, int y){
	x=root( x);
	y=root( y);
	if ( x==y)
		return ;
	if ( brr[x]> brr[y])
		swap( x,y);
	arr[x]=y;
	brr[y]+=brr[x];
}
void solve(){
	int n,m;
	cin>>n>>m;
	init();
	for ( int i=0;i<m;i++){
		int aa, bb;
		cin>>aa>>bb;
		aa--;bb--;
		join ( aa,bb);
	}
	int mx=0;
	for ( int i=0;i<n;i++)
		mx=max(brr[root(i)],mx);
	cout<<mx<<'\n';

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

	#ifndef ONLINE_JUDGE
		freopen ("INPUT.txt" , "r" , stdin);
		freopen ("OUTPUT.txt", "w" , stdout);
	#endif
	
	ll t=1;
	//cin>>t;
	for ( ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
    	solve();
    }
}

Measured memory_bytes: 5220
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <climits>
using namespace std;
using Int = long long;
int main()
{
    int N;
    cin >> N;
    vector<Int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    int x = 1, y = 2, z = 3;
    Int p = A[0], q = A[1], r = A[2], s = accumulate(&A[3], &A[N], 0ll);
    Int result = LLONG_MAX;
    while (y < N-1) {
        while (abs(p-q) > abs(p-q+2*A[x])) {
            p += A[x];
            q -= A[x];
            x++;
        }
        while (abs(r-s) > abs(r-s+2*A[z])) {
            r += A[z];
            s -= A[z];
            z++;
        }
        Int L[4] = {p, q, r, s};
        sort(L, L+4);
        result = min(result, abs(L[0]-L[3]));
        q += A[y];
        r -= A[y];
        y++;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>

//#define INF 100000000
//#define MOD (int) (1e9+7)
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

const int MAX = 1000000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    // 前処理
    COMinit();

    long long int ans = 0;

    long long int x, y;
    for(long long int i = 0; i <= n; i++){
        x = i;
        if((k-a*x)%b != 0) continue;
        y = (k-a*x)/b;
        if(y < 0 or y > n) continue;
        ans = (ans + (COM(n, x) * COM(n, y)) % MOD) % MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 23680
#include <stdio.h>

typedef unsigned long ulong;

static inline ulong diff(ulong a, ulong b){
    return __builtin_ctzl(a^b);
}
/*
static inline void pl(long n){
#define L 8
    char c[L];
    long i=L-1;
    do{
        c[i]=n%10+'0';
        n/=10;
        i--;
    }while(n>0);
    for(i++;i<L;i++){
        putchar_unlocked(c[i]);
    }
}

static inline void puts_unlocked(const char *s){
    for(size_t i=0; s[i]!='\0'; i++){
        putchar_unlocked(s[i]);
    }
    putchar_unlocked('\n');
}
*/
#define N 17
long data[1<<N];
char buf[819200];
size_t point=0;

static inline void pc(char c){
    buf[point] = c;
    point++;
}
static inline void pl(long n){
#define L 8
    char c[L];
    long i=L-1;
    do{
        c[i]=n%10+'0';
        n/=10;
        i--;
    }while(n>0);
    for(i++;i<L;i++){
        pc(c[i]);
    }
}

static inline void puts_unlocked(const char *s){
    for(size_t i=0; s[i]!='\0'; i++){
        pc(s[i]);
    }
    pc('\n');
}


static void solve(long a, long b, const size_t sp, const size_t ep, long mask){
    if(ep-sp<=2){
        data[sp+0] = a;
        data[sp+1] = b;
        return;
    }
    const ulong d = diff(a, b);
    mask ^= (1<<d);
    const ulong ad = a&(1<<d);
    const ulong bd = b&(1<<d);
    a &= mask;
    b &= mask;
    const ulong ab = a ^ (mask&(-mask));
    const size_t mp = (sp+ep)/2;
    //printf("%ld %ld %ld\n", aa, ab, bb);
    solve(a, ab, sp, mp, mask);
    solve(ab, b, mp, ep, mask);
    for(size_t i=sp; i<mp; i++){ data[i] |= ad; }
    for(size_t i=mp; i<ep; i++){ data[i] |= bd; }
}

int main(void){
    long n, a, b;
    scanf("%ld %ld %ld", &n, &a, &b);
    if(__builtin_popcountl(a)%2 == __builtin_popcountl(b)%2){
        puts("NO");
        return 0;
    }
    solve(a, b, 0, 1<<n, 0xFFFFFFFFFFFFFFFF);
    const size_t m = 1<<n;

    puts_unlocked("YES");
    for(size_t i=0; i<m-1; i++){
        pl(data[i]);
        pc(' ');
    }
    pl(data[m-1]);
    pc('\n');
    fwrite(buf, sizeof(char), point, stdout);
    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
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 int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    int num = 0;
    for(int i = 0;i< s.size();i++){
        if(s[i] != t[i]) num++;
    }
    cout << num << endl;
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long


signed main(){
  int n,m;
  cin>>n>>m;
  queue<int> br;
  stack<int> s;
  int a[100050],b,ans=0;
  rep(i,m){
    cin>>b;
    br.push(b);
  }
  a[0]=1;a[1]=1;
  if(br.front() == 1){
    a[1]=0;
    br.pop();
  }
  int check=0;
  repi(i,2,n+1){
    if(i != br.front() ){
      a[i]=a[i-1]+a[i-2];
      a[i]%=MOD;
      check=0;
     
    }else{
      check=1;
      a[i]=0;
      br.pop();
    }
   
    if(check==2){cout<<0<<endl;return 0;}
  }
 
  cout<<a[n]<<endl;
  return 0;
}

Measured memory_bytes: 1792
h,w = map(int,input().split())

while w != 0 and h != 0:
	for j in range(h):
		for i in range(w):
			if (i + (j % 2)) % 2 == 0:
				print("#", end="")
			if (i + (j % 2)) % 2 == 1:
				print(".", end="")
		print()
	print()
	h,w = map(int,input().split())

	

Measured memory_bytes: 9064
// Problem : 
// 			E - This Message Will Self-Destruct in 5s
// 			Editorial
// 		
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

/* DEBUGGING */
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef unsigned long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

void solve(){
	int n; cin >> n;
	vi v(n);
	rep(i,0,n) cin >> v[i];
	/*
	j-i = v[j]+v[i]
	i+v[i] = j-v[j];
	*/
	
	map<ll,ll>cnt;
	ll ans = 0;
	
	rep(i,0,n){
		ans += cnt[i-v[i]];
		cnt[i+v[i]]++;
	}
	
	cout << ans;
}

int main(){
    IOS;
    solve();
}

Measured memory_bytes: 26704
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N,M;
	cin>>N>>M;
	ll sum = 0LL;
	rep(i,M){
		int t;cin>>t;
		sum += t;
	}
	cout<<max(N-sum,-1LL)<<endl;
	return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int tmp = 0;
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a > b){
			tmp = a;
			a = b;
			b = tmp;
		}
		if(b > c){
			tmp = b;
			b = c;
			c = tmp;
		}
		if(a > b){
			tmp = a;
			a = b;
			b = tmp;
		}
		System.out.println(String.format("%d %d %d",a,b,c));
	}
}



Measured memory_bytes: 26496
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int g,x=1,i=1;//xは時刻iに到達できるborder
    cin >> g;
    while(true){
        if(g<=x){
            break;
        }
        i++;
        x+=i;
    }
    cout << i << endl;
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;


void calc() {

	Int X; std::cin >> X;
	Int ans = 1000 * (X / 500);
	ans += 5 * ((X % 500) / 5);

	std::cout << ans;

}


int main() {

	calc();

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
signed main(){
  ll a,b;
  cin>>a>>b;
  if(a%(b*2+1)==0){
    cout<<a/(b*2+1)<<"\n";
  }else{
    cout<<a/(b*2+1)+1<<"\n";
  }
  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++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

int main() {
  int N; cin>>N;
  cout<<(N+1)/2;
}


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

#define pb push_back
#define rep(i, a, n) for(int (i)=a; (i)<(n); (i)++)
#define FOR(i, n) rep(i, 0, n)
#define F(n) FOR(i, n)
#define FF(n) FOR(j, n)
#define repi(i, a, n) for(int (i)=a; (i)<=(n); (i)++)
#define FORI(i, n) repi(i, 1, n)
#define FI(n) FORI(i, n)
#define FFI(n) FORI(j, n)
#define IN(x) int x; cin>>(x);
#define INN(x, y) int x, y; cin>>(x)>>(y);
#define INFO(a) cout<<"info "<<a<<endl
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define vpii vector<pair<int, int> >
#define sortv(x) sort((x).begin(), (x).end())
#define sortvd(x) sort((x).begin(), (x).end(), greater<int>())
#define lboundv(x,v) lower_bound((x).begin(),(x).end(),(v))-(x).begin();
#define uboundv(x,v) upper_bound((x).begin(),(x).end(),(v))-(x).begin();
#define ite iterator
#define fi first
#define se second
#define mems(a, v) memset((a), (v), sizeof((a)))
#define lmid(l, r) ((l)+(r)-1)/2
#define rmid(l, r) ((l)+(r))/2+1
#define mp make_pair

typedef long long ll;
typedef long double LD;

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	int n, m, k;
	bool ans = false;
	cin>>n>>m>>k;
	F(n+1) {
		FF(m+1) if(i*(m-j)+j*(n-i) == k) {ans=true; break;}
		if(ans) break;
	}
	cout<<(ans ? "Yes" : "No")<<endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())
    c = Counter(list(map(int, input().split())))

    ans = 0
    for k, v in c.items():
        if k > v:
            ans += v
        if k < v:
            ans += v - k
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 18556
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
int a[100100];

int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	a[0]=0;
	int s=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		s+=abs(a[i]-a[i-1]);
	}
	a[n+1]=0;
	s+=abs(a[n+1]-a[n]);
	//cout<<"s:"<<s<<endl;

	for(int i=1;i<=n;i++){
		if(a[i]>a[i-1]&&a[i]>a[i+1]){
			cout<<s-(a[i]-max(a[i-1],a[i+1]))*2<<endl;
		}else if(a[i]<a[i-1]&&a[i]<a[i+1]){
			cout<<s-(min(a[i-1],a[i+1])-a[i])*2<<endl;
		}else{
			cout<<s<<endl;
		}
	}



return 0;
}


Measured memory_bytes: 1664
use std::collections::HashSet;
use std::io::{stdin, Read};

macro_rules! parse {
    ($iter: ident) => {
        $iter.next().unwrap().parse().unwrap()
    };
    ($iter: ident,2) => {
        (parse!($iter), parse!($iter))
    };
    ($iter: ident,3) => {
        (parse!($iter), parse!($iter), parse!($iter))
    };
    ($iter: ident,4) => {
        (parse!($iter), parse!($iter), parse!($iter), parse!($iter))
    };
    ($iter: ident, $n: ident) => {
        $iter.take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut iter = s.split_whitespace();
    let (a, b, c): (usize, usize, usize) = parse!(iter, 3);
    let mut m = HashSet::new();
    m.insert(a);
    m.insert(b);
    m.insert(c);
    if m.len() == 2 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const int N=1000;
int n,a[N][N];
signed main(void){
	ios::sync_with_stdio(false);
	while(cin>>n&&n){
		memset(a,0,sizeof(a));
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				cin>>a[i][j];
		for(int i=1,sum;i<=n;i++){
			sum=0;
			for(int j=1;j<=n;j++)
				sum+=a[i][j];
			a[i][n+1]=sum;
		}
		for(int j=1,sum;j<=n;j++){
			sum=0;
			for(int i=1;i<=n;i++)
				sum+=a[i][j];
			a[n+1][j]=sum;
		}
		int sum=0;
		for(int i=1;i<=n;i++)
			 sum+=a[i][n+1];
		a[n+1][n+1]=sum;
		for(int i=1;i<=n+1;i++,cout<<endl)
			for(int j=1;j<=n+1;j++)
				cout<<setw(5)<<a[i][j];
	}
}

Measured memory_bytes: 5108
length, t = map(int, input().split(" "))
target = [int(n) for n in input().split(" ")]
dp = [float("inf") for n in range(length + 1)]
dp[0] = 0
for i, coin in enumerate(target):
    for j in range(length):
        if coin + j <= length:
            dp[coin + j] = min(dp[coin + j], dp[j] + 1)
print(dp[length])


Measured memory_bytes: 7652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;


void solve(long long N, long long K, std::vector<long long> A, std::vector<long long> F){
    sort(A.begin(),A.end());
    sort(F.rbegin(),F.rend());
    long long l=-1 ,r=1e12;
    while (l+1<r){
        long long c =(l+r)/2;
        bool ok =[&]{
            long long s=0;
            for (int i = 0; i < N; i++)
            {
                s+=max(0LL,A[i]-c/F[i]);
            }
            return s<=K;
        }();
        if(ok) r=c; else l=c;
    }
    cout<<r<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> F(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&F[i]);
    }
    solve(N, K, std::move(A), std::move(F));
    return 0;
}


Measured memory_bytes: 3328
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in(), a = in(), b = in();
	cout << min(n * a, b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	string s; cin >> s;
	SORT(s);
	if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
bool is_prime(int x)
{
	if ((x & 1) == 0)
		return x == 2;
	int num1 = (int)sqrt(x);
	int num2 = 3;
	while (num2 <= num1)
	{
		if (x % num2 == 0)
			return false;
		num2 += 2;
	}
	return true;
}
int main()
{
	int n, num = 0;
	cin >> n;
	while (n--)
	{
		int x;
		cin >> x;
		if(is_prime(x))
		{
			num++;
		}
	}
	cout << num << endl;
	return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;typedef vector<int> ivec;typedef vector<string> svec;

int main(){
	ivec v;
	int q,a,x,p;
	cin >> q;
	for(int i=0;i<q;i++){
		cin >> a;
		if(a==0){
			cin >> x;
			v.push_back(x);
		}
		if(a==1){
			cin >> p;
			cout << v[p] <<"\n";
		}
		if(a==2){
			v.pop_back();
		}
	}
}


Measured memory_bytes: 3920
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
//#include <algorithm>
#include <vector>

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))

using namespace std;

#define MOD 1000000007

int main(int argc, char* argv[])
{
    long n, a, b;
    scanf("%ld", &n);
    scanf("%ld %ld", &a, &b);

    long zz[3]={0};
    long i;
    for(i=0; i<n; i++) {
        long tmp;
        scanf("%ld", &tmp);
        if(tmp<=a) {
            zz[0]++;
        }
        else if(tmp<=b) {
            zz[1]++;
        }
        else {
            zz[2]++;
        }
    }
    long min = 10000;
    for(i=0; i<3; i++) {
        if(min>zz[i])
            min=zz[i];
    }

    printf("%ld\n", min);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
string S; int len, ans;
int main() {
  cin >> S;
  len = S.size();
  for(int i = 0; i < len/2; ++i) {
    if(S[i] != S[len-i-1]) ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e6;
const int inf=1e9;
int num[size]={};//0:prime,1:not prime
void sieve(){
    num[0]=1;num[1]=1;
    rep(i,0,size)if(num[i]==0){
        for(int j=2*i;j<size;j=j+i) num[j]=1;
    }return;
}
deque<int> prime;
void judge(){
	rep(i,0,size)if(num[i]==0) prime.push_back(i);
    return;
}
int main(){
	int X;cin>>X;
	sieve();
	rep(i,X,2*X){
		if(num[i]==0){
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 4096
#include <iostream>
#include<string>
#include<cctype>
#include<algorithm>
#include <stdio.h>

using namespace std;

int main() {
 
	char x, y;
	int X, Y;
	cin >> x >> y;
	if (x == y)cout << "=" << endl;
	else {
		if (x == 'A')X = 1;
		if (y == 'A')Y = 1;
	    if (x == 'B')X = 2;
	    if (y == 'B')Y = 2;
		if (x == 'C')X = 3;
		if (y == 'C')Y = 3;
		if (x == 'D')X = 4;
		if (y == 'D')Y = 4;
		if (x == 'E')X = 5;
		if (y == 'E')Y = 5;
		if (x == 'F')X = 6;
		if (y == 'F')Y = 6;
		if (X > Y)cout << ">" << endl;
		else cout << "<" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
a,b = gets.split(" ").map{|v|
	v.to_i
}

if (a * b <= 0)
	puts ("Zero")
	exit
end

if (a > 0)
	puts ("Positive")
	exit
end

if ((b - a + 1)%2 == 1)
	#奇数個の掛け算
	puts ("Negative")
else
	puts ("Positive")
end


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

struct Point { double x, y; };

void koch(int n, Point a, Point b) {
	if (n == 0) return;
	Point s, t, u;
	double th = M_PI * 60.0 / 180.0;

	s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
	s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
	t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
	t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
	u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
	u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

	koch(n - 1, a, s);
	printf("%.8f %.8f\n", s.x, s.y);
	koch(n - 1, s, u);
	printf("%.8f %.8f\n", u.x, u.y);
	koch(n - 1, u, t);
	printf("%.8f %.8f\n", t.x, t.y);
	koch(n - 1, t, b);
}

int main() {
	Point a, b;
	int n;

	scanf("%d", &n);

	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;

	printf("%.8f %.8f\n", a.x, a.y);
	koch(n, a, b);
	printf("%.8f %.8f\n", b.x, b.y);

	return 0;
}


Measured memory_bytes: 2676
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,h[100005];
ll dp[100005];
#define ALL(v)  (v).begin(),(v).end()

    /*  ペア関連
    //vector<pair<long long, long long> > pairs(N);
    for(long long i=0; i<N; i++){
        long long a, b;
        cin >> a >> b;
        pairs[i] = make_pair(a, b);
    }
    
    //sort(pairs.begin(), pairs.end(),greater<pair<int,int> >());
	sort(pairs.begin(), pairs.end());
    */

 	//stack<int> sta;   
    //queue<int> que;


int main(){
	int flg,flg1,cnt,cnt1;
	flg=0;
	flg1=0;
	cnt=0;
	cnt1=0;
	
	int N,M,K;
	string s;
    
	std::cin >> N;
    //std::cin >> N >> M;
    //std::cin >> N >> M >> K;
    
	std::vector<long long> v(N);
	std::vector<long long> c(N);	
    //std::cin >> s;
    
    //ソート
    //std::sort(v.begin(),v.end());//昇順ソート
    //std::sort(v.begin(),v.end(),std::greater<long long>());//降順ソート
    
    // 配列入力
    
    for(long long i=0; i<N; i++){
		std::cin >> v[i];
	}
	for(long long i=0; i<N; i++){
		std::cin >> c[i];
	}
	
	int sum;
	sum=0;
	for(long long i=0; i<N; i++){
		if(v[i]>=c[i]){
			sum+=v[i]-c[i];
		}
	}
	
	
	//文字列入力
	/*
	for(long long i=0; i<s.length(); i++){
		
		if(s[i]!='1'){
	}
	*/
    if(1){
    	printf("%d",sum);
    	//puts("Yes");
    	//文字列の出力
    	//std::cout << s << std::endl;
	}
	else{
		//puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n; cin>>n; 
    int ac=0,wa=0,tle=0,re=0;
    while (n--){
        string s; 
        cin >> s;
        if (s=="AC") ac++;
        if (s=="WA") wa++;
        if (s=="TLE") tle++;
        if (s=="RE") re++;
    }
    cout << "AC x "<< ac <<endl;
    cout << "WA x "<< wa <<endl;
    cout << "TLE x "<< tle <<endl;
    cout << "RE x "<< re <<endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

int main() {
  int n, cnt = 0; cin >> n;
  vector<int> a(n); rep(i, n) cin >> a[i];
  rep(i, n) {
    if ((i+1) % 2 == 1 && a[i] % 2 == 1)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#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++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k;cin>>n>>k;
  vector<int>l(n);
  rep(i,n)cin>>l[i];
  sort(all(l),greater<int>());
  int res=0;
  rep(i,k)res+=l[i];
  cout<<res<<endl;
  

  return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    static int N;
    static int[] a;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();

        a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }

        solve();
    }

    static void solve() {
        long sum = 0;
        for (int ai : a) {

            int temp = 0;
            while (true) {
                if (ai % 2 == 0) {
                    temp++;
                    ai /= 2;
                } else {
                    break;
                }
            }
            sum += temp;
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 34260
import sys
from string import ascii_uppercase as A2Z

input = sys.stdin.readline


def main():
    H, W = map(int, input().split())
    S = [None] * H
    for i in range(H):
        S[i] = input().split()

    for h in range(H):
        for w in range(W):
            if S[h][w] == "snuke":
                ans = A2Z[w] + str(h + 1)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9888
def fact(n: int, mod: int) -> int:
    res = 1
    for i in range(n,1,-1):
        res = (res * i) % mod
        
    return res % mod

def judge(n:int, m:int, mod:int) -> int:
    if abs(n-m) >= 2:
        return 0
    elif abs(n-m) == 1:
        return (fact(n,mod) * fact(m,mod)) % mod
    else:
        return (2 * fact(n,mod) * fact(m,mod)) % mod
    
N, M = map(int, input().split())
MOD = 10**9+7

ans = judge(N,M,MOD)

print(ans)

Measured memory_bytes: 3064
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline




def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())

directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count

N=int(input())

x= [np.array(acinput())for i in range(N)]
#x = [acinput() for i in range(N)]
#print(tmp)
#x=sorted(tmp)

import itertools as it

from collections import defaultdict
#es=10**10

#dc={}
dc=defaultdict(int)

for cb in it.combinations(x,2):
    d=cb[0]-cb[1]
    d2=tuple(-d)
    d=tuple(d)
    dc[d]+=1
    dc[d2]+=1

#print(dc)    
if N==1:
    print(1)
else:
    print(N-max(dc.values()))
    
    


Measured memory_bytes: 13012
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
  ll sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
  ll x = tx-sx, y = ty-sy;
  rep(i, y) cout << 'U';
  rep(i, x) cout << 'R';
  rep(i, y) cout << 'D';
  rep(i, x) cout << 'L';
  cout << 'L';
  rep(i, y+1) cout << 'U';
  rep(i, x+1) cout << 'R';
  cout << 'D' << 'R';
  rep(i, y+1) cout << 'D';
  rep(i, x+1) cout << 'L';
  cout << 'U' << endl;
}

Measured memory_bytes: 3612
n, a, b, c = map(int, input().split())
take = []

for i in range(n):
    t = int(input())
    take.append(t)

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

def cal_cost(li, a):
    if li == []:
        return 10**12
    co = 0
    if len(li) == 1:
        co += abs(li[0] - a)
    else:
        co += abs(sum(li) - a)
        co += (len(li) - 1) * 10
    return co

min_cost = 10**12
for i in range(4**n):
    cost = 0
    num = Base_10_to_n(i, 4).zfill(n)
    for_A = []
    for_B = []
    for_C = []
    for j in range(n):
        if num[j] == '1':
            for_A.append(take[j])
        elif num[j] == '2':
            for_B.append(take[j])
        elif num[j] == '3':
            for_C.append(take[j])
    cost += cal_cost(for_A, a)
    cost += cal_cost(for_B, b)
    cost += cal_cost(for_C, c)
    if cost < min_cost:
        min_cost = cost

print(min_cost)


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

using ll=long long;
using namespace std;

#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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

const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int a, b;
    char op;
    while (true)
    {
        cin >> a >> op >> b;
        if (op == '?')
        {
            break;
        }
        if (op == '+')
        {
            cout << a + b << endl;
        }
        if (op == '-')
        {
            /* code */
            cout << a - b << endl;
        }
        if (op == '/')
        {
            /* code */
            cout << a/b << endl;
        }
        if (op == '*')
        {
            /* code */
            cout << a*b << endl;
        }
    }
}


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

int main(){
    
    int h,w;
    cin>>h>>w;

    int start;

    vector<vector<int>> m;
    for(int i=0;i<h;i++){
        vector<int> v;
        for(int j=0;j<w;j++){
            char c;
            cin>>c;
            if(c=='#')
                v.push_back(-1);
            else
                v.push_back(0);
        }
        m.push_back(v);
    }
    

    for(int i=0;i<h;i++){
        start = 0;
        for(int j=0;j<w;j++){
            if(m[i][j] == -1){
                for(int k=start;k<j;k++){
                    m[i][k] = j - start;
                }
                start = j+1;
            }
            if(j==w-1){
                for(int k=start;k<=j;k++){
                    m[i][k] = j- start+1;
                }
            }
        }
    }

    // for(int i=0;i<h;i++){
    //     for(int j=0;j<w;j++){
    //         cout<<m[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    // cout<<endl;

    for(int i=0;i<w;i++){
        start = 0;
        for(int j=0;j<h;j++){
            if(m[j][i] == -1){
                for(int k=start;k<j;k++){
                    m[k][i] += j - start;
                }
                start = j+1;
            }
            if(j==h-1){
                for(int k=start;k<=j;k++){
                    m[k][i] += j- start+1;
                }
            }
        }
    }

    // for(int i=0;i<h;i++){
    //     for(int j=0;j<w;j++){
    //         cout<<m[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }

    int ans=0;
    //int ma = 0;

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            ans = max(ans, m[i][j]);
           // cout<<ans<<" ";
        }
       // cout<<endl;
    }

    cout<<ans-1<<endl;


}

Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

using ll =  long long;

constexpr ll MOD = 1000000007;

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

    vector<int> quotients(1, 0);
    for(int i=1;i<=min(n, int(sqrt(n))+1);++i) {
        quotients.push_back(n/i);
        quotients.push_back(n/(n/i));
    }
    sort(quotients.begin(), quotients.end());
    quotients.erase(unique(quotients.begin(), quotients.end()), quotients.end());
    int m = quotients.size();

    vector<int> inv_quotients_idx(m, -1);
    {   
        int j = m-1;
        for(int i=1;i<m;++i) {
            while(i <= j && quotients[i]*quotients[j] > n) --j;
            if(i > j) break;
            inv_quotients_idx[i] = j;
            inv_quotients_idx[j] = i;
        }
    }
    
    vector<vector<ll>> dp(k+1, vector<ll>(m, 0));
    for(int j=1;j<m;++j) dp[0][j] = quotients[j];
    for(int i=1;i<k;++i) {
        for(int j=1;j<m;++j) {
            dp[i][j] = (dp[i-1][inv_quotients_idx[j]] * (quotients[j] - quotients[j-1])) % MOD;
        }

        for(int j=1;j<m;++j) {
            dp[i][j] += dp[i][j-1];
            dp[i][j] %= MOD;
        }
    }

    cout << dp[k-1][m-1] << endl;
    
}

Measured memory_bytes: 51452
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

class UnionFindTrees{
	public:
		UnionFindTrees(int _n){
			n = _n;
			root = vector<int>(_n);
			tree_size = vector<int>(_n,1);
			rep(i,_n) root[i] = i;
		}
		int find(int x){
			if(root[x]==x) return x;
			else return root[x]=find(root[x]);			
		}
		bool same(int x, int y){
			return find(x)==find(y);
		}
		void union_tree(int x, int y){
			if(same(x,y)) return;
			int rt_x = root[x];
			int rt_y = root[y];	
			root[rt_y] = rt_x;
			tree_size[rt_x] += tree_size[rt_y];
			n--;			
		}
		int get_tree_size(int x){
			return tree_size[find(x)];
		}
		int forest_size(){return n;}
	private:
		vector<int> root;
		vector<int> tree_size;
		int n;

};
int main(void) {
	int n,m,k; cin >> n >> m >> k;
	UnionFindTrees uft(n);
	vi friends(n,0);
	rep(i,m){
		int a,b; cin >> a >> b;
		a--; b--;
		uft.union_tree(a,b);
		friends[a]++;
		friends[b]++;
	}
	vi blocks(n,0);
	rep(i,k){
		int c,d; cin >> c >> d;
		c--; d--;
		if(uft.same(c,d)){
			blocks[c]++;
			blocks[d]++;
		}
	}
	vi ans(n);
	rep(i,n){
		ans[i] = uft.get_tree_size(i)-1;
//		cout << ans[i] << " ";
		ans[i] -= friends[i];
		ans[i] -= blocks[i];
	}
	rep(i,n) cout << ans[i] << " ";
	cout << endl;
}




Measured memory_bytes: 3200
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,pii> pl;
int n;
ll a[303][303];
const ll inf = 10000000000000;
priority_queue<pl, vector<pl>, greater<pl>> pq;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            scanf("%lld",&a[i][j]);
        }
    }

    ll ans = 0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            pq.emplace(a[i][j], pii(i,j));
            ans += a[i][j];
        }
    }
    int flag = 0;
    while(!pq.empty()){
        auto p = pq.top();
        pq.pop();
        int x = p.second.first;
        int y = p.second.second;
        ll d = inf;
        for(int i=1;i<=n;i++){
            if(i!=x && i!=y)d = min(d, a[x][i] + a[i][y]);
        }
        if (p.first > d){
            flag = 1;
            break;
        }
        else if (p.first == d){
            ans -= d;
        }
    }
    printf("%lld\n", flag ? -1 : ans);
}


Measured memory_bytes: 2168
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int n,i,res=0;
  string s,t,u;
  cin >> n;
  cin >> s;
  u=s.substr(0,1);
  for(i=1;i<n;i++){
    t=s.substr(i,1);
    if(t!=u){
      res++;
      u=t;
    }
  }
  res++;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 512
n, m = map(int, input().split())

order = [[] for i in range(n + 1)]
id_perf_map = [-1 for i in range(m + 1)]

for i in range(1, m + 1):
    p, y = map(int, input().split())
    id_perf_map[i] = p
    order[p].append((i, y))

id_num_map = [-1 for i in range(m + 1)]

for i in range(1, n + 1):
    order[i] = list(sorted(order[i], key=lambda x: x[1]))
    for idx, (city_id, _) in enumerate(order[i]):
        id_num_map[city_id] = idx + 1

for i in range(1, m + 1):
    print('{:06}{:06}'.format(id_perf_map[i], id_num_map[i]))



Measured memory_bytes: 38028
#include <iostream> 
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int inf = 1e9+123;


void solve()
{
	int n;
	string s;
	cin >>  n >> s;
	if((int)s.size()>n)
	{
		for(int i=0; i<n; i++)
			cout << s[i];
		cout << "..." << endl;
	}
	else
		cout << s;

}

int main()
{	
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
//	int t;
//	cin >> t;
//	while(t--)
	solve();
}

Measured memory_bytes: 3652