akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

typedef long long LL;

const int N = 100010;

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    int res = n / (m * 2 + 1);
    if(n % (m * 2 + 1))  res ++;
    printf("%d", res);
    return 0;
}

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

int main(void) {
    int a, b;
    char op;
    
    while(true) {
        cin >> a >> op >> b;
        if(op == '?') break;
        switch(op) {
            case '+' : cout << a + b << endl;   break;
            case '-' : cout << a - b << endl;   break;
            case '*' : cout << a * b << endl;   break;
            case '/' : cout << a / b << endl;   break;
        }
    }
    return 0;
}




Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int a,b,c,d;
  cin>>a>>b>>c>>d;
  for (int i = 0; i < 100; i++) {
 c=c-b;
    if(c<=0){
      cout<<"Yes"<<endl;
      return 0;
    }
    a=a-d;
    if(a<=0){
      cout<<"No"<<endl;
      return 0;
    }
    
    
}


}

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


int main() {
  string S, T;
  cin >> S >> T;
  
  int max_cnt = 0;
  for (int i = 0; i < (S.length()-T.length())+1; i++){
    int cnt = 0;
    for (int l = 0; l < T.length(); l++){
      if (S.at(i+l) == T.at(l)) {
        cnt++;
      }
    }
    max_cnt = max(max_cnt, cnt);
  }
  
  cout << T.length() - max_cnt;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define int long long 
using namespace std;

int32_t main(){

   int n;   cin >> n;
    unordered_map<int,int> f;

    for(int x=0;x<n;x++){
        int t;  cin >> t;
        f[t]++;
    }

    auto itr = f.begin();
    int ans = 0;

    for( ; itr != f.end() ; itr++){
        int fi = itr->first , se = itr-> second;
        if(se < fi) ans += se;
        else ans += (se - fi);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4260
class BIT:
  ini = 0
  def __init__(self, num):
    self.N = 1
    while self.N <= num:
      self.N *= 2
    self.T = [self.ini] * self.N
  def do(self, l, r):
    #合計
    return l + r
  def set(self, L):
    for i in range(len(L)):
      self.update(i, L[i])
  def update(self, x):
    k = x + 1
    self.T[k - 1] += 1
    k += k & -k
    while k <= N:
      self.T[k - 1] += 1
      k += k & -k
  def getV(self, x):
    ans = self.T[x - 1]
    x -= x & -x
    while x != 0:
      ans += self.T[x - 1]
      x -= x & -x
    return ans

import sys
input = sys.stdin.readline
N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]
MOD = 998244353

xy.sort(key = lambda x:x[1])
R = {}
for i in range(N):
  R[xy[i][1]] = i
xy.sort()

LU = [0] * N
LD = [0] * N
RU = [0] * N
RD = [0] * N

Sl = BIT(N)
for i in range(N):
  t = Sl.getV(R[xy[i][1]])
  LU[i] = i - t
  LD[i] = t
  Sl.update(R[xy[i][1]])

Sr = BIT(N)
for i in range(N-1 , -1 , -1):
  t = Sr.getV(R[xy[i][1]])
  RU[i] = (N - 1 - i) - t
  RD[i] = t
  Sr.update(R[xy[i][1]])

ans = 0
PL = [1]
for i in range(N + 1):
  PL.append(PL[-1] * 2 % MOD)

def na(x):
  return PL[x] - 1

for i in range(N):
  t = PL[N - 1]
  t = (t + na(LU[i]) * na(RD[i])) % MOD
  t = (t + na(LD[i]) * na(RU[i])) % MOD
  t = (t + na(LU[i]) * na(LD[i]) * na(RU[i])) % MOD
  t = (t + na(LU[i]) * na(LD[i]) * na(RD[i])) % MOD
  t = (t + na(LU[i]) * na(RD[i]) * na(RU[i])) % MOD
  t = (t + na(LD[i]) * na(RD[i]) * na(RU[i])) % MOD
  t = (t + na(LU[i]) * na(LD[i]) * na(RD[i]) * na(RU[i])) % MOD
  ans = (ans + t) % MOD

print(ans)

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   long f(long x) {
      for(long t : {1, 3, 5, 7, 8, 10, 12}) {
         if( x == t ) return 1;
      }
      for(long t : {4, 6, 9, 11}) {
         if( x == t ) return 2;
      }
      for(long t : {2}) {
         if( x == t ) return 3;
      }
      return 0;
   }
   void solve() {
      long x, y;
      scan(x, y);
      long s = f(x);
      long t = f(y);
      puts(s == t ? "Yes" : "No");
   }
};

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 256
n,k=map(int,input().split())
x=sorted(list(map(int,input().split())))
a=[]
for i in range(n-k+1):
    l=x[i]
    r=x[i+k-1]
    a.append(min(abs(l)+abs(r-l),abs(r)+abs(l-r)))
print(min(a))

Measured memory_bytes: 62576
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#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<stack>
#include<set>
using namespace std;
int a;
int main()
{
	cin>>a;
	cout<<a+a*a+a*a*a;
	return 0;
}

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

int main(){
    int x;
    cin >> x;
    vector<int> numbers(101000);
    queue<int> primes;
    rp(i,x+100){
        numbers.at(i)=i;
    }
    for(int i=2; i<x+100;i++){
        if(numbers.at(i)==0) continue;
        else{
            primes.push(i);
            for(int j=i*2; j<x+100; j+=i){
                numbers.at(j)=0;
            }
        }
    }
    while(1){
        if(primes.front()<x){
            primes.pop();
            continue;
        }
        cout << primes.front() << endl;
        break;
    }
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main()
{
	char n[3];
	
	scanf("%s", n);
	
	if(n[0] == 55 || n[1] == 55 || n[2] == 55){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1632
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto N = RD;
	auto S = new string[](N);
	foreach (i; 0..N)
	{
		S[i] = RD!string;
	}
	S.sort!"a.length < b.length"();

	struct Node
	{
		Node* par;
		Node*[] chi;
		int c;
		int cnt;

		this(Node* _par, int _c)
		{
			par = _par;
			c = _c;
		}

		Node* search(int d)
		{
			foreach (e; chi)
			{
				if ((*e).c == d)
					return e;
			}
			return null;
		}

		int[] getCnt()
		{
			auto res = new int[](26);
			foreach (e; chi)
			{
				res[(*e).c] = (*e).cnt;
			}
			return res;
		}

		Node* addChild(int d)
		{
			auto child = new Node(&this, d);
			chi ~= child;
			return child;
		}
	}

	Node* root = new Node(null, -1);
	
	long ans;
	foreach (i; 0..N)
	{
		auto SS = S[i];
		auto cnt = new int[][](SS.length+1, 26);
		foreach (j; 0..SS.length)
		{
			cnt[j+1] = cnt[j].dup;
			cnt[j+1][SS[j]-'a'] = 1;
		}

		Node* node = root;
		foreach_reverse (j; 0..SS.length)
		{
			auto cnt2 = (*node).getCnt();
			debug writeln(cnt2);
			foreach (k, e; cnt2)
			{
				ans += cnt[j+1][k] * e;
			}

			auto c = SS[j]-'a';
			auto r = (*node).search(c);
			if (r == null)
			{
				node = (*node).addChild(c);
			}
			else
			{
				node = r;
			}
			debug writeln("j:", j, " ", SS[j], " ans:", ans);
		}
		(*node).cnt += 1;
		debug writeln("i:", i, " ", SS, " ans:", ans);
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 307596
#include<iostream>
using namespace std;
int findMin(int x, int y){
	int Min;
	if(x<=y) Min = x;
	else Min = y;
	return Min;
}
int findMin(int x,int y,int z){
	int Min;
	Min = findMin(findMin(x,y),z);
	return Min;
}
int findMax(int x, int y){
	int Max;
	if(x>=y) Max = x;
	else Max = y;
	return Max;
}
int findMax(int x,int y,int z){
	int Max;
	Max = findMax(findMax(x,y),z);
	return Max;
}
 int main(){
 	int a,b,c;
 	cin>>a>>b>>c;
 	int place3 = findMax(a,b,c);
 	int place1 = findMin(a,b,c);
 	int place2;
 	if((a==findMax(a,b,c) && b==findMin(a,b,c))||(b==findMax(a,b,c) && a==findMin(a,b,c))){
 		place2 = c;
	 } 
	if((a==findMax(a,b,c) && c==findMin(a,b,c))||(c==findMax(a,b,c) && a==findMin(a,b,c))){
 		place2 = b;
	 } 	
	 if((c==findMax(a,b,c) && b==findMin(a,b,c))||(b==findMax(a,b,c) && c==findMin(a,b,c))){
 		place2 = a;
	 } 	
	 cout<<place1<<" "<<place2<<" "<<place3<<endl;	
 }


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define INF 1e9
typedef long long ll;

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

ll a, b, c, d;

void solve(){
  ll cnum = b/c - (a-1)/c;
  ll dnum = b/d - (a-1)/d;
  ll len = b - a + 1;
  ll lcmnum = b/lcm(c, d) - (a-1)/lcm(c, d);
  cout << len - cnum - dnum + lcmnum << endl;
}

int main(){
  cin >> a >> b >> c >> d;
  solve();
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,i,j,sum=0;
    cin>>n>>m;
    long long int A[m];
    for(i=0;i<m;i++)
    {
        cin>>A[i];
        sum+=A[i];
    }
    if(sum>n)
        cout<<-1;
    else
        cout<<(n-sum);
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll cnt = 0;
    rep(i,0,3){
        if(s[i] == 'o') cnt++;
    }
    print(700 + cnt * 100);

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ConsoleApplication52
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int[] c = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] e = new int[a];
            for (int k = 0; k < b; k++)
            {
                int[] d = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 0; j < a; j++)
                {
                    if (d[j] == c[k])
                        e[j]++;
                    if (d[j] != c[k])
                        e[c[k]-1]++;
                }
            }
            for (int g = 0; g < a; g++)
                Console.WriteLine(e[g]);
        }
    }
}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int n; cin >> n;
    int a, b; cin >> a >> b;
    vector<int> p(n);
    REP(i, n) cin >> p[i];

    int cnt1, cnt2, cnt3;
    cnt1 = cnt2 = cnt3 = 0;
    REP(i, n) {
        if (p[i] <= a) cnt1++;
        else if (p[i] <= b) cnt2++;
        else cnt3++;
    }

    int ans = min({cnt1, cnt2, cnt3});
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int MAX=100;
static const int INFTY=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,M[MAX][MAX];

void dijkstra(){
  int minv;
  int d[MAX],color[MAX];

  for(int i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }

  d[0]=0;color[0]=GRAY;
  while(1){
    minv=INFTY;
    int u=-1;
    for(int i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=BLACK){
        u=i;minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(int v=0;v<n;v++){
      if(color[v]!=BLACK && M[u][v] !=INFTY){
        if(d[v]>d[u]+M[u][v]){
          d[v]=d[u]+M[u][v];
          color[v]=GRAY;
        }
      }
    }
  }
  for(int i=0;i<n;i++){
    cout<<i<<" "<<( d[i]==INFTY? -1:d[i])<<endl;
  }
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      M[i][j]=INFTY;
    }
  }

  int k,c,u,v;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v>>c;
      M[u][v]=c;
    }
  }
  dijkstra();
  return 0;
}



Measured memory_bytes: 3112
// https://atcoder.jp/contests/abc065/tasks/abc065_d
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

struct UnionFind {
    vector<int> par; // 親の番号
    UnionFind(int size) : par(size, -1) {}
    // xとyの木を併合
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (par[y] < par[x])
                swap(x, y);
            par[x] += par[y];
            par[y] = x;
            return true;
        } else {
            return false;
        }
    }
    // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y) { return root(x) == root(y); }
    // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    int root(int x) { return par[x] < 0 ? x : par[x] = root(par[x]); }
    // 頂点 v が属するグループと同じグループに属する頂点数を得る
    int size(int x) { return -par[root(x)]; }
};

struct dist {
    int cost, from, to;
    bool operator<(const dist &t) const { return cost < t.cost; };
};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x, y;
    cin >> n;
    vector<P> vx(n), vy(n);
    REP(i, n) {
        cin >> x >> y;
        vx[i] = {x - 1, i};
        vy[i] = {y - 1, i};
    }
    sort(ALL(vx));
    sort(ALL(vy));
    vector<dist> vg;
    FOR(i, 1, n) {
        vg.push_back(
            {vx[i].first - vx[i - 1].first, vx[i].second, vx[i - 1].second});
        vg.push_back(
            {vy[i].first - vy[i - 1].first, vy[i].second, vy[i - 1].second});
    }
    sort(ALL(vg));
    UnionFind uf(n);
    ll ans = 0;
    for (auto &x : vg) {
        if (!uf.same(x.from, x.to)) {
            ans += x.cost;
            uf.unite(x.from, x.to);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6516
main(){
  double a,b,c,d,e,f,g,h;
  while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=-1){
    g=(b*f-c*e)/(b*d-a*e);
    h=(a*f-c*d)/(a*e-b*d);
    if(0.0005>g)
      if(g>-0.0005)
	g=0.0;
    if(0.0005>h)
      if(h>-0.0005)
	h=0.0;
    printf("%.3lf %.3lf\n",g,h);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	map<ll,ll>a;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		a[x]++;
	}
	bool ch=false;
	if(a.size()==1){
		auto itr=a.begin();
		ll key=itr->first;
		if(key==n-1){
			ch=true;
		}
		if(key<=n/2){
			ch=true;
		}
	}
	else if(a.size()==2){
		auto itr=a.begin();
		ll key1=itr->first;
		ll val1=itr->second;
		itr++;
		ll key2=itr->first;
		ll val2=itr->second;
		//cout << val2<<val1<<key2;
		if(key2==key1+1&&key2>val1&&(key2-val1)*2<=val2){
			ch=true;
		}
	}
	cout <<(ch? "Yes":"No");// your code goes here
	return 0;
}

Measured memory_bytes: 6528
import java.util.*;
import java.lang.*;

public class Main {
	static long[] a;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		long ans = a[0];
		for (int i = 0; i < n; i++) {
			ans = gcd(ans, a[i]);
		}
		System.out.println(ans);
	}
	static long gcd(long a, long b) {
	    if (b == 0) {
	        return a;
	    }
	    return gcd(b, a % b);
	}
}

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

l=[list(map(int,input().split())) for i in range(m)]

pl=list(map(int,input().split()))
ans=0
#中身を扱いやすいように加工する
kl=[]
sl=[]
for i in range(m):
    templ=l[i]
    k=templ[0]
    kl.append(k)
    sl.append(templ[1:k+1])

for i in range(2**n):
    #b=bin(i)
    pt=[0 for l in range(n)]
    for j in range(n):
        if ((i >> j) & 1):
            pt[j]=1
    flag=True#全ての電球が点灯するか
    for l in range(m):#1つの電球についてチェック
        count=0
        k=kl[l]
        s=sl[l]
        for sw in s:
            if pt[sw-1]==1:
                count+=1
        if count%2!=pl[l]:
            flag=False
            break
    if flag:
        ans+=1
    
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

void func1(int *x, int a) {
    if (*x < a) {
        *x = a;
    }
}

void func2(int *y, int a) {
    if (*y > a) {
        *y = a;
    }
}

int main(void) {
    int n, m;
    int j;
    int a[100000][2];

    scanf("%d%d", &n, &m);

    for (j = 0; j < m; j++) {
        scanf("%d%d", &a[j][0], &a[j][1]);
    }

    int x = a[0][0];
    int y = a[0][1];

    for (j = 1; j < m; j++) {
        func1(&x, a[j][0]);
        func2(&y, a[j][1]);
    }
    if (x <= y)
        printf("%d\n", y - x + 1);
    else
        printf("0\n");
    
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    
    vector<int> T(N), X(N), Y(N);
    int t, x, y;
    for (int i = 0; i < N; i++) {
        cin >> t >> x >> y;
        T[i] = t;
        X[i] = x;
        Y[i] = y;
    }
    
    bool flag = true;
    for (int i = 0; i < N; i++) {
        if (X[i] + Y[i] > T[i]) {
            flag = false;
            break;
        }else if ((X[i] + Y[i]) % 2 == 0 && T[i] % 2 != 0) {
            flag = false;
            break;
        }else if ((X[i] + Y[i]) % 2 == 1 && T[i] % 2 != 1) {
            flag = false;
            break;
        }
    }
    if (flag) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
    #include<string>
     
    using namespace std;
     
    #define SPEEDY cin.tie(0);ios::sync_with_stdio(false);
     
    #define REP(i,n) for(int i=0;i<(n);i++)
    #define FOR(i,X,n) for(int i=(X);i<(n);i++)
     
    int dp[4000][8000],dp2[4000][8000];
    int F[4000],T[4000],F2=0,T2=0;
    int X,Y;
     
    int DP(int a,int b){
		//cout<<a<<" "<<b<<endl;
    	if(dp[a][b]!=-1)return dp[a][b];
    	if(a==F2){
			//cout<<X<<endl;
    		return dp[a][b]=(X==b);
    	}
    	return dp[a][b]=(DP(a+1,b+F[a])||DP(a+1,b-F[a]));
    }
     
    int DP2(int a,int b){
    	if(dp2[a][b]!=-1)return dp2[a][b];
    	if(a==T2){
    		return dp2[a][b]=(Y==b);
    	}
    	return dp2[a][b]=(DP2(a+1,b+T[a])||DP2(a+1,b-T[a]));
    }
     
    int main(){
    	int count=0,mode=0;
    	string s;
    	cin>>s>>X>>Y;
    	REP(i,(int)s.size()){
    		if(s[i]=='T'){
    			if(mode==0){
    				F[F2]=count,F2++;
    				count=0,mode=1;
    			}
    			else{
    				T[T2]=count,T2++;
    				count=0,mode=0;
    			}
    		}
    		else{
    			count++;
    		}
    	}
    	if(mode==0){
    		F[F2]=count,F2++;
    		count=0,mode=1;
    	}
    	else{
    		T[T2]=count,T2++;
    		count=0,mode=0;
    	}
    	REP(i,4000)REP(j,8000){
    		dp[i][j]=-1,dp2[i][j]=-1;
    	}
    	cout<<((DP(1,F[0])&&DP2(0,0))?"Yes":"No")<<endl;
    	return 0;
    }


Measured memory_bytes: 250496
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second 
#define ull unsigned long long  
#define pii pair<int, int>
#define piii pair<int,pii>
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define int ll
using ll = long long;
const int N = 3*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#endif


void solve()
{
    int a,b ;
    cin >> a >> b ;
    if( a >= 13) cout << b ;
    else if( a >= 6) cout << b/2 ;
    else cout << 0 ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

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

int N;
pair<int, int> bomb[100010];
bool changed[100010], ans[200010], looked[100010];
vector<vector<int>> G, num;

int bin_s(int key){
	int ng=0, ok=N+1;
	while(ng+1<ok){
		int mid=(ng+ok)/2;
		if(bomb[mid].first>=key) ok=mid;
		else ng=mid;
	}
	return ok;
}

bool dfs(int key, bool flag){
	looked[key]=1;
	changed[key] ^= flag;
	bool res=changed[key];
	for(int i=0; i<G[key].size(); ++i){
		if(!looked[G[key][i]]){
			changed[key] ^= res;
			ans[num[key][i]] ^= res;
			res=dfs(G[key][i], res);
			changed[key] ^= res;
			ans[num[key][i]] ^= res;
		}
	}
	return res;
}

int main() {
	int M;
	cin >> N >> M;
	bomb[0]=make_pair(-1, 0);
	for(int i=1; i<=N; ++i){
		int A, B;
		cin >> A >> B;
		bomb[i]=make_pair(A, B);
	}
	bomb[N+1]=make_pair(2e9, 0);
	sort(bomb, bomb+N+1);
	for(int i=1; i<=N+1; ++i){
		changed[i]=(bomb[i-1].second!=bomb[i].second);
	}
	G.resize(N+2);
	num.resize(N+2);
	for(int i=1; i<=M; ++i){
		int L, R;
		cin >> L >> R;
		int li=bin_s(L), ri=bin_s(R+1);
		if(li<ri){
			G[li].emplace_back(ri);
			num[li].emplace_back(i);
			G[ri].emplace_back(li);
			num[ri].emplace_back(i);
		}
	}
	for(int i=1; i<=N+1; ++i){
		if(!looked[i]){
			if(dfs(i, 0)){
				cout << -1 << endl;
				return 0;
			}
		}
	}
	int cnt=0;
	for(int i=1; i<=M; ++i){
		if(ans[i]) ++cnt;
	}
	cout << cnt << endl;
	int now=1;
	for(int i=1; i<=M; ++i){
		if(ans[i]){
			cout << i;
			if(now<cnt) cout << ' ';
			++now;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 17280
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=1e6+10;

map<int,int> mp,MP;
vector<int> spf(N+1);

void sieve()
{
    for(int i=0;i<=N;++i)
        spf[i]=i;

    for(int i=2;i*i<=N;++i)
    {
        if(spf[i]==i)
        {
            for(int j=i*i;j<=N;j+=i)
            {
                if(spf[j]==j)
                    spf[j]=i;
            }

            spf[i]=i;
        }
    }
}

int pw(int x,int n)
{
    int res=1;

    x%=M;
    for(;n;n/=2)
    {
        if(n%2)
            res=(res*x)%M;
        x=(x*x)%M;
    }

    return res;
}

void solve()
{
    sieve();

    int n;
    cin>>n;

    vector<int> v(n);
    for(int i=0;i<n;++i)
        cin>>v[i];

    int tmp;
    for(int i=0;i<n;++i)
    {
        mp.clear();

        tmp=v[i];
        while(tmp!=1ll)
        {
            ++mp[spf[tmp]];
            tmp/=spf[tmp];
        }

        for(auto c:mp)
            MP[c.F]=max(MP[c.F],c.S);
    }

    int l=1;
    for(auto c:MP)
        l=(l%M*pw(c.F,c.S)%M)%M;

    int ans=0;
    for(int i=0;i<n;++i)
    {
        ans=(ans%M+(l%M*pw(v[i],M-2)%M)%M)%M;
    }

    cout<<ans;
}

int32_t main()
{
    //fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



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

int main(void) {
  long long N, A, B;
  cin >> N >> A >> B;
  if (A > B) {
    cout << 0 << endl;
  } else if (N == 1) {
    cout << (A == B ? 1 : 0) << endl;
  } else {
    cout << (N - 2) * (B - A) + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string S;
    cin >> S;

    int l = S.size();
    string t, u;
    t = S.substr(0, l/2);
    u = S.substr(l-(l/2), l/2);
    reverse(u.begin(), u.end());

    int ans = 0;
    for(int i=0;i<l/2;i++){
        if(t[i] != u[i])
            ans++;
    }

    cout << ans << endl;

}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
	int N; cin >> N;
    vector<string> sv(N);
    rep(i, N){
        cin >> sv[i];
        sort(all(sv[i]));
    }

    unordered_map<string, ll> smap;
    rep(i, N){
        smap[sv[i]];
        smap[sv[i]]++;
    }
    ll res=0;
    for(auto a: smap){
        if(a.second != 1) res += (a.second*(a.second-1))/2;
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 20132
#include<iostream>
using namespace std;
int main()
{
  int n; // 3 <= n <= 20
  cin >> n;
  int p[n];
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  int cnt = 0;
  for (int i = 1; i < n - 1; i++) {
    if ((p[i-1]<p[i] && p[i]<p[i+1]) ||
        (p[i-1]>p[i] && p[i]>p[i+1])) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
s=input()
n=len(s)

def f(i,t):
    if i == n-1:
        return sum(list(map(int, t.split('+'))))
    
    return f(i+1,t+s[i+1]) + f(i+1,t+'+'+s[i+1]) #sumの値を足してる

print(f(0,s[0]))

Measured memory_bytes: 3060
def factorials(M):#M!までのリストｘと其の逆元のリストyを返すmod INF
    INF=int(1e9+7)
    fac=[0]*(M+1)
    finv=[0]*(M+1)
    inv=[0]*(M+1)
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,M+1):
        fac[i]=(fac[i-1]*i)%INF
        inv[i]=INF-(inv[INF%i]*(INF//i))%INF
        finv[i]=finv[i-1]*inv[i]%INF
    return fac,finv
def nCr(n,r):
    INF=int(1e9+7)
    if n<r or r<0 or n<0 :
        return 0
    return fac[n]*(finv[r]*finv[n-r]%INF)%INF
N,K=map(int,input().split())
fac,finv=factorials(N)
for i in range(1,K+1):
    a=nCr(N-K+1,i)
    b=nCr(K-i+(i-1),i-1)
    print((a*b)%(10**9+7))


Measured memory_bytes: 42608
#include<iostream>
#include<cstdio>
using namespace std;
int n,x,cnt,ans;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i){
		scanf("%d",&x);
		if (x==i) ++cnt;else ans+=(cnt+1)>>1,cnt=0;
	}
	ans+=(cnt+1)>>1;
	printf("%d",ans);
	return 0;
}

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

int main(){
    int N;
    cin>>N;
    int Max=-1,SMax=-1,num=-1;
    for(int i=0;i<N;i++){
        int x;
        cin>>x;
        if(x>Max){SMax=Max; Max=x; num=i;}
        else if(x>SMax) SMax=x;
    }

    for(int i=0;i<N;i++){
        if(i!=num) cout<<Max<<endl;
        else cout<<SMax<<endl;
    }
}

Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
using namespace std;
const int M = 105;
int x[M],y[M],a[M];

int main(){
	int w,h,n; cin >> w >> h >> n;
	int area;
	int yux = 0;//原点x坐标 
	int yuy = 0;//原点y坐标
	bool vis = 1;
	for(int i = 1; i <= n; i++) cin >> x[i] >> y[i] >> a[i];

	for(int i = 1; i <= n; i++){
		if(a[i] == 1 && x[i] > yux){
			yux = x[i]; 
		}
		if(a[i] == 2){
			if(x[i] <= yux){
				vis = 0;
				break;
			}
			else if(w > x[i])w = x[i];
		}
		if(a[i] == 3 && y[i] > yuy){
			yuy = y[i]; 
		}
		if(a[i] == 4){
			if(y[i] <= yuy){
				vis = 0;
				break;
			}
			else if(h > y[i])h = y[i]; 
		}
	}
	if(vis == 1)  area = (w - yux)*(h - yuy);
	else area = 0;
	cout << area << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
 int a,b,sum=0;
  
  scanf("%d %d",&a,&b);
  
  if(a>b){
    sum+=a;
    sum=sum+(a-1);
    }
   else if(a<b){
     sum+=b;
     sum=sum+(b-1);
   }
    else sum=a*2;
  
  printf("%d",sum);
  
  
  
 return 0 ;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

class __ufnode
{
public:
    __ufnode *m_parent;
    int m_count;
 
    __ufnode()
    {
        m_parent = this;
        m_count = 1;
    }
 
    __ufnode *root()
    {
        return _getroot(this);
    }
 
    bool connect_to(__ufnode *t)
    {
        __ufnode *root = _getroot(this);
        __ufnode *target = _getroot(t);
        if( root == target ) return false;
        if( root->m_count > target->m_count )
        {
            target->m_parent = root;
            root->m_count += target->m_count;
        }
        else
        {
            root->m_parent = target;
            target->m_count += root->m_count;
        }
        return true;        
    }
 
private:
    __ufnode *_getroot(__ufnode *current)
    {
        if( current->m_parent == current ) return current;
        __ufnode *root = _getroot(current->m_parent);
        current->m_parent = root;
        return root;
    }
};
 
class unionfind
{
private:
    __ufnode *m_nodes;
    int m_size;
 
public:
    unionfind(int size)
    {
        m_nodes = new __ufnode[size];
        m_size = size;
    }
 
    ~unionfind()
    {
        delete m_nodes;
    }
 
    bool unite(int a, int b)
    {
        return m_nodes[a].connect_to(m_nodes + b);
    }
    
    bool issame(int a, int b)
    {
        return m_nodes[a].root() == m_nodes[b].root();
    }

    int getnum(int a)
    {
        return m_nodes[a].root()->m_count;
    }
 
    // すべてを連結。連結前に何個のグループにわけたか
    int connectall()
    {
        int count = 1;
        for( int i = 1; i < m_size; i++ )
        {
            if( unite(0, i) ) count++;
        }
        return count;
    }
};

int main()
{
    int n, m; cin >> n >> m;
    unionfind uf(n);
    rep(i, m)
    {
        int a, b; cin >> a >> b;
        uf.unite( a - 1, b - 1 );
    }
    int largest = 0;
    rep(i, n)
    {
        largest = max(largest, uf.getnum(i));
    }
    cout << largest << endl;
    return 0;    
}

Measured memory_bytes: 6376
from collections import deque
import copy

H,W=map(int,input().split())
S=[[x for x in input()] for _ in range(H)]
start_list=[]
length=[[-1]*W for _ in range(H)]
ans=0

for i in range(H):
  for j in range(W):
    if S[i][j]=='.':
      start_list.append((i,j))

for start in start_list:
  h,w=start
  d=deque([(h,w)])
  T=copy.deepcopy(S)
  L=copy.deepcopy(length)
  L[h][w]=0
  T[h][w]='#'
  while d:
    h,w=d.popleft()
    
    if h-1>=0 and T[h-1][w]=='.':
      d.append((h-1,w))
      L[h-1][w]=L[h][w]+1
      T[h-1][w]='#'
      ans=max(ans,L[h-1][w])
      
    if h+1<=H-1 and T[h+1][w]=='.':
      d.append((h+1,w))
      L[h+1][w]=L[h][w]+1
      T[h+1][w]='#'
      ans=max(ans,L[h+1][w])
      
    if w-1>=0 and T[h][w-1]=='.':
      d.append((h,w-1))
      L[h][w-1]=L[h][w]+1
      T[h][w-1]='#'
      ans=max(ans,L[h][w-1])
      
    if w+1<=W-1 and T[h][w+1]=='.':
      d.append((h,w+1))
      L[h][w+1]=L[h][w]+1
      T[h][w+1]='#'
      ans=max(ans,L[h][w+1])

print(ans)

Measured memory_bytes: 9632
#include <bits/stdc++.h>
using namespace std;
 
 
int main() 
{
    int A,B,C;
    cin >> A >> B >> C;
    if (A == B) {
        cout << C;
    }else if (B == C) {
        cout << A;
    }else{
      	cout << B;
    }
    
}

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

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

signed main(){
	cout<<fixed<<setprecision(7);
	
	int N, A, B, P;
	int a = 0, b = 0, c = 0;
	
	cin>>N>>A>>B;
	
	rep(i,N){
		cin>>P;
		if(P <= A) a++;
		else if(P <= B) b++;
		else c++;
	}
	
	cout<<min(a,min(b,c))<<endl;
	
	return 0;
}

Measured memory_bytes: 256
fun main (args : Array<String>) {
	val str1 = readLine()
	val str2 : String = str1.toString()
	var y : String = ""
	var m : String = ""
	var count : Int = 0
	for (i in str2) {
		if (count <= 1) {
			y += i
		} else {
			m += i
		}
		count++
	}
	return if ( (y.toInt() <= 12 && y.toInt() != 0) && (m.toInt() <= 12 && m.toInt() != 0) ) {
		println("AMBIGUOUS")
	} else if (m.toInt() <= 12 && m.toInt() != 0) {
		println("YYMM")
	} else if (y.toInt() <= 12 && y.toInt() != 0) {
		println("MMYY")
	} else {
		println("NA")
	}
}

Measured memory_bytes: 33828
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    int a[100005],b[100005];
    for(int i = 0;i < m;i++)cin >> a[i];
    sort(a,a+m);
    for(int i = 0;i < m-1;i++)b[i] = a[i+1] - a[i];
    sort(b,b+m-1);
    int sum = 0;
    for(int i = 0;i < (m-1) - (n-1);i++){
        sum += b[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 1024
n = int(input())
a = [int(i) for i in input().split()]
s1 = s2 = su = 0
for i in range(n):
  su += a[i]
  if (i % 2 == 0 and su <= 0):
    s1 += abs(su) + 1
    su = 1
  elif(i % 2 == 1 and su >= 0):
    s1 += abs(su) + 1
    su = -1
su = 0
for i in range(n):
  su += a[i]
  if (i % 2 == 0 and su >= 0):
    s2 += abs(su) + 1
    su = -1
  elif (i % 2 == 1 and su <= 0):
    s2 += abs(su) + 1
    su = 1
print(min(s1,s2))

Measured memory_bytes: 14468
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t--!=0){
			BigInteger b = sc.nextBigInteger().add(sc.nextBigInteger());
			System.out.println(b.toString().length()>80?"overflow":b.toString());
		}
	}
}

Measured memory_bytes: 18424
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int par[100005];
int ran[100005];
void init(int n){
	for(int i=0;i<n;i++){
		par[i]=i;
		ran[i]=0;
	}
}
int find(int x){
	if(par[x] == x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}
void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x == y) return ;
	if(ran[x]<=ran[y]){
		par[x]=par[y];
	}else{
		par[y]=par[x];
		if(ran[x] == ran[y]) ran[x]++;
	}
}
bool same(int x,int y){
	return find(x)==find(y);
}
struct edge{
	int u,v,cost;
};
bool comp(edge a,edge b){
	return a.cost<b.cost;
}
edge s[100005];
int V,E;
int kruskal(){
	sort(s,s+E,comp);
	init(V);
	int res=0;
	for(int i=0;i<E;i++){
		edge e=s[i];
		if(!same(e.u,e.v)){
			unite(e.u,e.v);
			res+=e.cost;
		}
	}
	return res;
}
int main(){
	while(scanf("%d",&V) && V){
		scanf("%d",&E);
		for(int i=0;i<E;i++){
			int w,e,r;
			scanf("%d,%d,%d",&w,&e,&r);
			edge tt;
			tt.u=w;
			tt.v=e;
			tt.cost=(r-100)/100;
			s[i]=tt;
		}
		printf("%d\n",kruskal());
	}
}

Measured memory_bytes: 1272
n=gets
s=gets.chomp
left = s.count '('
right = s.count ')'
a=0
depth=0
s.chars.each do |c|
  if c == '('
    a -= 1
  else
    a += 1
  end
  depth = [depth, a].max
end

# p [depth, left, right]
puts '(' * depth + s + ')' * (left + depth - right)


Measured memory_bytes: 1788
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    string S;
    cin >> S;
    bool n = false,e = false,w = false,s = false;
    rep(i,S.size()){
        if(S[i] == 'N'){
            n = true;
        }
        if(S[i] == 'E'){
            e = true;
        }
        if(S[i] == 'W'){
            w = true;
        }
        if(S[i] == 'S'){
            s = true;
        }
    }
    if(n && s && w && e)cout << "Yes";
    else if(n && s && (!w && !e))cout << "Yes";
    else if(w && e && (!n && !s))cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
#define N 55
int a[N];
int n;
bool judge()
{
	for(int i=1;i<=n;i++)
	{
		if(a[i]!=i) return false;
	}
	return true;
}
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
	}
	if(judge())
	{
		cout<<"YES\n";
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			swap(a[i],a[j]);
			if(judge())
			{
				cout<<"YES\n";
				return 0;
			}
			swap(a[i],a[j]);
		}
	}
	cout<<"NO\n";
#ifndef ONLINE_JUDGE
//	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



Measured memory_bytes: 256
import math
a, b, h, m = map(int, input().split())
an = m*0.5+((12+h)%12)*30
bn = m*6
max = -1
min = -1
if an >= bn:
    max = an
    min = bn
else:
    max = bn
    min = an
c = max-min
rad = math.radians(c)
ans = a**2+b**2-2*a*b*math.cos(rad)
ans = math.sqrt(ans)
print(ans)



Measured memory_bytes: 9520
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
using namespace std;

int main() {

    int y, m, d;
    while(cin >> y >> m >> d) {
        if( y > 1989 ) {
            cout << "heisei " << y - 1988 << " " << m << " " << d;
        } else if ( y == 1989 ) {
            if ( m > 1 || ( m == 1 && d >= 8) ) {
                cout << "heisei 1 " << m << " " << d;
            } else {
                cout << "showa 64 " << m << " " << d;
            }
        } else if ( y > 1926 ) {
            cout << "showa " << y - 1925 << " " << m << " " << d;
        } else if ( y == 1926) {
            if ( m == 12 && d >= 25 ) {
                cout << "showa 1 "<< m << " " << d;
            } else {
                cout << "taisho 15 "<< m << " " << d;
            }
        } else if ( y > 1912 ) {
            cout << "taisho " << y - 1911 << " "<< m << " " << d;
        } else if ( y == 1912 ) {
            if ( m >= 8 || ( m == 7 && d >= 30) ) {
                cout << "taisho 1 "<< m << " " << d;
            } else {
                cout << "meiji 45 "<< m << " " << d;
            }
        } else if ( y > 1868 ) {
            cout << "meiji " << y - 1867 << " " << m << " " << d;
        } else if ( y == 1868 ) {
            if( m >= 10 || ( m == 9 & d >= 8 ) ) {
                cout << "meiji 1 " << m << " " << d;
            } else {
                cout << "pre-meiji";
            }
        } else {
            cout << "pre-meiji";
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<set>

using namespace std;

int main() {
  int n;
  while(cin>>n && n!=0) {
    set<pair<int, int> > mySet;
    for(int i=0; i<n; i++) {
      int x, y;
      cin>>x>>y;
      mySet.insert(make_pair(x, y));
    }
    int m;
    cin>>m;
    int nowX = 10, nowY = 10;
    string dir;
    int move;
    for(int i=0; i<m; i++) {
      cin>>dir;
      cin>>move;
      for(int j=0; j<move; j++) {
	if(dir == "N") {
	  nowY++;
	}
	else if(dir == "S") {
	  nowY--;
	}
	else if(dir == "E") {
	  nowX++;
	}
	else if(dir == "W") {
	  nowX--;
	}
	if(mySet.find(make_pair(nowX, nowY)) != mySet.end()) {
	  mySet.erase(make_pair(nowX, nowY));
	}
      }
    }
    if(mySet.empty()) {
      cout<<"Yes"<<endl;
    }
    else {
      cout<<"No"<<endl;
    }
  }
}

Measured memory_bytes: 1200
/*
4
abd
abcd
c
b
0
=>yes, where a=1,b=4,c=3,d=2
*/

#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
main(){
	int n,i,j;
	string s;
	for(;cin>>n,n;){
		map<pair<char,char>,int>m;
		vector<string>v;
		for(;n;n--){
			cin>>s;
			for(i=0;i<v.size();i++){
				for(j=0;j<min(v[i].length(),s.length());j++){
					if(v[i][j]==s[j])continue;
					if(m[make_pair(v[i][j],s[j])])goto fail;
					m[make_pair(s[j],v[i][j])]=1;break;
				}
				if(j==s.length()&&v[i].length()>s.length())goto fail;
			}
			v.push_back(s);
		}
		cout<<"yes"<<endl;continue;
		fail:
		for(n--;n;n--)cin>>s;
		cout<<"no"<<endl;
	}
}

Measured memory_bytes: 1264
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  string s;
  int K;
  cin >> s;
  cin >> K;
  int N = s.size();
  vector<string> v;
  set<string> vset;
  for(int i=0; i<N; ++i){
    for(int j=1; j<K+1; ++j){
      string sub = s.substr(i, j);
      if(i+j-1< N && vset.find(sub) == vset.end()){
        v.push_back(sub);
        vset.insert(sub);
      }
    }
  }
  sort(v.begin(), v.end());

  cout << v[K-1] << endl;

}

Measured memory_bytes: 1792
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
c=Counter(a)
ans=0
for i in a:
  if c[i]==0:
    continue
  pt=2**len(format(i,'b'))
  c[i]-=1
  if c[pt-i]>=1:
    ans+=1
    c[pt-i]-=1
print(ans)

Measured memory_bytes: 33288
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define N (int)1e5
int main()
{
	int x, sum = 0, ans;
	cin >> x;
	for (int i = 0; sum < x; i++)
	{
		sum += i;
		if (x <= sum)
		{
			cout << i << endl;
			break;
		}
	}
}

Measured memory_bytes: 256