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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
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;
}


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


///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    int H,W; cin >> H >> W;
    char grid[H][W];
    REP(i,H){
        REP(j,W){
            cin >> grid[i][j];
        }
    }

    REP(i,H){
        REP(j,W){
            if (grid[i][j] != '#') continue;
            int cnt = 0;
            REP(k,4){
                int x = i + dx[k];
                int y = j + dy[k];
                if (x < 0) continue;
                if (x >= H) continue;
                if (y < 0) continue;
                if (y >= W) continue;
                if (grid[x][y] == '#') cnt++;
            }
            if (cnt == 0){
                puts("No");
                return 0;
            }
        }
    }

    puts("Yes");
}

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

public class Main
{
	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);
 		
 		int i =fr.nextInt() ,j =fr.nextInt() ;	double a =i*i ,b =j*j ;
 		
 		int h =fr.nextInt() ,m =fr.nextInt() ;
 		double H =h*30.0 + (m*30.0)/60.0 ,M =m*6.0 ,ang =Math.abs (H-M);
 		//System.out.println(H) ;
 		
 		ang =Math.min(ang , 360.0-ang) ;	double rad =Math.PI/180.0 ;	rad *= ang ;
 		//System.out.println(Math.cos(rad)) ;
 		double c = a + b - (2.0*i*j*Math.cos(rad)) ;	c =Math.sqrt(c) ;
		op.println(c) ;	op.flush();	op.close();
	}
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br =new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st==null || (!st.hasMoreElements())) 
			{
				try
				{
					st =new StringTokenizer(br.readLine());
				}
				catch(IOException e)
				{
					e.printStackTrace();
				}
				
			}
			return st.nextToken();
		}

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next()) ;
		}
	}
}

Measured memory_bytes: 33304
import java.util.*;

public final class Main{

   public static void main(String ...args){
       Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();
       int R = sc.nextInt();
       int res = N >= 10 ? R : (R + ( 100 * ( 10 - N)));
       System.out.println(res);
   }
}

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

int main(){

  vector<int> vc;
  int n;

  while(cin >> n){
    if(n != 0){
    	vc.push_back(n);
    }
    else{
      cout << vc.back() << endl;
    	vc.pop_back();
    }
  }
  
  return 0;
}

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

int n, a;
vector<int> v;
int p[100010];

int main () {

	cin >> n;
	v.push_back(0);
	for (int i = 0; i < n; i ++) {
		cin >> a;
		v.push_back(a);
	}
	v.push_back(0);
	n += 2;
	for (int i = 1; i < n; i ++) {
		p[i] = p[i-1] + abs(v[i] - v[i-1]);
		//cout << p[i] << " ";
	}
	
	for (int i = 1; i < n-1; i ++) {
		//cout << p[i-1] << " " << p[n-1] - p[i] << "\n";
		cout << p[i-1] + (p[n-1] - p[i+1]) + abs(v[i-1] - v[i+1]) << "\n";
	}

	return 0;
}

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

const int maxV = 80 * 160;

int H,W;
int F[100][100] = {0};
bool dp[100][100][2*maxV] = {false};
int A,B;

int main(){
	cin >> H >> W;
	for(int i = 1; i <= H; i++){
		for(int j = 1; j <= W; j++){
			cin >> A;
			F[i][j] = A;
		}
	}
	for(int i = 1; i <= H; i++){
		for(int j = 1; j <= W; j++){
			cin >> B;
			F[i][j] = abs(F[i][j] - B);
		}
	}
	dp[0][1][0] = true;
	for(int i = 1; i <= H; i++){
		for(int j = 1; j <= W; j++){
			for(int k = 0; k < maxV+1; k++){
				int u1 = k + F[i][j];
				int u2 = abs(k - F[i][j]);

				if(dp[i-1][j][u1]){
					dp[i][j][k] = true;
				}
				if(dp[i-1][j][u2]){
					dp[i][j][k] = true;
				}
				if(dp[i][j-1][u1]){
					dp[i][j][k] = true;
				}
				if(dp[i][j-1][u2]){
					dp[i][j][k] = true;
				}
			}
		}
	}
	for(int i = 0; i < maxV; i++){
		if(dp[H][W][i]){
			cout << i << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 200960
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

int main() {

	int N, A, B;
	cin >> N >> A >> B;

	
	co(min(N*A, B));
	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	int k;
	cin >> k;
	string s;
	cin >> s;
	if (k >= s.size())
		cout << s << '\n';
	else
		cout << s.substr(0, k) << "...\n";
}


Measured memory_bytes: 3656
#include <string>
#include <iostream>
#include <vector>
using namespace std;

int solve() {
  vector<string> vs(3);
  cin >> vs[0];
  if(vs[0] == "0") return 1;
  cin >> vs[1] >> vs[2];

  for(int k=0; k<3; k++) {
    int N = vs[k].length();
    int sa = 0, sb = 0;
    for(int i=1; i<N; i++) {
      if(vs[k][i] == 'A') sa++;
      if(vs[k][i] == 'B') sb++;
    }
    if(k < 2) {
      if(vs[k+1][0] == 'A') sa++;
      if(vs[k+1][0] == 'B') sb++;
    }
    else {
      if(sa >= 10 and sb >= 10) {
        if(sa > sb) sa++;
        else sb++;
      }
      else {
        if(sa == 10) sa++;
        if(sb == 10) sb++;
      }
    }
    printf("%d %d\n", sa, sb);
  }
  return 0;
}

int main() {
  while(!solve());
}



Measured memory_bytes: 3260
"use strict"
// inputに入力データ全体が入る
function Main(input){
    console.log(input.split(" ").map(e=>+e).reduce((a, b)=>a*b-(a+b-1)));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#define REP(i, n) for(int i=0; i<(n); i++)
#define REPS(i, n) for(int i=0; i<=(n); i++)
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define FORS(i, a, b) for(int i=a; i<=(b); i++)
// for container x
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#pragma endregion

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

Measured memory_bytes: 3796
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))

def main():
    n = ni()
    d = na()

    ans = 0
    for i in range(n):
        for j in range(i+1, n):
            ans += d[i] * d[j]
    
    print(ans)

main()

Measured memory_bytes: 2940
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  # log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    N = I()
    a = LI()
    ans = a[0]
    for i in range(1,N):
        ans ^= a[i]
    ansl = []
    for i in a:
        ansl.append(i^ans)
    print(" ".join(map(str, ansl)))


if __name__ == '__main__':
    main()

Measured memory_bytes: 125368
n = int(input())
ans = list(input())
count = 0
a = set()
for i in range(n):
    if ans[i] == 'I':
        count += 1
        a.add(count)
    elif ans[i] == 'D':
        count -= 1
        a.add(count)

print(max(max(a), 0))

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

int main(){
    string s;
    cin>>s;
    bool flag = false;
    rep(i,s.size()){
        for(int j=i+1; j < s.size();j++){
            if(s[i]==s[j]){
                flag = true;
                break;
            }
        }
    }
    if(flag){
        cout<<"no"<<endl;
    }else{
        cout<<"yes"<<endl;
    }
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2, class T3> void add( T1 &x, T2 y, T3 m = MOD )
{
	x += y;
	if( x >= m )
		x -= m;
}

template<class T1, class T2, class T3> void sub( T1 &x, T2 y, T3 m = MOD )
{
	x -= y;
	if( x < 0 )
		x += m;
}

int main() 
{
	fastio();

	int n;
	cin>>n;
	vector<ll>a(n),b(n),diff(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
		diff[i] = a[i] - b[i];
	}

	// a[i] +2, b[j] +1, -> diff[i] +2, diff[j] -1
	ll decrease = 0, sum = 0;
	for(int i=0;i<n;i++)
	{
		if( diff[i] < 0 )
		{
			decrease += ( abs(diff[i])/2 );
		}
		else
		{
			sum += diff[i];
		}
	}

	if( decrease >= sum )
		cout<<"Yes";
	else
		cout<<"No";


	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}


Measured memory_bytes: 512
N=int(input())
H=list(map(int,input().split()))

dp=[0]*N

dp[1]=abs(H[0]-H[1])

for i in range(2,N):
    a,b=dp[i-1]+abs(H[i-1]-H[i]),dp[i-2]+abs(H[i-2]-H[i])
    if a<b:
        dp[i]+=a
    else:
        dp[i]+=b

print(dp[-1])



Measured memory_bytes: 13928
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int, int>
#define vpi vector<pi>
#define ff first
#define ss second
#define endl '\n'
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
 
#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);
}
#else
#define debug(...)
#endif
 
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
	for (int i = 0; i < v.size(); ++i)
		os << v[i] << " ";
	return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &v)
{
	for (auto it : v)
		os << it << " ";
	return os;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, const pair<T, S> &v)
{
	os << v.ff << " " << v.ss;
	return os;
}
 
const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;
 
const int N = 100005;
int n, k;
vi moves;
int dp[N][3];
int mini, maxi;
 
int winner = 1;
 
int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}
 
bool inrange(int x)
{
	if (x > mini && x < maxi)
		return true;
	return false;
}
 
bool solve(int n, int p)
{	
  	if (n<0) return 1;
	if (n < mini)
	{
		//return dp[n][p] = 0;
		return 0;
	}
	if (dp[n][p] != -1)
		return dp[n][p];
	
	for (int i = 0; i < moves.size(); i++)
	{
		if (n - moves[i] == 0)
		{
			return dp[n][p] = 1;
		}
		if (p == 1)
		{
			if (solve(n - moves[i], 2) == 0)
			{
				return dp[n][p] = 1;
			}
		}
		else if (p == 2)
		{
			if (solve(n - moves[i], 1) == 0)
			{
				return dp[n][p] = 1;
			}
		}
	}
	return dp[n][p] = 0;
}
 
signed main()
{
 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
#ifdef __APPLE__
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
 
	time_t t1, t2;
	t1 = clock();
 
	cin >> n >> k;
	memset(dp, -1, sizeof(dp));
	mini = inf;
	maxi = -1;
 
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		moves.pb(x);
		mini = min(mini, x);
		maxi = max(maxi, x);
	}
 
	if (solve(k, 1))
	{
		cout << "First" << endl;
	}
	else
		cout << "Second" << endl;
 
	t2 = clock();
	cerr << endl
		 << t2 - t1 << endl;
 
	return 0;
}

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

typedef long long ll;

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

  vector<ll> h(N);
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }

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

  ll ans = 1e9;
  for (int i = 0; i + K -1 < N; i++) {
    ans = min(ans, h[i + K - 1] - h[i]);
  }

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

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

int main() {
  int a[5];
  for (int i = 0; i < 5; i++) {
    cin >> a[i];
  }
  int k;
  cin >> k;
  bool flag = true;
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 5; j++) {
      if (i == j) {
        continue;
      }
      if (abs(a[i] - a[j]) > k) {
        flag = false;
      }
    }
  }
  if (!flag) {
    cout << ":(" << endl;
  }
  else {
    cout << "Yay!" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();
    let x: u32 = read();

    let m: Vec<u32> = (0..n).map(|_| read()).collect();

    let min = m.iter().min().unwrap();
    let sum = m.iter().sum::<u32>();
    let ans = (x - sum) / min + n;

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	int n;
	cin >> n;
	int c = 0;
	for(int i = 1; i <= n; i ++)
	{
		int x;
		cin >> x;
		if(i % 2 == 1 && x % 2 == 1)
			c ++;
	}
	cout << c;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 3616
import * as fs from "fs";

const MOD: number = 1e9 + 7;

const input = fs.readFileSync("/dev/stdin", "utf8");

let s: string = input;
let sum: number = 0;
for (let i = 0; i < s.length; i++) {
    sum += +s[i];
}

let ans = sum % 9 ? "No" : "Yes";
console.log(ans);


Measured memory_bytes: 32620
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>

using namespace std;

int main(){
  char s[100000] = "";
  int count[26] = {};
  cin >> s;
  for (int i=0;i<strlen(s);i++) {
    count[(int)s[i]-97] = 1;
  }
  for (int i=0;i<26;i++) {
    if (count[i]==0) {
      cout << (char)(i+97) << endl;
      return(0);
    }
  }
  cout << "None" << endl;
  return(0);
}


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

    long double a,b,n;
    cin>>a>>b>>n;
    long long x;
    if(n<b)x = n;
    else x = b-1;
    long long ans = floor(a*x/b)-a*floor(x/b);
    cout<<ans<<endl;

    return 0;
}



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

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

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

	stack<int> st;
	queue<int> ans;

	int v;
	while (cin >> v) {
		if (v == 0) {
			ans.push(st.top());
			st.pop();
		} else {
			st.push(v);
		}
	}

	if (ans.empty()) {
		cout << 0 << endl;
	} else {
		while (!ans.empty()) {
			cout << ans.front() << endl;
			ans.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 2988
import collections
import itertools

n = int(input())
word = [input() for i in range(n)]
counter = collections.Counter(word)
rank_word = counter.most_common()
most_common = rank_word[0][1]
most_common_lst = [i[0] for i in rank_word if i[1] == most_common]
lst = sorted(most_common_lst)
for i in lst:
    print(i)

Measured memory_bytes: 49152
while True:
    n,k=map(int,input().split())
    if n==0 and k==0:
        break
    a=[]
    for i in range (n):
        a.append(int(input()))
        c=0
    for i in range(k):
        c+=a[i]
        b=c
    for i in range(k,n):
        c+=a[i]
        c-=a[i - k]
        b=max(b,c)
    print(b)



Measured memory_bytes: 9608
// vim: set fdm=marker:
// {{{
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <utility>

using namespace std ;

typedef long long ll ;

// }}}

char A[222222];

int stat[222];


int main()
{
    cin >> A;
    int len = strlen(A);
    ll ans = 0 ;
    for(int i = 0 ; i != len ; i++) {
        ans += i - stat[A[i]];
        stat[A[i]]++;
    }
    cout << ans+1 << endl ;
    return 0;
}



Measured memory_bytes: 384
W,H,N=map(int,input().split())
xya=[list(map(int,input().split())) for i in range(N)]
X=[0,W]
Y=[0,H]
for i in range(N):
    if xya[i][2]==1:
        X[0]=max(xya[i][0],X[0])
    if xya[i][2]==2:
        X[1]=min(xya[i][0],X[1])
    if xya[i][2]==3:
        Y[0]=max(xya[i][1],Y[0])
    if xya[i][2]==4:
        Y[1]=min(xya[i][1],Y[1])
if X[0] >= X[1] or Y[0] >= Y[1]:
    print(0)
else:
    print((X[1]-X[0]) * (Y[1]-Y[0]))

Measured memory_bytes: 3064
// nlather (Nishant Raj Lather)
// Chrollo_Lucifer

/* ------------------------------ TEMPLATE BEGIN ------------------------------ */

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

/* ----------------- ORDERED SET (POLICY BASED DS) ----------------- */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree
    <T, null_type, less<T>, rb_tree_tag, 
    tree_order_statistics_node_update>;

/* -------------- BETTER RANDOM (RAND() IS DANGEROUS) -------------- */
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)

/* ----------------- CUSTOM HASH FUNCTION FOR UMAP ----------------- */
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = 
            chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

/* ----------------------- DEBUGGING UTILITY ----------------------- */
#define cerr cout
void _print() {cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v) {
    cerr << t; if(sizeof...(v)) cerr << ", "; _print(v...);
}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define rep(i, x, n) for (ll i = (ll)(x); i < (ll)(n); i++)
#define rrep(i, x, n) for (ll i = (ll)(x); i >= (ll)(n); i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define bs binary_search
#define minSelf(a, b) a = min(a, b)
#define maxSelf(a, b) a = max(a, b)
#define mem(arr, x) memset(arr, x, sizeof(arr))
using ll = long long int;
using ld = long double;
template <typename T, typename V> using P = pair<T, V>;
template <typename T> using V = vector<T>;
const ll MOD = 998244353;
const ll INF = 0x3f3f3f3f; // ~1e9 (1061109567)
const ld PI = 3.1415926535897932384626;
const ld EPS = 1e-9;
#define endl '\n' // REMOVE FOR INTERACTIVE TASKS
const ll MAX = 3e5+5;

/* ------------------------------- TEMPLATE END ------------------------------- */

bool check(string s) {
    rep(i, 0, s.size()/2) 
        if(s[i] != s[s.size()-i-1])
            return 0;
    return 1;
}

void solve() {
    string s;
    cin >> s;
    if(check(s) && check(s.substr(0, s.size()/2))) cout << "Yes\n";
    else cout << "No\n";
}

int main() {
    boost
    ll t = 1;
    // cin >> t;
    while(t--) solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int field[11][11];
int land[20];
pair<int,int> place[20];

int w,h,n;
bool ok;

struct landInfo{
	int minx;
	int miny;
	int maxy;
	int maxx;
};

landInfo mem[20];
landInfo fin[20];

bool no=false;

void dfs(int num,int sum){
	if(no)
		return;
	if(num==n+1){
		if(sum==h*w){
			if(ok)
				no=true;
			else{
				ok=true;
				for(int i = 1; i < num; i++)
					fin[i]=mem[i];
			}
		}
		return;
	}
	else{
		// ßûð·×ÄµÄÝé
		for(int i = 1; i <= land[num]; i++){
			if(land[num]%i!=0)
				continue;
			int tate=i;
			int yoko=land[num]/i;
			// Ç±É»ÝÌynÌÔÌÊuðÁÄ­é©
			for(int j = 0; j < tate; j++){
				for(int k = 0; k < yoko; k++){
					// ÍÝoÄÈ¯êÎAßé
					int minx=place[num].second-k;
					int miny=place[num].first-j;
					int maxx=minx+yoko-1;
					int maxy=miny+tate-1;
					if(minx>=0&&miny>=0&&minx<w&&miny<h&&maxx>=0&&maxy>=0&&maxx<w&&maxy<h){
						// àµ¼ÌynÌÍÍÆðíÁÄ¢È¯êÎ
						bool f=false;
						for(int l = 1; l < num; l++){
							if(!((maxx<mem[l].minx||maxy<mem[l].miny)||(minx>mem[l].maxx||miny>mem[l].maxy))){
								f=true;
								break;
							}
						}
						if(!f){
							landInfo li;
							mem[num].minx=minx;
							mem[num].maxx=maxx;
							mem[num].miny=miny;
							mem[num].maxy=maxy;
							dfs(num+1,sum+land[num]);
							if(no)
								return;
						}
					}
				}
			}
		}
	}
}

int main(){
	while(cin>>w>>h>>n&&!(w==0&&h==0&&n==0)){
		ok=false;
		no=false;
		int b,k;
		for(int i = 0; i < n; i++){
			cin>>b>>k;
			land[b]=k;
		}
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin>>field[i][j];
				if(field[i][j]!=0){
					place[field[i][j]].first=i;
					place[field[i][j]].second=j;
				}
			}
		}
		// ÔÉynðßÄ¢­
		dfs(1,0);
		if(ok&&!no){
			for(int i = 1; i <= n; i++)
				for(int j = fin[i].miny; j <= fin[i].maxy; j++)
					for(int k = fin[i].minx; k <= fin[i].maxx; k++)
						field[j][k]=i;
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					cout<<field[i][j];
					if(j!=w-1)
						cout<<" ";
				}
				cout<<endl;
			}
		}
		else
			cout<<"NA"<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}

int main() {
  int n;
  cin>>n;
  vi a(n);
  rep(i,n) cin>>a[i];
  sort(all(a));
  cout<<a[n-1]-a[0]<<endl;
}


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

int main() {
  int n;
  cin>>n;
  vector<pair<string,int>>a(n);
  int sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i].first>>a[i].second;
    sum+=a[i].second;
  }
  string x;
  cin>>x;
  int ans=0;
  for(int i=0;i<n;i++){
    ans+=a[i].second;
    if(x==a[i].first) break;
  }
  cout<<sum-ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using ll=long long;
using namespace std;
const auto mod=1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int a,b,c;cin >> a >>b >>c;
  string ans="win";
  if(a+b+c>=22) ans="bust";  
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = in.nextInt(); // Scanner has functions to read ints, longs, strings, chars, etc.
        int m = in.nextInt();
        in.nextLine();

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        System.out.println(getMax(arr, m));
    }

    private static int getMax(int[] arr, int m) {
        Arrays.sort(arr);
        long sum = 0;
        int mod = 1000000007;
        int l = arr.length;
        long base = 1;

        for (int i = 0; i <= l - m; i++) {
            //System.out.println(arr[m + i - 1] + " " + arr[l - m - i] + " " + base);
            sum = (sum + base * arr[m + i - 1] - base * arr[l - m - i]) % mod;
            base = (base * (m + i) % mod) * ((getInverseMod(i + 1, mod)[0] + mod) % mod) % mod;
        }

        return (int) ((sum + mod) % mod);
    }

    private static long[] getInverseMod(int i, int mod) {
        if (mod == 0) {
            return new long[]{1, 0};
        }
        long[] temp = getInverseMod(mod, i  % mod);
        return new long[]{temp[1], temp[0] - i / mod * temp[1]};
    }
}


Measured memory_bytes: 60588
""" tutorial02
    https://atcoder.jp/contests/abc106/tasks/abc106_b
"""
import sys
import math

def f(n):
    count = 0
    for j in range(1, int(math.sqrt(n)+1)):
        if n % j == 0:
            count = count + (2 if n / j != j else 1)
            if count > 8:
                break

    return count

def main(n):
    """ main
    """
    result = 0

    for i in range(1, n+1):
        if i % 2 == 1 and 8 == f(i):
            result = result + 1

    return result

if __name__ == "__main__":
    N = int(sys.stdin.readline())

    print(main(N))

Measured memory_bytes: 9164
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
// #define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

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

	int n;
  cin>>n;n--;
  	vi a(n);
  cin>>a;
  int t=a[0]+a[n-1];
  rep(i,n-1)t+=min(a[i],a[i+1]);
  cout<<t<<endl;
}


Measured memory_bytes: 256
S = list(map(int, input()))

if 0<S[0]*10+S[1]<=12 and 0<S[2]*10+S[3]<=12:
    print('AMBIGUOUS')
elif 0<S[0]*10+S[1]<=12:
    print('MMYY')
elif 0<S[2]*10+S[3]<=12:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#define LEN 100001

int head, tail;
typedef struct pp{
	char name[100];
	int t;
} p;
p Quene[LEN];

void enquene(p x){
	Quene[tail] = x;
	tail = (tail + 1) % LEN;
}
p dequene(){
	p x = Quene[head];
	head = (head + 1) % LEN;
	return x;
}
int min(int a, int b){
	if (a < b){
		return a;
	}else{
		return b;
	}
}
int main() {
	int n, q;
	int sumtime = 0, c;
	p u;
	scanf("%d %d", &n, &q);
	head = 0;
	tail = n;
	int i;
	for(i = 0; i<n; i++){
		scanf("%s", Quene[i].name);
		scanf("%d", &Quene[i].t);
	}
	while (head != tail) {
		u = dequene();
		c = min(q, u.t);
		u.t -= c;
		sumtime += c;
		if (u.t > 0) {
			enquene(u);
		}else {
			printf("%s %d\n", u.name, sumtime);
		}
	}
	return 0;
}

Measured memory_bytes: 10756
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int,int>;
vvint to;
vint ans;

void dfs(int v,int p = -1){
  for(int u: to[v]){
    if(u == p) continue;
    ans[u] += ans[v];
    dfs(u,v);
  }
}

signed main(){
  int n,q;
  cin >> n >> q;
  to.resize(n);
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans.resize(n);

  rep(i,q){
    int p,x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }

  dfs(0);

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

Measured memory_bytes: 24320
main=do
 n<-readLn
 print$(`mod`1000000007)$product[1+sum[f q p|q<-[1..n]]|p<-[2..n],all((/=0).(p`mod`))[2..p-1]]
f n x
 |n`mod`x==0=1+f(n`div`x)x
 |otherwise=0

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,C,K;
    cin >> N >> C >> K;
    vector<int>T(N);
    for (int i = 0; i < N; i++) {
        cin >> T.at(i);
    }
    sort(T.begin(), T.end());

    int count = 0;
    int icount = 0;

    if (C == 1){
        cout << N << endl;
        return 0;
    }

    for (int i = 0; i < N; i++) {
        if (i == N-1){
            count++;
        }
        for (int j = 1; j < min(C,N-i); j++) {
            if (T.at(i) + K >= T.at(i+j)){
                icount++;
                if (j == min(C,N-i)-1){
                    count++;
                    i += icount;
                    icount = 0;
                }
            }
            else {
                count++;
                i += icount;
                icount = 0;
                break;
            }
        }
    }
    cout << count << endl;
}

        




Measured memory_bytes: 3732
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        double[] probs = new double[n];
        for(int i = 0 ; i < n ; i++) {
            probs[i] = scan.nextDouble();
        }

        double[] dp = new double[n+1];
        dp[0] = 1; // probability of 0 heads is one when there is no coin toss - Obvious. 
            // intuition : cumulative probability of current num of heads is = 
            //             probability of current head * probability of head-1 times 
            //             + probability of current tail * probability of head times.
            //Also as soon as one more coin toss gets added to the set - we have to 
            //compute all the cumulative probabilities again as they must have changed as well with this 
            // new member in the set.

        for(int toss = 0 ; toss < n ; toss++){
            for(int heads = toss+1 ; heads >= 0 ; heads--) {
                if(heads > 0 ) {
                    dp[heads] =  dp[heads-1] * probs[toss] +  dp[heads] * (1-probs[toss]);
                } else {
                    dp[heads] = dp[heads]*(1-probs[toss]); // 0 heads so only tails to work.
                }
            }
        }

        // now count the probabilities when heads are more.
        double answer = 0.0;
        for(int i = n ; i > n/2 ; i--) {
            answer += dp[i];
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 36044
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

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

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

// Make Combination table using "Pascal's Triangle" at Compile-Time
template<size_t N> struct CombTable { // {{{
    static_assert(N < 70u, "Template parameter <N> is too large. It may be Overflow.");
    i64 mat[N+1][N+1];
    constexpr explicit CombTable() {
        for (int n = 0; n <= N; ++n) {
            for (int r = 0; r <= n; ++r) {
                mat[n][r] = ((r == 0 || n == r) ? (1) : (mat[n-1][r-1] + mat[n-1][r]));
            }
        }
    }
    i64 operator() (int n, int r) const { return (r < 0 || n < r) ? 0 : mat[n][r]; }
}; // }}}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    CombTable<60> comb;

    var(int, N);
    vector<int> cnt(128);

    rep(i, 0, N) {
        var(string, s);
        cnt[s.front()] += 1;
    }

    i64 hoge[10] {};

    hoge[0] = cnt['M'];
    hoge[1] = cnt['A'];
    hoge[2] = cnt['R'];
    hoge[3] = cnt['C'];
    hoge[4] = cnt['H'];

    i64 ans = 0;
    rep(i, 0, 5) rep(j, i+1, 5) rep(k, j+1, 5) {
        ans += (hoge[i] * hoge[j] * hoge[k]);
    }
    print(ans);

    return 0;
}


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

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

Measured memory_bytes: 256
x, n = gets.chomp.split.map(&:to_i)
arr = gets.chomp.split.map(&:to_i)

cnt = 0
left = 1
loop do
	now = x + cnt * left 
	if arr.index(now) == nil then
		puts now 
		exit
	end
	cnt += 1 if left == 1
	left *= -1
end




Measured memory_bytes: 14392
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<iomanip>
#include<map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = 1e9 + 7;
int dx[8] = { 1,0,-1,0,1,1,-1,-1 };
int dy[8] = { 0,1,0,-1,1,-1,1,-1 };





int main() {

	int n;
	cin >> n;
	vector <int> a(n);

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

	int maxi = 0;
	int num = 0;

	for (int i = 0; i < n; i++) {
		if (maxi < a[i]) {
			maxi = a[i];
			num = i;
		}
	}

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


	int maxi2 = a[n - 2];

	for (int i = 0; i < n; i++) {
		if (i == num) {
			cout << maxi2 << endl;
		}
		else {
			cout << maxi << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 2432
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
ans=0
for i in range(n-1,-1,-1):
    a=ab[i][0]
    b=ab[i][1]
    t=(ans+a)%b
    if t!=0:
        ans=ans+(b-t)
print(ans)

Measured memory_bytes: 27380
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
const int maxn = 100005;
int N, a[maxn], b[maxn];
bool check() {
	static int A[maxn], B[maxn];
	memcpy(A, a, sizeof A);
	memcpy(B, b, sizeof B);
	sort(A+1, A+N+1);
	sort(B+1, B+N+1);
	for(int i=1; i<=N; ++i) if(A[i]!=B[i]) return false;
	int n = unique(A+1, A+N+1)-A-1;
	for(int i=1; i<=N; ++i)
		a[i] = lower_bound(A+1, A+n+1, a[i])-A;
	for(int i=1; i<=N; ++i)
		b[i] = lower_bound(A+1, A+n+1, b[i])-A;
	return true;
}
vector<int> v[maxn];
int vis[maxn];
void dfs(int x) {
	vis[x] = 1;
	vector<int> &t = v[b[x]];
	for(int i=0; i<(int)t.size(); ++i) 
		if(!vis[t[i]]) dfs(t[i]);
}
int main() {
	scanf("%d", &N);
	for(int i=1; i<=N; ++i) scanf("%d", a+i), a[N+1] ^= a[i];
	for(int i=1; i<=N; ++i) scanf("%d", b+i), b[N+1] ^= b[i];
	++N;
	if(!check()) {
		puts("-1");	return 0;
	}
	int ans = 0;
	for(int i=1; i<N; ++i) ans += a[i]!=b[i];
	++ans;
	for(int i=1; i<=N; ++i) 
		if(a[i]!=b[i] or i==N) v[a[i]].push_back(i);
	for(int i=1; i<=N; ++i) 
		if((a[i]!=b[i] or i==N) && !vis[i]) ++ans, dfs(i);
	printf("%d\n", ans-2);
	return 0;
}

Measured memory_bytes: 12288
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20190304_04 {
    class Program {
        static void Main(string[] args) {
            var line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var a = line[0];
            var b = line[1];
            var k = line[2];
            var count = 0;
            for (int i = Math.Min(a, b); i > 0; i--)  {
                if (a % i == 0 && b % i == 0) {
                    count++;
                    if (count == k) {
                        Console.WriteLine(i);
                        return;
                    }
                }
            }
        }
    }
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n;
  scanf("%d",&n);
  vector<int> is(1000010,0);
  vector<int> v(n);
  rep(i,n)scanf("%d",&v[i]),is[v[i]]++;
  ll res = 0;
  rep(i,n){
    bool ok = (is[1] < 1 && is[v[i]] <= 1) || (v[i] == 1 && is[1] <= 1);
    for(ll j = 2;j*j <= v[i];j++){
      if((v[i]%j) != 0)continue;
      if(is[j] >= 1 || is[v[i]/j] >= 1){
        ok = false;
        break;
      }
    }
    if(ok)res++;
  }
  cout << res << endl;

  




  return 0;
}

Measured memory_bytes: 8044
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 3e18+7
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i,N) cin >> A[i];


    bool flg = true;
    int ans = 0;
    for(int i=0;i<N;i++){
        while(i+1<N && A[i]==A[i+1]) ++i;

        if(i+1<N && A[i]<A[i+1]){
            while(i+1 < N && A[i] <= A[i+1]) ++i;
        }
        else if(i+1 < N && A[i] > A[i+1]){
            while(i+1 < N && A[i] >= A[i+1]) ++i;
        }
        ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640