akhauriyash/Code-Regression huggingface dataset:
#define scanf_s scanf
//#define gets_s gets
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 1000//0
#define _MAX 81
int main(void)
{
	int max = 120 * 60;
	int t, h, s, s3;
	while (1) {
		scanf_s("%d %d %d", &t, &h, &s);
		if ((t == -1 && h == -1) && s == -1) break;
		h += t * 60; 
		s += h * 60;
		s = max - s;
		s3 = s * 3;
		h = 0; t = 0;
		if (s > 0) {
			h = s / 60;
			s %= 60;
		}
		if (h > 0) {
			t = h / 60;
			h %= 60;
		}
		if (t > 0 && t / 10 > 0) printf("%d:", t);
		else printf("0%d:", t);
		if (h > 0 && h / 10 > 0) printf("%d:", h);
		else printf("0%d:", h);
		if (s > 0 && s / 10 > 0) printf("%d\n", s);
		else printf("0%d\n", s);
		h = 0; t = 0;
		if (s3 > 0) {
			h = s3 / 60;
			s3 %= 60;
		}
		if (h > 0) {
			t = h / 60;
			h %= 60;
		}
		if (t > 0 && t / 10 > 0) printf("%d:", t);
		else printf("0%d:", t);
		if (h > 0 && h / 10 > 0) printf("%d:", h);
		else printf("0%d:", h);
		if (s3 > 0 && s3 / 10 > 0) printf("%d\n", s3);
		else printf("0%d\n", s3);
	}

}

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

using namespace std;

//State
//dp[mask]: The number of ways of matcxhing the subset of women
// represnted by mask(each bit corresponds to a woman) to the first i number of men 
// where i = count of ones in mask

//Initialization
//dp[0] = 1

//Transitions
//dp[mask] = dp[mask]+dp[newmask] for all newmask obtaining by deleting a one from the mask

//Order of evaluation
//1 to 2^N-1 (increasing order of mask)

//Answer
//dp[(1<<N)-1]

//Time Complexity: O(N*2^N)

const int mod = 1e9+7;
int A[21][21];
int dp[(1<<21)-1]={0};

vector<int> getOnes(int mask, int N){
	vector<int> result;
	for(int i=0; i<N; i++){
		if((mask & (1<<i)) != 0){
			result.push_back(i);
		}
	}
	return result;
}

int main(){
	int N;
	cin >> N;
	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){
			cin >> A[i][j];
		}
	}
	dp[0] = 1;
	for(int mask=1; mask<(1<<N); mask++){
		vector<int> ones = getOnes(mask, N);
		int man = ones.size()-1;
		//cout << mask<<" "<< man << ones.size() << endl;
		for(int woman: ones){
			if(A[man][woman]==1){
				int newMask = (mask & ~(1<<woman));
				dp[mask] = (dp[mask] + dp[newMask]) % mod; 
			}
		}
	}
	/*for(int i=0; i<(1<<N); i++){
	    cout << dp[i] << " ";
	}
	cout << endl;*/
	cout << (dp[(1<<N)-1]) % mod << endl;
}

Measured memory_bytes: 11772
#include <stdio.h>

char change(int n)
{
  	return (n + 'a' - 1);
}

int main(void)
{
  	long long int	n;
  	int	i;
  	int	a[100];
  
  	scanf("%lld", &n);
  
    i = 0;
  	while(n > 0LL)
    {
      	a[i] = n % 26LL;
      	if (a[i] == 0)
      	{
      	    a[i] = 26;
      	    n = n - 26;
      	}
        i++;
      	n = n / 26LL;
    }
  
    i--;
  	for(; i>=0; i--)
    {
        printf("%c", change(a[i]));
    }
  	return (0);
}

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

int main(){
  
  string S;
  cin >> S;
  int flg = 1;
  
  for(int i = 1; i <= S.length(); ++i){
    if(i % 2 == 0){
      if(S[i - 1] == 'R'){
        flg = 0;
        break;
      }
    }
    else{
      if(S[i - 1] == 'L'){
        flg = 0;
        break;
      }
    }
  }
  
  cout << ((flg == 1) ? "Yes" : "No") << endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String str = sc.next();
		StringBuilder sb = new StringBuilder(str);
		int ans = 0;
		int l = 0;
		int r = N - 1;
		while (true) {
			if (sb.charAt(l) == 'R') {
				l++;
			}
			if (sb.charAt(r) == 'W') {
				r--;
			}
			if (l < r && sb.charAt(l) == 'W' && sb.charAt(r) == 'R') {
				sb.setCharAt(l, 'R');
				sb.setCharAt(r, 'W');
				ans++;
				l++;
				r--;
			}
			if (l >= r || l >= N || r < 0) {
				break;
			}
		}
		System.out.println(ans);
	}

}

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

int main(){

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    double h,a;
    cin >> h >> a;
    double ans = h/a;
    ll res = ceil(ans);
    cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
As = map(int, input().split())
sorted_As = sorted(As, reverse=True)
alice_sum = 0
bob_sum = 0
for i, a in enumerate(sorted_As):
    if (i+1) % 2 == 1:
        alice_sum += a
    else:
        bob_sum += a
print(alice_sum - bob_sum)

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

vector<vector<int>> G;
vector<int> out_x; 
vector<int> visited;
vector<int> dist;

/*void dfs(int now, int plus){
    visited.at(now) = 1;
    out_x.at(now) += plus;
    for(int i=0; i<G.at(now).size(); i++){
        int next = G.at(now).at(i);
        if(visited.at(next)==0 && dist.at(next) > dist.at(now)){
            dfs(next, plus);
        }
    }
}*/

int main(){
    int n,q;
    cin >> n >> q;
    G.resize(n);
    out_x = vector<int>(n,0);
    dist = vector<int>(n,-1);
    for(int i=0; i<n-1; i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        G.at(a).push_back(b);
        G.at(b).push_back(a);
    }
    queue<int> que;
    vector<int> parent(n,0);
    que.push(0);
    dist.at(0) = 0;
    while(!que.empty()){
        int front=que.front();
        for(int i=0; i<G.at(front).size(); i++){
            int next=G.at(front).at(i);
            if(dist.at(next) == -1){
                dist.at(next) = dist.at(front)+1;
                que.push(next);
                parent.at(next) = front; 
            }
        }
        que.pop();
    }
    vector<int> ans(n,0);
    vector<pair<int,int>> count_plus;//i番目の命令が深さいくつのとこからか
    vector<pair<int,int>> ope;//操作の内容
    for(int i=0; i<q; i++){
        int p,x;
        cin >> p >> x;
        p--;
        //visited = vector<int>(n,0);
        //dfs(p,x);
        out_x.at(p) += x;
        pair<int, int> pa;
        pa=make_pair(dist.at(p), i);
        count_plus.push_back(pa);
        pa=make_pair(p,x);
        ope.push_back(pa);
    }
    /*
    sort(count_plus.begin(), count_plus.end());
    for(int i=0; i<q; i++){
        pair<int, int> s;
        s = count_plus.at(i);
        int index;
        index=s.second;
        s = ope.at(index);
        int place,plus;
        place = s.first;
        //plus = s.second;
        if(place == 0) continue;
        out_x.at(place) += out_x.at(parent.at(place));
    }
    */
    vector<pair<int,int>> point(n);
    for(int i=0; i<n; i++){
        pair<int,int> s=make_pair(dist.at(i), i);
        point.at(i) = s;
    }
    sort(point.begin(), point.end());
    for(int i=0; i<n; i++){
        pair<int, int> s = point.at(i);
        int place = s.second;
        if(place==0) continue;
        out_x.at(place) += out_x.at(parent.at(place));
    }
    for(int i=0; i<n; i++){
        cout << out_x.at(i) << endl;
    }
}


Measured memory_bytes: 23632
from itertools import combinations_with_replacement
N, M, Q = [int(n) for n in input().split()]
X = [[int(n) for n in input().split()] for _ in range(Q)]
ans = 0
for A in combinations_with_replacement(range(1, M+1), N):
    t = 0
    for x in X:
        if A[x[1]-1]-A[x[0]-1] == x[2]: t += x[3]
    ans = max(ans, t)
print(ans)


Measured memory_bytes: 9108
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n+1];
		int[] b = new int[n+1];
		boolean status=false;
		for(int i=1;i<=n;i++) {
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
		}
		for(int i=1;i<=n-2;i++) {
			if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2]) {
				status=true;
				break;
			}
		}
		System.out.println(status?"Yes":"No");
		sc.close();
	}

}

Measured memory_bytes: 36168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(2e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    ll n ,m, ans = 1;
    cin >> n >> m;
    if(abs(n-m)>1){
        cout << 0 << endl;
    }
    else{
        REP(i,n) ans = ans*(i+1) % MOD;
        REP(i,m) ans = ans*(i+1) % MOD;
        if(n==m) ans = ans*2 %MOD;
        cout << ans << endl;
    }
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    map<string,int> mp;
    string s[n];
    ll ans = 0;
    for(int i = 0; i < n; i++){
        cin >> s[i];
        mp[s[i]]++;
    }
    int m;
    cin >> m;
    string t[m];
    for(int i = 0; i < m; i++){
        cin >> t[i];
        mp[t[i]]--;
    }
    for(auto p:mp){
        if(p.second > 0){
            if(ans < p.second) ans = p.second;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int ac=0,bc=0,i,j=0, ok=0;
  char a[202],b[102];
  scanf("%s %s",a,b);
  // printf("%s %s",a,b);////////

  while(1){
    ac++;
    if(a[ac]=='\0'){
      break;
    }
  }  
  //printf("%d",ac);///
  while(1){
    bc++;
    if(b[bc]=='\0'){
      break;
    }
  }  
  //printf("%d\n",bc);////////
  for(i=0;i<ac;i++){
    a[ac+i]=a[i];
  }
  a[ac+ac]='\0';
  //printf("%s\n",a);//////// okokok
  for(i=0;i<ac+ac;i++){
    //if(a[i]==b[0]){
    for(j=0;j<bc;j++){
      if(i+j>=ac+ac){
	break;
      }
      if(b[j]!=a[i+j]){
	break;
      }
     
      // }
    if ( j == bc-1 ) ok = 1;
  }
  
}
//printf("%d\n",j);///////
//  if(j==bc-1){
if(ok == 1){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 944
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  string s; cin >> s;
  int n = s.size();
  int w = 26;
  vector<vector<int>> next(n + 1, vector<int>(26, n));
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < w; j++) {
      next[i][j] = next[i + 1][j];
      if (s[i] == (char)(j + 'a')) {
        next[i][j] = i;
      }
    }
  }

  vector<int> dp(n + 1, inf);
  dp[n] = 1;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < w; j++) {
      if (next[i][j] == n) {
        dp[i] = 1;
      } else {
        dp[i] = min(dp[i], dp[next[i][j] + 1] + 1);
      }
    }
  }
  /*
  for (int i = 0; i <= n; i++) {
    cerr << dp[i] << " ";
  }
  cerr << endl;
  */

  int cur = 0;
  string ans = "";
  while (cur < n) {
    // cerr << cur << endl;
    if (dp[cur] == 1) {
      for (int j = 0; j < w; j++) {
        if (next[cur][j] == n) {
          ans += (char)(j + 'a');
          break;
        }
      }
      break;
    }

    for (int j = 0; j < w; j++) {
      // cerr << "cur = " << cur << " j = " << j << " " << next[cur][j] + 1 << endl;
      if (dp[cur] == dp[next[cur][j] + 1] + 1) {
        ans += (char)(j + 'a');
        cur = next[cur][j] + 1;
        break;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 27780
#include<stdio.h>
long long gcd(long long a,long long b){
  if(a<b)return gcd(b,a);
  if(b==0)return a;
  return gcd(b,a%b);
}
long long lcm(long long a,long long b){
  return a*(b/gcd(a,b));
}
int main(){
  long long a,b,m,s=1,i,c[3];
  while(1){
    for(i=0;i<3;i++){
      scanf("%lld %lld",&a,&m);
      if(a==0)continue;
      b=a;
      for(c[i]=1;b-1;c[i]++)b=(b*a)%m;
    }
    if(a==0)return 0;
    printf("%lld\n",lcm(c[0],lcm(c[1],c[2])));
  }
}

Measured memory_bytes: 600
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=100000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u];i;i=sq[i].nxt)
#define fir first
#define sec second
#define mp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

namespace My_Math{
	#define N 100000

	int fac[N+100],invfac[N+100];

	int add(int x,int y) {return x+y>=maxd?x+y-maxd:x+y;}
	int dec(int x,int y) {return x<y?x-y+maxd:x-y;}
	int mul(int x,int y) {return 1ll*x*y%maxd;}
	ll qpow(ll x,int y)
	{
		ll ans=1;
		while (y)
		{
			if (y&1) ans=mul(ans,x);
			x=mul(x,x);y>>=1;
		}
		return ans;
	}
	int inv(int x) {return qpow(x,maxd-2);}

	int C(int n,int m)
	{
		if ((n<m) || (n<0) || (m<0)) return 0;
		return mul(mul(fac[n],invfac[m]),invfac[n-m]);
	}

	int math_init()
	{
		fac[0]=invfac[0]=1;
		rep(i,1,N) fac[i]=mul(fac[i-1],i);
		invfac[N]=inv(fac[N]);
		per(i,N-1,1) invfac[i]=mul(invfac[i+1],i+1);
	}
	#undef N
}
using namespace My_Math;

int n1,n2,m,a[100100],b[100100];

int main()
{
	n1=read();n2=read();m=read();
	int mn1,mn2;mn1=mn2=maxd;
	rep(i,1,n1) {a[i]=read();mn1=min(mn1,a[i]);}
	rep(i,1,n2) {b[i]=read();mn2=min(mn2,b[i]);}
	int ans=mn1+mn2;
	rep(i,1,m)
	{
		int x=read(),y=read(),c=read();
		ans=min(ans,a[x]+b[y]-c);
	}
	printf("%d",ans);
	return 0;
}



Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>

using namespace std;

int main(void) {
    int64_t H, W, N;
    cin >> H >> W >> N;

    map<pair<int,int>,int> mp;
    while(N--) {
        int a, b;
        cin >> a >> b;
        mp[make_pair(a-1, b+1)]++;
        mp[make_pair(a-1, b)]++;
        mp[make_pair(a-1, b-1)]++;
        mp[make_pair(a, b+1)]++;
        mp[make_pair(a, b)]++;
        mp[make_pair(a, b-1)]++;
        mp[make_pair(a+1, b+1)]++;
        mp[make_pair(a+1, b)]++;
        mp[make_pair(a+1, b-1)]++;
    }

    vector<int64_t> ans(10);
    for(auto itr=mp.begin(); itr!=mp.end(); itr++) {
        int a = itr->first.first;
        int b = itr->first.second;
        if(1 < a && a < H && 1 < b && b < W) {
            ans[itr->second]++;
        }
    }

    ans[0] = (H-2)*(W-2) - accumulate(ans.begin()+1, ans.end(), 0L);

    for(auto e: ans) {
        cout << e << endl;
    }
    return 0;
}


Measured memory_bytes: 56576
N = int(input())
TA = [[int(_) for _ in input().split()] for _ in range(N)]
x, y = TA.pop(0)
for ta in TA:
    if ta[1] * x - ta[0] * y < 0:
        y = ta[1] * (1 + (y - 1) // ta[1])
        x = y * ta[0] // ta[1]
    elif ta[1] * x - ta[0] * y > 0:
        x = ta[0] * (1 + (x - 1) // ta[0])
        y = x * ta[1] // ta[0]
print(x + y)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while(n > 0) {
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,c;cin>>n>>c;
    vector<ll> a(n), b(n);
    rep(i,n){cin>>a[i];}
    rep(i,n){cin>>b[i];}
    ll lim = 401;
    vector<vector<ll>> dp(n+1, vector<ll>(c+1, 0));
    vector<vector<ll>> sum(n+1,vector<ll>(c+1, 0));
    rep(i,n){
        rep(j,c+1){
            repr(k,a[i], b[i]+1){
                sum[i][j] += modpow(k, j, MOD);
                sum[i][j] %= MOD;
            }
        }
    }
    dp[0][0]=1;
    rep(i,n){
        rep(j,c+1){
            for(int k=0;j+k<=c;k++){
                dp[i+1][j+k] += dp[i][j]*sum[i][k];
                dp[i+1][j+k] %= MOD;
            }
        }
    }
    cout << dp[n][c] << endl;
    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>
#include <climits>

using namespace std;
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define all(x) (x).begin(),(x).end()

using int64 = long long;




int main() {
    int a,b;
    char op;
    cin >> a >> op >> b;
    if (op == '+') cout << a + b << endl;
    else cout << a - b << endl;

}


Measured memory_bytes: 504
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int n,v,p;
ll a[100100],b[100100],m;

bool check(int j){
	int i;
	ll t,lft,tmp;
	for(i=0; i<n; ++i){
		b[i] = a[i];
	}
	lft = m*(v-1);
	b[j] += m; t = b[j];
	for(i=0; i<n; ++i){
		if(!lft){
			break;
		}
		tmp = min({m+a[i]-b[i],max(t-b[i],0ll),lft});
		b[i] += tmp;
		lft -= tmp;
	}
	for(i=n-1; i>=0; --i){
		if(!lft){
			break;
		}
		tmp = min(m+a[i]-b[i],lft);
		b[i] += tmp;
		lft -= tmp;
	}
	if(lft){
		return false;
	}
	sort(b,b+n,greater<ll>());
	return (b[p]<=t);
}

int main(void){
	int i,ok,ng,med,ans=0;
	cin >> n >> m >> v >> p; --p;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	sort(a,a+n);
	ok = n-1; ng = -1;
	while(ok-ng>1){
		med = (ok+ng)/2;
		if(check(med)){
			ok = med;
		}else{
			ng = med;
		}
	}
	for(i=0; i<n; ++i){
		if(a[i]>=a[ok]){
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <vector>
#include <iomanip>
#include <algorithm>
using namespace std;

void print_vector(vector<int> num)
{
	for(int i = 0; i < num.size(); i++){
		if(i){
			cout << " ";
		}
		cout << num[i];
	}
	cout << endl;
}
int bubbleSort(vector<int> &A)
{	
	int count = 0;
	for(int i = 0; i <= A.size() - 1; i++){
		for(int j = A.size() - 1; j >= i + 1; j--){
			if(A[j] < A[j - 1]){
				count++;
				int a = A[j];
				A[j] = A[j - 1];
				A[j - 1] = a;
			}
		}
	}
	return count;
}
int main(void)
{
	int n;
	cin >> n;
	vector<int> A(n);
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	
	int count = bubbleSort(A);
	
	print_vector(A);
	cout << count << endl;
	return 0;
}

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

template <typename T>
T gcd(T x, T y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}

template <typename T>
T lcm(T x, T y)
{
    if (x == 0 || y == 0)
        return 0;
    return x / gcd(x, y) * y;
}

int main()
{
    char X, Y;
    cin >> X >> Y;
    if (X == Y)
    {
        cout << '=' << endl;
    }
    else
    {
        cout << (X < Y ? '<' : '>') << endl;
    }
}


Measured memory_bytes: 764
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int>a(3);
    rep(i,3)cin>>a[i];
    sort(ALL(a));
    if(a[0]==5&&a[1]==5&&a[2]==7)YES;
    else NO;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define int ll
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)	
#define REP(i,b) FOR(i,0,b)
int read(){
	int i;
	scanf("%lld",&i);
	return i;
}
using vi=vector<int>;
#define PB push_back
#define ALL(x) x.begin(),x.end()
using pi=pair<int,int>;

void chmin(int&a,int b){
	a=a<b?a:b;
}
void chmax(int&a,int b){
	a=a>b?a:b;
}

const int Nmax=114514;

vi g[Nmax];
void AddEdge(int a,int b){
	g[a].PB(b);
	g[b].PB(a);
}
bool vis[Nmax];
int ans[Nmax];
void dfs2(int v,int d){
	if(vis[v])return;
	vis[v]=true;
	ans[v]=d;
	for(auto to:g[v])
		dfs2(to,-d);
}

vi t[2][Nmax];
int dfs(int v,int k){
	int res=-1;
	for(auto ch:t[k][v]){
		int w=dfs(ch,k);
		if(res==-1)
			res=w;
		else{
			AddEdge(res,w);
			res=-1;
		}
	}
	if(res==-1)res=v;
	return res;
}

signed main(){
	int n=read(),root[2];
	REP(k,2)
		REP(i,n){
			int p=read();
			if(p==-1)root[k]=i;
			else t[k][p-1].PB(i);
		}
	REP(i,n)
		if(int(t[0][i].size())%2!=int(t[1][i].size())%2){
			cout<<"IMPOSSIBLE"<<endl;
			return 0;
		}
	REP(k,2)
		dfs(root[k],k);
	REP(i,n)
		if(int(t[0][i].size())%2==0&&!vis[i])
			dfs2(i,1);
	cout<<"POSSIBLE"<<endl;
	REP(i,n)
		printf(i<n-1?"%lld ":"%lld\n",ans[i]);
}


Measured memory_bytes: 17664
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(void)
{
    int n;
    char s[300001];
    int w,e;
    int foww[300000],bace[300000];
    int min;

    scanf("%d %s",&n,s);
    w=e=0;
    for(int i=0;i<n;i++){
        if(s[i]=='W')w++;
        foww[i]=w;
    }
    for(int i=n-1;i>=0;i--){
        if(s[i]=='E')e++;
        bace[i]=e;
    }
    min=9999999;
    for(int i=0;i<n;i++){
        if(s[i]=='W')foww[i]--;
        else if(s[i]=='E')bace[i]--;
        if(min>foww[i]+bace[i]){
            min=foww[i]+bace[i];
        }
        //printf(">%d %d\n",foww[i],bace[i]);
    }
    printf("%d\n",min);
    return 0;
}

Measured memory_bytes: 2816
#include<iostream>
using namespace std;
int N,i,dp[1<<7];
int main(void){
  cin>>N;
  dp[0]=1;
  for(i=0;i<=N;i++)if(dp[i])dp[i+4]=dp[i+7]=1;
  cout<<(dp[N]?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=3000;
const int MAXSWAP=3000;
const int MOD=1000000007;
const int INV2=(MOD+1)/2;
void inc(int &a,int b) { if((a+=b)>=MOD) a-=MOD; }
int combine(int a,int b) { return (ll)(a+b)*INV2%MOD; }

int n,nswap;
int sval[MAXN];
int swapidx[MAXSWAP][2];

int pless[MAXN][MAXN];
int acpy[2][MAXN];
int bcpy[2][MAXN];

int solve() {
	REP(i,n) REP(j,n) pless[i][j]=sval[i]<sval[j]?1:0;
	REP(k,nswap) {
		int a=swapidx[k][0],b=swapidx[k][1];
		REP(i,n) acpy[0][i]=pless[a][i],acpy[1][i]=pless[i][a];
		REP(i,n) bcpy[0][i]=pless[b][i],bcpy[1][i]=pless[i][b];
		pless[a][b]=pless[b][a]=combine(acpy[0][b],bcpy[0][a]);
		REP(j,n) if(j!=a&&j!=b) pless[a][j]=pless[b][j]=combine(acpy[0][j],bcpy[0][j]);
		REP(i,n) if(i!=a&&i!=b) pless[i][a]=pless[i][b]=combine(acpy[1][i],bcpy[1][i]);
	}
	int ret=0; REP(i,n) FOR(j,i+1,n) inc(ret,pless[j][i]); REP(i,nswap) ret=(ll)ret*2%MOD; return ret;
}

void run() {
	scanf("%d%d",&n,&nswap);
	REP(i,n) scanf("%d",&sval[i]);
	REP(i,nswap) REP(j,2) scanf("%d",&swapidx[i][j]),--swapidx[i][j];
	printf("%d\n",solve());
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 35456
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(numOfPeople,numOfType);
    vector<int> okashi(numOfPeople,0);
    rep(i,numOfType){
        Cini(d);
        rep(j,d){
            int index;
            cin >> index;
            index--;
            okashi[index]++;
        }
    }
    int count = 0;
    rep(i,numOfPeople)if(okashi[i]==0)count++;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define sz() size()
#define fr first
#define sc second
#define int long long
#define mp make_pair
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
using namespace std;

string s,t;

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    srand(chrono::steady_clock::now().time_since_epoch().count());
    int ans = 0;
    cin >> s >> t;
    for(int i=0;i<s.size();i++){
        if(s[i] != t[i]) ans++;
    }
    rc(ans);
}





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

def f(ai,m):
    return (ai*ai)%m

if x==0:
    print(0)
elif x==1:
    print(n)
elif m==1:
    print(0)
elif n<=m*2:
    asum=x
    ai=x
    for i in range(1,n):
        ai=f(ai,m)
        asum+=ai
    print(asum)   
else:
    chk=[-1]*m
    asum00=[0]*m
    ai,asum=x,0
    for i in range(m):
        if chk[ai]!=-1:
            icnt0=chk[ai]
            break
        else:
            chk[ai]=i
            asum00[i]=asum
        asum+=ai
        ai=f(ai,m)
    icnt=i
    asum0=asum00[icnt0]
        
    icntk=icnt-icnt0
    n0=n-1-icnt0
    nk=n0//icntk
    nr=n0%icntk
    asumk=asum-asum0

    air,asumr=ai,0
    for i in range(nr):
        asumr+=air
        air=f(air,m)
    asumr+=air
       
    ans=asum0+asumk*nk+asumr    
    print(ans)       


Measured memory_bytes: 67272
// ABC094
// A - Cats and Dogs
#include<bits/stdc++.h>

using namespace std;

int main(){
    int a,b,x;
    cin >> a >> b >> x;
    if(a<=x && x<=a+b) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  int a,b;
  cin>>a>>b;
  int c;
  c=b-a;
  int s(0);
  for(int i(1);i<c;i++){
    s+=i;
  }
  cout<<s-a<<endl;
  return 0;
}

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

int main() {
  ll A, B, C;
  cin >> A >> B >> C;

  ll ans;
  if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) ans = 0;
  else ans = min({A*B, B*C, C*A});
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
vector<int> G[400000];
int vis[400000];
bool dfs(int v) {
	if (vis[v] == 1) return 0;
	if (vis[v] == 2) return 1;
	vis[v] = 1;
	for (int to : G[v]) {
		if (!dfs(to)) return 0;
	}
	vis[v] = 2;
	return 1;
}
int main() {
	int N, M;
	cin >> N >> M;
	string s;
	cin >> s;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		if (s[a] == s[b]) {
			G[a * 2].push_back(b * 2 + 1);
			G[b * 2].push_back(a * 2 + 1);
		}
		else {
			G[a * 2 + 1].push_back(b * 2);
			G[b * 2 + 1].push_back(a * 2);
		}
	}
	bool ok = 0;
	for (int i = 0; i < N; i++) {
		if (vis[i]) continue;
		if (!dfs(i)) {
			ok = 1;
			break;
		}
	}
	if (ok) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 24836
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Text.RegularExpressions;
using static MyIO;


public class B
{
	public static void Main()
	{
		int N = GetInt();
		int[] p = new int[N + 1];
		for(int i = 1; i <= N; i++)
			p[i] = GetInt();

		int[] r = new int[N + 1];
		for(int i = 1; i <= N; i++)
			r[p[i]] = i;

		int C = 30000;
		int[] a = new int[N];
		int[] b = new int[N];
		for(int i = 1; i <= N; i++)
		{
			a[i - 1] = C * i;
			b[i - 1] = C * (N - i) + r[i];
		}

		Console.WriteLine(string.Join(" ", a));
		Console.WriteLine(string.Join(" ", b));
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 19680
#include <bits/stdc++.h>
using namespace std;int main() {
	int n;
	cin >> n;
	long long int ans=0;
	for(int i=1;i<=n;i++){
	if(i%3!=0 && i%5!=0)ans=ans+i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
use whiteread::parse_line;

fn main() {
    let (a, b, c): (i32, i32, i32) = parse_line().unwrap();
    
    if a == b {
        println!("{}", c)
    } else if b == c {
        println!("{}", a)
    } else {
        println!("{}", b)
    }
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
const ll MOD=1000000007,MOD2=998244353;

//nのp乗
ll power(ll n,ll p){
    if(p==0){return 1;}
    if(p%2==1){return n*power(n,(p-1)/2)*power(n,(p-1)/2);}
    else{return power(n,p/2)*power(n,p/2);}
}

int main() {
    int K,N;
    cin>>K>>N;
    vector<int> A(N);
    rep(i,N){
        cin>>A.at(i);
    }
    vector<int> B(N);
    rep(i,N-1){
        B.at(i)=A.at(i+1)-A.at(i);
    }
    B.at(N-1)=K-A.at(N-1)+A.at(0);
    int ans=B.at(0);
    rep(i,N){
        ans=max(ans,B.at(i));
    }
    cout<<K-ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
void solve()
{
    ll x, y;
    cin>>x>>y;
    for(ll i=0; i<=x; i++)
    {
        ll ans=(i*2)+(x-i)*4;
        if(ans==y)
        {
            cout<<"Yes";
            return;
        }
    }
    cout<<"No";
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

Measured memory_bytes: 3628
import java.util.*;

class Main {
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();
      	String t = sc.next();
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	String u = sc.next();
      	if (u.equals(s)) a--; else b--;
      	System.out.println(a + " " + b);
    }
}

Measured memory_bytes: 22868
#include <stdio.h>
#include <string.h>
 
int main(void){
  int n,d;
  int a,b,c;
  int p = 0;
  scanf("%d %d",&n,&d);
  a = d*2;
  a=a+1;
  p=n/a;
  b=n%a;
  if(b>0){
  p++;
  }
    
  printf("%d",p);
  return 0;
}

Measured memory_bytes: 128
N, M = map(int, input().split())

AB = []
for i in range(M):
    ab = list(map(int, input().split()))
    AB.append(ab)
    
import itertools

per = list(itertools.permutations(list(range(2, N+1))))

count = 0
for i in range(len(per)):
    #print(per[i])
    path = [1] + list(per[i])
    #print(path)
    
    for j in range(len(path)-1):
        p1 = [path[j], path[j+1]]
        p2 = [path[j+1], path[j]]
        if (p1 not in AB) and (p2 not in AB):
            break
    else:
        count += 1
        
print(count)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n;
  cin >> n;
  vi l(100);
  l[0] = 2;
  l[1] = 1;
  for (ll i = 2; i <= n;i++){
    l[i] = l[i - 1] + l[i - 2];
  }
  print(l[n]);
}


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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n, l;
    cin >> n >> l;
    int sum = 0, abs_min = 100000000;

    // 処理
    rep(i, n) {
        sum += l + i;
        abs_min = min(abs_min, abs(l + i));
    }

    // 出力
    if (sum < 0)
        cout << sum + abs_min << endl;
    else
        cout << sum - abs_min << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int x; int a; int b;
    cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b))
        cout << "A" << endl;
    else
        cout << "B" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int H,W;

vector<string> s;

int main(){
    cin >> H >> W;
    s.resize(H);
    rep(i,0,H - 1){
        cin >> s[i];
    }
    rep(i,0,H - 1){
        rep(j,0,W - 1){
            if(s[i][j] == '#') cout << "#";
            else{
                int cou = 0;
                rep(x,max(0,i - 1),min(H - 1,i + 1)) rep(y,max(0,j - 1),min(W - 1,j + 1)){
                    cou += s[x][y] == '#';
                }
                cout << cou;
            }
        }

        cout << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		Scanner scan = new Scanner(System.in);

		while(scan.hasNext())
		{
			int ans=0;
			int n = scan.nextInt();
			for(int a=0; a<=9; a++)
				for(int b=0; b<=9; b++)
					for(int c=0; c<=9; c++)
						for(int d=0; d<=9; d++)
						{
							if(n==a+b+c+d)
								ans++;
						}
			System.out.println(ans);
			ans=0;
		}
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

ll solve(ll a[],ll N,bool plus){
  ll s = 0;
  ll r = 0;
  for(int i=0;i<N;i++){
    s += a[i];
    if( plus && s<=0 ){
      r += abs(s)+1;
      s = 1;
    }else if( (!plus) && s>=0 ){
      r += abs(s)+1;
      s = -1;
    }
    plus = !plus;
  }
  return r;
}

int main(){
  ll N; cin>>N;
  ll a[N]; CINA(a,N);
  ll r1 = solve(a,N,0);
  ll r2 = solve(a,N,1);
  ll r = min(r1,r2);
  cout << r;

}

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

int main(){
    int h, w;
    cin >> h >> w;
    char S[60][60];
    int R[60][60];
    int black_cnt = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> S[i][j];
            if(S[i][j] == '#') black_cnt += 1;
            R[i][j] = 1e9;
        }
    }
    R[0][0] = 0;
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};
    queue<pair<int, int>> q;
    q.push(make_pair(0, 0));
    while(q.size()){
        pair<int, int> tmp = q.front();
        q.pop();
        for(int i = 0; i < 4; i++){
            int nx = tmp.first + dx[i];
            int ny = tmp.second + dy[i];
            if(nx < 0 or ny < 0 or nx >= h or ny >= w or S[nx][ny] == '#'){
                continue;
            }
            if(R[tmp.first][tmp.second] + 1 < R[nx][ny]){
                R[nx][ny] = R[tmp.first][tmp.second] + 1;
                q.push(make_pair(nx, ny));
            }
        }
    }
    if(R[h - 1][w - 1] != 1e9){
        cout << h * w - (R[h - 1][w - 1] + 1) - black_cnt << endl;
    }
    else cout << -1 << endl;

    return 0;
}

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, acos, atan, asin
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 fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

s = STR()
l = len(s)
ans = [1 for _ in range(l)]
tmpl = 0
tmpr = 0
for i in range(l - 1):
    if i > 0 and s[i] == 'R' and s[i - 1] == 'R':
        ans[i] += ans[i - 1]
        ans[i - 1] = 0
for i in reversed(range(l)):
    if i < l - 1 and s[i] == 'L' and s[i + 1] == 'L':
        ans[i] += ans[i + 1]
        ans[i + 1] = 0
for i in range(l - 1):
    if s[i] == 'R' and s[i + 1] == 'L':
        tmp0 = ans[i]
        tmp1 = ans[i + 1]
        ans[i] = (tmp0 + 1) // 2 + tmp1 // 2
        ans[i + 1] = (tmp1 + 1) // 2 + tmp0 // 2
for i in range(l):
    print(ans[i], end=' ')
print('')

Measured memory_bytes: 73372
#include<stdio.h>

int main(){
	int a, b, c, d, e;
	int num[5];
	int i, j,tmp;

	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);

	num[0] = a;
	num[1] = b;
	num[2] = c;
	num[3] = d;
	num[4] = e;
	
	for (i = 0; i < 5; i++){
		for (j = 4; j> 0; j--){
			if (num[j - 1] < num[j]){
				tmp = num[j];
				num[j] = num[j - 1];
				num[j- 1] = tmp;
			}
		}
	}

	a=num[0];
	b=num[1];
	c=num[2];
	d=num[3];
	e=num[4];
	

	printf("%d %d %d %d %d\n",a, b, c, d, e);

	return 0;
}

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

int main(){
  int A,B;
  cin >> A >> B;

  int ans=0;

  for(int i=0; i<2; ++i){
    if(A>=B){
      ans = ans + A;
      A = A-1;
    } else {
      ans = ans + B;
      B = B-1;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 1000000007
using namespace std;
int main()
{
	int n,i,j,k;
	cin>>n;
	long long a[n+1][n+1];
	for(i=1;i<=n;i++)for(j=1;j<=n;j++)cin>>a[i][j];
	long long ans=0;
	
	for(k=1;k<=n;k++)
	{
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
			{
				if(a[k][i]>a[k][j]+a[j][i])
				{
					cout<<"-1";
					return 0;
				}
			}
		}
	}
	
	for(i=1;i<=n;i++)
	{
		for(j=i+1;j<=n;j++)
		{
			ans+=a[i][j];
			for(k=1;k<=n;k++)
			{
				if(k!=i and k!=j and a[i][k]+a[k][j]==a[i][j])
				{
					ans-=a[i][j];
					break;
				
				}
			}	
		}
	}
	
	cout<<ans;
}

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

int main (void){
  string s;
  long long int a = 0,ans = 1;

  cin >> s;
  a = s.size();
  reverse(s.begin(),s.end());
  vector<long long int> q(a,0);

  q[0] = fmod((s[0] - '0'),2019);

  for(int i = 1;i < a;i++){
    ans = (ans * 10) % 2019;
    q[i] = fmod((s[i] - '0') * ans,2019);
    q[i] += q[i-1];
    q[i] = q[i] % 2019;
  }

  vector<int> l(2020,0);
  ans = 0;

  for(int i = 0;i < a;i++){
    l[q[i]]++;
  }
  l[0]++;

  for(int i = 0;i < 2019;i++){
    ans = ans + l[i] * (l[i] - 1) / 2;
  }



  cout << ans << endl;
  return 0;

}

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

using namespace std;

int main(){
        int n;
        cin>>n;
        int all=1,odd=1;
        for(int i=1;i<=n;i++) {
                int val;
                cin>>val;
                all*=3;
                odd*=(val&1)?1:2;
        }
        cout<<all-odd;
}


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

int main () {
		string ans,o,e;
		cin >> o >> e;
		int n,j=0;
		n = o.size() + e.size();

		for(int i=0;i<n;i++){
			j = i/2;
			if(i%2==0)ans.push_back(o[j]);
			if(i%2==1)ans.push_back(e[j]); 
		}
		cout << ans;

	
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define int long long
#define endl "\n"
#define all(x) x.begin(), x.end()
#define deb(x) cout << #x << " --> " << (x) << endl
#define pb push_back
#define mod 1000000007  // 1e9 + 7
#define prec(x, y) fixed << setprecision(y) << x
#define print(v)                       \
    for (auto x : v) cout << x << " "; \
    cout << endl

void solve() {
    int i, j, n, k = 1000;
    cin >> n;
    if (n % k == 0) {
        cout << 0 << endl;
        return;
    }
    cout << k - n % k << endl;
}

//Fuck Ratings
//Once a Charas always a Charas

int32_t main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int _t = 1;
    // cin >> _t;
    while (_t--)
        solve();
}

Measured memory_bytes: 3576
#include<stdio.h>
int main(void)
{
	int k,i=0,j;
	char s[101];
	scanf("%d%s",&k,s);
	while(1){
		if(s[i]=='\0'){
			break;
		}
		i++;
	}
	if(i<=k){
		printf("%s\n",s);
	}
	else{
		for(j=0;j<k;j++){
			printf("%c",s[j]);
		}
		printf("...\n");
	}
	return 0;
}

Measured memory_bytes: 1656