akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <list>
#include <algorithm>
#include <map>
#include <iterator>
#include <limits>
#include <numeric>
#include <type_traits>
#include <cmath>
#include <cstdlib>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

#define ALL(v) (v).begin(), (v).end()
#define endl "\n"
typedef long long int ll;

template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (int i = 0; i<vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

int SumDigitValues(int x)
{
	int sum = 0;
	while (x)
	{
		sum += x % 10;
		x = x / 10;
	}

	return sum;
}

int Factorial(int n)
{
	if (n < 0) return 0;
	if (n == 0) return 1;
	return n * Factorial(n - 1);
}

int factorial(int n)
{
	if (n > 1)
	{
		return n * factorial(n - 1);
	}
	else
	{
		return 1;
	}
}

int gcd(int x, int y)
{
	if (y == 0)
		return x;
	else 
		return gcd(y, x % y);
}

vector<int> Divisors(int x)
{
	vector<int> divisors;
	divisors.push_back(1);
	for (int a = 2; a <= x; a++)
	{
		if (x % a == 0) divisors.push_back(a);
	}
	return divisors;
}

vector<int> CommonDivisors(int a, int b)
{
	vector<int> divisorsA = Divisors(a);
	vector<int> divisorsB = Divisors(b);
	vector<int> commonDivisors;
	set_intersection(divisorsA.begin(), divisorsA.end(), divisorsB.begin(), divisorsB.end(), std::back_inserter(commonDivisors));
	return commonDivisors;
}

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

	string s; cin >> s;

	sort(s.begin(), s.end());
	cout << (s[0] == s[1] and s[1] != s[2] and s[2] == s[3] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;
#define MAXN 100000
#define LL long long
int tot,vis[MAXN],n,ans;
LL prim[MAXN],a[MAXN+5],b[MAXN+5];
map<LL,int>cnt;
void Pre()
{
	for(int i=2;i<MAXN;i++)
	{
		if(!vis[i]) prim[tot++]=i;
		for(int j=0;prim[j]*i<MAXN;j++)
		{
			vis[i*prim[j]]=1;
			if(i%prim[j]==0) break;
		}
	}
}
void Solve(int i,LL x)
{
	a[i]=b[i]=1;
	for(int j=0;prim[j]*prim[j]*prim[j]<=x;j++)
	{
		int c=0;
		while(x%prim[j]==0) x/=prim[j],c++;
		if(c%3==1) a[i]*=prim[j],b[i]*=prim[j]*prim[j];
		else if(c%3==2) a[i]*=prim[j]*prim[j],b[i]*=prim[j];
	}
	if(x!=1)
	{
		LL k=sqrt(x);
		if(k*k==x) a[i]*=k*k,b[i]*=k;
		else
		{
			a[i]*=x,b[i]*=x*x;
//			if(x>3037000499)
//			{
//				printf("!!");
//			}
		}
	}
}
int main()
{
//	freopen("anticube.in","r",stdin);
//	freopen("anticube.out","w",stdout);
	Pre();
	scanf("%d",&n);
	LL x;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&x);
		Solve(i,x);
		cnt[a[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(cnt[a[i]]==0) continue;
		if(a[i]==b[i]) 	ans++,cnt[a[i]]=0;
		else ans+=max(cnt[a[i]],cnt[b[i]]),cnt[a[i]]=0,cnt[b[i]]=0;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 14720
#include<iostream>
#include<vector>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long   llong;
typedef vector<int> vi;

template<class Type>//long long推奨.
Type pow_mod(Type n,Type k,Type m){//n^k(mod m).
	if(k==0) return 1;
	else if(k%2) return n*pow_mod(n,k-1,m)%m;
	else{
		Type tmp=pow_mod(n,k/2,m);
		return tmp*tmp%m;
	}
}

//pow_mod.
int main(){
	llong mod=998244353;
	
	int n;
	cin>>n;
	
	vi d(n);
	int tmp=0;
	REP(i,n){
		cin>>d[i];
		tmp=max(tmp,d[i]);
	}
	
	vi cnt(n,0);
	REP(i,n) cnt[d[i]]++;
	
	if(d[0]==0 and cnt[0]==1){}
	else{
		cout<<0<<endl;
		return 0;
	}
	
	llong ans=1;
	REP(i,tmp){
		if(cnt[i]==0){
			cout<<0<<endl;
			return 0;
		}
		ans*=pow_mod((llong)cnt[i],(llong)cnt[i+1],mod);
		ans%=mod;
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
import java.util.*;
import java.io.*;

public class Main {

	private static final int mod =(int)1e9+7;
	public static void main(String[] args) throws Exception  {
	      Scanner  sc=new Scanner(System.in);
	      PrintWriter out=new PrintWriter(System.out);
	     int a=sc.nextInt();
	     int b=sc.nextInt();
	     int c=sc.nextInt();
	     if(a%2==0&&b%2==0&&c%2==1) {
	       System.out.println("NO");
	     }else {
	       int  sum=a;
	       for(int i=0;i<=100;i++) {
	         sum+=a;
	         if(sum%b==c) {
	           System.out.println("YES");
	          return;
	         }
	       }
	       System.out.println("NO");
	     }

	}


	static boolean vis[]=new boolean[10001];
	      static long gcd(long a, long b) 
	      { 
	          if (a == 0) 
	              return b; 
	          return gcd(b % a, a); 
	      } 

static long nCr(int n,int r) {
  int dp[][]=new int[2001][2001];
  for(int i=0;i<2001;i++) {
    dp[0][i]=0;
  }
  for(int i=0;i<2001;i++) {
    dp[i][0]=1;
  }
  for(int i=1;i<2001;i++) {
    for(int j=1;j<2001;j++) {
      if(i==j) {
        dp[i][j]=1;
      }else {
        dp[i][j]=dp[i-1][j-1]+dp[i][j-1];
      }
    }
  }
  return dp[n][r];
}
      
}

Measured memory_bytes: 35844
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;

/* typedef */

typedef map<string,bool> msb;

/* global variables */

int n;
int ds[MAX_N];

/* subroutines */

/* main */

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

  while (tn--) {
    string num;
    cin >> num;

    n = num.length();

    for (int i = 0; i < n; i++) ds[i] = num[i] - '0';

    int count = 0;
    while (n > 1) {
      count++;
      int sum = ds[n - 2] + ds[n - 1];
      if (sum < 10) {
	n--;
	ds[n - 1] = sum;
      }
      else {
	ds[n - 2] = 1;
	ds[n - 1] = sum % 10;
      }
    }
    //cout << count << endl;

    cout << ((count & 1) ? "Fabre" : "Audrey") << " wins." << endl;
  }

  return 0;
}

Measured memory_bytes: 1204
function main(input) {
  const x = BigInt(input[0]);
  let power5 = [];
  const width = ((x<100)?x:1000);

  for(let i=-width;i<width;i++){
    power5[i+width]=BigInt(i*i*i*i*i);
  }
  let judge = false;
  for(let i=-width;i<width;i++){
    for(let j=-width;j<width;j++){
      if((power5[i+width]-power5[j+width])===x){
        console.log(i + " " + j);
        judge = true;
        break;
      }
    }
    if(judge){
      break;
    }
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 35148
#ABC111A
n = input()
a = n[:1]
b = n[1:2]
c = n[2:3]
if a == "1":
    a = "9"
else:
    a = "1"
if b == "1":
    b = "9"
else:
    b = "1"
if c == "1":
    c = "9"
else:
    c = "1"
print(a+b+c)

Measured memory_bytes: 3060
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long x,t;
  cin>>x>>t;
  cout<<(((x-t)>0) ? x-t : 0);
  cout<<'\n';
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
int n, x, y, z, ans = 1, pos, rpc, dp[45][1 << 17];
void init ();
signed main () {
	cin >> n >> x >> y >> z;
	init ();
    for (int i = 1; i <= n; i ++) {
    	ans *= 10;
    	ans %= MOD;
	}
    for (int i = 1; i <= n; i ++)
        for (int cur = 0; cur <= rpc; cur ++)
            for (int dig = 1; dig <= 10; dig ++) {
                int now = (cur << dig) | (1 << dig - 1);
                now = now & rpc;
                if ((now & pos) ^ pos)
					dp[i][now] = (dp[i][now] + dp[i - 1][cur]) % MOD;
            }
    for (int i = 0; i <= rpc; i ++)
		ans = (ans - dp[n][i] + MOD) % MOD;
    cout << ans;
    return 0;
}
void init () {
    pos = (1 << (x - 1)) | (1 << (x + y - 1)) | (1 << (x + y + z - 1));
    rpc = (1 << (x + y + z)) - 1;
    dp[0][0] = 1;
    return ;
}


Measured memory_bytes: 44580
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
using namespace std;

int main(){
	int a,b,k;
	cin >> a >> b >> k;
	int j = 0;
	for(int i = min(a, b); i > 0; i--){
		if(a % i == 0 && b % i == 0){
			j++;
			if(j == k){
				cout << i << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int a, b, c; cin >> a >> b >> c;
    cout << min(c, b/a) << endl;
}

Measured memory_bytes: 256
S,C=map(int,input().split())
#X回操作をするとS+x,c-2x 2S+2x=c-2x 4x=c-2s xはほぼc-2s//4
if C<=2*S:
    print(C//2)
else:
    ans=S
    for x in range(max(0,(C-2*S)//4-10),(C-2*S)//4+10):
        if C-2*x<2*(S+x):
            break
        ans=S+x
    print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1'000'000'007;
long long A,B,x,y,z,w;
long long sumx,sumy,sumxx,sumyy;
int main(){
    cin>>A>>B;
    cin>>z;
    for(int i=1;i<A;i++){
        cin>>x;
        sumx += (x - z) * i;
        sumx %= MOD;
        sumxx += (x - z) * i % MOD * i;
        sumxx %= MOD;
        z = x;
    }
    cin>>w;
    for(int j=1;j<B;j++){
        cin>>y;
        sumy += (y - w) * j;
        sumy %= MOD;
        sumyy += (y - w) * j % MOD * j;
        sumyy %= MOD;
        w = y;
    }

    long long ans = A * B % MOD * sumx % MOD * sumy;
    ans %= MOD;
    ans -= B * sumxx % MOD * sumy;
    ans %= MOD;
    ans -= A * sumx % MOD * sumyy;
    ans %= MOD;
    ans += sumxx * sumyy;
    ans %= MOD;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int X, N;
  cin >> X >> N;
  int p[N];
  for (int i = 0; i < N; i++) cin >> p[i];
  for (int j = 0;; j++) {
    bool isok = true;
    for (int i = 0; i < N; i++) {
      isok &= p[i] != X - j;
    }
    if (isok) {
      cout << X - j << endl;
      return 0;
    }
    isok = true;
    for (int i = 0; i < N; i++) {
      isok &= p[i] != X + j;
    }
    if (isok) {
      cout << X + j << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;

// #include "debug.h"
// #define debug(...) 42

using ll = long long;

void solve() {
   int n;
   cin >> n;
   vector <int> h(n);
   for(int i = 0; i < n; i++) {
      cin >> h[i];
   }
   h[0]--;
   for(int i = 1; i < n; i++) {
      if(h[i - 1] < h[i]) {
         h[i]--;
      }
      if(h[i] < h[i - 1]) {
         cout << "No" << endl;
         return;
      }
   }
   cout << "Yes" << endl;
} 

int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   int testcase = 1;
   // cin >> testcase;

   for(int i = 0; i < testcase; i++) {
      solve();
   } 
   return 0;
}


Measured memory_bytes: 3692
#include<stdio.h>
using namespace std;

int main() {
	int n; scanf("%d", &n);
	int c = 0;
	while (n--) {
		int d; scanf("%d", &d);
		for (int i = 1; i*i <= d; i++)if ((d - i) % (2 * i + 1) == 0)goto g;
		c++; g:;
	}
	printf("%d\n", c);
}

Measured memory_bytes: 2688
a, b, x = gets.split.map(&:to_i)
if 2*x<=a**2*b
    ans = Math.atan2(a*b**2, 2*x) * 180 / Math::PI
else
    ans = Math.atan2(2*(a**2*b-x), a**3) * 180 / Math::PI
end
puts "%.15f" % ans

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#define int long long
using namespace std;

signed main() {
	int n;
	int a;
	cin >> n >> a;
	n %= 500;
	if (n <= a) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include<random>
#include<iostream>
using namespace std;

long long modinv(int x){
	long long mod = 1000000007;
	/*x^(mod-2)*/
	long long p = mod - 2;
	long long ret = 1;
	long long x_ = x;
	while(p>0){
		if(p%2 == 1){
			ret = (ret * x_) % 1000000007;
		}
		p /= 2;
		x_ = (x_ * x_)  % 1000000007;
	}
	return ret;
}

int main() {
	long long X,Y,a,b;
	cin >> X >> Y;
	if((2*Y-X) % 3 !=0 || (2*X-Y) % 3 !=0){
		cout << 0 << "\n";
		return 0;
	}
	if(2*Y-X <0 || 2*X-Y <0){
		cout << 0 << "\n";
		return 0;
	}
	
	a = (2*Y-X)/3;
	b = (2*X-Y)/3;
	
	long long ans=1;
	for(int i=0;i<b;i++){
		ans = (ans*(a+i+1)) % 1000000007;
		ans = (ans * modinv(i+1)) % 1000000007;
	}
	
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n, D;
    cin >> n >> D;
    vector<lint> d(n);
    for (int i = 0; i < n; ++i) {
        cin >> d[i];
    }
    lint Q;
    cin >> Q;
    vector<lint> q(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> q[i];
    }
    vector<lint> dist(n + 1);
    dist[0] = D;
    for (int i = 1; i < n; ++i) {
        dist[i] = min(dist[i - 1], abs(dist[i - 1] - d[i - 1]));
    }
    vector<int> ret(n, -1);
    lint mini = 1;
    for (int i = n - 1; i >= 0; --i) {

        if (dist[i] >= mini) {
            ret[i] = 1;
        } else {
            ret[i] = 0;
        }
        if (d[i] / 2 < mini) {
            mini += d[i];
        }
    }
    for (int i = 0; i < Q; ++i) {
        if (ret[q[i] - 1] == 1)
            cout << "YES"
                 << "\n";
        else
            cout << "NO"
                 << "\n";
    }
    return 0;
}

Measured memory_bytes: 15616
#include "bits/stdc++.h"
using namespace std;
	#define sim template < class c
	#define ris return * this
	#define dor > debug & operator <<
	#define eni(x) sim > typename \
	  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
	sim > struct rge { c b, e; };
	sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
	sim > auto dud(c* x) -> decltype(cerr << *x, 0);
	sim > char dud(...);
	struct debug {
	#ifdef LOCAL
	~debug() { cerr << endl; }
	eni(!=) cerr << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) {
	  ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) {
	  *this << "[";
	  for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	  ris << "]";
	}
	#else
	sim dor(const c&) { ris; }
	#endif
	};
	#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
	#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
	#define lb lower_bound 
	#define ub upper_bound
	#define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define mi          map<int,int>
	#define mii         map<pi,int>
	#define vi vector<int> 
	#define vvi vector<vi>
	#define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
	#define all(c) (c).begin(),(c).end()
	#define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
	 
	 const int  N=1e6;
	 const int INF=1e18;
	 int mod= 1e9+7;
	 int dx[4]={0,0,+1,-1};
	 int dy[4]={+1,-1,0,0};  
	 
	 
	int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	 return res;
	}
	 
	const int sq=320+10;	
	 
					
	void solve() {	  
			 int n;
			 cin>>n;
		     vi v(n,0);
		     int cz=0;
		     rep(i,0,n) {
				 cin>>v[i];
				 if(v[i]==0) cz++;
			 }
			 if(cz>0) {
				   cout<<0<<endl;
				   return;
				 }	 
			 
			 int p=1;
			 rep(i,0,n) {
				   if(v[i]<=(int)1e18/p) {
					     p*=v[i];
					   }
				   else {
					     cout<<-1<<endl;
					     return;
					   } 				       	   
				 }	 
				 
				 cout<<p<<endl;
		
			
		 
		 
		}
		 
		   
				
	  int32_t main() {  
		  cool;
		  int t=1;
		   //~ cin>>t;         
		  
		  while (t--)
			 solve();	
		
		  return 0;
		}
		


Measured memory_bytes: 3992
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    int n;
    cin >> n;
    int max_height=INT_MIN;
    int count=0;

    for (int i=0;i<=n-1;i++)
    {
        int a;
        cin >> a;
        if (a>=max_height)
        {
            count++;
        }
        max_height=max(max_height,a);
    }

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

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int n;
  cin>>n;
  ll x=0;
  ///
  ll dp[100010];
  rep(i,100010) dp[i]=i;
  rep(i,100010){
   for(int pow6=6;pow6<=n;pow6*=6){
     if(i-pow6<0) break;
     chmin(dp[i],dp[i-pow6]+1);
   }
    for(int pow9=9;pow9<=n;pow9*=9){
     if(i-pow9<0) break;
     chmin(dp[i],dp[i-pow9]+1);
   }
    
  }//rep
  cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {  
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a>=1&&a<=9&&b>=1&&b<=9) {
			System.out.println(a*b);
		}else {
			System.out.println(-1);
		}
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// -------------------- I/O -------------------- //
///////////////////////////////////////////////////
// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (auto it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> std::vector<T> inputVec(int N) {
	std::vector<T> vec(N);
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
	return vec;
}
template<typename T> void inputVec(std::vector<T>& vec) {
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
	const int N = inputVal<int>();
	const int L = inputVal<int>();
	vector<int> f(N + 1,0);
	int iMin = 0;
	int absMin = 10000000;
	int sum = 0;
	for (int i = 1; i <= N; ++i) {
		f[i] = L + i - 1;
		sum += f[i];
		int absf = abs(f[i]);
		if (absf <= absMin) {
			absMin = absf;
			iMin = i;
		}
	}

	outputVal(sum - f[iMin]);
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << std::fixed << std::setprecision(15);
	Main();

	double tmp;
	cin >> tmp;

	return 0;
}


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

using namespace std;

using ll=long long ;
void solve() {
    ll n; cin >> n;
    ll res = 0;
    int i = 0;
    while (n) {
        ll k = 1ll<<i;
        if (n & k) {
            res |= k;
            n += (i&1)?k:-k;
        }
        i++;
    }
    if (res == 0) {
        cout << 0;
        return;
    }
    //cout << res << "\n";
    int h = 63-__builtin_clzll(res);
    for (int i = h; i >= 0; i--) {
        int x = (res & (1ll<<i))? 1:0;
        cout << x;
    }
}

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


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

int main(){
    string s;cin>>s;
    string bf,wf;
    int n=s.size();
    rep(i,n){
        if(i%2==0){
            bf+='0';
            wf+='1';
        }
        else{
            bf+='1';
            wf+='0';
        }        
    }

    int difbf=0,difwf=0;
    rep(i,n){
        if(s[i]!=bf[i]) difbf++;
        if(s[i]!=wf[i]) difwf++;
    }

    cout<<min(difbf,difwf)<<endl;
}



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

using LL=long long;
const LL INF = 1'000'000'000'000'000'00;

int V, E;
vector<vector<LL>> dist;


void WarashallFloyd() {
	for (int i = 0; i < V; i++)
		for (int j = 0; j < V; j++)
			for (int k = 0; k < V; k++) {
				if (dist[j][i] == INF || dist[i][k] == INF)continue;
				dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
			}
}

int main() {
	cin >> V >> E;
	dist = vector<vector<LL>>(V, vector<LL>(V, INF));
	for (int i = 0; i < V; i++)dist[i][i] = 0LL;
	for (int i = 0; i < E; i++) {
		int s, t; LL d;
		cin >> s >> t >> d;
		dist[s][t] = d;
	}

	WarashallFloyd();

	bool flag = false;
	for (int i = 0; i < V; i++)
		if (dist[i][i] < 0)flag = true;

	if (flag) {
		cout << "NEGATIVE CYCLE" << endl;
	}
	else {
		for (int i = 0; i < V; i++) {
			for (int j = 0; j < V; j++) {
				if (dist[i][j] == INF)cout << "INF";
				else cout << dist[i][j];
				cout << (j == V - 1 ? "\n" : " ");
			}
		}
	}
}


Measured memory_bytes: 3224
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }




int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, D; cin >> N >> D;
    ll m = 2*D+1;
    cout << (N + m-1)/m << endstr;
    return 0;
}


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

using namespace std;
typedef long long LL;

int ans, N;
void dfs(string s){
  if(s.size()>=10) return;
  int n3=0, n5=0, n7=0;
  LL n=0;
  rep(i,s.size()){
    if(s[i]=='3') n3++, n+=3*pow(10,i);
    if(s[i]=='5') n5++, n+=5*pow(10,i);
    if(s[i]=='7') n7++, n+=7*pow(10,i);
  }
  if(n<=N&&n3&&n5&&n7) ans++;
  dfs(s+'3'); dfs(s+'5'); dfs(s+'7');
}

int main(){
  cin >> N;
  ans=0;
  dfs("");
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int n;
	scanf("%d",&n);
	if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
	printf("hon");
	else if(n%10==3)
	printf("bon");
	else
	printf("pon");
	return 0;
 } 

Measured memory_bytes: 1732
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
	int n,a[7]={1,2,4,8,16,32,64};
	while(scanf("%d",&n)!=EOF)
	{
		int sum=0,i;
		for(i=6;i>=0;i--)
		{
			if(a[i]<=n)
			{
			  printf("%d\n",a[i]);
			  break;
		    }
		}		
	}
	return 0;
}


Measured memory_bytes: 256
import math
n = int(input())

def fractal(A,B):
    global a1
    global a2
    global a3
    x1 = A[0]
    y1 = A[1]
    x2 = B[0]
    y2 = B[1]
    a1 = [(2*x1 + x2)/3, (2*y1 + y2)/3]
    a3 = [(x1 + 2*x2)/3, (y1 + 2*y2)/3]
    X = a3[0] - a1[0]
    Y = a3[1] - a1[1]
    a2 = [a1[0] + X/2 - Y*math.sqrt(3)/2, a1[1] + X*math.sqrt(3)/2 + Y/2]
    
A = [0,0]
B = [100,0]
fract = [A,B]
for i in range(n):
    l = len(fract)
    f = list(fract)
    for k in range(l-1):
        fractal(f[k], f[k+1])
        fract.insert(4*k+1,a1)
        fract.insert(4*k+2,a2)
        fract.insert(4*k+3,a3)        
for i in fract:
    print('{0:.6f}'.format(i[0]) + ' {0:.6f}'.format(i[1]))
#print(fract)    


Measured memory_bytes: 6304
import itertools
N = int(input())
L = list(map(int,input().split()))

C = list(itertools.combinations(L,3))

counter = 0
for c in C:
    if c[0] != c[1] and c[1] != c[2] and c[2] != c[0] and c[0]+c[1] > c[2] and c[1]+c[2] > c[0] and c[2]+c[0] > c[1]:
        counter += 1

print(counter)

Measured memory_bytes: 20612
n = input()
if len(n) == 1:
  print(0)
  exit()
cnt = 0
li = []
for i in n:
  li.append(int(i))
#print(li)
cnt = 0

for i in range(1, len(li)):
  if li[i] == li[i-1]:
    if li[i] == 1:
      li[i] = 0
    else:
      li[i] = 1
    cnt += 1
print(cnt)

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

int main() {
  int n;
  cin >> n;
  int a, b, c;
  int dp[n][3];
  cin >> dp[0][0] >> dp[0][1] >> dp[0][2];
  rep(i, n) {
    if (i == 0) continue;
    cin >> a >> b >> c;
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a;
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b;
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c;
  }
  cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));

  
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int m,i,j,big,k;
		int count = 0;
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.nextLine());
		int array[] = new int[n];

		for(m=0;m<n;m++)array[m] = Integer.parseInt(in.next());

	for (i=0; i<n-1; i++){               //???????????????????????????????????°i
		for (j=n-1; j>=i+1; j--){        //?????????????°?????????£??\????´???¨??????????????????????????°j
			if (array[j] < array[j-1]){
				big = array[j-1];        //??§???????????????????´????????????????????????????????????°big
				array[j-1] = array[j];   //??????????????§??\???????????????
				array[j] = big;
				count++;                 //???????????\??????????????°?????????????????????
			}
		}
	}
	for(k = 0;k<n-1;k++){
		System.out.print(array[k]+" ");
	}
    System.out.println(array[k]);
			System.out.println(count);
	}
}

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

using namespace std;
#define         MAX         1000000
#define         ll          long long
#define         input       freopen("input.txt","r",stdin)
#define         output      freopen("output.txt","w",stdout)



int main() {

    ll x;
    cin>>x;

    if(x<500){
        cout<<(x/5)*5<<endl;
    }else{
        ll ans = (x/500)*1000;
        ll tmp = x%500;
        //cout<<ans<<endl;
        //cout<<tmp<<endl;
        cout<<ans+((tmp/5)*5)<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	int N, count = 0, memo = 0;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 1; i < N; i++) {
		count++;
		if (A[i - 1] < A[i]) count = 0;
		memo = max(memo, count);
	}
	cout << memo << endl;
	system("pause");
}

Measured memory_bytes: 888
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1000000000

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

void solve(){

	int a,b,c;
	cin >> a >> b >> c;

	int sum= a+b+c;

	if(sum>=22)cout << "bust" << endl;
	else cout << "win" << endl;
}
	
	

signed main() 
{   
	IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    int k;
    cin >> s >> k;
    int len=s.size();
    int n=min(len,k);
    bool jud=true;
    for(int i = 0; i < n; i++) {
        if(s[i]!='1'){
            jud=false;
            cout << s[i] << "\n";
            return 0;
        }
    }
    cout << "1" << "\n";
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,M,X,Y; cin >> N >> M >> X >> Y;
    vector<int> x(N);
    vector<int> y(M);
    for(int i = 0; i < N; i++)
    {
        cin >> x.at(i);
    }
    for(int i = 0; i < M; i++)
    {
        cin >> y.at(i);
    }
    int maxx = -101,miny = 101;
    for(int i = 0; i < N; i++)
    {
        if(maxx < x.at(i))
        {
            maxx = x.at(i); //xの最大値
        }
    }
    for(int i = 0; i < M; i++)
    {
        if(miny > y.at(i))
        {
            miny = y.at(i); //ｙの最小値
        }
    }
    if(maxx < X)
    {
        maxx = X;
    }
    if(miny > Y)
    {
        miny = Y;
    }
    if(maxx < miny)
    {
        cout << "No War" << endl;
    }
    else
    {
        cout << "War" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a==b){
      cout<<"Draw"<<endl;
    }else if(a==1){
      cout<<"Alice"<<endl;
    }else if(b==1){
      cout<<"Bob"<<endl;
    }else if(a>b){
      cout<<"Alice"<<endl;
    }else{
      cout<<"Bob"<<endl;
    }    
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using i8 = std::int8_t;
using u8 = std::uint8_t;
using i16 = std::int16_t;
using u16 = std::uint16_t;
using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

auto main() -> i32 {
	char s[200005];
	scanf("%s", s);
	i32 r = 0;
	for (i32 i = 0; s[i]; ++i) {
		int d = s[i] - '0';
		r = (r + d) % 9;
	}
	puts(r == 0 ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 1856
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();// 人数
        int m = sc.nextInt();// 種類
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 1; i <= m; i++) {
            // 初期化
            map.put(i, 0);
        }

        for (int i = 0; i < n; i++) {
            int count = sc.nextInt();// 調査した食べ物の数
            for (int j = 0; j < count; j++) {
                int food = sc.nextInt();
                map.put(food, map.get(food)+1);
            }
        }

        int count = 0;
        for (Map.Entry entry: map.entrySet()){
            if ((Integer) entry.getValue() == n) count++;
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

ll n,q;
ll a[200010],b[200010];
ll v[200010];
bool reached[200010]={0};
vector<ll> g[200010];

void dfs(ll s){
	reached[s]=1;
	FOR(i,g[s].size()){
		if(!reached[g[s][i]]){
			v[g[s][i]]+=v[s];
			dfs(g[s][i]);
		}
	}
}

int main(){
	
	cin >> n >> q;
	
	FOR(i,n-1){
		cin >> a[i] >> b[i];
		g[a[i]].push_back(b[i]);
		g[b[i]].push_back(a[i]);
	}

	
	FOR(i,200005){
		v[i]=0;
		
	}
	ll p,x;
	FOR(i,q){
		cin >> p >> x;
		v[p]+=x;
	}
	dfs(1);
	FOR(i,n){
		cout << v[i+1] << " ";
	}
	cout << endl;

}

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

int main(){
    int n; cin>>n;
    int cnt,ans=0;
    for(int i=1; i<=n; i+=2){
        cnt=0;
        for(int j=1; j<=i; j++){
            if(i%j == 0)cnt++;
        }
        if(cnt == 8)ans++;
    }

    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

void __start__() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef MY
    freopen("/home/ainur/CLionProjects/wow/input.txt", "r", stdin);
    freopen("/home/ainur/CLionProjects/wow/output.txt", "w", stdout);
#else
#define endl '\n'
    //freopen("search.in", "r", stdin);
    //freopen("search.out", "w", stdout);
#endif
}

#define sz(x) (int)x.size()
#define yes cout<<"Yes\n"
#define  no cout << "No\n"
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ft first
#define sd second
#define read(a) for(auto &qwqw:a)cin >> qwqw;
#define print(a) for(auto qwqw:a)cout<<qwqw<<' ';
#define print_plus(a) for(auto qwqw:a)cout<<qwqw+1<<' ';
//#define FOR(i, b, n) for(int i=b;i<n;i++) #define FOR(i, n) FOR(i, 0, n) #define FOR(n) FOR(i, 0, n)
mt19937_64 rnd(time(0));
#define int long long
using ll = long long;
using vi = vector<int>;
using ld = long double;
using vb = vector<bool>;
using pii = pair<int, int>;
using vd = vector<long double>;


int log2(int q) {
    int c = 0;
    while (q) {
        q >>= 1;
        c++;
    }
    return c;
}

void test_case() {
    int n, m, k, ans = 0;
    cin >> n >> m >> k;
    vector<string> a(n);
    read(a);
    for (int mask = 0; mask < (1 << n); ++mask) {
        for (int tmask = 0, c = 0; tmask < (1 << m); ++tmask) {
            c=0;
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) {
                    c += (!(mask & (1 << i)) && !(tmask & (1 << j))) && a[i][j] == '#';
                }
            }
            ans += (c == k);
        }
    }
    cout << ans;

}

signed main() {
    __start__();
    int Q = 1;
    //cin >> Q;
    while (Q--) {
        test_case();
    }
}





Measured memory_bytes: 3636
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

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

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

int main(void) {
  int n;
  vector<int> v(n);
  cin>>n;
  double ans = 0;
  for(int i=0 ; i<n; i++) {
    double x;
    cin>>x;
    ans += 1.0/x;
  }
  std::cout << setprecision(10) << 1.0/ans << std::endl;

  
  return 0;
}



Measured memory_bytes: 256
n = int(input())
pn = list(map(int, input().split()))
 
pnSort = sorted(pn)
 
if pn == pnSort:
    print("YES")
else:
    change = []
    index = 0
    for i,j in zip(pn, pnSort):
        if i != j:
            change.append(index)
            if len(change) == 2:
                break
        index += 1
 
    tmp = pn[change[0]]
    pn[change[0]] = pn[change[1]]
    pn[change[1]] = tmp
    
    if pn == pnSort:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 3064
#include <stdio.h>

#define DEF_ELM_MAX 100

	int R[DEF_ELM_MAX];

void swap(int *x, int *y)
{
	int tmp;
	tmp = *x;
	*x = *y;
	*y = tmp;
	return;
}



int selectionSort(int *A, int N) // N??????????´??????????0-?????????????????????A
{
	int i;
	int j;
	int minj;
	int cnt = 0;
	int flag;

	for ( i = 0 ; i < N ; i++ ) {
		minj = i;
		flag = 0;
		for ( j = i ; j < N ; j++ ) {
			if ( A[j] < A[minj] ) {
				minj = j;
				flag = 1;
			}
		}
		if (flag) {
			swap(&A[i], &A[minj]);
			cnt++;
		}
	}
	return cnt;
}

int main(void)
{
	int N;
	int i;

	int ans;
//
	scanf("%d", &N);
	for ( i = 0 ; i < N ; i++ ) {
		scanf("%d", &R[i]);
	}
//
	ans = selectionSort(R, N);
//
	for ( i = 0 ; i < N ; i++ ) {
		if (i > 0) {
			printf(" ");
		}
		printf("%d", R[i]);
	}
	printf("\n%d\n", ans);
	return 0;
}

Measured memory_bytes: 604
#include <stdio.h>
int main(void){
int N, i, ac=0, wa=0, tle=0, re=0;
char s[4];

    //printf("N S1 S2 ... SN = ");   
    scanf("%d",&N); 

    for(i=0;i<N;i++){
    scanf("%s",s);
       if(s[0]=='A'){
         ac++;
       }
       else if(s[0]=='W'){
         wa++;
       }
       else if(s[0]=='T'){
         tle++;
       }
       else{
         re++;
       }
    }
    printf("AC x %d\n",ac);
    printf("WA x %d\n",wa);
    printf("TLE x %d\n",tle);
    printf("RE x %d\n",re);
return 0;
}

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

struct Node{
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k){
	Node *y = NIL;
	Node *x = root;
	Node *z;

	z = (Node *)malloc(sizeof(Node));
	z -> key = k;
	z->left = NIL;
	z->right = NIL;

	while(x != NIL){
		y = x;
		if(z->key < x->key){
			x = x->left;
		}else{
			x = x->right;
		}
	}
	z->parent = y;

	if(y == NIL){
		root = z;
	}else{
		if(z->key < y->key){
			y->left = z;
		}else{
			y->right = z;
		}
	}
}

void inorder(Node *u){
	if(u==NIL)return;
	inorder(u->left);
	cout << " " << u->key;
	inorder(u->right);
}

void preorder(Node *u){
	if(u==NIL)return;
	cout << " " << u->key;
	preorder(u->left);
	preorder(u->right);
}

int main(){
	int n,i,x;
	string com;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> com;
		if(com=="insert"){
			cin >> x;
			insert(x);
		}else if(com=="print"){
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 26412
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
pair<ll, ll> a[N];
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n;
    cin >> n;
    for (ll i = 0; i < n; i++)
        cin >> a[i].first, a[i].second = i + 1;
    sort(a, a + n);
    for (ll i = 0; i < n; i++)
        cout << a[i].second << " ";
    return 0;
}

Measured memory_bytes: 2432
ref = ["",
       "',.!?",
       "abcABC",
       "defDEF",
       "ghiGHI",
       "jklJKL",
       "mnoMNO",
       "pqrsPQRS",
       "tuvTUV",
       "wxyzWXYZ"]

def inp(s):
    n = int(s[0])
    p = (len(s)-1)%len(ref[n])
    return ref[n][p]

while 1:
    try:
        pushes = raw_input()
    except:
        break
    ans = ""
    s = ""
    for push in pushes:
        l = len(s)
        if push == "0":
            if l > 0: ans += inp(s)
            else: ans += " "
            s = ""
        elif l == 0 or s[-1] == push:
            s += push
        else:
            ans += inp(s)
            s = push
    if l > 0:
        ans += " "*l if s[0] == "0" else inp(s)
    print ans

Measured memory_bytes: 4244
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = {0, -1, 0, 1};

struct cell
{
    int i, j;
};

void solve(int N, int M, vector<string> S)
{
    auto is_valid = [&](int i, int j) {
        return 0 <= i && i < N && 0 <= j && j < M && S.at(i).at(j) == '.';
    };

    mf_graph<int> graph(N * M + 2);
    int s = N * M, t = N * M + 1;
    auto to_id = [&](int i, int j) {
        return i * M + j;
    };
    auto to_ij = [&](int id) {
        return (cell){id / M, id % M};
    };

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < M; j++)
        {
            if (!is_valid(i, j))
                continue;
            int id = to_id(i, j);

            if ((i + j) % 2 == 0)
            {
                // s -> even
                graph.add_edge(s, id, 1);

                // even -> odd
                for (int v = 0; v < (int)di.size(); v++)
                {
                    if (!is_valid(i + di.at(v), j + dj.at(v)))
                        continue;
                    int id_o = to_id(i + di.at(v), j + dj.at(v));
                    graph.add_edge(id, id_o, 1);
                }
            }
            else
            {
                // odd -> t
                graph.add_edge(id, t, 1);
            }
        }
    }

    cout << graph.flow(s, t) << endl;

    for (auto &&e : graph.edges())
    {
        if (e.from == s || e.to == t || e.flow == 0)
            continue;
        cell even = to_ij(e.from);
        cell odd = to_ij(e.to);
        if (even.i == odd.i)
        {
            if (even.j < odd.j)
            {
                S.at(even.i).at(even.j) = '>';
                S.at(odd.i).at(odd.j) = '<';
            }
            else
            {
                S.at(odd.i).at(odd.j) = '>';
                S.at(even.i).at(even.j) = '<';
            }
        }
        else
        {
            if (even.i < odd.i)
            {
                S.at(even.i).at(even.j) = 'v';
                S.at(odd.i).at(odd.j) = '^';
            }
            else
            {
                S.at(odd.i).at(odd.j) = 'v';
                S.at(even.i).at(even.j) = '^';
            }
        }
    }

    for (int i = 0; i < N; i++)
    {
        cout << S.at(i) << endl;
    }
}

int main()
{
    int N;
    cin >> N;
    int M;
    cin >> M;
    vector<string> S(N);
    for (int i = 0; i < N; i++)
    {
        cin >> S.at(i);
    }
    solve(N, M, move(S));
    return 0;
}


Measured memory_bytes: 5580
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>
using namespace std;
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}
int gcd(int x, int y){
	if(x<y){
    return gcd(y,x);
  }
  if(y==0){
    return x;
  }
  return gcd(y,x%y);
}
int moji(char in)
{
    int ans = (int)in-(int)'a'+1;
    if((in < 1) || (in > 26)){
        ans = 100;
    }
    return ans;
}





int main() {
  string s;
  cin>>s;
  for(int i=0;i<3;i++){
    if(s.at(i)=='1'){
      cout<<9;
    }else{
      cout<<1;
    }
    if(i==2){
      cout<<""<<endl;
    }
  }





  

  
  
  


  
  


  

  




  
  
}

  

  

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

int main(){
    int A, B, C, X, Y, d, s = 0, ab = 0;
    cin >> A >> B >> C >> X >> Y;
    if(X > Y){
        d = X - Y;
        ab = 1;
    }
    else if(X < Y){
        d = Y - X;
        ab = -1;
    }
    else d = 0;
    if(A+B < 2*C){
        if(ab == 1){
            s += Y*(A+B);
            if(A > 2*C){
                s += 2*C*d;
                cout << s << endl;
                return 0;
            }
            else{
                s += A*d;
                cout << s << endl;
                return 0;
            }
        }
        else if(ab == -1){
            s += X*(A+B);
            if(B > 2*C){
                s += 2*C*d;
                cout << s << endl;
                return 0;
            }
            else{
                s += B*d;
                cout << s << endl;
                return 0;
            }
        }
        else{
            s += X*(A+B);
            cout << s << endl;
            return 0;
        }
    }
    else{
        if(ab == 1){
            s += Y*2*C;
            if(A > 2*C){
                s += 2*C*d;
                cout << s << endl;
                return 0;
            }
            else{
                s += A*d;
                cout << s << endl;
                return 0;
            }
        }
        else if(ab == -1){
            s += X*2*C;
            if(B > 2*C){
                s += 2*C*d;
                cout << s << endl;
                return 0;
            }
            else{
                s += B*d;
                cout << s << endl;
                return 0;
            }
        }
        else{
            s += X*2*C;
            cout << s << endl;
            return 0;
        }
    }

    return 0;
}

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

namespace TYC
{
	const int N = 55, mod = 1e9 + 7;

	int n, F[N][N], C[N][N];

	void work()
	{
		scanf("%d", &n);
		for (int i = 0; i <= n; i++)
		{
			C[i][0] = 1;
			for (int j = 1; j <= i; j++)
				C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
		}
		F[1][0] = F[1][1] = n;
		for (int i = 1; i < n; i++)
			for (int j = 0; j <= i; j++)
				for (int k = max(1, j); i + k <= n; k++)
					if ((k - j) % 2 == 0)
						for (int a = 0; a <= k; a++)
							(F[i + k][abs(a - (k - j) / 2)] += int((long long)F[i][j] * C[n - i][k] % mod * C[k][a] % mod)) %= mod;
		printf("%d\n", F[n][0]);
	}
}

int main()
{
	TYC::work();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    for (int i = 0; i < h; i++) {
        cin >> a.at(i);
    }


    vector<int> col(h, 0), row(w, 0);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (a.at(i).at(j) == '#') {
                col.at(i) = 1;
                break;
            }
        }
    }
    for (int j = 0; j < w; j++) {
        for (int i = 0; i < h; i++) {
            if (a.at(i).at(j) == '#') {
                row.at(j) = 1;
                break;
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (col.at(i) == 1 && row.at(j) == 1) {
                cout << a.at(i).at(j);
            }
        }
        if (col.at(i) == 1) {
            cout << endl;
        }
    }
}


Measured memory_bytes: 256