akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N = 0, A = 0, ans = 0;
  cin >> N;
  vector<int> v;
  bool flag = true;
  
  for(int i = 0; i < N; i++){
    cin >> A;
    v.push_back(A);
  }
  
  while(flag){
    for(int i = 0; i < N; i++){
      if((v[i] % 2) != 0){
        flag = false;
        break;
      }
      else{
        v[i] = v[i] / 2;
      }
      if(i == N-1) ans++;
    }
  }
  cout << ans << endl;
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int n, ans = 0;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    rep(i, n) {
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;



ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}

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



int main() {
	int i, j, k;
	//ll N, M, K;
	int N, M, K;
	ll a, b, c;
	cin >> a >> b >> c;
	ll d = c - a - b;
	if (d <= 0) {
		cout << "No";
		return 0;
	}
	if (d* d > 4 * a * b) {
		cout << "Yes";
	}
	else cout << "No";
	return 0;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<double, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

void add_mod(ll &a, ll b){
	a += b;
	a %= MOD;
}

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

int main(void){
	int i,n;
	ll ans=0ll,a;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a;
		ans += a;
	}
	cout << (ans-n) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int n,ans = 0;
    cin>>n;
    int arr [ n -1 ];
    for(int i = 0;i<n-1;i++)
    {
        cin>>arr[i];
    }
    ans = arr[0] + arr[n-2];
    for(int i = 1;i<n-1;i++)
    {
        ans = ans + min(arr[i],arr[i-1]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(100000)

class UnionFind:
    def __init__(self, num):
        self.p = [x for x in range(num)]
    def root(self, x):
        if self.p[x] == x:
            return x
        else:
            self.p[x] = self.root(self.p[x])
            return self.p[x]
    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx != ry:
            self.p[ry] = rx

def main():
    N, M = (int(x) for x in input().split())
    u = UnionFind(N)

    for i in range(M):
        x,y,_ = map(int, input().split())
        u.unite(x-1, y-1)

    rlist = set()
    for i in range(N):
        rlist.add(u.root(i))

    print(len(rlist))

if __name__ == '__main__':
    main()


Measured memory_bytes: 16016
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

constexpr ll mod=1e9+7;
ll inv_mod(ll a){
    ll n=mod-2;
    ll ans = 1,x=a;
    while(n != 0){
        if(n&1) ans = ans*x%mod;
        x = x*x%mod;
        n = n >> 1;
    }
    return ans;
  }
class Factorial{
 private:
    vector<ll> fac;
    vector<ll> ifac;
 public:
    
    Factorial(ll N){
        fac.reserve(N+1);
        fac.push_back(1);
        REP(i,N) fac.push_back(fac[i]*(i+1)%mod);
        ifac.resize(N+1);
        ifac[N]=inv_mod(fac[N]);
        REP(i,N) ifac[N-1-i]=(ifac[N-i]*(N-i))%mod;
    }

    ll fact(ll a){return fac[a];}
    ll ifact(ll a){return ifac[a];}

    ll cmb(ll a,ll b){
        if(a==0&&b==0) return 1;
        if(a<b||a<0||b<0) return 0;
        ll tmp =ifact(a-b)*ifact(b)%mod;
        return tmp*fac[a]%mod;
    }
    ll per(ll a,ll b){
        if(a==0&&b==0) return 1;
        if(a<b||a<0||b<0) return 0;
        return fac[a]*ifac[a-b]%mod;
    }
};
int main(){
    int N,M;cin>>N>>M;
    Factorial get(N+100000);
    ll ans=1;
    rep(num,2,sqrt(M)+1){
        int cnt=0;
        while(M%num==0){
            M/=num;
            cnt++;
        }
        (ans*=get.cmb(N+cnt-1,cnt))%=mod;
    }
    if(M>1) (ans*=N)%=mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <functional>
using namespace std;

int main()
{
  int N;
  bool first = true;
  while (cin >> N) {
    if (!first)
      cout << endl;

    int point[4][13], rate[10];
    for (int i = 0; i < 4; ++i) {
      for (int j = 0; j < 13; ++j)
	cin >> point[i][j];
    }
    rate[0] = 0;
    for (int i = 0; i < 9; ++i)
      cin >> rate[i+1];

    vector<pair<int, int> > card(5);
    for (int loop = 0; loop < N; ++loop) {
      set<char> suit;
      map<int, int> cnt;

      for (int i = 0; i < 5; ++i) {
	string s;
	cin >> s;
	if (s[0] == 'A')
	  card[i].first = 1;
	else if (s[0] == 'T')
	  card[i].first = 10;
	else if (s[0] == 'J')
	  card[i].first = 11;
	else if (s[0] == 'Q')
	  card[i].first = 12;
	else if (s[0] == 'K')
	  card[i].first = 13;
	else
	  card[i].first = s[0] - '0';
 
	if (s[1] == 'S')
	  card[i].second = 0;
	else if (s[1] == 'C')
	  card[i].second = 1;
	else if (s[1] == 'H')
	  card[i].second = 2;
	else
	  card[i].second = 3;

	suit.insert(s[1]);
	++cnt[card[i].first];
      }
      sort(card.begin(), card.end());

      vector<int> same;
      for (map<int, int>::iterator it = cnt.begin(); it != cnt.end(); ++it)
	same.push_back(it->second);
      sort(same.begin(), same.end(), greater<int>());

      bool straight = true;
      for (int i = 1; i < 5; ++i) {
	if (card[i-1].first+1 != card[i].first)
	  straight = false;
      }
      bool straight_A = false;
      if (card[0].first == 1 && card[1].first == 10 && card[2].first == 11 && card[3].first == 12 && card[4].first == 13)
	straight_A = true;

      int rank = 0;
      if (suit.size() == 1 && straight_A)
	rank = 9;
      else if (suit.size() == 1 && straight)
	rank = 8;
      else if (same[0] == 4)
	rank = 7;
      else if (same[0] == 3 && same[1] == 2)
	rank = 6;
      else if (suit.size() == 1)
	rank = 5;
      else if (straight || straight_A)
	rank = 4;
      else if (same[0] == 3)
	rank = 3;
      else if (same[0] == 2 && same[1] == 2)
	rank = 2;
      else if (same[0] == 2)
	rank = 1;

      int ans = 0;
      for (int i = 0; i < 5; ++i)
	ans += point[card[i].second][card[i].first-1];
      ans *= rate[rank];
      cout << ans << endl;
    }
    first = false;
  }
  return 0;
}

Measured memory_bytes: 936
#include<cstdio>
int a[203040],x[203045];
int main()
{
	int n;long long ans=0;
	scanf("%d",&n);x[n+1]=1;
	for (int i=1;i<=n;++i) scanf("%d",&a[i]);
	for (int i=1;i<=n;++i)
		if (a[i]>i-1)
		{
			printf("-1");
			return 0;
		}
	for (int i=n;i>=1;--i)
	{
		x[i]=x[i+1]-1;
		if (x[i]>a[i])
		{
			printf("-1");
			return 0;
		}
		if (x[i]!=a[i]) ans+=a[i];
		x[i]=a[i];
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1664
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a1 = sc.nextInt();
        int a2 = sc.nextInt();
        int a3 = sc.nextInt();

        if (a1 + a2 + a3 <= 21) {
            System.out.println("win");
        } else {
            System.out.println("bust");
        }
    }
}


Measured memory_bytes: 23380
#!/usr/bin/env python3

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    L = input().split()
    ans = 0
    for i, l in enumerate(L):
        if l == '0':
            ans = i + 1
    
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9112
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
using namespace std;
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define app push_back
#define elif else if
#define int long long
#define free ferer465346
#define rt return
int a[100][100];
int dp[100][100];
void solve() {
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j) {
			char x;
			cin >> x;
			if (x == '#')
				a[i][j] = 1;
			else
				a[i][j] = 0;
			dp[i][j] = 1000000;
		}
	dp[0][0] = a[0][0];
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j) {
			if (i) 
				dp[i][j] = min(dp[i][j], dp[i - 1][j] + (!a[i - 1][j] && a[i][j]));
			if (j)
				dp[i][j] = min(dp[i][j], dp[i][j - 1] + (!a[i][j - 1] && a[i][j]));
		}
	cout << dp[h - 1][w - 1];
	return;
}
signed main() {
	ios::sync_with_stdio(false);

	solve();
	
	return 0;
} 

Measured memory_bytes: 1016
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int X, N;
  cin >> X >> N;
  bitset<102> ns(false);
  F0R(i, N) {
    int p;
    cin >> p;
    ns.set(p);
  }
  vector<int> ps;
  F0R(i, 102) {
    if (!ns.test(i)) ps.push_back(i);
  }
  //sort(rng(ps));

  int n = lower_bound(rng(ps), X) - ps.begin();
  if (n == ps.size() || n == 0) {
    cout << X;
    return 0;
  }

  int r = ps[n];
  int l = ps[n - 1];

  cout << (abs(r - X) < abs(l - X) ? r : l);
}
#endif


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

int n, k, a = 1;
int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        if (a * 2 <= a + k)
        {
            a *= 2;
        }
        else
        {
            a += k;
        }
        
    }
    cout << a << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		int n = readNum();
		String[] sa = readFlds();
		for (String s : sa) {
			if ("Y".equals(s)) {
				pln("Four");
				return;
			}
		}
		pln("Three");
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
typedef long long ll;
typedef pair<ll, int> P;
struct edge{int to; ll cost;};
const ll INF = 1e17;
const int MAX_V = 1e5+1;

vector<edge> G[MAX_V];
ll d[MAX_V];
int V;

void dijkstra(int s){
  priority_queue<P, vector<P>, greater<P>> que;
  rep(i, V) d[i] = INF;
  d[s] = 0;
  que.push(P(0, s));
  while(!que.empty()){
    P p = que.top();
    que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    rep(i, G[v].size()){
      edge e = G[v][i];
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}

int main(){
  cin >> V;
  rep(i, V-1){
    int a, b; ll c;
    cin >> a >> b >> c;
    a--, b--;
    G[a].push_back({b, c});
    G[b].push_back({a, c});
  }
  dijkstra(0);
  rep(i, V){
    if(d[i] % 2) cout << "1" << endl;
    else cout << "0" << endl;
  }
  return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

void solve(long long N, long long M){
    if(N % 2 == 0) {
        REP(i, M / 2 + M % 2) {
            cout << (i+1) << " " << (N-i) << endl;
        }

        REP2(i, M / 2 + M % 2, M) {
            cout << (i+1) << " " << (N-i-1) << endl;
        }
    } else {
        REP(i, M) {
            cout << (i+1) << " " << (N-i-1) << endl;
        }
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}



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

using namespace std;
typedef long long int ll;

int main() {
  vector<vector<ll> > c(3, vector<ll>(3));
  for (ll j=0; j < 3; ++j) {
    for (ll k=0; k < 3; ++k) {
      cin >> c[j][k];
    }
  }
  for (ll j=0; j < 3; ++j) {
    ll m = c[j][0];
    for (ll k=1; k < 3; ++k) {
      m = min(m, c[j][k]);
    }
    for (ll k=0; k < 3; ++k) {
      c[j][k] -= m;
    }
  }
  for (ll j=0; j < 3; ++j) {
    ll m = c[0][j];
    for (ll k=1; k < 3; ++k) {
      m = min(m, c[k][j]);
    }
    for (ll k=0; k < 3; ++k) {
      c[k][j] -= m;
    }
  }
  bool f = true;
  for (ll j=0; j < 3; ++j) {
    for (ll k=0; k < 3; ++k) {
      if (c[j][k] != 0) {
        f = false;
        break;
      }
    }
  }
  cout << (f?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k;
  vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin >> k;
  cout << a.at(k-1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll func(ll n){
    if(n==0) return 0;
    else if(n%2!=0){
        if(((n+1)/2)%2!=0) return 1;
        else return 0;
    }
    else return func(n-1)^n;
}
int main(){
    ll a,b;
    cin>>a>>b;
    cout<<(func(b)^func(a-1))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;



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

int a = 0;
int b = 0;
int c = 0;


void input(void) {
	
	return ;
}


int main(void) {
	while (CI a >> b >> c) {
		if ((a >= 1989 && b >= 1 && c >= 8) || (a >= 1989 && b >= 2) || (a >= 1990)) {
			a -= 1988;
			CO "heisei "  << a << " " << b << " " << c E
		}
		else {
			if ((a >= 1926 && b >= 12 && c >= 25) || (a >= 1927)) {
				a -= 1925;
				CO "showa " << a << " " << b << " " << c E
			}
			else {
				if ((a >= 1912 && b >= 7 && c >= 30) || (a >= 1912 && b >= 8) || (a >= 1913)) {
					a -= 1911;
					CO "taisho " << a << " " << b << " " << c E
				}
				else {
					if ((a >= 1868 && b >= 9 && c >= 8) || (a >= 1868 && b >= 10) || (a >= 1869)) {
						a -= 1867;
						CO "meiji " << a << " " << b << " " << c E
					}
					else {
						CO "pre-meiji" E
					}
				}
			}
		}
	
	}
	


	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
using namespace std;
int main(){
	char a[3];
	cin>>a;
	if(a[0]=='M')cout<<6;
	if(a[0]=='F')cout<<2;
	if(a[0]=='W')cout<<4;
	if(a[0]=='T'){
		if(a[1]=='H')cout<<3;
		if(a[1]=='U') cout<<5;
	}
	if(a[0]=='S'){
		if(a[1]=='A')cout<<1;
		else cout<<7;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int D = sc.nextInt();
        int x = sc.nextInt();
        sc.close();

        for (int i = 0; i < 10; i++) {
            x = r * x - D;
            System.out.println(x);
        }
    }
}


Measured memory_bytes: 21332
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long int i=0;i<(n);++i)
typedef long long int ll;

class BIronBarCutting {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll n;
        in >> n;
        vector<ll> a(n);
        ll su=0L;
        rep(i,n){
            in >> a[i];
            su+=a[i];
        }
        int id=0;
        ll d=su;
        vector<ll> b=a;
        rep(i,n-1){
            b[i+1]+=b[i];
        }
        rep(i,n-1){
            d=min(d,abs(b[i]-(su-b[i])));
        }
        out <<d <<endl;
	}
};


int main() {
	BIronBarCutting solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define MAX 100000
#define INFTY (1 << 30)

class Edge {
	public:
	    int t, w;
	    Edge() {}
	    Edge(int t, int w) : t(t), w(w) {}
};

vector<Edge> G[MAX];
int n, d[MAX];
bool vis[MAX];
int cnt;

void bfs(int s) {
	for(int i = 0; i < n; i++) d[i] = INFTY;
	queue<int> Q;
	Q.push(s);
	d[s] = 0;
	int u;
	while(!Q.empty()) {
		u = Q.front();
		Q.pop();
		for(int i = 0; i < G[u].size(); i++) {
			Edge e = G[u][i];
			if(d[e.t] == INFTY) {
				d[e.t] = d[u] + e.w;
				Q.push(e.t);
			}
		}
	}
}

 
void solve() {
	bfs(0);
	int maxv = 0, tgt = 0;
	for(int i = 0; i < n; i++) {
		if(d[i] == INFTY) continue;
		if(maxv < d[i]) {
			maxv = d[i];
			tgt = i;
		}  
	}
	
	bfs(tgt);
	maxv = 0;
	for(int i = 0; i < n; i++) {
		if(d[i] == INFTY) continue;
		if(maxv < d[i]) {
			maxv = d[i];
		}
	}
	
	cout << maxv << endl;
}

main() {
	int s, t, w;
	cin >> n;
	
	for(int i = 0; i < n - 1; i++) {
		cin >> s >> t >> w;
		
		G[s].push_back(Edge(t, w));
		G[t].push_back(Edge(s, w)); 
	}
	
	solve();
}

Measured memory_bytes: 9900
S = input()
T = input()
TS = list(zip(T, S))

TS_set = set()
for t,s in TS:
  TS_set.add((t,s))

S_set = set()
for x in TS_set:
  S_set.add(x[1])

T_set = set()
for x in TS_set:
  T_set.add(x[0])

print("Yes" if S == T or len(TS_set) == len(S_set) == len(T_set) else "No")


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

int main(){
    int n,s=0;
    scanf("%d",&n);
    vector<int> v(n);
    for(int i=0;i<n;i++){
            scanf("%d",&v[i]);
            s+=v[i];
    }
    sort(v.begin(), v.end());
    if(v[n-1]<s-v[n-1]) printf("Yes\n" );
    else printf("No\n" );
    return 0;
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

constexpr ll INF = 1e16;

#define rep(i, N) for(ll i=0; i<N; ++i)

ll max(ll a, ll b) {return a < b ? b : a; }
ll min(ll a, ll b) {return a > b ? b : a; }
double maxf(double a, double b) { return a < b ? b : a; }

int main() {
  string s;
  cin>>s;

  if(s == "SUN") cout<<"7"<<endl;
  if(s == "MON") cout<<"6"<<endl;
  if(s == "TUE") cout<<"5"<<endl;
  if(s == "WED") cout<<"4"<<endl;
  if(s == "THU") cout<<"3"<<endl;
  if(s == "FRI") cout<<"2"<<endl;
  if(s == "SAT") cout<<"1"<<endl;

  return 0;
}

Measured memory_bytes: 256
from math import gcd

A, B = map(int, input().split())

d = gcd(A, B)
ans = 1
i = 2
while i <= pow(d, 1/2)+1:
  if d%i == 0:
    ans += 1
    while d%i == 0:
      d //= i
  i += 1
ans += (d > 1)
print(ans)

Measured memory_bytes: 9360
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = a; i <= min(b, a+k-1); i++) cout << i << endl;
    for (int i = max(b-k+1, a+k); i <= b; i++) cout << i << endl;
}

Measured memory_bytes: 3636
import numpy as np

n=int(input())
A=np.array(list(map(int,input().split())))
minus = np.count_nonzero(A < 0)
A = np.abs(A)

if 0 in A or minus % 2 == 0:
  print(np.sum(A))
else:
  print(np.sum(A) - 2 * np.min(A))

Measured memory_bytes: 38144
#include <stdio.h>

int main()
{
    int i;
    long long int n, sum=0, mod, temp;
    scanf("%lld", &n);
    temp = n;
    for( ; temp!=0; ){
        sum += (temp%10);
        temp/=10;
    }
    if((n%sum) == 0)
        printf("Yes\n");
    else
        printf("No\n");
                    //printf("%lld", sum);

    return 0;
}

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

#define pb                push_back
#define mp                make_pair
#define all(x)            (x).begin(),(x).end()
#define fi                first
#define se                second
#define vc                vector
#define pii               pair<ll,ll>
#define endl              "\n"
#define rep(i,a,b)        for(ll i=a;i<b;i++)
#define repe(i,a,b)       for(ll i=a;i<=b;i++)
#define bac(i,a,b)        for(ll i=a;i>b;i--)
#define bace(i,a,b)       for(ll i=a;i>=b;i--)
#define fast              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ll                long long int
#define ld                long double
#define mod1              (ll)(1e9 + (ll)7)
#define mod2              (ll)998244353
#define pi                (float)3.14159265358979323846
#define inf               LLONG_MAX
#define ninf              LLONG_MIN

#define DECIMAL(n)        std::cout << std::fixed << std::setprecision(n)
#define SORT(v)           sort(all(v))
#define RSORT(v)          sort(all(v),greater<ll>())
#define REVERSE(v)        reverse(all(v))

#define pow(i,n)          (ll)pow((ll)i,n)
#define pow2(n)           ((ll)1<<n)
#define sz(x)             (ll)x.size()

typedef std::priority_queue<ll, std::vector<ll>, std::greater<ll> > min_pq;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

inline string inttos(ll a){std::stringstream soso; soso<<a; return soso.str();}
inline ll stoint(const std::string &s) {std::stringstream soso; soso << s; long long x; soso >> x; return x;}
inline std::string inttobin(ll x) {return std::bitset<7>(x).to_string();}
inline void swp(ll &a, ll &b){auto temp=a;a=b;b=temp;}

//pri - 1000000009
//ba  - 937,991,1013,1409,1741,4391

void solve(){
    ll a,b,n;
    cin>>a>>b>>n;
    ll x = min(n,b-1);
    cout<<(a*x)/b<<endl;

}


signed main(){
    fast
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        //freopen("output.txt","w",stdout);
    #endif
    ll t=1;
    //cin>>t;
    rep(i,0,t){
       solve();
    }

}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using ll = int_fast64_t;
#define REP(i,b,e) for(ll i=b; i<e; i++)

struct fenwick {
	std::vector<ll> data;
	fenwick(int n): data(n+1, 0) {}

	void add(int idx, ll x){
		idx++;
		while(idx<data.size()){
			data[idx] += x;
			idx += idx & -idx;
		}
	}

	ll _sum(int idx){
		ll ret = 0;
		while(idx>0){
			ret += data[idx];
			idx -= idx & -idx;
		}
		return ret;
	}

	ll sum(int l, int r){
		l++, r++;
		return _sum(r-1) - _sum(l-1);
	}
};


int main(){
	int n, q;
	scanf("%d %d", &n, &q);
	fenwick bit(n);
	REP(i, 0, n){
		ll a;
		scanf("%ld", &a);
		bit.add(i, a);
	}

	REP(i, 0, q){
		ll t, x, y;
		scanf("%ld %ld %ld", &t, &x, &y);
		if(t==0) bit.add(x, y);
		else printf("%ld\n", bit.sum(x, y));
	}
	return 0;
}



Measured memory_bytes: 8228
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define MAX (1 << 29)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s)
    ret += to_string(x);
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int N;
  cin >> N;
  vector<int> ans(N);
  FOR(i, N) {
    int A;
    cin >> A;
    ans[A - 1] = i + 1;
  }
  FOR(i, N) cout << ans[i] << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 1152
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

x = I()
while not is_prime(x):
    x += 1

print(x)

Measured memory_bytes: 38512
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int n=0;
	int len=s.size();
	for(int i=0;i<len;i++)
	{
		if(s[i]=='A'&s[i+1]=='C')
		{
			n++;
			cout<<"Yes"<<endl;
			break;
		} 
	}
	if(n==0)
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
char str[200];
int main() {
	scanf("%s",&str);
	int n=strlen(str);
	for (int i=n;i>=1;--i) str[i]=str[i-1]; 
	int l=1,r=n;
	while (l<r) {
		if (str[l]!=str[r]) {
			printf("No");
			return 0;
		}
		++l;--r;
	}
	l=1,r=(n-1)/2;
	while (l<r) {
		if (str[l]!=str[r]) {
			printf("No");
			return 0;
		}
		++l;--r;
	}
	l=(n+3)/2,r=n;
	while (l<r) {
		if (str[l]!=str[r]) {
			printf("No");
			return 0;
		}
		++l;--r;
	}	
	printf("Yes");
	return 0;
} 

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  ll h = in();

  method(func,ll,ll h){
    if(h==1){
      return 1;
    }
    return 2 * func(h/2) + 1;
  };

  cout << func(h) << endl;
  return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  bool easy = true;
  for (int i = 0; i < S.size(); i++) {
    if (i % 2 == 0) {
      if (S.at(i) == 'L') {
        easy = false;
      }
    } else {
      if (S.at(i) == 'R') {
        easy = false;
      }
    }
  }
  
  if (easy) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main(){
  int N;
  cin >> N;
  int sum=0;
  for(int i=0;i<N;i++){
    int l,r;
    cin >> l >> r;
    sum = sum+r-l+1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int A;
int B;
char res[10];
int main(){
  int i;
  rd(A);
  rd(B);
  if(A > B){
    swap(A, B);
  }
  ;
  for(i=(0);i<(B);i++){
    res[i] = '0' + A;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200119-1

// --- original code ---
// int A, B;
// char res[10];
// {
//   rd(A,B);
//   sortE(A,B);
//   rep(i,B) res[i] = '0' + A;
//   wt(res);
// }


Measured memory_bytes: 256
import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(r) * (math.factorial(n - r)))

N, M = map(int, input().split())

ans = 0
if N >= 2:
    ans += comb(N, 2)
if M >= 2:
    ans += comb(M, 2)

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

int main(void)
{
	int n, x, ii, jj, kk;
	char c;
	long cnt[1000];
	int idx;

	memset(cnt, (int)0, sizeof(long) * 1000);

	idx = 0;
	for (;;) {
		scanf("%d %d", &n, &x);
		scanf("%c", &c);
		if (n == 0 && x == 0) {
			break;
		}
		for (ii = 1; ii <= n; ii++) {
			for (jj = ii + 1; jj <= n; jj++) {
				for (kk = jj + 1; kk <= n; kk++) {
					if (ii + jj + kk == x) {
						cnt[idx]++;
					}
				}
			}
		}
		idx++;
	}

	for (ii = 0; ii < idx; ii++) {
		printf("%ld\n", cnt[ii]);
	}
	return 0;
}

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

int table[505][505];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // init
    int N, M, Q; cin >> N >> M >> Q;
    int l, r, p[101010], q[101010];
    for(int i=0; i < M; ++i) {
        cin >> l >> r;
        ++table[l][r];
    }
    for(int i=0; i < Q; ++i) cin >> p[i] >> q[i];

    // sum
    for(int i=0; i <= N; ++i)
        for(int j=0; j <= N; ++j)
            table[i][j+1] += table[i][j];

    // calc
    for(int i = 0; i < Q; ++i) {
        int res = 0;
        for(int j=p[i]; j <= q[i]; ++j) res += table[j][q[i]]; // from left side, sum up the num of trains
        cout << res << '\n';
    }

    return 0;
}

Measured memory_bytes: 2688
using System;
using System.Linq;
 
class Program {
  static void Main() {
    int[] n = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
    Console.WriteLine(n[0] == 5&&n[1] == 5&&n[2] == 7 ? "YES" : "NO");    
  }
}

Measured memory_bytes: 13396
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;

void swap(int a,int b) {
	int tmp = a;
	a = b;
	b = tmp;
}

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

	vector<ll>a(n + 5);
	vector<ll>count(n + 5);
	vector<ll>ans(n + 5);
	ll total = 0;

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

	for (ll i = 1; i <= n; i++) {
		count[i] = 0;
		ans[i] = 0;
	}

	for (ll i = 0; i < n; i++) {
		count[a[i]]++;
	}

	for (ll i = 1; i <= n; i++) {
		total+=count[i]*(count[i]-1)/2;
	}

	for (ll i = 1; i <= n; i++) {
		ans[i]= total- (count[i]-1);
	}

	for (ll i = 0; i < n; i++) {
		cout << ans[a[i]] << endl;
	}

	return 0;
}

Measured memory_bytes: 8004
n = int(input())
A = list(map(int, input().split()))

B = sorted(A)
c = 0

for i in range(n-1):
    t = cnt = 0
    x = A.index(B[i])
    
    while x != i:
        y = A.index(B[x])
        A[x], A[y] = B[x], B[i]
        cnt += 1
        t += B[x] + B[i]
        x = y
    if cnt:
        c += min(t, (B[i]+B[0])*2+t-(B[i]-B[0])*cnt)
print(c)


Measured memory_bytes: 5624
import java.util.Scanner;

public class Main {

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

			String regex = "^[a|e|i|o|u]$";
			if (c.matches(regex)) {
				System.out.println("vowel");
			} else {
				System.out.println("consonant");
			}

		} finally {
			sc.close();
		}
	}
}

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


def solve(N: int, S: str):
    p = 0
    pre = S[0]
    for i in range(1,N):
        if S[i] == pre:
            p += 1
        pre = S[i]
    print(N - p)

    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<string> x(n);
    getline(cin, x.at(0));
    for(int i = 0; i < n; ++i){
        getline(cin, x.at(i));
    }

    set<string> s;
    for(ll i = 0; i < n; ++i){
        if(s.count(x.at(i))){
            cout << "No" << endl;
            return 0;
        }
        s.insert(x.at(i));
        if(i > 0 && x.at(i - 1).back() != x.at(i).front()){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

int main(){
    int A,B,C;
    cin>>A>>B>>C;
    if (A==B) {
        cout<<C<<endl;
    }
    else if (A==C) {
        cout<<B<<endl;
    }
    else if (B==C) {
        cout<<A<<endl;
    }
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int X, Y;
	cin >> X >> Y;

	bool ok = false;
	rep(i, 0, X + 1)
	{
		int a = i, b = X - i;
		if (a * 2 + b * 4 == Y)ok = true;
	}

	if (ok)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

const int MAX = 10000;
long long fac[MAX], finv[MAX], inv[MAX];

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

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

int main()
{
    ll N, K;
    cin >> N >> K;

    // 前処理
    COMinit();

    REP(i, K){
        cout << (COM(N-K+1, i+1) % MOD * COM(K-1, i) % MOD)% MOD << endl;
    }
    return 0;
}

Measured memory_bytes: 512
s=input()
n=len(s)
str=s
str=str[::-1]
if(s!=str):
    print('No')
else:
    temp=(n-1)//2
    st=""
    for i in range(temp):
        st+=s[i]
    str1=st
    str1=str1[::-1]
    if(st!=str1):
        print('No')
    else:
        temp=(n+3)//2
        temp=temp-1
        st1=""
        for i in range(temp,n):
            st1+=s[i]
        str2=st1
        str2=str2[::-1]
        if(st1!=str2):
            print('No')
        else:
            print('Yes')


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

int main() {
	int a,b;
	cin >> a >> b;
	int x = a+b;
	int y = a-b;
	int z = a*b;
	int p = max(x,y);
	cout << max(p,z) << endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(n: usize, m: usize, ob: [[usize; 2]; n],);
    let mut wv: Vec<Vec<i64>> = Vec::new();
    wv.resize(4, Vec::new());
    let weight = ob[0][0];
    for o in ob {
        wv[o[0] - weight].push(o[1] as i64);
    }
    for i in 0..4 {
        wv[i].sort();
        wv[i].reverse();
        if i < 3 {
            wv[i].insert(0, 0);
        }
    }

    let mut ans = 0i64;
    let mut tmp1 = 0i64;
    for i in 0..wv[0].len() {
        tmp1 += wv[0][i];
        let mut tmp2 = tmp1;
        for j in 0..wv[1].len() {
            tmp2 += wv[1][j];
            let mut tmp3 = tmp2;
            for k in 0..wv[2].len() {
                tmp3 += wv[2][k];
                let mut tmp4 = tmp3;
                let mut w2 = weight * (i + j + k) + j + 2 * k;
                for l in 0..wv[3].len() {
                    if w2 + weight + 3 > m {
                        break;
                    }
                    w2 += weight + 3;
                    tmp4 += wv[3][l];
                }
                if w2 <= m {
                    ans = max(ans, tmp4);
                }
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    string s;
    bool f=false;
    cin>>s;
    REP(i,s.size()-1){
        if(s[i]=='A'&&s[i+1]=='C')f=true;
    }
    if(f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto s = readln.chomp;
    auto goal = readln.split.to!(int[]);
    struct Move{
        bool x;
        int d;
    }
    Move[] moves;
    moves ~= Move(true, 0);
    int x = 0, y = 0;
    bool firstFlag = true;
    foreach (c; s) {
        if (c == 'F') {
            if (firstFlag) {
                x++;
            } else {
                moves[$-1].d++;
            }
        } else {
            firstFlag = false;
            moves ~= Move(!moves[$-1].x, 0);
        }
    }
    auto xmoves = moves.filter!(m => m.x).map!(m => m.d).array;
    auto ymoves = moves.filter!(m => !m.x).map!(m => m.d).array;
    bool[Tuple!(size_t,int)] memo;
    bool func(int x, int g, int[] d) {
        if (auto r = tuple(d.length, x) in memo) return *r;
        if (d.empty) return x == g;
        return memo[tuple(d.length, x)] = func(x+d.front, g, d[1..$]) || func(x-d.front, g, d[1..$]);
    }
    auto xok = func(x, goal[0], xmoves);
    memo = null;
    auto yok = func(y, goal[1], ymoves);
    writeln(xok && yok ? "Yes" : "No");
}



Measured memory_bytes: 382204