akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>











string s;



void solve()
{
	cin>>s;
	if(s.substr(0,4)=="YAKI")cout<<"Yes\n";
	else cout<<"No\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main() {
  long long n;
  cin >> n;
  int min = 0;
  for (int i = sqrt(n); i > 0; i--) {
    if (n % i == 0) {
      int x = n / i;
      while (x > 0) {
        min++;
        x /= 10;
      }
      break;
    }
  }
  cout << min << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
ll kitai(ll m){// 2倍
    return m + 1;
}
int main(){
    ll N,K;
    cin >>N>>K;
    vector<ll> wa(N + 1);
    wa[0] = 0;
    ll n;
    rep(i,N){
        cin >> n;
        wa[i + 1] = wa[i] + kitai(n);
    }
    ll ans = 0;
    rep(i,N - K + 1){
        ans = max(ans,wa[i + K] - wa[i]);
    }
    if(ans % 2 == 0){
    cout << ans / 2 << endl;
    }
    else cout << ans / 2 << ".5" << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(ll i=n;i<=N;++i)
#define rap(i,n,N) for(int i=n;i>=N;--i)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
//#define ff fi.fi
//#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cerr << ">>>>>> " << #x << " -> " << x << endl
#define nani(x) cerr <<  "Line " << __LINE__ << ": " << #x << " is " << x << endl
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define piii pair<int,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl '\n'
const int MAX = 50+5;
const ll MAX2 = 11;
const ll MOD = 1000000007;
const ll MOD2 = 1000005329;
const ll INF = 2e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 2000;

int n,m,k,x,y,c,le[MAX][MAX],ri[MAX][MAX],jk,ans;

int main(){
//	cout<<fixed<<setprecision(10);
//    freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n>>m>>k;
    rep(i,1,n)rep(j,1,m)le[i][j] = -1e9, ri[i][j] = 1e9;
    while(k--){
    	cin>>x>>y>>c;
    	rep(i,1,n)rep(j,1,m){
    		jk = abs(i-x) + abs(j-y);
    		if(c+jk<le[i][j]||c-jk>ri[i][j])return cout<<"No\n",0;
    		le[i][j] = max(le[i][j],c-jk), ri[i][j] = min(ri[i][j],c+jk);
		}
	}
	rep(i,1,n)rep(j,1,m)ans+=le[i][j];
	cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3220
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    long N = in.nextLong();

    int ans = digit(N);
    for (long i = 1; i <= Math.sqrt(N); i++) {
      if (N % i == 0) {
        ans = Math.min(ans, digit(N / i));
      }
    }

    System.out.println(ans);
  }

  public static int digit(long l) {
    return String.format("%d", l).length();
  }
}

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

const int MAXN = 123;
int N;
int freq[MAXN];

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		int d; scanf("%d", &d);
		freq[d]++;
	}
	bool ans = true;
	int diam = N-1;
	while (freq[diam] == 0) diam--;
	int mi = 0;
	while (freq[mi] == 0) mi++;
	ans &= (mi == (diam + 1) / 2);
	ans &= (freq[mi] == (diam % 2) + 1);
	for (int i = mi+1; i <= diam; i++) ans &= (freq[i] >= 2);
	if (ans) puts("Possible");
 	else puts("Impossible");

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;

int main(void)
{
	int i,n,m,d;
	char s[7];
	while(1)	{
		scanf("%s",s);
		if(s[0]=='#')	break;
		scanf("%d %d %d",&n,&m,&d);
		if(n>=32 || (n==31 && m>=5))	{
			strcpy(s,"?");
			n=n-30;
		}
		printf("%s %d %d %d\n",s,n,m,d);
	}
	return 0;
}


Measured memory_bytes: 2700
#include<bits/stdc++.h>
#define f(i,a,b) for(int i = a; i < b; i++)
#define fd(i,a,b) for(int i = a; i > b;i--)
#define long long ll
#define fl(i,a,b) for(ll i = a; i < b; i++)
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VS vector<string>
#define VL vector<long long>
#define VC vector<char>
#define VF vector<float>
#define PB push_back
#define F first
#define S second
#define fa(i,skill) for(auto i : skill)
#define fr(i,skill) for(VI :: reverse_iterator i = skill.rbegin(); i != skill.rend(); i++)
using namespace std;
 void edit(VI &skill,int n)
{
    f(i,0,n)
        {
            int x;
            cin >> x;
            skill.PB(x);
        }
}

int main()
{
	int n;
	cin >> n;
	VI l;
	edit(l,n);
	sort(l.begin(), l.end());
	int ans = 0;
	f(i,0,n)
	{
		f(j,i+1,n)
		{
			if (l[j] == l[i])
			{
				continue;
			}
			int x = l[i] + l[j];
			f(k,j+1,n)
			{
				if (l[k] == l[i] || l[k] == l[j])
				{
					continue;
				}
				if (x > l[k])
				{
					ans++;
				}
			}
		}
	}
	cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

signed main(){

	lli n,k;
	cin>>n>>k;

	lli maxK = (n-1)*(n-2)/2;
	if(k>maxK){
		cout<<-1<<endl;
		return 0;
	}
	if(DEBUG)cout<<"maxK="<<maxK<<endl;
	
	/*最大のものをまず構築する*/
	vector<pair<lli,lli>> ans;
	for(lli i=n-1;i>0;i--){
		ans.push_back(make_pair(n,i));
	}
	/*次に目標の数まで減らす*/
	lli start = n-1;
	lli next = n-2;
	for(lli i=0;i<maxK-k;i++){
		if(next==0){
			start--;
			next = start-1;
		}
		ans.push_back(make_pair(start,next));
		next--;
	}
	cout<<ans.size()<<endl;
	REP(i,0,ans.size()){
		cout<<ans[i].first<<" "<<ans[i].second<<endl;
	}
 
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <utility>
#include <queue>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

llint h, w;
char c[25][25];
llint dist[25][25][25][25];
llint dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};

void bfs(llint sx, llint sy, llint dist[25][25])
{
	for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
			dist[x][y] = inf;
		}
	}
	dist[sx][sy] = 0;
	
	queue<P> Q;
	Q.push(P(sx, sy));
	
	llint x, y;
	while(Q.size()){
		x = Q.front().first, y = Q.front().second;
		Q.pop();
		for(int i = 0; i < 4; i++){
			llint nx = x + dx[i], ny = y + dy[i];
			if(nx < 1 || nx > w || ny < 1 || ny > h) continue;
			if(c[nx][ny] == '#') continue;
			if(dist[nx][ny] < inf/2) continue;
			dist[nx][ny] = dist[x][y] + 1;
			Q.push(P(nx, ny));
		}
	}
}
int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> h >> w;
	for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
			cin >> c[x][y];
		}
	}
	
	for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
			if(c[x][y] == '#') continue;
			bfs(x, y, dist[x][y]);
		}
	}
	
	llint ans = 0;
	for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
			for(int y2 = 1; y2 <= h; y2++){
				for(int x2 = 1; x2 <= w; x2++){
					if(c[x][y] == '#' || c[x2][y2] == '#') continue;
					ans = max(ans, dist[x][y][x2][y2]);
				}
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 

int main(){
  ll n,k;
  cin >>n>>k;
  mint ans=0;
  for(int i=k;i<n+2;i++){
    ll sum=i*(n-i+1)+1;
    ans +=sum;
  }
  cout << ans<<endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  string s;
  int k;
  cin >> s;
  cin >> k;
  const int sub = 26, len = s.size();
  int remain = k, now;
  vector<int> vec(len);
  vector<char> res(len);
  rep(i,len) {
    now = s[i] - 'a';
    char ans;
    if (now == 0) {
      ans = s[i];
    } else {
      if (remain >= (sub - now)) {
        ans = 'a';
        remain -= (sub - now);
      } else {
        ans = s[i];
      }
    }
    res[i] = ans;
  }

  if (remain > 0) {
    if (res.back() == 'a') {
      int tt = remain / 26;
      remain -= tt * 26;
    }
    int tar = res.back() - 'a';
    tar = (tar + remain) % sub;
    char t = 'a' + tar;
    res[len-1] = t;
  }

  for (auto itr : res) cout << itr;
  END;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)
const ll MOD=998244353;
ll n,a,b,k;

ll ad(ll x,ll y){
  return (x+y)%MOD;
}

ll mlt(ll x,ll y){
  return (x*y)%MOD;
}

ll pwr(ll x,ll y){
  ll pw[32]={},w=1;
  pw[0]=x;
  fr(i,31) pw[i+1]=mlt(pw[i],pw[i]);
  fr(i,32){
    w=mlt(w,1+(y%2)*(pw[i]-1));
    y/=2;
  }
  return w;
}

ll inv(ll x){
  return pwr(x,MOD-2);
}

ll nC[300010]={1};
ll comb(ll r){
  if(nC[r]==0) nC[r]=mlt(comb(r-1),mlt(n-r+1,inv(r)));
  return nC[r];
}

int main(){
  cin>>n>>a>>b>>k;
  ll ans=0,j,l,p;
  fr(i,n+1){
    j=i*a;l=k-j;p=l/b;
    if(l<0) break;
    if(p>n || l%b>0) continue;
    ans=ad(ans,mlt(comb(i),comb(p)));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 11904
#include<cstdio> 
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
using namespace std;
#define fo(i,j,k) for(i=j;i<=k;i++)
#define fd(i,j,k) for(i=j;i>=k;i--)
#define cmax(a,b) (a=(a>b)?a:b)
#define cmin(a,b) (a=(a<b)?a:b)
typedef long long ll;
const int N=2e5+5,M=1e7+50,mo=1e9+7;
int pd[N],dis[N],now[N],n,m,i,j,S,T,ttt,ans;
char s[105][105];
int tt,fst[N],nxt[N],c[N],Ref[N],b[N];
void cr(int x,int y,int z,int re)
{
	tt++;
	b[tt]=y;
	c[tt]=z;
	Ref[tt]=tt+re;
	nxt[tt]=fst[x];
	fst[x]=tt;
}
int flow(int x,int y)
{
	pd[x]=ttt;
	if (x==T)
	{
		ans+=y;
		return y;
	}
	for(int p=now[x];p;p=nxt[p])
		if (pd[b[p]]!=ttt&&c[p]&&dis[b[p]]+1==dis[x])
		{
			int l=flow(b[p],min(y,c[p]));
			if (l)
			{
				c[p]-=l;
				c[Ref[p]]+=l;
				now[x]=p;
				return l;
			}
		}
	return now[x]=0;
}
int change()
{
	int mn=1e9;
	fo(i,S,T)
		if (pd[i]==ttt)
			for(int p=fst[i];p;p=nxt[p])
				if (pd[b[p]]!=ttt&&c[p])
					cmin(mn,dis[b[p]]+1-dis[i]);
	if (mn==1e9) return 0;
	fo(i,S,T) if (pd[i]==ttt) dis[i]+=mn;
	return 1;
}
int main()
{
	scanf("%d %d\n",&n,&m);
	S=0;
	T=n+m+1;
	fo(i,1,n)
	{
		scanf("%s",s[i]+1);
		fo(j,1,m) 
		{
			if (s[i][j]=='S')
			{
				cr(S,i,1e9,1);
				cr(i,S,0,-1);
				cr(S,j+n,1e9,1);
				cr(j+n,S,0,-1);
			}
			else if (s[i][j]=='T')
			{
				cr(i,T,1e9,1);
				cr(T,i,0,-1);
				cr(j+n,T,1e9,1);
				cr(T,j+n,1e9,-1);
			}
			else if (s[i][j]=='o')
			{
				cr(i,j+n,1,1);
				cr(j+n,i,1,-1);
			}
		}
	}
	ans=0;
	do
	{
		fo(i,S,T) now[i]=fst[i];
		ttt++;
		while (flow(S,1e9)>0) ttt++;
	}while (change());
	if (ans>=1e9) ans=-1;
	printf("%d",ans);
}

Measured memory_bytes: 4480
int main(void){
  int n, x[101] ,i ,s=0 , t = 0, t2 = 0;
  
  scanf("%d",&n);
  
  for(i = 0; i < n; i ++){
    scanf("%d",&x[i]);
    s += x[i];
  }
  
  for(i = 0; i < n; i ++){
    t += pow(x[i]-s/n, 2.0);
    t2 += pow(x[i]-(s/n+1), 2.0);
  }
    
  printf("%d",t>t2 ? t2 : t);
}

  
  

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int gcd(int a, int b) {
    if(a < b) return gcd(b, a);
    else if(b == 0) return a;
    else return gcd(b, a % b);
}
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int A[100010];
    rep(i, N) cin >> A[i];
    int G = 0;
    rep(i, N) G = gcd(G, A[i]);
    int maximam = 0;
    rep(i, N) maximam = max(maximam, A[i]);
    if(K % G == 0 && K <= maximam) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }


    return 0;
}


Measured memory_bytes: 3868
r, c, k = map(int, input().split())
dp = [[[0] * (c+1) for _ in range(r+1)] for _ in range(4)]

v_dict = dict()
for _ in range(k):
    y, x, v = map(int, input().split())
    v_dict[(y, x)] = v

for y in range(1, r+1):
    for x in range(1, c+1):
        prev_y_max = 0
        for i in range(4):
            prev_y_max = max(dp[i][y-1][x], prev_y_max)
        dp[0][y][x] = max(prev_y_max, dp[0][y][x-1])
        if (y, x) in v_dict:
            v = v_dict[(y, x)]
            dp[1][y][x] = max(prev_y_max + v, dp[0][y][x-1] + v, dp[1][y][x-1])
            dp[2][y][x] = max(dp[1][y][x-1] + v, dp[2][y][x-1])
            dp[3][y][x] = max(dp[2][y][x-1] + v, dp[3][y][x-1])
        else:
            for i in range(1, 4):
                dp[i][y][x] = dp[i][y][x-1]
ans = 0
for i in range(4):
    ans = max(dp[i][r][c], ans)
print(ans)


Measured memory_bytes: 402656
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod = 1e9+7;
const int inf= 1<<30;
const int maxn = 3000005;
int r[maxn],c[maxn];
vi rows[maxn];

void solve(){
	int n,m,k;
	cin >> n >> m >> k;
	int maxr = 0, maxc = 0;
	for(int i=0; i < k; i++){
		int u,v;
		cin >> u >> v;
		r[u]++;
		maxr = max(maxr,r[u]);
		rows[u].pb(v);
		c[v]++;
		maxc = max(maxc,c[v]);
	}
	int ans = maxr + maxc;
	set<int> cols;
	int cuantas =0;

	for(int i=1; i <=m; i++){
		if(c[i] != maxc) continue;
		cols.insert(i);
	}

	for(int i=1; i <=n; i++){
		if(r[i] != maxr) continue;
		int cont =0;
		for(auto x : rows[i]){
			if(cols.find(x) != cols.end()) cont++;
		}

		if(cont != (int) cols.size()) cuantas++;
	}

	if(cuantas == 0) ans--;
	cout << ans << endl;
}

int main(){
	int t=1;
	while(t--){
		solve();
	}
	return 0;
}


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

int main()
{
    string s;
    cin>>s;
    for(int i=0;i<19;i++)
    {
        if(s[i]==',') s[i]=' ';
        else if(s[i]==' ') s[i]=',';
    }
    cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace  std;
int main() {
    int n, k;
    cin >> n >> k;
    int sum = 0;
    vector<int> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        if (x[i] > k / 2) {
            sum += 2*(k - x[i]);
        } else {
            sum += 2*(x[i]);
        }
    }
    cout << sum << endl;
}



Measured memory_bytes: 3600
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
ll MOD = 1e9 + 7;
ll A[100000];
ll ans[100000];
int main() {
	int N;
	cin >> N;
	ll sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}
	ans[N - 1] = sum;
	for (int i = 0; i + 1 < N; i += 2) ans[N - 1] -= A[i] * 2;
	ans[N - 1] /= 2;
	for (int i = N - 2; i >= 0; i--) {
		ans[i] = A[i] - ans[i + 1];
	}
	for (int i = 0; i < N; i++) cout << ans[i] * 2 << " ";
	cout << endl;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define loop(i,b,n) for(int i=b;i<(n);++i)
#define each(e,v) for(auto &&e : v)

#define all(v) (v).begin(),(v).end()
#define sz(v) (int)v.size()

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const double EPS = 1e-9;
const ll MOD = 1e+9 + 7;

template<typename A,typename B> inline void chmin(A &a,B b){ if(a>b) a=b; }
template<typename A,typename B> inline void chmax(A &a,B b){ if(a<b) a=b; }
template <typename T> inline void print(const T& x) { cout << x << endl; }

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

    int s = (int)(sqrt(n) + 1);

    vector<int> f(n+1,0);

    for(int x=1; x<=s; ++x){
        int x2 = x*x;
        for(int y=1; y<=s; ++y){
            int y2 = y*y;
            int xy = x*y;
            for(int z=1; z<=s; ++z){
                int m = x2 + y2 + xy + (x + y + z)*z;
                if(m<=n) ++f[m];
            }
        }
    }

    for(int i=1; i<=n; ++i){
        print(f[i]);
    }

    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

import javax.sql.rowset.serial.SerialArray;

public class Main {

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

			int R = sc.nextInt();
			int G = sc.nextInt();
			
			int ans = ( 2 * G ) - R ;
		    System.out.println(ans);

		}
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int a, b;
  cin >> a >> b;
  rrep(i,1000) {
    if (i*8/100 == a && i*10/100 == b) {
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 105
using namespace std;
typedef long long int64;
int main()
{
    int n,temp;
    cin>>n;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        cin>>temp;
        if(temp%2==0)
            ans++;
    }
    cout<<pow(3,n)-pow(2,ans)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

vector<vector<P>> g(200000);
vector<int> ans(200000, 0), visit(200000, 0);

void dfs(int v, bool color) {
  visit[v] = 1;
  for (auto cp : g[v]) {
    int c = cp.first;
    int d = cp.second;

    // 探索済みならすきっぷ
    if (visit[c] > 0) continue;

    bool ceven = d % 2 == 0;

    bool next = ceven ? color : !color;

    ans[c] = next;
    dfs(c, next);
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<int> u(n), v(n), w(n);
  for (int i = 0; i < n - 1; i++) {
    cin >> u[i] >> v[i] >> w[i];
    u[i]--;
    v[i]--;
    g[u[i]].push_back(P(v[i], w[i]));
    g[v[i]].push_back(P(u[i], w[i]));
  }

  int root = u[0];

  dfs(root, 0);

  for (int i = 0; i < n; i++) {
    cout << ans[i] << ln;
  }

  return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n, k;
string s;

vector<int> block;
int num[MAX_N];

int ans;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &k);

  cin >> s;

  for (int i = 0; i < n; ++i) {
    if (s[i] == '0') {
      if (i == 0 || s[i - 1] == '1') {
        num[i] = 1;
      }
    }
  }

  for (int i = 1; i < n; ++i) {
    num[i] += num[i - 1];
  }

  num[n] = num[n - 1] + 1;

  int cnt = num[n - 1];

  if (k >= cnt) {
    printf("%d\n", n);
    return 0;
  }

  ans = -1;

  for (int i = 0; i < n; ++i) {
    int add = (s[i] == '0') ? k - 1 : k; // already using 0 part

    auto itr = upper_bound(num + i, num + n + 1, num[i] + add);

    int ind = (itr - num) - 1;

    if (num[ind] - num[i] != add) break;

    int score = ind - i + 1;

    ans = max(ans, score);
  }

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

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n,m;
    cin >> n >> m;
    int a[n];
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }

    double p[n]={};
    int canselect = 0;
    for(int i = 0; i < n; i++){
        p[i] = (double)a[i]/(double)sum;
        bool flag = p[i] *4 * m >= 1.0;
        // cout << a[i] << " " << flag << endl;
        if(flag){
            canselect++;
        }
    }

    if(canselect >= m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    // cout << canselect << " " << m << " " << sum << endl;


}

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

using ll = long long;

//constant
const ll MOD = 1e+9 + 7;
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// view vector
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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

#include <iostream>

using namespace std;

template<typename Int, Int mod>
class ModInt {
public:
	static const Int Mod = mod;
	Int x;
	ModInt() { x = 0; }
	ModInt(int a) { Int t = a % mod; if (t < 0) t += mod; x = t; }
	ModInt(long long a) { Int t = a % mod; if (t < 0) t += mod; x = t; }
	Int get() const { return x; }

	ModInt& operator += (ModInt that) { if ((x += that.x) >= mod) x -= mod; return *this; }
	ModInt& operator -= (ModInt that) { if ((x += mod - that.x) >= mod) x -= mod; return *this; }
	ModInt& operator *= (ModInt that) { x = (long long)(x)*that.x % mod; return *this; }
	bool operator == (ModInt that) const { return x == that.x; }
	ModInt operator + (ModInt that) const { return ModInt(*this) += that; }
	ModInt operator - (ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator * (ModInt that) const { return ModInt(*this) *= that; }
	ModInt operator - () const { return ModInt(-this->x); }
	inline friend ostream& operator << (ostream& out, ModInt m) { return out << m.x; }

	ModInt power(long long k) const {
		ModInt r(1); ModInt b = *this;
		if (k <= 0) return r;
		while (k) { if (k & 1) r *= b; b *= b; k >>= 1; }
		return r;
	}
	ModInt inverse() const {
		long long a = x, b = mod, u = 1, v = 0;
		while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
		return ModInt(u);
	}
};

#define MOD (1000000007)
typedef ModInt<int, MOD> Mint;

// ***************************************


int main(void) {

	int H, W;
	cin >> H >> W;
    vector<vector<char>> table(H, vector<char>(W));
	for (auto& col : table) {
		for (auto& cell : col) {
			cin >> cell;
		}
	}

	vector<vector<Mint>> dp(H, vector<Mint>(W));
	dp[0][0] = 1;

	REP(i, H) {
		REP(j, W) {
			if (i < H-1 && table[i + 1][j] == '.') dp[i + 1][j] += dp[i][j];
			if (j < W-1 && table[i][j+1] == '.') dp[i][j+1] += dp[i][j];
		}
	}

	cout << dp[H-1][W-1].get() << endl;
	
	return 0;
}

Measured memory_bytes: 5248
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,k;
	string s;
	char x;
	cin>>n>>s>>k;
	x=s[k-1];
	for(int i=0;i<n;i++){
		if(s[i]!=x) s[i]='*';
	}
	cout<<s<<endl;
	return 0;
}


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

int main() {
  int n, q;
  cin >> n;
  map<int, int> a;//key=Ai,value=何回出てきたか
  int64_t s = 0;
  for (int i = 0; i < n; i++) {
    int ai;
    cin >> ai;
    if (a.count(ai)) a.at(ai)++;
    else a[ai] = 1;
    s += ai;
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    int b, c;
    cin >> b >> c;
    if (a.count(b)) {
      if (a.count(c)) {
        s += (c - b) * a[b];
        a[c] += a[b];
        a.erase(b);
      }else {//Aにcはない
        a[c] = a[b];
        a.erase(b);
        s += (c - b) * a[c];
      }
    }
    cout << s << endl;
  }
}

Measured memory_bytes: 6592
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

static const double eps = 1e-8;

int main(){
	double n;	
	while(~scanf("%lf",&n)){
		if(n==-1.0) break;
		int a = n;
		double b = n - (double)a;

		bitset<8> front;
		for(int i=0;i<8;i++){
			if(a & (1<<i)) front |= (1<<i);
		}

		bitset<4> rear;
		for(int i=0;i<4;i++){
			b*=2.0;
			if(b + eps > 1.0){
				rear |= (1<<i);
				b -= 1.0;
			}
		}

		if(!(b+eps > 0.0 && b-eps < 0.0) || a != front.to_ulong()) {
			printf("NA\n");
		}
		
		
		else {
			string r = rear.to_string();
			reverse(r.begin(),r.end());
			printf("%s.%s\n",front.to_string().c_str(),r.c_str());
		}
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
 
using namespace std;
typedef unsigned long long int ll;
const ll hell = 100005; 

bool comp( vector<ll> a, vector<ll> b )
{
    return a[0]<b[0];
}
ll binpow(ll a,ll b) 
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
            res*=a;
        a*=a;
        b >>= 1;
    }
    return res;
}
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll a[n], f[n+1]={0};
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        f[a[i]]++;
    }
    ll sum=0;
    for(ll i=0;i<=n;i++)
        sum+=f[i]*(f[i]-1)/2;
    for(ll i=0;i<n;i++)
    {
        ll tsum=sum;
        tsum=tsum-f[a[i]]*(f[a[i]]-1)/2;
        f[a[i]]--;
        tsum=tsum+f[a[i]]*(f[a[i]]-1)/2;
        cout<<tsum<<endl;
        f[a[i]]++;
    }
    return 0;
}


Measured memory_bytes: 5760
li = []
count = 0

for i in range(5):
    li.append(int(input()))

    amari = list(map(lambda x: x % 10, li))
    sho = list(map(lambda x: x // 10, li))

for j in range(5):
    if amari[j] != 0:
        sho[j] = (sho[j]+1)*10
    else:
        sho[j] = sho[j]*10
        count += 1
        amari[j] += 123

if count == 5:
    print(sum(sho))
else:
    print(sum(sho) - 10 + min(amari))


Measured memory_bytes: 3064
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int[] p={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97},d=new int[25];
		for(int i=2;i<=n;++i){
			int I=i;
			for(int j=0;j<25;++j){
				while(I%p[j]==0){
					I/=p[j];
					++d[j];
				}
			}
		}

		int r=0;
		for(int i=0;i<25;++i){
			if(d[i]>=74)
				++r;
			for(int j=0;j<25;++j){
				if(i==j)
					continue;
				if(d[i]>=2&&d[j]>=24)
					++r;
				if(d[i]>=4&&d[j]>=14)
					++r;
				for(int k=j+1;k<25;++k){
					if(i!=k&&d[i]>=2&&d[j]>=4&&d[k]>=4)
						++r;
				}
			}
		}
		System.out.println(r);
	}
}


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

int main() {
  int n;
  std::string s, t;
  cin >> n >> s >> t;
  for (int i = 0; i < n;i++){
    cout << s.substr(i,1) << t.substr(i,1);
  }
  cout << endl;
}


Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>

using namespace std;


int main() {
	int R, G, B, N;
	cin >> R >> G >> B >> N;

	int count = 0;
	
	for (int r = 0; r <= N / R; r++) {
		int m = N - r * R;
		for (int g = 0; g <= m / G; g++) {
			int l = m - g * G;
			if (l % B == 0) {
				count++;
			}
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1LL << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	ll ans = linf;
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			mins(ans, i + n / i);
		}
	}
	cout << ans - 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int r;
    cin >> r;
    cout << (int)r*r << endl;
    return 0;
}

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

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
typedef long double ld;
vector<pair<ld,int>> p;
vector<ll> v;
ll a[200010],b[200010],dp[200010][40],c[200010];
int main(){
	ll i,j,n,t;
	cin >> n >> t; t++;
	for(i=0;i<n;i++){
		cin >> a[i] >> b[i];
		a[i]++; b[i]++;
		if(a[i]>=2){
			p.push_back({(ld)(a[i] - 1)/(ld)b[i],i});
		}else{
			v.push_back(b[i]);
		}
	}
	sort(p.rbegin(),p.rend());
	sort(v.begin(),v.end());
	for(i=0;i<=p.size();i++){
		for(j=0;j<40;j++){
			dp[i][j] = 100000000000;
		}
	}
	dp[0][0] = 1;
	for(i=1;i<=p.size();i++){
		for(j=0;j<40;j++){
			int k = p[i - 1].second;
			if(dp[i - 1][j]<=t) dp[i][j] = min(dp[i][j],dp[i - 1][j]);
			if(j>=1 && dp[i - 1][j - 1]<=t && a[k]*dp[i - 1][j - 1] + b[k]<=t) dp[i][j] = min(dp[i][j],a[k]*dp[i - 1][j - 1] + b[k]);
		}
	}
	ll sum = 0,ans = 0;
	int k = 0;
	for(j=39;j>=0;j--){
		while(k<v.size() && dp[p.size()][j] + sum + v[k]<=t){
			sum += v[k];
			k++;
		}
		if(dp[p.size()][j]<=t)ans = max(ans,j+k);
	}
/*	for(j=0;j<40;j++){
		if(dp[p.size()][j]<=t){
			ans = max(ans,j + c[j]);
		}
	}*/
	cout << ans << endl;
}


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

a_str = input()
a_list = list(map(int,a_str.split()))

n_list = []
for a in a_list:
    if int(a) % 2 != 0:
        n_list.append(0)
        break
    else:
        i = 0
        while int(a) > 1 and int(a) % 2 == 0:
            a = int(a) / 2
            i += 1
    n_list.append(i)
print(min(n_list))




Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N;
int xyh[100][3];

int main(){
    cin>>N;
    rep(i,N) cin>>xyh[i][0]>>xyh[i][1]>>xyh[i][2];

    int ans[3];
    for(int cx=0;cx<=100;cx++){
        for(int cy=0;cy<=100;cy++){
            bool first=true;
            int H=1;
            rep(i,N){
                if(xyh[i][2]==0) continue;
                int res=abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy)+xyh[i][2];
                if(first){
                    H=res;
                    first=!first;
                }else{
                    if(!(res==H)) goto a;
                }
            }
            rep(i,N){
                if(xyh[i][2]==0 && H-abs(xyh[i][0]-cx)-abs(xyh[i][1]-cy)>0)
                    goto a;
            }
            ans[0]=cx; ans[1]=cy; ans[2]=H;
            goto b;
            a:;
        }
    }
    b:;

    cout<<ans[0]<<' '<<ans[1]<<' '<<ans[2]<<endl;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    S = INPUT()

    ans = 0
    for i in range(1000):
        tmp = str(i).zfill(3)
        cnt = 0
        for j in range(N):
            if S[j] == tmp[cnt]:
                cnt += 1
                if cnt == 3:
                    ans += 1
                    break

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 75212
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
using namespace std;
 
int behind_black_num[200000];
int behind_white_num[200000];
int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
 
    bool no_black = true;
    if(S[N - 1] == '#'){
        behind_black_num[N - 1] = 1;
    } else {
        behind_white_num[N - 1] = 1;
    }
    for(int i = N - 2; i >= 0; i--){
        behind_black_num[i] = behind_black_num[i + 1];
        behind_white_num[i] = behind_white_num[i + 1];
        if(S[i] == '#'){
            behind_black_num[i]++;
        } else {
            behind_white_num[i] ++;
        }
    }
    if(behind_black_num[0] == 0 || behind_white_num[0] == 0){
        cout << 0 << endl;
        return 0;
    }
 
    int ans = INT_MAX;
    int first_black = 0;
    int changed_black_no;
    int white_no = 0;
    int black_no = 0;
    for(int i = 0; i < N; i++){
        if(S[i] == '#'){
            first_black = i;
            break;
        }
    }
    ans = behind_black_num[first_black];

    int turned_white = 0;
    for(int i = first_black; i < N; i++){
        if(S[i] == '#'){
            ans = min(ans, turned_white + behind_white_num[i]);
            turned_white ++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  int n;
  cin>>n;
  vector<char> s(n);
  cinv(s,0,n);
  string flag="Three";
  FOR(i,0,n){
    if(s[i]=='Y') flag="Four";
  }
  cout<<flag<<endl;
}


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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

const int maxn = 1e5+10;
const int mod = 1e9+7;

using namespace std;

void solve(){
    int n;
    cin>>n;
    map<string,int> mapa;
    for(int i=0;i<n;++i){
        string s;
        cin>>s;
        mapa[s]++;
    }
    cout<<"AC x " << mapa["AC"] << endl;
    cout<<"WA x " << mapa["WA"] << endl;
    cout<<"TLE x " << mapa["TLE"] << endl;
    cout<<"RE x " << mapa["RE"] << endl;

}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3656
int a[4],b[4];
main(i,j){
  for(;~scanf("%f%f",&f,&g);a[i]++,b[j]++)
    i=f<0.2?3:f<0.6?2:f<1.1?1:0,j=g<0.2?3:g<0.6?2:g<1.1?1:0;
  for(i=0;i<4;i++)
    printf("%d %d\n",a[i],b[i]);
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;

int main()
{
	string a, b;
	cin >> a >> b;
	int cnt = 0;
	for(int i = 0; i < 3; i++) {
		if(a[i] == b[i]) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
/*
 * n都市数 
 * M電車の数
 */
vector<long long> at_coder_express2(int n, int m, int q, vector<std::pair<int, int>> lr,vector<pair<int, int>> pq) {
  int mat[501][501];
  long long mul[501][501];
  for(int rr=0;rr<501;rr++) {
    for(int ll=0;ll<501;ll++){
      mat[rr][ll] = 0;
      mul[rr][ll] = 0;
    }
  }

  for(auto iter=lr.begin();iter != lr.end(); iter++) {
    mat[(*iter).first][(*iter).second]++;
  }
  for(int ll = 1; ll < 501;ll++) {
    for(int rr=1;rr<501;rr++) {
      mul[ll][rr] = mul[ll][rr-1] + mat[ll][rr];
    }
  }
  /*
  for(int i=1;i<=n;i++) {
    for(int j=1;j<=n;j++) {
      cout << "(" << i << ", " << j << ") -> " << mul[i][j] << endl;
    }
  }
  */

  // pqはまだ使わない
  vector<long long> ans;
  for(int i=0;i<q;i++) {
    pair<int, int> pq_i = pq[i];
    long long a = 0;
    for(int j = pq_i.first; j <= pq_i.second; j++) {
      //cout << "i: " << i << "pq_i.second: " << pq_i.second << " mul[i][pq_i.second]: " << mul[i][pq_i.second]  << "add " << mul[i][pq_i.second] - mul[i][pq_i.first-1] << endl; 
      a += mul[j][pq_i.second] - mul[j][pq_i.first-1];
    }
    ans.push_back(a);
  }
  return ans;
}

int main() {
  int n, m, q;
  cin >> n;
  cin >> m;
  cin >> q;
  vector<pair<int, int>> lr;
  for(long long i=0LL;i<m;i++) {
    int l, r;
    cin >> l;
    cin >> r;
    lr.push_back(make_pair(l, r));
  }
  vector<pair<int, int>> pq;
  for(long long i=0LL;i<q;i++) {
    int l, r;
    cin >> l;
    cin >> r;
    pq.push_back(make_pair(l, r));
  }
  vector<long long> ans = at_coder_express2(n, m, q, lr, pq);
  for(long long i=0;i<ans.size();i++) {
    cout << ans[i];
    if(i != ans.size() - 1)
      cout << endl;
  }
}

Measured memory_bytes: 9840
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>

using namespace std;

#define int long long

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, d, a;
    cin >> n >> d >> a;
    vector<pair<int, int>> inp(n);
    for (int i = 0; i < n; i++)
        cin >> inp[i].first >> inp[i].second;
    sort(inp.begin(), inp.end());

    queue<pair<int, int>> rb;
    int cur_damage = 0;
    int total = 0;
    for (int i = 0; i < n; i++)
    {
        while (!rb.empty())
        {
            if (rb.front().first < inp[i].first)
            {
                cur_damage -= rb.front().second;
                rb.pop();
            } else
                break;
        }

        if (inp[i].second - cur_damage > 0)
        {
            int need_bombs = (inp[i].second - cur_damage + a - 1) / a;
            cur_damage += need_bombs * a;
            total += need_bombs;
            rb.push({inp[i].first + 2 * d, need_bombs * a});
        }
    }

    cout << total << "\n";

    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;

const int maxn = 105, maxw = 1e5+5;

int n, s;
ll w[maxn], v[maxn], dp[maxn][maxw];

int main(){
	scanf("%d %d", &n, &s);
	for(int i = 1; i<=n; i++) scanf("%lld %lld", &w[i], &v[i]);
	dp[0][0] = 0;
	for(int i = 1; i<=n; i++){
		for(int j = 1; j<=s; j++){
			dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			if (j-w[i]>=0) dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]]+v[i]);
		}
	}
	printf("%lld\n", dp[n][s]);
	return 0;
}


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

typedef long long ll;

const int N = 200010;

int a[N];
ll pre[N];

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i){
        scanf("%d", &a[i]);
        pre[i] = pre[i - 1] + a[i];
    }
    std::map <ll, int> Hash;
    for (int i = 0; i <= n; ++ i){
        ++ Hash[pre[i]];
    }
    ll ans = 0;
    for (auto u : Hash){
        ans += 1ll * u.second * (u.second - 1) >> 1;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 15104
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
using namespace std;

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

    map<char, int> moji_count;
    
    for(char i = 'a'; i <= 'z'; i++){
        moji_count[i] = 0;
    }
    
    for(int j = 0; j < S.size(); j++){
        moji_count[S[j]]++;
    }

    
    for(auto p : moji_count){
        auto key = p.first;
        auto value = p.second;
        if(value == 0){
            cout << key << endl;
            return 0;
        }
    }
    
    cout << "None" << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
 
#define rp(i, k, n) for (int i = k; i < n; i++)
using ll = long long;
using ld = double;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;

int mypow(int X, int n) {  // 繰り返し２乗法　計算量log(n)
    if(n == 0) return 1;
    int Y = mypow(X, n/2);
    if(n % 2 == 1) return X * Y % 13 * Y % 13;
    else return Y * Y % 13;
}

int main() {
    int n; cin >> n;
    vector<ll> A(n);
    ll s = 0; ll t = 0;
    rp(i, 0, n) {
        ll a;
        scanf("%lld", &a);
        s += a;
        A[i] = a;
        if(i%2==1) t += a;
    }
    ll x = s - t*2;
    printf("%lld ", x);
    rp(i, 0, n-1) {
        x = A[i] * 2 - x;
        printf("%lld ", x);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 4044