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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
#define IINF 9999999999999;
using std::cin;
using std::cout;
using std::endl;
using std::ios;
using vint = std::vector<int>;
using ll = long long;
using vll = std::vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = std::min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = std::max(a, b); }

int A, B;


int main() {
    cin >> A >> B;
    if(A + B == 15) cout << "+" << endl;
    else if(A * B == 15) cout << "*" << endl;
    else cout << "x" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int gcd(int,int,int);

int main()
{
int n,i,j,k,a=0;
scanf("%d",&n);

for(i=1;i<=n;i++)
{
    for(j=1;j<=n;j++)
    {
        for(k=1;k<=n;k++)
        {
            a += gcd(i,j,k);
        }
    }
}

printf("%d",a);
return 0;
}

int gcd(int a,int b,int c)
{
    int x,y,z,tmp;
    if(a<b)
    {
        tmp = a;
        a = b;
        b = tmp;
    }
    int gcd=0;
    x = a%b;
    while(x!=0)
    {
        a = b;
        b = x;
        x = a%b;
    }
    gcd = b;
if(c<gcd)
    {
        tmp = c;
        c = gcd;
        gcd = tmp;
    }
    x = c%gcd;
    while(x!=0)
    {
        c = gcd;
        gcd = x;
        x = c%gcd;
    }
return gcd;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long ll;
using namespace std;
int main(void){
    int h,w;cin>>h>>w;
    int t[h][w];
    rep(i,h)rep(j,w){
        int x;cin>>x;
        t[i][j]=(x%2)? 1:0;
    }
    int res=0;
    queue<pair<int,int>> from,to;
    rep(i,h)rep(j,w-1){
        if(t[i][j]%2==1){
            t[i][j+1]++;
            from.push({i,j});
            to.push({i,j+1});
            res++;
        }
    }
    rep(i,h-1){
        if(t[i][w-1]%2==1){
            t[i+1][w-1]++;
            from.push({i,w-1});
            to.push({i+1,w-1});
            res++;
        }
    }
    cout<<res<<endl;
    rep(i,res){
        auto F=from.front(),T=to.front();
        from.pop();to.pop();
        cout<<F.first+1<<" "<<F.second+1<<" "<<T.first+1<<" "<<T.second+1<<endl;
    }
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 3e5 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r; 
}

void solve()
{
		int n = 100, m = 100;
		int x, y;
		cin >> x >> y;
		char a[n][m];
		x--, y--;
		rep(i, n) {
				rep(j, m){
					if(i < n / 2) a[i][j] = '.';
					else a[i][j] = '#';
				}
		}
		swap(x, y);
		rep(i, n){
			rep(j, m){
				if((i + j) % 2 == 0 && i % 2 == 0){
						if(x) x--, a[i][j] = '#';
				}
				if((i + j) % 2 == 0 && i % 2 == 0 && y && i >= n / 2 + 2) a[i][j] = '.', y--;
			}
		}
		cout << "100 100\n";
		rep(i, 100) {rep(j, 100) cout << a[i][j]; cout << "\n"; }
}
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    // Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int w,a,b,aww;
int main () {
cin >> w >> a >> b;
	if (a > b) {
		aww= a - (b+w);
	}
	else {
		aww= b - (a+w);
	}
	if (aww <= 0) {
		cout << 0 << endl;
	}
	else {
		cout << aww << endl;
	}
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc116/tasks/abc116_b
s = int(input())
a = [s]
for n in range(1, 1000000):
    if a[n - 1] % 2 == 0:
        v = a[n - 1] // 2
    else:
        v = a[n - 1] * 3 + 1
    if a.count(v) == 1:
        print(n + 1)
        exit()
    else:
        a.append(v)


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(){
  int n,miss=0,most=0;
  long long int hess;
  cin >> n;
  long long int bell[n];
  for(int i=0;i<n;i++){
    cin >> bell[i];
    if(bell[i]>most){
      most=bell[i];
    }
  }
  for(int i=1;i<most/2;i++){
    for(int j=0;j<n;j++){
      if(bell[j]%i!=0){
	miss++;
      }
    }
    if(miss==0){
      cout << i << endl;
    }
    miss=0;
  }
  return (0);
}

Measured memory_bytes: 1168
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }

int main() {
   int A, B;
   cin >> A >> B;
   int max = 0;
   max = A + B;
   if (max < A + A - 1) max = A + A - 1;
   if (max < B + B - 1) max = B + B - 1;
   
   cout << max << endl;
   
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define db double
#define pb push_back
#define wrln cout<<'\n';
#define pii pair<int,int>
using namespace std;
const int H=1e9+7;
const int N=1e5+100;

ll a,b,c,d,n;

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


    cin>>n; a=1; b=1; c=1;
    if (n<2)
    {
        cout<<0; return 0;
    }
    for (int i=1; i<=n; i++)
    {
        a*=10; a%=H;
        b*=8;  b%=H;
        c*=9;  c%=H;
    }
    c=(2*c-b);
    while (c<0) c+=H;
    a-=c;
    while (a<0) a+=H;
    cout<<a;
}


Measured memory_bytes: 3636
/*
 * 2666.cc: Arojam's Mask
 */

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

/* constant */

const int MAX_N = 100;
const int MAX_R = 100;
const int MAX_E = 4;
const int EBITS = 1 << MAX_E;
const int INF = 1 << 30;

/* typedef */

typedef pair<int,int> pii;
typedef vector<pii> vpii;

struct Stat {
  int d, i, r, bits;
  Stat() {}
  Stat(int _d, int _i, int _r, int _bits): d(_d), i(_i), r(_r), bits(_bits) {}
  void print() {
    printf("Stat: i=%d, r=%d, bits=%d: d=%d\n", i, r, bits, d);
  }
};

/* global variables */

vpii nbrs[MAX_N];
int cs[MAX_N];
int dists[MAX_N][MAX_R + 1][EBITS];

/* subroutines */

/* main */

int main() {
  int n, m, e, s, t, r;
  cin >> n >> m >> e >> s >> t >> r;

  for (int i = 0; i < m; i++) {
    int ai, bi;
    cin >> ai >> bi;
    nbrs[ai].push_back(pii(bi, 0));
    nbrs[bi].push_back(pii(ai, 0));
  }
  for (int i = 0; i < e; i++) {
    int ai, bi, ci;
    cin >> ai >> bi >> ci;
    int bit = 1 << i;
    cs[ci] = bit;
    nbrs[ai].push_back(pii(bi, bit));
    nbrs[bi].push_back(pii(ai, bit));
  }

  int ebits = 1 << e;
  
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= r; j++)
      for (int bits = 0; bits < ebits; bits++) dists[i][j][bits] = INF;
  dists[s][0][cs[s]] = 0;

  queue<Stat> q;
  q.push(Stat(0, s, 0, cs[s]));

  while (! q.empty()) {
    Stat u = q.front(); q.pop();
    //u.print();
    if (u.i == t) break;

    int vd = u.d + 1;
    if (cs[u.i] && dists[s][0][u.bits] > vd) {
      dists[s][0][u.bits] = vd;
      q.push(Stat(vd, s, 0, u.bits));
    }

    if (u.r >= r) continue;

    vpii &nbru = nbrs[u.i];
    for (vpii::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int &vi = vit->first, &eb = vit->second;
      if (eb != 0 && (u.bits & eb) == 0) continue;

      int vr = u.r + 1;
      int vbits = u.bits | cs[vi];

      if (dists[vi][vr][vbits] > vd) {
	dists[vi][vr][vbits] = vd;
	q.push(Stat(vd, vi, vr, vbits));
      }
    }
  }

  int mind = INF;
  for (int j = 0; j <= r; j++)
    for (int bits = 0; bits < ebits; bits++)
      if (mind > dists[t][j][bits]) mind = dists[t][j][bits];

  printf("%d\n", (mind >= INF) ? -1 : mind);
  return 0;
}

Measured memory_bytes: 1844
#include<iostream>

using namespace std;

int main()
{
  int N,M,ans,i,N3,N2,N1,t,judge;
  cin>>N>>M;
  int s[M],c[M];
  
  for(i=0;i<M;i++)
  {
    cin>>s[i]>>c[i];
  }
  for(ans=0;ans<1000;ans++)
  {
    //桁数を出す
    if(N==3)//3桁
    {
      N1=ans/100;
      t=ans/10;
      N2=t%10;
      N3=ans%10;
      if(N1==0)//桁頭が0なら3桁にならん
      {
        judge=-1;
      }
    }
    else if(N==2)//2桁
    {
      N1=ans/10;
      N2=ans%10;
      N3=0;
      if(N1==0)//桁頭0なら2桁にならん
      {
        judge=-1;//引いといたら=Mにはならんだろってこと
      }
    }
    else if(N==1)//1桁
    {
      N1=ans;
      N2=0;
      N3=0;
    }
    //M回判定
    for(i=0;i<M;i++)
    {     
      switch(s[i])
      {
        case 1://1番目のジャッジ
          if(c[i]==N1)
          {
            judge++;        
          }
          break;
        case 2:
          if(c[i]==N2)
          {
            judge++;
          }
          break;
        case 3:
          if(c[i]==N3)
          {
            judge++;
          }
          break;
      }
    }//Mの判定終わり
    if(judge==M)//judgeがMと一致するならば条件をすべて満たしている
    {
      cout<<ans;
      goto end;
    }
    judge=0;//judgeのリセット
  }//ansのLoop終わり
  cout<<"-1";  
  end:
  ;
}


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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll dp[60][6000];
const int base = 3000;
void solve() {
    ll n, a;
    cin >> n >> a;
    vec<ll> x(n);
    REP(i, n) { cin >> x[i]; }

    dp[0][base] = 1;
    REP(i, n) {
        REP(j, 2 * base) {
            if(dp[i][j] == 0)
                continue;
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j + x[i] - a] += dp[i][j];
        }
    }
    cout << dp[n][base] - 1 << en;
}

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

    solve();
    /*
    ll t;
    cin >> t;
    REP(i, t)
    solve();
    */

    return 0;
}


Measured memory_bytes: 4276
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
  
int main() {
    int64_t N, a = 1;
    cin >> N;
    for (int i = 0; i < N; i++) {
        a = a * (i + 1) % 1000000007;
    }
    cout << a << endl;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
    var nums = chunk.split(" ");
    for(var i = 0; i < nums.length; i ++){
        nums[i] = Number(nums[i]);
    }
    var output = "No";
    if (nums[0] < nums[1] && nums[1] < nums[2]){
        output = "Yes";
    }
    console.log(output);
});

Measured memory_bytes: 7644
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}
import java.lang

import scala.reflect.ClassTag

object Main {
  def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {
    converter(in.readLine)
  }

  def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {
    get[String].split("\\s+").map(converter)
  }

  implicit val intConverter: String => Int = s => Integer.parseInt(s)
  implicit val longConverter: String => Long = s => lang.Long.parseLong(s)

  def get[T1, T2](
                   implicit in: BufferedReader,
                   converter1: String => T1,
                   converter2: String => T2
                 ): (T1, T2) = {
    getArray[String] match {
      case Array(v1, v2) => (converter1(v1), converter2(v2))
    }
  }

  def get[T1, T2, T3](
                       implicit in: BufferedReader,
                       converter1: String => T1,
                       converter2: String => T2,
                       converter3: String => T3
                     ): (T1, T2, T3) = {
    getArray[String] match {
      case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))
    }
  }

  implicit class TimesInt(val n: Int) {
    def times(f: Int => Unit): Unit = {
      for (i <- 0 until n) {
        f(i)
      }
    }
  }

  def main(args: Array[String]): Unit = {
    implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val n = get[Int]
    val as = Array.fill(n)(get[Long]).sorted
    val ras = as.reverse

    out.println(
      if (n % 2 == 1) {
        Math.max(
          ras.slice(0, n / 2).sum * 2
            - ras.slice(n / 2, n / 2 + 2).sum
            - ras.slice(n / 2 + 2, ras.length).sum * 2,
          -as.slice(0, n / 2).sum * 2
            + as.slice(n / 2, n / 2 + 2).sum
            + as.slice(n / 2 + 2, as.length).sum * 2
        )
      } else {
        Math.max(
          ras.slice(0, n / 2 - 1).sum * 2
            + ras.slice(n / 2 - 1, n / 2).sum
            - ras.slice(n / 2, n / 2 + 1).sum
            - ras.slice(n / 2 + 1, ras.length).sum * 2
          ,
          -as.slice(0, n / 2 - 1).sum * 2
            - as.slice(n / 2 - 1, n / 2).sum
            + as.slice(n / 2, n / 2 + 1).sum
            + as.slice(n / 2 + 1, as.length).sum * 2
        )
      }
    )
    out.flush()
  }
}

Measured memory_bytes: 45956
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

vector<pair<ll,ll>> edge[55];
vector<pair<ll,ll>> edge2[55*2500];

ll a[110], b[110], c[110], d[110];

ll value(ll v, ll s) {
  return v*2500LL + s;
}

vector<ll> dijkstra(ll s, vector<Pll> *edge) {
  priority_queue<Pll, vector<Pll>, greater<Pll>> pq;
  vll dist(55LL*2500LL, LLONG_MAX);
  dist[s] = 0LL;
  pq.push(make_pair(dist[s],s));
  while(!pq.empty()) {
    auto tmp = pq.top();
    pq.pop();
    ll from = tmp.second;
    ll d = tmp.first;
    if(dist[from]<d) continue;
    for(auto p : edge[from]) {
      ll to = p.first;
      ll d = p.second;
      if(dist[to]>dist[from]+d) {
        dist[to] = dist[from] + d;
        pq.push(make_pair(dist[to],to));
      }
    }
  }
  return dist;
}

int main() {
  ll n, m, s;
  cin >> n >> m >> s;
  rep(i,m) {
    ll u, v;
    cin >> u >> v >> a[i] >> b[i];
    u--; v--;
    edge[u].push_back(make_pair(v,i));
    edge[v].push_back(make_pair(u,i));
  }
  rep(i,n) cin >> c[i] >> d[i];
  rep(i,n) {
    rep(j,2500) {
      ll to = min(j + c[i], 2499LL);
      edge2[value(i,j)].push_back(make_pair(value(i,to),d[i]));
      for(auto p : edge[i]) {
        ll to = p.first;
        ll edge_ind = p.second;
        if(j < a[edge_ind]) continue;
        edge2[value(i,j)].push_back(make_pair(value(to,j-a[edge_ind]),b[edge_ind]));
      }
    }
  }
  s = min(s,2499LL);
  auto dist = dijkstra(value(0LL,s),edge2);
  rep(i,n) {
    if(i==0) continue;
    ll ans = (LLONG_MAX)/2;
    rep(j,2500) ans = min(ans,dist[value(i,j)]);
    cout << ans << endl;
  }
  return 0;
}

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

#define MAX 100

long long N;

int e[MAX + 1];

int num( int m )
{
	int cnt = 0;
	for( int i = 0; i <= N; i++ ) {
		if( e[i] >= m - 1 ) {
			cnt++;
		}
	}
	return cnt;
}

int main() {
	cin >> N;

	for( int i = 2; i <= N; i++ ) {
		int cur = i;
		for( int j = 2; j <= cur; j++ ) {
			while( cur % j == 0 ) {
				e[j]++;
				cur /= j;
			}
		}
	}

	int ans = num( 75 ) + num( 25 ) * ( num( 3 ) - 1 ) + num( 15 ) * ( num( 5 ) - 1 )
				+ num( 5 ) * ( num( 5 ) - 1 ) * ( num( 3 ) - 2 ) / 2;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s[s.size()-1] != 's') {
        s += "s";
    } else {
        s += "es";
    }
    cout << s << endl;
}


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

int main(){
  string s;
  cin>>s;
  int index1=s.size();
  int index2=0;
  for(int i=0,j=s.size()-1;i<s.size()-1,j>=1;){
    if(s[i]=='A'){
        index1=min(i,index1);
    }
    if(s[j]=='Z'){
        index2=max(j,index2);
    }
    i++;
    j--;
  }
  cout<<index2-index1+1<<endl;
}


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

int main() {
  int N,M,C,sum,count;
  sum = 0;
  count = 0;
  cin >>N >>M >>C;
  vector<int> B(M);
  for (int i = 0; i < M; i++) {
    cin >> B.at(i);
  }
  vector<int> A(M);
  vector<int> AB(M);
  for (int j=0; j < N ; j++){
    for (int i=0 ; i < M; i++){
      cin >> A.at(i);
      AB.at(i) = A.at(i) * B.at(i);
    }
    sum = 0;
    for (int k=0; k<M; k++){
      sum = sum + AB.at(k);
    }
    if (sum + C > 0){
      count=count+1;
    }
  }
  cout << count << endl;
      

      
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define endl "\n"
#define fi(st,n) for (int i = (st); i <= (int)(n); ++i)
#define fj(st,n) for (int j = (st); j <= (int)(n); ++j)
#define fk(st,n) for (int k = (st); k <= (int)(n); ++k)
#define fq(st,n) for (int q = (st); q <= (int)(n); ++q)
#define fw(st,n) for (int w = (st); w <= (int)(n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (int)(n); ++(i))
#define ei(st,n) for (int i = (st); i >= (int)(n); --i)
#define ej(st,n) for (int j = (st); j >= (int)(n); --j)
#define ek(st,n) for (int k = (st); k >= (int)(n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (int)(n); --(i))
#define ri(st,n) for (int i = (st); i < (int)(n); ++i)
#define rj(st,n) for (int j = (st); j < (int)(n); ++j)
#define rk(st,n) for (int k = (st); k < (int)(n); ++k)
#define rq(st,n) for (int q = (st); q < (int)(n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (int)(n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 1e9 + 7;
const int maxn = (int) 444 + 5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(10);
//srand(time(0));

int n, m, ans;
int t[maxn], u[maxn], k[maxn], a[maxn][maxn];

int main()
{
//    fin("t.in");
    sync;
    cin >> n >> m;
    clean(k);
    ans = 0;
    fi(1, n)
    {
    	fj(1, m)
    	{
    		cin >> a[i][j];
    	}
    	++k[a[i][1]];
    	ans = max(ans, k[a[i][1]]);
    }
    fi(1, max(n, m))
    {
    	t[i] = 1;
    	u[i] = 1;
    }
    fi(1, m - 1)
    {
    	int mx = 0;
    	int mxk = 0;
    	fj(1, m)
    	{
    		if (t[j] && k[j] > mx)
    		{
    			mxk = j;
    			mx = k[j];
    		}
    	}
    	t[mxk] = 0;
//    	cout << "mxk - " << mxk << endl;
    	fj(1, n)
    	{
    		if (t[a[j][u[j]]] == 0)
    		{
	    		while (t[a[j][u[j]]] == 0)
	    		{
	    			++u[j];
	    		}
	    		++k[a[j][u[j]]];
	    	}
    	}
    	int o = 0;
    	fj(1, m)
    	{
    		if (t[j])
    		{
	    		o = max(o, k[j]);
//	    		cout << j << " " << k[j] << endl; 
    		}
    	}
//    	cout << o << endl;
    	ans = min(o, ans);
    }
    cout << ans << endl;
    return 0;
}

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

typedef struct
{
    int s;
    int c;
} num_t;

// --------------- 比較用の関数 cmp -------------------
int cmp(const void *p, const void *q)
{
    return ((num_t *)p)->s - ((num_t *)q)->s;
}

int main()
{
    /* ------- 宣言と入力 ------- */

    int N, M;

    cin >> N >> M;

    int s[M];
    int c[M];
    int ans[N];

    for (int i = 0; i < M; i++)
    {
        cin >> s[i] >> c[i];
    }

    /* ------- 計算 ------- */

    vector<pair<int, int>> p(M);

    for (int i = 0; i < M; i++)
    {
        p[i] = make_pair(s[i],c[i]);
    }

    sort(p.begin(), p.end());

    for (int i = 0; i < M; i++)
    {
        if (i != 0 && p[i - 1].first == p[i].first && p[i - 1].second != p[i].second)
        {
            cout << "-1" << endl;
            return 0;
        }

        if (N > 1 && p[i].first == 1 && p[i].second == 0)
        {
            cout << "-1" << endl;
            return 0;
        }
    }

    for (int i = 0; i < N; i++)
    {
        ans[i] = 0;
    }
    if (N == 1)
        ans[0] = 0;
    else
        ans[0] = 1;
    for (int i = 0; i < M; i++)
    {
        ans[p[i].first - 1] = p[i].second;
    }

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

    return 0;
}

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

int main()
{
    long n, k;
    cin>>n>>k;
    vector<int> a(n), b(n);
    for(int i=0; i<n; ++i) cin>>a[i]>>b[i];

    auto f=[&](int p)->long {
        long res=0;
        long x=(k&~(1<<p))|((1<<p)-1);
        if (x>k) return 0;

        for(int i=0; i<n; ++i) {
            if ((a[i]|x)==x)
                res+=b[i];
        }
        return res;
    };

    long res=0;
    for(int i=0; i<31; ++i) {
        res=max(res, f(i));
    }
    cout<<res<<endl;
}


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

int mod = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<ll> b(n+1, 0);
    rep(i, n) {
        cin >> a[i];
        b[i+1] = b[i] + a[i];
    }

    ll ans = 0;

    rep(i, n) {
        ll sum = (b[n] - b[i+1]) % mod;
        ans += a[i] * sum;
        ans %= mod;
    }

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

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

int main() {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
  
    int dx = x2 - x1;
    int dy = y2 - y1;
    
    int x3 = x2 - dy;
    int y3 = y2 + dx;
    int x4 = x3 - dx;
    int y4 = y3 - dy;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
using namespace std;
const int Max_N = 1e2+10;
const int Max_W = 1e5+10;
const int Max_value = 1e5+10;
long long v[Max_value];
int w[Max_W];
long long dp[Max_N][Max_W];

int main() {
    int N;
    cin >> N;
    int W;
    cin >> W;

    for (int i = 1; i <= N; i++) {
        cin >> w[i] >> v[i];
    }
    
    for (int i = 1; i <= N; i++) {
        for (int j = 0 ; j <= W; j++) {
            if (j >= w[i]) {
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]);
            }
            else{
                dp[i][j] = dp[i-1][j];
            }
            
        }
    }
    
    cout << dp[N][W];
    
    
    return 0;
}


Measured memory_bytes: 81408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

template<class T> inline bool cmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool cmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll MAXN=1e5+5;
const ll MAXLG=__lg(MAXN)+2;

ll x,y;
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin>>x>>y;
    cout<<x+y/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
using namespace std;
const int N=1e5+10;
ll X[N],a[N],change[N],ans[N],tmp[N],loc[N];
int n,m;
ll K;
inline void prework(){
    for(int i=1;i<=n;++i){
    	change[i]=i;
	}
    for(int i=1;i<=m;++i){
    	swap(change[a[i]],change[a[i]+1]);
	}
}
inline void solve(long long y){
    for(int i=1;i<=n;++i){
    	ans[i]=i;
	}
    for(;y;y>>=1){
		if(y&1){
			for(int i=1;i<=n;++i){
				tmp[i]=ans[change[i]];
			}
			for(int i=1;i<=n;++i){
				ans[i]=tmp[i];
			}
		}
		for(int i=1;i<=n;++i){
			tmp[i]=change[change[i]];
		}
		for(int i=1;i<=n;++i){
			change[i]=tmp[i];
		}
	}
	for(int i=1;i<=n;++i){
		tmp[i]=X[ans[i]];
	}
	for(int i=1;i<=n;++i){
		X[i]=tmp[i];
	}
}
int main(){
	cin>>n;
    for(int i=1;i<=n;++i){
    	cin>>loc[i];
    	X[i]=loc[i]-loc[i-1];
    }
    cin>>m>>K;
	for(int i=1;i<=m;++i){
		cin>>a[i];
	}
    prework();
    solve(K);
    long long now=0;
    for(int i=1;i<=n;++i){
        now+=X[i];
        printf("%lld.0\n",now);
    }
    return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,num,flag=0,flag2=0;
  long long tanka,sell;
  while(cin>>n,n!=0){
    flag=0;flag2=0;
    vector<int> nu;
    vector<int> vi;
    vector<pair<int,long long> > pii;
    for(int i=0;i<n;i++){
      cin>>num>>tanka>>sell;
      for(int j=0;j<vi.size();j++){
	if(num==vi[j]){
	  flag2=1;
	  break;
	}
      }
      if(flag2==0){
	flag=0;
	for(int j=pii.size()-1;j>=0;j--){
	  if(pii[j].first==num){
	    flag=1;
	    pii.push_back(make_pair(num,((tanka*sell)+pii[j].second)));
	    if(((tanka*sell)+pii[j].second)>=1000000)
	      vi.push_back(num);
	    break;
	  }
	}
	if(flag==0){
	  nu.push_back(num);
	  pii.push_back(make_pair(num,tanka*sell));
	  if((tanka*sell)>=1000000)
	    vi.push_back(num);
	}
      }
    }
    if(vi.empty())
      cout<<"NA"<<endl;
    else{
      for(int k=0;k<nu.size();k++){
	for(int l=0;l<vi.size();l++){
	  if(nu[k]==vi[l])
	    cout<<nu[k]<<endl;
	}
      }
    }
  }
  return 0;
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> x(n), y(n), p(n);
  for (int i = 0; i < n; i++) cin >> x.at(i) >> y.at(i) >> p.at(i);
  
  vector<ll> originx(n), originy(n);
  for (int i = 0; i < n; i++) {
    originx.at(i) = abs(x.at(i)) * p.at(i);
    originy.at(i) = abs(y.at(i)) * p.at(i);
  }
  
  vector<vector<ll>> bitx((1 << n), vector<ll>(n)), bity((1 << n), vector<ll>(n));
  for (int bit = 0; bit < (1 << n); bit++) {
    for (int i = 0; i < n; i++) bitx[bit][i] = originx[i];
    for (int i = 0; i < n; i++) {
      if (bit & (1 << i)) {
        for (int j = 0; j < n; j++) {
          bitx[bit][j] = min(bitx[bit][j], abs(x[i] - x[j]) * p[j]);
        }
      }
    }
  }
  for (int bit = 0; bit < (1 << n); bit++) {
    for (int i = 0; i < n; i++) bity[bit][i] = originy[i];
    for (int i = 0; i < n; i++) {
      if (bit & (1 << i)) {
        for (int j = 0; j < n; j++) {
          bity[bit][j] = min(bity[bit][j], abs(y[i] - y[j]) * p[j]);
        }
      }
    }
  }
  
  int bitmax = pow(3, n);
  vector<ll> ans(n + 1, 1e18);
  for (int bit = 0; bit < bitmax; bit++) {
    int nowx = 0, nowy = 0, now = bit, count = 0;
    for (int i = 0; i < n; i++) {
      if (now % 3 == 1) {
        nowx |= (1 << i);
        count++;
      }
      else if (now % 3 == 2) {
        nowy |= (1 << i);
        count++;
      }
      now /= 3;
    }
    ll keep = 0;
    for (int i = 0; i < n; i++) {
      keep += min(bitx[nowx][i], bity[nowy][i]);
    }
    ans[count] = min(ans[count], keep);
  }
  
  for (int i = 0; i <= n; i++) cout << ans[i] << '\n';
}

Measured memory_bytes: 12968
#include<iostream>
using namespace std;
int t[10001];
int n,m,a,b,ans=0;
int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>t[i];
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>a;
    t[n]=a;
    for(b=0;t[b]!=a;b++);
    if(b!=n)ans++;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3128
int_list = list(map(int, input().split()))

int_list_min = sorted(int_list)

max_diff = int_list_min[2] - int_list_min[0]
min_diff = int_list_min[2] - int_list_min[1]
ans = 0

if (max_diff + min_diff)%2 == 1:
    ans += 1
    min_diff += 1

ans += (max_diff - min_diff)//2 + min_diff
print(ans)

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

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

    int k = 0;
    
    vector<int> A(N);
    vector<int> B(N);

    for (int i=0; i < N; i++) {
        cin >> A.at(i);
    }
    while(true){
        for (int i=0; i<N; i++) B.at(i)=A.at(i)%2;
        if (B == vector<int>(N)){
            for (int i=0; i<N; i++) A.at(i)/=2;
            k++;
        }
        else break;
    }
    cout << k << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vvl = vector<vector<ll>>;
using vl  = vector<ll>;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll MOD = 1000000007;
const double PI = acos(-1);  
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
//map<int,int>mp

ll n;
ll ans;
//string s;
signed main(){
	acc_io;
	ans=0;
	cin>>n;
	ll rt;
	ll a=0,b=0;
	rt=sqrt(n);
	for(int i=rt;i>0;i--){
		if(n%i==0){
			b=n/i;
          a=i;
			break;
		}
	}
//		cout<<a<<" "<<b<<endl;
	a=max(a,b);
	int ans=1;
	rep(i,0,10){
		a/=10;
		if(a>0){
			ans++;
		}
		else{
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<list>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back

#define ll __int64
#define P pair<ll,ll>
//#define __int64 long long

int n;
vector<int>p;
vector<int>ans;

int main(){	
	cin>>n;
	for(int i=2;i<=55555;i++){
		bool ok=1;
		for(int j=2;j*j<=i;j++){
				if(i%j==0)ok=0;
		}
		if(ok)p.pb(i);
	}

	int z=0;
	rep(i,p.size()){
		int x=p[i],k=0;
		if(x%10==1)ans.push_back(p[i]),z++;
		if(z>=n)break;
	}

	rep(i,n){
		cout<<ans[i];
		if(i==n-1)cout<<endl;
		else cout<<" ";
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<string>
#include<string.h>
#include<list>
#include<queue>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<deque>
#include<stack>
using namespace std;
#define debug(x) cout<<"###"<<x<<"###"<<endl;
const int INF=0x3f3f3f3f,MAXN=1e3+5;
typedef long long ll;
int dp[1<<17];
int cost[MAXN],p[MAXN];
int main(){
	int n,m;
	cin>>n>>m;
	memset(p,0,sizeof(p));
	for(int i=1;i<=m;i++){
		int b;
		scanf("%d%d",&cost[i],&b);
		for(int j=0;j<b;j++){
			int t;
			scanf("%d",&t);
			p[i]|=(1<<(t-1));
		}
	}

	memset(dp,0x3f,sizeof(dp));
//	int N=(1<<n);
//	for(int i=0;i<(1<<n);i++)dp[i][0]=0;
	dp[0]=0;
	for(int i=1;i<=m;i++){
		for(int s=0;s<(1<<n);s++){
			dp[s|p[i]]=min(dp[s]+cost[i],dp[s|p[i]]);
		}
	}

	if(dp[(1<<n)-1]==INF){
		cout<<"-1"<<endl;
	}
	else{
		cout<<dp[(1<<n)-1]<<endl;
	}
	return 0;
}
/*
2 1
30 2
1 2
*/

Measured memory_bytes: 768
#include <iostream>
#include <cctype>

int main()
{
    std::string a, b, c;
    std::cin >> a >> b >> c;

    std::string res;
    res += toupper(a[0]);
    res += toupper(b[0]);
    res += toupper(c[0]);
    std::cout << res << std::endl;
    return 0;
}


Measured memory_bytes: 256
S = input()

s = []
for i in range(len(S)):
    s.append(S[i])
ans = 0

while(1):
    n = len(s)
    del s[n-1]
    a = ""
    b = ""
    n = len(s)
    if n%2==1:
        continue
    for i in range(n//2):
        a = a+s[i]
    for i in range(n//2):
        b = b+s[n//2+i]
    if a==b:
        ans = len(a)+len(b)
        break

print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_135
{
    class C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] aArray= ReadInts();
            int[] bArray = ReadInts();
            long res = 0;
            for(int i = 0; i < n; i++)
            {
                if (bArray[i] > aArray[i])
                {
                    res += aArray[i];
                    if (bArray[i] - aArray[i] >= aArray[i + 1])
                    {
                        res += aArray[i + 1];
                        aArray[i + 1] = 0;
                    }
                    else
                    {
                        res += bArray[i] - aArray[i];
                        aArray[i + 1] -= bArray[i] - aArray[i];
                    }
                }
                else
                {
                    res += bArray[i];
                }
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int a, b, c;
  std::cin >> a >> b >> c;
  std::set<int> p;
  p.insert(a);
  p.insert(b);
  p.insert(c);
  std::cout << p.size() << std::endl;
  return 0;
}


Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
int f(int bigger, int smaller) {
    int ret = 2 * smaller * (bigger / smaller);
    int next_smaller = bigger % smaller;
    if (next_smaller == 0) return ret - smaller;
    return ret + f(smaller, next_smaller);
}

signed main() {
    int N, X;
    cin >> N >> X;
    int bigger = max(N - X, X);
    int smaller = min(N - X, X);
    cout << f(bigger, smaller) + N << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main() {
  ll m, n;
  cin >> m >> n;
  if (m == 1 && n == 1) {
    cout << 1 << endl;
  } else if (m == 1 || n == 1) {
    cout << m * n - 2 << endl;
  } else {
    cout << (m - 2) * (n - 2) << endl;
  }

  return 0;
}


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

int main() {
	int N, K;
	cin >> N >> K;
	int* A = new int[N];
	long long sum = 0;
	for (int n = 0; n < N; n++) {
		cin >> A[n];
		sum += A[n];
	}
	set<long long> candidates;

	for (long long i = 1; i * i <= sum; i++) {
		if (sum % i == 0) {
			candidates.insert(i);
			candidates.insert(sum/i);
		}
	}
	long long ans = 1;
	for (long long x : candidates) {
		long long need = 0;

		long long* r = new long long[N];
		for (int n = 0; n < N; n++) r[n] = A[n] % x;
		sort(&(r[0]), &(r[N]));
		long long tot = 0;
		for (int n = 0; n < N; n++) tot += r[n];
		int l = N - tot / x;
		need = 0;
		for (int i = 0; i < l; i++) need += r[i];
		if (need <= K) ans = max(ans, x);
	}
	cout << ans << endl;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int rec(double rem, int prd, int n, int cur){
	if(abs(rem) < EPS) return 1;
	if(n <= 0 || prd < cur) return 0;
	
	int res = 0;
	if(1.0 / cur < rem + EPS){
		res += rec(rem - 1.0 / cur, prd / cur, n - 1, cur);
	}
	res += rec(rem, prd, n, cur + 1);
	return res;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int p, q, a, n;
	while(cin >> p >> q >> a >> n, n){
		cout << rec(p * 1.0 / q, a, n, 1) << endl;
	}
	return 0;
}


Measured memory_bytes: 3208
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;
 
typedef pair<int,string> P;
int n;
vector<P> v;
int pos[100],pos2[100];
vector<int> v2[100];
 
struct state{
  int n,c;
  set<int> s;
  bool operator < (const state &s) const {
    return c > s.c;
  }
};
 
void solve(){
  priority_queue<state> Q;
  state u,u2;
  set<int> s;
  bool f = false;
  u.n = u.c = 0;
  u.s = s;
 
  for(Q.push(u);!Q.empty();){
    u = Q.top();
    Q.pop();
 
    int next = u.n == n ? n : pos2[u.n];
    
    if(next < n){
      if(u.s.find(next) != u.s.end()) continue;
       
      f = false;
      if(v[next].first == 2){
        f = true;
        for(int i=0;i<v2[next].size();i++){
          if(u.s.find(v2[next][i]) == u.s.end()){
            f = false;
            break;
          }
        }
      }
 
      u2 = u;
      u2.n = next + 1;
      u2.c++;
      u2.s.insert(next);
      Q.push(u2);
 
      if(!f){
        u2 = u;
        u2.s.insert(next);
        u2.n = pos[next];
        Q.push(u2);
      }
    } else {
      cout << u.c << endl;
      return;
    }
  }
  cout << 0 << endl;
}  
 
int main(){
  string str;
  cin >> n;
  fill(pos,pos+n,-1);
  fill(pos2,pos2+n,-1);
  for(int i=0;i<n;i++){
    cin >> str;
    if(str == "goto"){
      cin >> str;
      str.erase(str.end()-1);
      v.push_back(P(1,str));
    } else{
      str.erase(str.end()-1);
      v.push_back(P(0,str));
    }
  }
 
  for(int i=0;i<n;i++){
    if(v[i].first){
      for(int j=i;j>=0;j--){
        if(pos2[j] >= 0) break;
        pos2[j] = i;
      }
      for(int j=0;j<n;j++){
        if(v[j].first == 0 && v[i].second == v[j].second){
          pos[i] = j;
          if(i > j){
            v[i].first = 2;
            for(int k=j+1;k<i;k++) if(v[k].first) v2[i].push_back(k);
          }
          break;
        }
      }
    }
  }
 
  for(int i=n-1;i>=0;i--){
    if(pos2[i] >= 0) break;
    pos2[i] = n;
  }
 
  solve();
}

Measured memory_bytes: 1960
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll pow(ll x,ll y){
  if(y==0) return 1;
  ll ret=pow(x,y/2);
  ret%=mod;
  ret*=ret;
  ret%=mod;
  if(y%2==1) ret*=x;
  return ret%mod;
}
int main(){
  int n;
  cin>>n;
  vector<ll> vec;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    vec.push_back(a);
  }
  sort(vec.begin(),vec.end());
  cout<<vec[n/2]-vec[n/2-1]<<endl;
}


Measured memory_bytes: 1400
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kishan Sairam Adapa
 */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define ll long long int
#define MOD ((int)(1e9) + 7)

using namespace std;

class BContestWithDrinksEasy {
public:
    void solve(istream& cin, ostream& cout) {
        int n; cin >> n; ll sum =0;
        vector<int> t; for(int i=0; i<n; i++) {int tp; cin >> tp; t.push_back(tp); sum += tp;}
        int m; cin >> m;
        for(int i=0; i<m ;i++) {
            int p, x; cin >> p >> x;
            p--;
            cout << sum - t[p] + x << '\n';
        }
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    BContestWithDrinksEasy solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
S = input()
if (S[0] == S[1] and S[2] == S[3] and S[0] != S[2]) or (S[0] == S[2] and S[1] == S[3] and S[0] != S[3]) or (S[0] == S[3] and S[1] == S[2] and S[0] != S[1]):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384