akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <sstream>
#include <map>
#include <queue>
using namespace std;

#define REP(i,n,m) for(int i=n;i<m;i++)
#define rep(i,n) REP(i,0,n)

class State{
public:
	string s;
	int cost;
	int idx[2];

	State(string ts,int tcost,int tidx[]){
		s = ts;
		cost = tcost;
		idx[0] = tidx[0];
		idx[1] = tidx[1];
	}
};

int di[13][4] = {
	{-1,-1,2,-1},
	{-1,2,5,-1},
	{0,3,6,1},
	{-1,-1,7,2},
	{-1,5,-1,-1},
	{1,6,9,4},
	{2,7,10,5},
	{3,8,11,6},
	{-1,-1,-1,7},
	{5,10,-1,-1},
	{6,11,12,9},
	{7,-1,-1,10},
	{10,-1,-1,-1},
};

void printPuzzle(string s){
	cout<<"  "<<s.substr(0,1)<<endl;
	cout<<" "<<s.substr(1,3)<<endl;
	cout<<s.substr(4,5)<<endl;
	cout<<" "<<s.substr(9,3)<<endl;
	cout<<"  "<<s.substr(12,1)<<endl;
	cout<<"----------------------------\n";
}

queue<State> open;
map<string,int> closed,closed2;

int main(void){
	string alpha = "abcdefghijkl";
	int idx[] = {0,12};

	open.push(State("abcdefghijkla",0,idx));
	closed.insert(pair<string,int>("abcdefghijkla",0));

	while(!open.empty()){
		State st = open.front(); open.pop();
		if(st.cost >= 14) continue;

		rep(i,2){
			rep(j,4){
				int to = di[st.idx[i]][j];
				if(to == -1) continue;

				string res = st.s;
				int tmp = res[st.idx[i]];
				res[st.idx[i]] = res[to];
				res[to] = tmp;

				if(closed.find(res) == closed.end()){
					idx[0] = i==0 ? to : st.idx[0];
					idx[1] = i==1 ? to : st.idx[1];
					open.push(State(res,st.cost+1,idx));
					closed.insert(pair<string,int>(res,st.cost+1));
				}
			}
		}
	}

	while(1){
		int x;
		cin>>x;
		if(x == -1) break;

		stringstream ss;
		ss<<alpha[x];
		rep(i,12){
			cin>>x;
			ss<<alpha[x];
		}

		string start = ss.str();

		while(!open.empty()) open.pop();
		closed2.clear();

		for(idx[0]=0;start[idx[0]]!='a';idx[0]++);
		for(idx[1]=start.length()-1;start[idx[1]]!='a';idx[1]--);
		open.push(State(start,0,idx));
		closed2.insert(pair<string,int>(start,0));

		int ans = -1;

		while(!open.empty()){
			State st = open.front(); open.pop();
			if(closed.find(st.s) != closed.end() && st.cost + closed[st.s] <= 20){
				ans = st.cost + closed[st.s];
				break;
			}
			if(st.cost >= 7) continue;

			rep(i,2){
				rep(j,4){
					int to = di[st.idx[i]][j];
					if(to == -1) continue;

					string res = st.s;
					int tmp = res[st.idx[i]];
					res[st.idx[i]] = res[to];
					res[to] = tmp;

					if(closed2.find(res) == closed2.end()){
						idx[0] = i==0 ? to : st.idx[0];
						idx[1] = i==1 ? to : st.idx[1];
						open.push(State(res,st.cost+1,idx));
						closed2.insert(pair<string,int>(res,st.cost+1));
					}
				}
			}
		}

		if(ans == -1) cout<<"NA\n";
		else cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 12000
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<list>
#include<math.h>
using namespace std;

#define ll long long
#define vecint vector<int>
#define listint list<int>

#define REP(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define print(a) cout << a << endl


int main(){
  int x=0,N,ans=0;
  string S;

  cin >> N;
  cin >> S;

  rep(i,N){
    if(S[i]=='I') x++;
    else x--;
    ans = max(x,ans);
  }
  print(ans);
  return 0;
}


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

using namespace std;

const int inf = 2e9, Nmax = 2e5 + 5;
typedef long long ll;

int n, m, i, x,y, c;
int d[Nmax], t[Nmax];
pair<int, pair<int,int> > edge[2*Nmax];
ll ans;

int boss(int x)
{
    if(x == t[x]) return x;
    return t[x] = boss(t[x]);
}

void unite(int x, int y)
{
    x = boss(x), y = boss(y);
    t[x] = y;
}

int main()
{
//    freopen("input", "r", stdin);
 //   freopen("output", "w", stdout);

    cin.sync_with_stdio(false);

    cin >> n >> m;
    for(i=0; i<n; ++i) d[i] = inf, t[i] = i;

    for(i=1; i<=m; ++i)
    {
        cin >> x >> y >> c;
        d[x] = min(d[x], c+1);
        d[y] = min(d[y], c+2);
        edge[i] = {c, {x, y}};
    }

    for(int j=0; j<2; ++j)
    {
        for(i=1; i<n; ++i)
            d[i] = min(d[i], d[i-1] + 2);
        d[0] = min(d[0], d[n-1] + 2);
    }

    for(i=0; i<n; ++i)
        edge[++m] = {d[i], {i, i+1}};

    sort(edge+1, edge+m+1);

    for(i=1; i<=m; ++i)
    {
        x = edge[i].second.first;
        y = edge[i].second.second;
        c = edge[i].first;

        if(boss(x) != boss(y))
            ans += c, unite(x, y);
    }

    cout << ans << '\n';
    return 0;
}


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

AC_flag = [0] * N
WA_count = [0] * N
total_WA = 0

for i in range(M):
    p, S = input().split()
    if S == 'AC':
        if AC_flag[int(p)-1] == 0:
            AC_flag[int(p)-1] = 1
            total_WA += WA_count[int(p)-1]
    else:
        if AC_flag[int(p)-1] == 0:
            WA_count[int(p)-1] += 1

print('%d %d' % (sum(AC_flag), total_WA))

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

#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

class DFlippingSigns {
public:
	void solve(std::istream& in, std::ostream& out) {
        int N;
        in >> N;
        ll _min = 1e9;
        ll minus = 0;
        ll ans = 0;
        REP(i, N) {
            ll a;
            in >> a;
            if (a < 0) minus++;
            a = abs(a);
            _min = min(_min, a);
            ans += a;
        }
        if (minus % 2 == 1) {
            ans -= _min*2;
        }
        out << ans << '\n';
	}
};


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


Measured memory_bytes: 256
#include<cstdio>
#include<stack>
#include<cstdlib>
using namespace std;
stack<int> num;
char s[1002];
int main()
{
	int a, b;
	while(scanf("%s", s) != EOF){
		if(s[0] == '+')
		{
			a = num.top();
			num.pop();
			b = num.top();
			num.pop();
			num.push(a+b);
		}
		else if(s[0] == '-')
		{
			a = num.top();
			num.pop();
			b = num.top();
			num.pop();
			num.push(b-a); 
		}
		else if(s[0] == '*')
		{
			a = num.top();
			num.pop();
			b = num.top();
			num.pop();
			num.push(a*b);
		}
		else{
			num.push(atoi(s));
		}
	}
	printf("%d\n", num.top());
	return 0;
}  


Measured memory_bytes: 2744
#include<stdio.h>
#include<stdlib.h>
#define INF 20000
#define WHITE 0
#define BLACK 1
void prim();
int w(int,int);
int n,**G,mincost,*d,*color;
int main(){
  int a,i,j,totalcost;
  scanf("%d",&n);
  G = (int**)malloc(sizeof(int*) * n);     // dynamic alloction
  color = (int*)malloc(sizeof(int) * n);   // *
  d = (int*)malloc(sizeof(int) * n);       // *
  for(i=0; i<n; i++){                      // *
    G[i] = (int*)malloc(sizeof(int) * n);  // *
    color[i] = WHITE;                      // * initialization
    d[i] = INF;                            // * *
  }                                        // * *
  d[0] = 0;                                // end
  for(i=0; i<n; i++){                 // input data
    for(j=0; j<n; j++){               // *
      scanf("%d",&a);                 // *
      G[i][j] = (a == -1 ? INF : a);  // *
    }                                 // *
  }                                   // end
  prim();
  for(i=0,totalcost=0; i<n; i++){  // sum of cost
    totalcost += d[i];             // *
  }                                // end
  printf("%d\n",totalcost);
  return 0;
}

void prim(){
  int i,u,v;
  while(1){
    mincost = INF;
    for(i=0; i<n; i++){
      if(color[i] != BLACK && d[i] < mincost){
        mincost = d[i];
        u = i;
      }
    }
    if(mincost == INF){
      break;
    }
    color[u] = BLACK;
    for(v=0; v<n; v++){
      if(color[v] != BLACK && w(u,v) < d[v]){
        d[v] = w(u,v);
      }
    }
  }
}

int w(int i,int j){
  return G[i][j];
}

Measured memory_bytes: 640
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  var P = [[[0]],[[1]]];
  for(var i=1;i<N;i++){
    var P2=new Array();
    for(var k=0;k<P.length;k++){
      var Psub1 = [...P[k],[0]];
      var Psub2 = [...P[k],[1]];
      P2.push(Psub1);
      P2.push(Psub2);
    }
    P=[...P2];

  }
  var ans=0;
  input.shift();
  var anssub=new Array();
  var I = input.map(i => i.split(" "));
  for(var i=0;i<P.length;i++){
    var flag=0;
    var cnt=0;
    for(var k=0;k<I.length;k++){
      if(I[k].length==1){
        if(P[i][cnt]==1){
          flag=1;
        }else{
          flag=0;
        }
        cnt++;
      }else if(I[k][0]!=""){
        if(flag==1){
          if(P[i][I[k][0]-1]!=I[k][1]){
            break;
          }
        }
      }
      if(k==I.length-1){
        anssub.push(P[i]);
      }
    }
  }
  for(var i=0;i<anssub.length;i++){
    var cnt2=0;
    for(var k=0;k<N;k++){
      if(anssub[i][k]==1){
        cnt2++;
      }
      
    }
    ans=Math.max(cnt2,ans);
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 55180
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

#[allow(unused_macros)]
macro_rules! vec_md {
    ( $ init : expr ; $ ( $ dim : expr ) ;* ) => { vec_md ! ( $ ( $ dim ) ;* => $ init ) };
    ( $ head : expr ; $ ( $ tail : expr ) ;* => $ init : expr ) => { vec ! [ vec_md ! ( $ ( $ tail ) ;* => $ init ) ; $ head ] };
    ( $ head : expr => $ init : expr ) => { vec ! [ $ init ; $ head ] };
}

fn main() {
    input! {
        n: usize,
        a: [i64; n]
    }

    let mut dp = vec_md![None;n+1;n+1];
    println!("{}", rec(&mut dp, &a, 0, n));
}

fn rec(dp: &mut Vec<Vec<Option<i64>>>, a: &Vec<i64>, l: usize, r: usize) -> i64 {
    if l == r {
        return 0;
    }
    if let Some(src) = dp[l][r] {
        return src;
    }

    let ret = if (l + r) % 2 == a.len() % 2 {
        std::cmp::max(
            rec(dp,a,l+1,r) + a[l],
            rec(dp,a,l,r-1) + a[r-1]
        )
    } else {
        std::cmp::min(
            rec(dp,a,l+1,r) - a[l],
            rec(dp,a,l,r-1) - a[r-1]
        )
    };
    dp[l][r] = Some(ret);
    ret
}

Measured memory_bytes: 166268
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<vector>
using namespace std;

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//infinity
#define INTINF 2000000000
#define LONGINF 2000000000

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
	long long n, k; cin >> n >> k;

	long long ans = 0;
	FOR(i, 1, n+1){
		long long c = n / i;
		long long ac = (i-k)*c < 0 ? 0 : (i-k)*c;

		long long u = n % i;
		long long au = u+1-k < 0 ? 0 : u+1-k;
		au -= (k==0) ? 1 : 0;
		ans += ac + au;
		/*
		cout << c << " " << ac << " ";
		cout << u << " " << au << " ";
		cout << ans << endl;
		*/
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int a, b, c, d, p;
  scanf("%d%d%d%d%d", &a, &b, &c, &d, &p);
  int ans = a * p;
  int t;
  if(p <= c) t = b;
  else t = b + (p - c) * d;
  if(ans > t) ans = t;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2696
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int maxn=200005;
int n;
ll a[maxn],l1[maxn],l2[maxn],r1[maxn],r2[maxn];

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	scanf("%d",&n);
	REP(i,n)scanf("%lld",&a[i]);
	ll sum=0;
	REP(i,n){
		sum+=a[i];
		if(a[i]==0){
			l1[i]=min(sum-a[i],l1[i-1]+1);
			l2[i]=min(sum,l2[i-1]+2);
			continue;
		}
		l1[i]=min(sum-a[i],l1[i-1]+1-(a[i]&1));
		l2[i]=min(sum,l2[i-1]+(a[i]&1));
		l1[i]=min(l1[i],l2[i]);
	}
	sum=0;
	for(int i=n;i>=1;i--){
		sum+=a[i];
		if(a[i]==0){
			r1[i]=min(sum-a[i],r1[i+1]+1);
			r2[i]=min(sum,r2[i+1]+2);
			continue;
		} 
		r1[i]=min(sum-a[i],r1[i+1]+1-(a[i]&1));
		r2[i]=min(sum,r2[i+1]+(a[i]&1));
		r1[i]=min(r1[i],r2[i]);
	}
	ll ans=Inf;
	rep(i,n+1)ans=min(ans,l1[i]+r2[i+1]),ans=min(ans,l2[i]+r1[i+1]);
	printf("%lld\n",ans);
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/


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

#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
int mod = 1e9 + 7, size = 1e6 + 1;

int main()
{
    fast

    string s;
    cin >> s;
    int ans = 0;

    vector <int> v;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == 'R') ++ans;
        else {
            v.pb(ans);
            ans = 0;
        }
    }

    v.pb(ans);
    cout << *max_element(v.begin(), v.end()) << endl;
}
// () ! # &


Measured memory_bytes: 3616
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////


///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	vector< pair<int, int> > V;
	int n;
	cin >> n;
	cout << endl;
	for(int i = 0; i < n; i++){
		//cout << "i: " << i << endl;
		int a, b;
		cin >> a >> b;
		
		V.pb(mp(b, a));
	}
	
	//cout << "wyswietlenie V before: " << endl;
	//for(auto it : V){
		//cout << it.first << " " << it.second << " " << endl;
	//}
	
	//ascending sort by first value
	
	sort(V.begin(), V.end());
	
	//cout << "wyswietlenie V sorted: " << endl;
	//for(auto it : V){
		//cout << it.first << " " << it.second << " " << endl;
	//}
	
	int time = 0;
	
	for(auto it : V){
		time += it.second;
		if(time > it.first){
			cout << "No" << '\n';
			return 0;
		}
	}
	
	//cout << "TIME: " << time << endl;
	cout << "Yes" << "\n";
	
	return 0;
}


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

#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)

#define ii pair<int, int>
#define mp make_pair
#define FF first
#define SS second

#define vi vector<int>
#define vii vector<ii>
#define ll long long
#define vll vector<ll>

#define eb emplace_back
#define ef emplace_front
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()

#define oo 1000000007
#define OO 1000000000000000007LL

using namespace std;

#define Pro "tmp"
#define maxN 300007

int a[maxN], b[maxN];
set <int> st[maxN];

int mergeSet(int a, int b) {
    if ((int)st[a].size() < (int)st[b].size()) swap(a, b);
    ftoit (it, st[b]) st[a].insert(*it);
    st[b].clear();
    return a;
}

int main() {

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

    fto (i, 1, n) {
        scanf("%d", &a[i]);
        b[i] = a[i];
    }
    sort(b+1, b+n+1);

    queue <int> q;
    fto (i, 1, n) {
        st[i].insert(a[i]);
        q.push(i);
    }

    ll sol = 0LL;
    fto (i, 1, n) {
        int ans = 0;
        set <int> cur_set;

        int new_idx = 0;
        while (!q.empty()) {
            int idx = q.front();
            q.pop();

            ans += (int)st[idx].size();
            if (st[idx].count(b[i])) {
                st[idx].erase(b[i]);
                new_idx = mergeSet(idx, new_idx);

                if ((int)st[new_idx].size()) q.push(new_idx);
                break;
            }

            new_idx = mergeSet(idx, new_idx);
        }

        sol += ans-1;
    }

    printf("%lld\n", sol);
    return 0;
}



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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define for_each(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = __INT_MAX__;               // 2^31 - 1
const long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

bool dp[100005];
int main() {
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    rep(i, k + 1) {
        rep(j, n) {
            if (i + a[j] <= k && !dp[i]) dp[i + a[j]] = true;
        }
    }
    dp[k] ? out("First") : out("Second");
    return 0;
}


Measured memory_bytes: 384
n = int(input())
edges = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

def dfs(v):
    d= [0] * n
    q=[v]
    visited = [0] * n
    while q:
        v=q.pop()
        visited[v] = 1
        visited.append(v)
        for i in edges[v]:
            if not visited[i]:
                d[i] = d[v] + 1
                q.append(i)
    return d

dist_from0 = dfs(0)
dist_fromn = dfs(n-1)

f = 0
s = 0
for i in range(n):
    if dist_fromn[i] >= dist_from0[i]:
        f += 1
    else:
        s += 1
if f>s:
    print("Fennec")
else:
    print("Snuke")


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

int main() {
  int n, m;
  cin >> n >> m;
  map<int, vector<int>> road;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    road[a].push_back(b);
    road[b].push_back(a);
  }

  vector<int> ans(n + 1);
  queue<int> q;
  q.push(1);

  while (!q.empty()) {
    int room = q.front();
    q.pop();
    for (int nRoom : road[room]) {
      if (ans[nRoom] == 0) {
        ans[nRoom] = room;
        q.push(nRoom);
      }
    }
  }

  rep(i, n + 1) {
    if (i <= 1) continue;
    if (ans[i] == 0) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  rep(i, n + 1) {
    if (i <= 1) continue;
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 15672
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = int(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = int(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) begin(x), end(x)
#define dump(x) cerr << #x " = " << x << endl
#define unittest_name_helper(counter) unittest_ ## counter
#define unittest_name(counter) unittest_name_helper(counter)
#define unittest __attribute__((constructor)) void unittest_name(__COUNTER__) ()
using ll = long long;
using namespace std;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
template <class T, class U> inline void chmax(T & a, U const & b) { a = max<T>(a, b); }
template <class T, class U> inline void chmin(T & a, U const & b) { a = min<T>(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
template <typename T> ostream & operator << (ostream & out, vector<T> const & xs) { REP (i, int(xs.size()) - 1) out << xs[i] << ' '; if (not xs.empty()) out << xs.back(); return out; }

template <typename UnaryPredicate>
int64_t binsearch(int64_t l, int64_t r, UnaryPredicate p) {
    assert (l <= r);
    -- l;
    while (r - l > 1) {
        int64_t m = l + (r - l) / 2;
        (p(m) ? r : l) = m;
    }
    return r;
}

vector<ll> solve(int n, int q, vector<ll> const & a, vector<ll> const & x) {
    vector<ll> acc(n + 1);
    partial_sum(ALL(a), acc.begin() + 1);
    vector<ll> acc_even(n + 1);
    REP (i, n) {
        acc_even[i + 1] = acc_even[i] + (i % 2 == 0 ? a[i] : 0);
    }

    vector<int> order(q);
    iota(ALL(order), 0);
    sort(ALL(order), [&](int i, int j) { return x[i] > x[j]; });

    auto get_l_r = [&](int k) {
        int l = max(0, n - 2 * k);
        int r = n - k;
        return make_pair(l, r);
    };
    auto pred = [&](ll x, int k) {
        int l, r; tie(l, r) = get_l_r(k);
        ll d = max(abs(a[l] - x), abs(a[r - 1] - x));
        if (l - 1 >= 0 and abs(a[l - 1] - x) <= d) return false;
        // if (r < n and abs(a[r] - x) < d) return false;
        return true;
    };

    vector<ll> answer(q);
    int k = 1;
// dump(n);
// dump(a);
    for (int i : order) {
        while (k < (n + 1) / 2 and not pred(x[i], k)) ++ k;
        int l, r; tie(l, r) = get_l_r(k);
        answer[i] = (acc[n] - acc[r]) + (n % 2 == 0 ? acc[l] - acc_even[l] : acc_even[l]);
// cerr << endl;
// dump(i);
// dump(x[i]);
// dump(k);
// dump(l);
// dump(r);
    }
    return answer;
}

int main() {
    int n, q; cin >> n >> q;
    vector<ll> a(n); REP (i, n) cin >> a[i];
    vector<ll> x(q); REP (i, q) cin >> x[i];
    for (ll y_i : solve(n, q, a, x)) {
        cout << y_i << endl;
    }
    return 0;
}


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

int main(){
	int n,a,b;
	cin>>n>>a>>b;
	if(n==2){
		cout<<"Borys"<<endl;
		return 0;
	}
	if(abs(a-b)%2==0){
		cout<<"Alice"<<endl;
	}else{
		cout<<"Borys"<<endl;
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <limits>
//auto std::numeric_limits<float>::infinity() { return __builtin_huge_valf(); }
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)

int main()
{
    string S;
    cin >> S;
    if (S == "hi" || S == "hihi" || S == "hihihi" || S == "hihihihi" || S == "hihihihihi")
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
#include <complex>
using namespace std;
int main()
{
    int a,b,sum;
    cin>>a>>b;
    sum=a*b;
    if(sum%2==0) cout<<"Even";
    else cout<<"Odd";
    system ("pause"); 
    return 0;
}

Measured memory_bytes: 504
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <string.h>
#include <unordered_map>
#include <set>
#include <vector>
#include <algorithm>
#include <limits.h>
#define MOD 1000000007
#define N 100010
using namespace std;
typedef long long ll;

int n;
int t[N], a[N];

void solve()
{
    if(n == 1){
        if(a[0] == t[0]){
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
        return;
    }
    long long ans = 0;
    vector<int> dp(n, INT_MAX);
    dp[0] = 1;
    for(int i = 1; i < n; ++ i){
        if(t[i] > t[i-1]){
            dp[i] = 1;
        }else{
            dp[i] = t[i];
        }
    }
    bool conf = false;
    if(a[n-1] > t[n-1]){
        cout << 0 << endl;
        return;
    }
    dp[n - 1] = 1;
    for(int i = n-2; i >= 0; -- i){
        if(a[i] > a[i + 1]){
            if(a[i] > t[i] || (dp[i] == 1 && a[i] != t[i])){
                conf = true;
                break;
            }else{
                dp[i] = 1;
            }
        }else{
            if(dp[i] == 1){
                if(a[i] < t[i]){
                    conf = true;
                    break;
                }
            }else{
                dp[i] = min(a[i], t[i]);
            }
        }
    }
    if(!conf){
        ans = 1;
        for(int i=0; i<n; ++i){
            ans *= dp[i];
            ans %= MOD;
        }
    }
    cout << ans << endl;
}

int main()
{
    while(cin >> n){
        for(int i=0; i<n; ++i){
            cin >> t[i];
        }
        for(int i=0; i<n; ++i){
            cin >> a[i];
        }
        solve();
    }
    return 0;
}


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

int main() {   
        int N,X;
        int L[127];
        cin >> N >> X;
        int ans = 1;
        int D = 0;
        for (int i = 0; i < N; i++){ 
                cin >> L[i];
                D += L[i];
                if(D<=X){
                        ans += 1;
                }               
        }               
        cout << ans << endl;
        return 0;
}       

Measured memory_bytes: 384
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val p = readLine()!!.split(' ').map { it.toInt() }
    (1 until n - 1)
            .filter { p.slice(it - 1..it + 1).sorted()[1] == p[it] }
            .count()
            .let { println(it) }
}


Measured memory_bytes: 38304
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N;cin >> N;
    int l,r;
    int ans = 0;
    REP(i,N){
        cin >> l >> r;
        ans += r-l+1;
    }
    cout << ans << endl;
    return 0;
}

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

main(){

  int n;
  scanf("%d",&n);
  int a[n];
  for(int i=0;i<n;++i)scanf("%d",&a[i]);

  sort(a,a+n);
  int ans=0;
  for(int i=0;i<n;++i){
    for(int j=i+1;j<n;++j){
      for(int k=j+1;k<n;++k){
        if(a[k]<a[i]+a[j])ans++;
      }
    }
  }
  printf("%d",ans);


}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N; 
 string S;
  cin >> N;
  cin >> S;
  int count = 0;
  for(int i=0; i < N-2;i++){
    if(S.at(i) == 'A' && S.at(i+1) == 'B' && S.at(i+2) == 'C')
      count ++;
  }
  cout << count << endl;
  
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
            string inp = Console.ReadLine();
            int i = 0;
            int len = inp.Length;
            for(i=0;i<len;i++)
            {
  
                if (char.IsUpper(inp,i))
                {
                    Console.Write(char.ToLower(inp[i]));
                }
                else if (char.IsLower(inp,i))
                {
                    Console.Write(char.ToUpper(inp[i]));
                }
                else
                {
                   Console.Write(inp[i]);

                }
            }
            Console.Write("\n");
    }
}


Measured memory_bytes: 9232
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    int h,w,q;
    cin >> h >> w;
    vector<string>x(h);
    vector<int> y (h,0);
    vector<int> z (w,0);
    for(int i=0;i<h;i++){
        cin >> x[i];
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(x[i][j]=='#'){
                y[i]+=1; //0 dame
                z[j]+=1;
            }
        }
    }
    for(int i=0;i<h;i++){
        if(y[i]>0){
            for(int j=0;j<w;j++){
                if(z[j]>0){
                    cout << x[i][j];
                }
            }
            cout << "\n";
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric> // accumulate
#include <queue>
#include <string>
#include <cmath> // sqrt
#include <map>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

ll dp[310][310][310]; // dp[グラフの長さ][通ったノードの個数][1と強連結なノードの個数]

int main() {
    int n, m;
    cin >> n >> m;

    dp[0][1][1] = 1;

    for (int i = 0; i < m; i++) {
        for (int j = 0; j <= n; j++) {
            for (int k = 0; k <= n; k++) {
                dp[i+1][j+1][k] += dp[i][j][k] * (n-j);
                dp[i+1][j+1][k] %= mod;

                dp[i+1][j][k] += dp[i][j][k] * (j-k);
                dp[i+1][j][k] %= mod;

                dp[i+1][j][j] += dp[i][j][k] * k;
                dp[i+1][j][j] %= mod;
            }
        }
    }

    cout << dp[m][n][n] << endl;
}

Measured memory_bytes: 226816
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;

struct edge {
    i64 from, to, cost;
    edge(i64 from, i64 to) : from(from), to(to), cost(1) {}
    edge(i64 from, i64 to, i64 cost) : from(from), to(to), cost(cost) {}
};
using Graph = vector<vector<edge>>;

constexpr i64 INF = std::numeric_limits<i64>::max();
constexpr i64 SINF = std::numeric_limits<i64>::max() / 10;
const i64 dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
//const i64 dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//const i64 dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//const i64 dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e : t) fill_v(e, v);
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

void solve(long long A, long long B, long long C){
    cout << max(0LL, C - (A - B)) << endl;
}

int main() {
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
M,D = [int(i) for i in input().split(" ")]
s = 0
for m in range(1,M+1):
    for d in range(20,(D+1)):
        d1 = d % 10
        d2 = d//10
        if d1 * d2 == m and d1 >= 2 and d2 >= 2:
            s+=1
print(s)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
typedef int ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll p,q,a,n;

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


ll dfs(ll p,ll q,ll nowa,ll nown,ll j) {
	if(p <= 0) {
		return p == 0;
	}
	if(nown >= n) {
		return 0;
	}
	if(q * (n - nown) < p * j) {
		return 0;
	}
	ll g = gcd(p,q);
	p /= g;
	q /= g;
	
	ll ret = 0;
	for(ll i = j;i * nowa <= a;i++) {
		ll l = q * i / gcd(q,i);

		ret += dfs((p * l / q) - (l / i),l,nowa * i,nown + 1,i);
	}
	return ret;
}


int main(){

	while(1) {
		cin >> p >> q >> a >> n;
		if(p == 0) {
			return 0;
		}
		cout << dfs(p,q,1,0,1) << endl;
	}

	return 0;
}



Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		if ((b <= c) || (d <= a)) {
			System.out.println(0);
		} else {
			if (a < c) {
				if (b < d) System.out.println(b - c);
				else System.out.println(d - c);
			} else {
				if (b < d) System.out.println(b - a);
				else System.out.println(d - a);
			}
		}
	}
}

Measured memory_bytes: 21844
fun main(args: Array<String>) {
  val (n, x) = listOfInt()
  val lList = listOfInt()
  var sum = 0
  var cnt = 1
  for (l in lList) {
    sum += l
    if (sum > x) break
    cnt++
  }
  println(cnt)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 212345;
int a[MAX_N];

ll solve(int N) {
  if (a[0] != 0) return -1;
  for (int i = 0; i + 1 < N; i++) {
    if (a[i+1] - a[i] >= 2) return -1;
  }
  ll res = 0;
  int cur = 0;
  for (int i = 1; i < N; i++) {
    if (a[i] == a[i-1] + 1) {
      cur = a[i];
    } else {
      res += cur;
      cur = a[i];
    }
  }
  res += cur;
  return res;
}
int main2() {
  int N = nextInt();
  REP(i, N) a[i] = nextInt();

  ll ans = solve(N);
  if (ans == -1) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
using namespace std;


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

    int length;
    if (s.size() % 2 == 0)
        length = s.size() - 2;
    else
        length = s.size() - 1;

    for (int i = length; i >= 2; i -= 2) {
        int cnt = i / 2;
        for (int j = 0; j < i / 2; j++) {
            if (s[j] == s[i/2 + j]) {
                cnt--;
            }
        }
        if (cnt == 0) {
            cout << i << endl;
            return 0;
        }
    }
	return 0;
}

Measured memory_bytes: 256
import math

a,b,h,m=map(int,input().split())
#m分の分針の角度
mk=m/60*360
mkx=b*math.sin(math.radians(mk))
mky=b*math.cos(math.radians(mk))

#h時m分の時針の角度
hk=h/12*360+m/60*360/12
hkx=a*math.sin(math.radians(hk))
hky=a*math.cos(math.radians(hk))

l=((mkx-hkx)**2+(mky-hky)**2)**0.5
print(l)

Measured memory_bytes: 62436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
 
bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
int n[5];
 
int main(){
    for(int i = 0; i < 4; i++)  cin >> n[i];

    bool flag[4];
    for(int i = 0; i < 4; i++)  flag[i] = false;
    for(int i = 0; i < 4; i++){
        if(n[i] == 1)   flag[0] = true;
        if(n[i] == 7 )  flag[1] = true;
        if(n[i] == 9)   flag[2] = true;
        if(n[i] == 4) flag[3] = true;
    }

    for(int i = 0; i < 4; i++){
        if(!flag[i]){
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

A_max = max(A)
A_min = min(A)

c = 1000
s = 0
p = 0

for i in range(N - 1):
    # 買い時判定
    if A[i] < A_max and A[i] < A[i + 1]:
        t = c // A[i]
        p = A[i]
        c -= A[i] * t
        s += t
        continue

    # 売り時判定
    if A[i] > A_min and p < A[i] and A[i] > A[i + 1]:
        c += A[i] * s
        s = 0
        p = 0
        continue

# 最終日
c += A[N - 1] * s
s = 0

print(c)


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

int main(){
  string S, T;
  cin >> S >> T;
  int ans =0;
  REP(i, (int)S.size()){
    if(S[i] != T[i]){
      ans++;
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3828
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

int main(){

  int n;
  while(cin>>n&&n!=0){
    map<string,int> score;
    set<string> time[100];
    for(int i = 0; i < n; i++){
      string name;
      cin>>name;
      score[name]=0;
      int t;
      cin>>t;
      for(int j = 0; j < t; j++){
	int d;
	cin>>d;
	time[d].insert(name);
      }
    }
    for(int i = 0; i < 100; i++){
      if(time[i].size()>0){
	int getScore=n+1-time[i].size();
	for(set<string>::iterator it = time[i].begin();it!=time[i].end();it++){
	  score[*it]+=getScore;
	}
      }
    }
    int minPoint=1000000000;
    string name;
    for(map<string,int>::iterator it=score.begin();it!=score.end();it++){
      if(minPoint>it->second){
	minPoint=min(minPoint,it->second);
	name=it->first;
      }
      else if(minPoint==it->second){
	name=min(name,it->first);
      }
    }
    cout<<minPoint<<" "<<name<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() { 
  int a;
  cin >>a;
  while(a>=10){
    a=a-10;
    }
  if(a==3){
    cout<<"bon"<<endl;
    }
  if(a==0||a==6||a==1||a==8){
    cout<<"pon"<<endl;
    }
  if(a==2||a==4||a==5||a==7||a==9){
    cout<<"hon"<<endl;
    }
  return 0;
  }



Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = new[] { 60, 80, 100, 120, 140, 160 };
			var w = new[] { 2, 5, 10, 15, 20, 25 };
			var p = new[] { 600, 800, 1000, 1200, 1400, 1600, 0 };

			var n = 0;
			while ((n = int.Parse(Console.ReadLine())) != 0)
			{
				var r = 0;
				while (n-- != 0)
				{
					var xyhw = Console.ReadLine().Split(' ').Select(j => int.Parse(j)).ToArray();
					int i;
					for (i = 0; i < 6; i++)
					{
						if (s[i] >= xyhw[0] + xyhw[1] + xyhw[2] && w[i] >= xyhw[3])
							break;
					}
					r += p[i];
				}
				Console.WriteLine(r);
			}
		}
	}
}

Measured memory_bytes: 6148
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,ans=1;
  cin>>n>>k;
  for(int i=0; i<n; i++){
    if(ans<k){
      ans*=2;
    }else{
      ans+=k;
    }
  }
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
// ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;
ll mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return * this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    cin >> n;
    vi d(n);
    rep(i,n) cin >> d.at(i);
    vi distance(n);
    rep(i,n) distance.at(d.at(i))++;
    if(distance.at(0)!=1 || d.at(0)!=0){
        cout << 0 << endl;
        return 0;
    }
    bool isEnd = false;
    for(ll i=1; i<n; i++){
        if(distance.at(i)==0){
            isEnd = true;
        }else{
            if(isEnd){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    mint res = 1;
    rep(i,n-1){
        if(distance.at(i)==0) break;
        mint tmp = distance.at(i);
        res *= tmp.pow(distance.at(i+1));
    }
    cout << res << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    int n, t[2], x[2], y[2];
    bool ans=true;
    t[0] = 0; x[0] = 0; y[0] = 0;
    cin >> n;
    for(int i=0; i<n; i++){
        if(i>0){
            t[0] = t[1]; x[0] = x[1]; y[0] = y[1];
        }
        cin >> t[1] >> x[1] >> y[1];
        int t2, x2, y2;
        t2 = t[1] - t[0];
        x2 = abs(x[1] - x[0]);
        y2 = abs(y[1] - y[0]);
        if(t2 < x2 + y2 || t2%2 != (x2 + y2)%2){
            ans = false;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256