akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
    while (true){
        int x,y;
        char op;
        cin >> x >> op >> y;
        if(op == '?') break;
        else if(op == '+') cout << x+y << endl;
        else if(op == '-') cout << x-y << endl;
        else if(op == '*') cout << x*y << endl;
        else if(op == '/') cout << x/y << endl;
    }
}


Measured memory_bytes: 3080
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int h1=sc.nextInt();
    int m1=sc.nextInt();

    int h2=sc.nextInt();
    int m2=sc.nextInt();

    int k=sc.nextInt();


    if((h2-h1)*60+(m2-m1)-k>=0){
      System.out.println((h2-h1)*60+(m2-m1)-k);
    }else{
      System.out.println(0);
    }

  }
}


Measured memory_bytes: 27000
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
    int n;
    cin >> n;
    vector<ll> h(n+2, INF);
    rep(i, n) cin >> h[i];
    vector<ll> dp(n+2, INF);
    dp[0] = 0;
    rep(i, n){
        chmin(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
        chmin(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
    }
    cout << dp[n-1] << endl;
    return 0;
}


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

int main()
{
    int i = 0, j = 0, k = 0, l, m, n;
    int ja = 0, jb = 0, jc = 0, key = 1, judge = 0;
    string sa, sb, sc;
    
    cin >> sa >> sb >> sc;
    
    l = sa.size();
    m = sb.size();
    n = sc.size();
    
    do {
        if(key == 1) {
            if(ja == 1) {
                judge = 1;
                
            } else {
                
                if(sa[i] == 'b') {
                    key = 2;
                } else if(sa[i] == 'c') {
                    key = 3;
                }
                
                i++;
                if(i == l) {
                    ja = 1;
                }
            }
            
        } else if(key == 2) {
            if(jb == 1) {
                judge = 1;
                
            } else {
                
                if(sb[j] == 'a') {
                    key = 1;
                } else if(sb[j] == 'c') {
                    key = 3;
                }
                
                j++;
                if(j == m) {
                    jb = 1;
                }
            }
            
        } else {
            if(jc == 1) {
                judge = 1;
                
            } else {
                
                if(sc[k] == 'a') {
                    key = 1;
                } else if(sc[k] == 'b') {
                    key = 2;
                }
                
                k++;
                if(k == n) {
                    jc = 1;
                }
            }
        }
        
    } while(judge == 0);
    
    if(key == 1) {
        cout << "A\n";
    } else if(key == 2) {
        cout << "B\n";
    } else {
        cout << "C\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
from math import gcd


def lcm(a, b):
    return a * b // gcd(a, b)


def total(x):
    return x * (n // x) * (n // x + 1) // 2


n = int(input())
# a, b = map(int, input().split())
a, b = 3, 5

print(total(1) - total(a) - total(b) + total(lcm(a, b)))


Measured memory_bytes: 9180
import java.io.PrintWriter;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<String, Integer> map = new TreeMap<>();
		int max = 0;
		for (int i = 0; i < n; i++) {
			String s = sc.next();
			int val = map.containsKey(s) ? map.get(s) + 1 : 1;
			map.put(s, val);
			max = Math.max(max, val);
		}
		PrintWriter out = new PrintWriter(System.out);
		for (String key : map.keySet()) {
			if (map.get(key) == max) {
				out.println(key);
			}
		}
		out.flush();
	}
}

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

const int 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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};

istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

// combination
mint choose(int n, int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x / y;
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

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

    mint ans = 0;
    mint l = m;

    combination Comb(n);

    rep(i, k+1) {
      mint comb = Comb(n-1,n-1-i) * l * ((l-1).pow(n-1-i));
      ans += comb;
    }

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

Measured memory_bytes: 6372
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
const long long MOD = 1000000007;

void solve(long long N, long long K){
    ll ans = 0;
    for(ll X = K; X <= N+1; X++){
        ans = (ans +  X * (N - X + 1) + 1)% MOD;
    }
    cout<<ans<<endl;
}

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


Measured memory_bytes: 3684
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N,C = inpl()
datas = [[] for i in range(C)]
Times = set()
for _ in range(N):
	s,t,n = inpl()
	datas[n-1].append([s,t])
	Times.add(s-0.5)
	Times.add(t)

dataset = []
for c in range(C):
	data = sorted(datas[c])
	if len(data) == 0: continue
	bs,bt = data[0]
	for i in range(1,len(data)):
		s,t = data[i]
		if bt == s:
			#Times.remove(s-0.5)
			s = bs
		else:
			dataset.append([bs-0.5,bt])
		bs,bt = s,t
	dataset.append([bs-0.5,bt])

ddT = defaultdict(int)
for i,t in enumerate(sorted(list(Times))):
	ddT[t] = i
	
L = len(Times)
imos = [0]*L
for s,t in dataset:
	s,t = ddT[s],ddT[t]
	imos[s] += 1
	imos[t] -= 1

tmp = 0
ans = 0
for i in range(L):
	tmp += imos[i]
	ans = max(tmp,ans)

print(ans)


Measured memory_bytes: 64220
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define per(i,x,y) for (int i=(x); i>=(y); i--)
#define ll long long
#define ld long double
#define inf 1000000000
#define INF 1000000000000000000ll
#define pii pair<int,int>
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define sqr(x) ((x)*(x))
#define y1 y1_
#define cmin(x,y) (x)=(y)<(x)?(y):(x)
#define cmax(x,y) (x)=(y)>(x)?(y):(x)
#define mset(x,y) memset((x),(y),sizeof(x))
#define mcpy(x,y) memcpy((x),(y),sizeof(y))
using namespace std;
#define int ll
const ld pi=acos(-1);
const ld eps=1e-8;
//////////////////////// header files ////////////////////////
ll read(){
	char ch=getchar(); ll x=0; int op=1;
	for (; !isdigit(ch); ch=getchar()) if (ch=='-') op=-1;
	for (; isdigit(ch); ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
void write(ll a){
	if (a<0) putchar('-'),a=-a;
	if (a>=10) write(a/10); putchar(a%10+'0');
}
////////////////////////// fast i/o //////////////////////////
#ifdef mod
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x%mod) if (p&1) ret=ret*x%mod;
	return ret;
}
ll get_inv(ll x){
	return ksm(x,mod-2);
}
#else
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x) if (p&1) ret=ret*x;
	return ret;
}
#endif
//////////////////////////// qpow ////////////////////////////
void solve(){
	ll a=read(),b=read(),c,ans;
	if (a>b) swap(a,b);
	if (a==1 && b==1){ cout<<0<<endl; return; }
	//if (a==2 && b==2){ cout<<1<<endl; return; }
	c=a*b; c=sqrt(c); if (c*c>=a*b) c--;
	ans=c*2; if (c*(c+1)>=a*b) ans--;
	if (c>=a) ans--;
	cout<<ans<<endl;
}
//#define local
signed main(){
#ifdef local
	freopen("test.in","r",stdin); freopen("test.out","w",stdout);
#endif
	int T=read(); while (T--) solve();
	return 0;
}
// sample data:
/*

*/

// rest:
/*

*/

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
 
#define REP(i,b,n) for(int i=b;i<n;++i)
#define REPR(i,b,n) for(int i=n-1;i>=b;--i)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PI acos(-1.0)

#define LIM 1000010

using namespace std;

static const double EPS = 1e-9;
typedef pair<int, int> pii;
typedef long long ll;

int dist_fl[] = {9, 24, 3, 15, 10, 17, 8};
vector<string> surf(8);

char solve(){

	int cnt = 0, dist = 0;
	
	for(int i=0; i < 8; ++i){
		for(int j=0; j<8; ++j){
			
			if(cnt!=0)
				dist++;
			
			if(surf[i][j]=='1')
				cnt++;
			
			if(cnt==4){
				for(int k=0; k<7; ++k){
					if(dist_fl[k]==dist)
						return (char)('A'+k);
				}
			}
		}
	}
}

int main(){
		
	while(cin>>surf[0]>>surf[1]>>surf[2]>>surf[3]
				>>surf[4]>>surf[5]>>surf[6]>>surf[7], !cin.eof()){
		
		cin.ignore();
		cout << solve() << endl;
	}
	
	return 0;
}
		

Measured memory_bytes: 1184
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		System.out.println(s.substring(0, 1)+(s.length()-2)+s.substring(s.length()-1, s.length()));
	}
}


Measured memory_bytes: 21588
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;
int ina[5000][5000];
int main()
{
	string s;
	cin >> s;
	int k;
	cin >> k;
	for (int i = 0; i < 5000; i++) {
		for (int j = 0; j < 5000; j++) {
			ina[i][j] = -1;
		}
	}
	for (int i = 0; i < s.size(); i++) {
		int a = s[i] - 'a';
		for (int j = 0; j <= i; j++) {
			ina[j][i - j] = a;
		}
	}
	int nk = 0;
	string chd[5];
	bool inaB[5000] = { false };
	int inayoC = 0;
	while (true) {
		int miv = 26, mip;
		for (int i = 0; i < s.size(); i++) {
			if (ina[i][0] < miv&&!inaB[i]) {
				miv = ina[i][0];
				mip = i;
			}
			else if (ina[i][0] == miv&&!inaB[i]) {
				int df = 1;
				while (ina[i][df] == ina[mip][df]) {
					df++;
				}
				if (ina[i][df] < ina[mip][df]) {
					miv = ina[i][0];
					mip = i;
				}
			}
		}
		inaB[mip] = true;
		//cout << "mip:" << mip << endl;
		//ここまでで頭文字の最小値
		int rop = 0;
		while (ina[mip][rop] != -1) {
			rop++;
		}
		//cout << "rop:" << rop << "mip:" << mip << endl;
		int inayoD = 0;
		int inayoE = 0;
		while(true) {
			int i = nk;
			string l;
			//cout << "inayoE:" << inayoE << endl;
			if (inayoE >= rop) {
				//cout << "breaked" << endl;
				break;
			}
			for (int j = 0; j <= inayoE; j++) {
				l += ((char)(ina[mip][j])+'a');
			}
			//cout << l << endl;
			bool f = false;
			for (int j = 0; j < i; j++) {
				if (l == chd[j]) {
					f = true;
					break;
				}
			}
			if (!f) {
				chd[i] = l;
				nk++;
				if (nk == k) {
					cout << l << endl;
					return 0;
				}

			}
			inayoD++;
			//if (inayoD > 15) break;
			inayoE++;
		}
		inayoC++;
		//if (inayoC > 30) break;
	}
    return 0;
}



Measured memory_bytes: 97920
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

long long comb(int n, int r) {
  vector<vector<long long>> v(n + 1,vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v[n][r];
}

int main(){
    int n;
    long long cnt;
    map<string,long long> dic;
    vector<string> s;
    cin>>n;
    s.resize(n);
    cnt=0;

    for(int i=0; i<n; i++){
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
        if(dic.find(s[i])==dic.end()){
            dic[s[i]]=1;
        }else{
            cnt+=dic[s[i]];
            dic[s[i]]++;
        }
    }

    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 18176
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		long[]A = new long[N];
		string[] str = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			A[i] = long.Parse(str[i]);
		}
		long[]B = new long[N];
		long a1;
		long c = 1;
		long x = 0;
		bool flag = true;
		if(N%2==1){
		for(var i=1;i<N-1;i=i+2){
			a1 = B[i-1];
			c = 1;
			x = 0;
			for(var j=0;j<=40;j++){
				long b1 = a1/c%2;
				long b2 = A[i]/c%2;
				if((b1+b2)%2==1){
					x += c;
				}
				c *= 2;
			}
			B[i+1] = x;
		}
		a1 = B[N-1];
		c = 1;
		x = 0;
		for(var j=0;j<=40;j++){
			long b1 = a1/c%2;
			long b2 = A[0]/c%2;
			if((b1+b2)%2==1){
				x += c;
			}
			c *= 2;
		}
		B[1] = x;
		for(var i=2;i<N-1;i=i+2){
			a1 = B[i-1];
			c = 1;
			x = 0;
			for(var j=0;j<=40;j++){
				long b1 = a1/c%2;
				long b2 = A[i]/c%2;
				if((b1+b2)%2==1){
					x += c;
				}
				c *= 2;
			}
			B[i+1] = x;
		}
      	for(var j=0;j<N;j++){
          Console.Error.Write(B[j]+" ");
        }
		long c1 = B[N-2];
		long c2 = B[0];
		long c3 = 1;
		long x1 = 0;
		for(var j=0;j<=40;j++){
				long b1 = c1/c3%2;
				long b2 = c2/c3%2;
				long b3 = A[N-1]/c3%2;
				if((b1+b2)%2!=b3){
					flag = false;
				}
				c3 *= 2;
		}
		c1 = B[N-1];
		c2 = B[1];
		c3 = 1;
		x1 = 0;
		for(var j=0;j<=40;j++){
				long b1 = c1/c3%2;
				long b2 = c2/c3%2;
				long b3 = A[0]/c3%2;
				if((b1+b2)%2!=b3){
					flag = false;
				}
				c3 *= 2;
		}
		} else {
			for(var i=1;i<N-1;i=i+2){
			a1 = B[i-1];
			c = 1;
			x = 0;
			for(var j=0;j<=40;j++){
				long b1 = a1/c%2;
				long b2 = A[i]/c%2;
				if((b1+b2)%2==1){
					x += c;
				}
				c *= 2;
			}
			B[i+1] = x;
			}
			for(var j=0;j<N;j++){
          Console.Error.Write(B[j]+" ");
			}
		long c1 = B[N-2];
		long c2 = B[0];
		long c3 = 1;
		long x1 = 0;
		for(var j=0;j<=40;j++){
				long b1 = c1/c3%2;
				long b2 = c2/c3%2;
				long b3 = A[N-1]/c3%2;
				if((b1+b2)%2!=b3){
					flag = false;
				}
				c3 *= 2;
		}
		for(var i=2;i<N-1;i=i+2){
			a1 = B[i-1];
			c = 1;
			x = 0;
			for(var j=0;j<=40;j++){
				long b1 = a1/c%2;
				long b2 = A[i]/c%2;
				if((b1+b2)%2==1){
					x += c;
				}
				c *= 2;
			}
			B[i+1] = x;
			}
			for(var j=0;j<N;j++){
          Console.Error.Write(B[j]+" ");
			}
		c1 = B[N-1];
		c2 = B[1];
		c3 = 1;
		x1 = 0;
		for(var j=0;j<=40;j++){
				long b1 = c1/c3%2;
				long b2 = c2/c3%2;
				long b3 = A[0]/c3%2;
				if((b1+b2)%2!=b3){
					flag = false;
				}
				c3 *= 2;
		}
		}
		string ans = "No";
		if(flag){
			ans = "Yes";
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 31196
N = int(input())

ans = [0] * (10 ** 4 + 1)
for x in range(1, 10 ** 2 + 1):
    for y in range(1, 10 ** 2 + 1):
        for z in range(1, 10 ** 2 + 1):
            tmp = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if tmp <= N:
                ans[tmp] += 1

print (*ans[1:N + 1], sep = '\n')


Measured memory_bytes: 68692
def countingSort(A, B, k):
    from collections import defaultdict
    C = defaultdict(int)
    for a in A:
        C[a] += 1
    cnt = 0
    for i in range(max(C.keys()) + 1):
        for _ in range(C[i]):
            B[cnt] = i
            cnt += 1


def resolve():
    n = int(input())
    A = [int(i) for i in input().split()]
    B = [0] * n
    countingSort(A, B, max(max(A), n))
    print(*B)

resolve()



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

int main () {
  int N ;
  cin >> N ;
  double ans = 0  ;
  for(int i = 0 ; i < N ; i++ ){
    double a ; string S ;
    cin >> a >> S ;
    if(S == "JPY") {
      ans += a ;
    } else {
      ans += a * 380000.0 ;
    }
  }
  cout << ans << endl ;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;
static const int INF = (int)1e8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOREQ(i,k,n) for (int i=(k); i<=(int)(n); ++i)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FIND(m,w) ((m).find(w)!=(m).end())

int c[10001][1261]={};
int main(void){
  int N,M;
  while(cin>>N>>M,N&&M){
    REP(i,10001)REP(j,1261)c[i][j]=0;
    int r;
    cin>>r;
    while(r--){
      int t,n,m,s;
      cin>>t>>n>>m>>s;
      REP(time,1260){
        if(time>=t){
          if(s){
            c[m][time]++;
          }else{
            c[m][time]--;
          }
        }
      }
    }
    
    int q; cin>>q;
    while(q--){
      int ans = 0;
      int t1,t2,m;
      cin>>t1>>t2>>m;
      for(int time = t1; time < t2; time++){
        if(c[m][time]) ans ++;
      }
      cout<<ans<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 48000
def GCD(x, y):
    if y != 0:
        return GCD(y, x % y)
    else:
        return x

N = input()
monsters = [int(s) for s in input().split()]

x = monsters[0]
for y in monsters[1:]:
    gcd = GCD(x, y)
    x = gcd

print(gcd)

Measured memory_bytes: 62832
#include<cmath>
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
using namespace std;
using ll = long long;

int main() {
    int t = 1;
    for(int i = 0; i < t; ++i){
	    
	    string s;
	    cin >> s;
	    bool flag = 0;
	    int cnt = 0;
	    int ans = 0;
	    int count = 0;
	    for (int i = 0; i < s.length(); i++) 
    { 
        if (s[i] == 'S') 
            count = 0; 
  
       else
        { 
            count++;//increase count 
            ans = max(ans, count); 
        } 
    } 
	    cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>


int main(){
  int n,i,p[101],m[101][101],j,l,k;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }
  for(i=1;i<=n;i++){
    m[i][i]=0;
  }
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=(1<<21);
      for(k=i;k<=j-1;k++){
        if(m[i][j]>m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]){
	    m[i][j]=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	}
      }
    }
  }
  printf("%d\n",m[1][n]);
  return 0;
}
    



Measured memory_bytes: 2104
#include <iostream>

int main() {
    int H[2], M[2], K;
    std::cin >> H[0] >> M[0] >> H[1] >> M[1] >> K;

    std::cout << (H[1] * 60 + M[1]) - (H[0] * 60 + M[0]) - K << "\n";
}

Measured memory_bytes: 3624
#include<cstdio>
#include<algorithm>
#include<set>
using namespace std;
struct node{
	int x,y;
	node(){}
	node(int x,int y):x(x),y(y){}
	inline bool operator <(const node &b)const{return x<b.x||x==b.x&&y<b.y;}
}a[55];
int x[55],y[55],n;
short f1,f2;
set<node> S;
inline bool cmp(node a,node b){return a.x*f1<b.x*f1||a.x*f1==b.x*f1&&a.y*f2<b.y*f2;}
inline int calc(int p,int q){
	int i,ans=0;
	f1=p>0?1:-1;f2=q>0?1:-1;
	S.clear();
	sort(a,a+n,cmp);
	for(i=0;i<n;++i){
		if(S.find(node(a[i].x-p,a[i].y-q))==S.end())++ans;
		S.insert(node(a[i].x,a[i].y));
	}
	return ans;
}
int main(){
	int i,j,ans;
	scanf("%d",&n);ans=n;
	for(i=0;i<n;++i){
		scanf("%d%d",x+i,y+i);
		a[i].x=x[i];a[i].y=y[i];
	}
	for(i=0;i<n-1;++i)
		for(j=i+1;j<n;++j)ans=min(ans,calc(x[j]-x[i],y[j]-y[i]));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc119/tasks/abc119_b


def main():
    btc = 380000
    N = int(input())
    total = 0
    for _ in range(N):
        a, b = input().split()
        if b == "JPY":
            total += float(a)
        else:
            total += (float(a) * btc)
    print(total)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        while(true) {
            int n = sc.nextInt();
            if(n == 0) {
                break;
            }

            int[] arr = new int[n];
            for(int i=0; i<n; i++) {
                arr[i] = sc.nextInt();
            }

            int ans = Integer.MAX_VALUE;
            for(int i=0; i<n; i++) {
                for(int j=0; j<n; j++) {
                    if(i != j) {
                        int diff = Math.abs(arr[i]-arr[j]);
                        ans = Math.min(ans, diff);
                    }
                }
            }
            System.out.println(ans);
        }

    }
}



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

using namespace std;

#define endl '\n'
#define maxn 1000010
const int MOD = 1000000007;

int dp[maxn];

void solve() {
    for (int i = 2; i <= 1000000; i++)
        for (int j = i; j <= 1000000; j += i)
            if (dp[j] == 0)dp[j] = i;
    int n;
    cin >> n;

    vector<int> v(n);
    int gcd = 0;
    unordered_map<int, int> mp;
    bool fd = false;

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

        if (gcd == 0)gcd = v[i];
        else gcd = __gcd(v[i], gcd);

        int now = dp[v[i]], cur = v[i];

        if(fd)continue;
        while (cur > 1) {
            while (cur % now == 0)cur /= now;
            if (mp[now] > 0) {
                fd = true;
                break;
            } else mp[now]++;
            now = dp[cur];
        }
    }
    if (!fd)cout << "pairwise coprime";
    else if (gcd == 1)cout << "setwise coprime";
    else cout << "not coprime";
}

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


    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 10872
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	T1, T2 := ReadInt(), ReadInt()
	A1, A2 := ReadInt(), ReadInt()
	B1, B2 := ReadInt(), ReadInt()

	p := (A1 - B1) * T1
	q := (A2 - B2) * T2
	if p > 0 {
		p, q = -p, -q
	}
	if p+q < 0 {
		fmt.Println(0)
		return
	}
	if p+q == 0 {
		fmt.Println("infinity")
		return
	}
	s := (-p) / (p + q)
	t := (-p) % (p + q)
	if t == 0 {
		fmt.Println(2 * s)
	} else {
		fmt.Println(2*s + 1)
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


Measured memory_bytes: 1844
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;

bool ok(ll target, ll d, ll num) {
  string str = to_string(target);

  char ch = '0' + num;

  if (str[d - 1] == ch) {
    return true;
  }
  return false;
}

int main() {
  ll n, m;
  scanf("%lld %lld", &n, &m);

  vector<pair<ll, ll>> list;
  for (ll i = 0; i < m; i++) {
    ll s, c;
    scanf("%lld %lld", &s, &c);

    list.emplace_back(make_pair(s, c));
  }

  ll ans = -1;
  ll start;
  ll end;
  if (n == 1) {
    start = 0;
    end = 9;
  }
  if (n == 2) {
    start = 10;
    end = 99;
  }
  if (n == 3) {
    start = 100;
    end = 999;
  }
  // start = 702;
  // end = 702;
  for (ll i = start; i <= end; i++) {
    bool all_ok = true;
    for (ll j = 0; j < m; j++) {
      bool o = ok(i, list[j].first, list[j].second);
      if (!o) {
        all_ok = false;
      }
    }
    if (all_ok) {
      ans = i;
      goto END;
    }
  }

END:

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {

    static void solve(int[] arr, int numberOfBrokeAss) {
      Arrays.sort(arr);
      int result = 0;
      for(int i = 0; i<numberOfBrokeAss; i++){
        result+=arr[i];
      }
      System.out.println(result);
    }

    public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int n = in.nextInt();
            int parameter = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n ; i++) {
            	arr[i] = in.nextInt();
        	}
      		solve(arr,parameter);

    }
}

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

int main(){
	int N;
	cin >> N;
    string s;
    cin >> s;
    int count = N; 
    for(int i = 0;i < N;i++){
    	if(s[i] == s[i + 1]){
    		count--;
    		
    	}
    }
cout << count << endl;
}

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

using vvc = vector<vector<char>>;
using vpii = vector<pair<int, int>>;

vpii next_step(vpii const& step, vvc& a) {
	int const h = a.size(), w = a.front().size();
	int const d[][2] = { -1, 0, 1, 0, 0, -1, 0, 1 };
	vpii r;
	for (auto const& x : step) {
		for (auto const& y : d) {
			int i = x.first + y[0], j = x.second + y[1];
			if (i >= 0 && i < h && j >=0 && j < w && a[i][j] == '.') {
				a[i][j] = '#';
				r.emplace_back(i, j);
			}
		}
	}
	return r;
}

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

    int h, w;
    cin >> h >> w;
    vvc a(h);
    vpii step;

    for (int i = 0; i < h; i++) {
		a[i].resize(w);
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
            if (a[i][j] == '#')
                step.emplace_back(i, j);
        }
    }

	int n = h * w - step.size();
    int ans = 0;
    while (n > 0) {
		ans++;
		step = next_step(step, a);
		n -= step.size();
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 14312
#include <iostream>
#include <vector>

using namespace std;

int insSort(int *arr,int N){
    for(int i=1;i<N;i++){
        int v = arr[i];
        int j = i-1;
        while(j>=0 && arr[j]>v){
            arr[j+1] = arr[j];
            j--;
        }
        arr[j+1] = v;
        for(int k=0;k<N;k++){
            cout << arr[k];
            if(k!=N-1) cout << " ";
        }
        cout << endl;       
    }
    return 0;
}

int main(){
    int N,l;
    cin >> N;
    int arr[N];

    for(int i=0;i<N;i++){
        cin >> arr[i];
    }
  	for(int i=0;i<N;i++){
      cout << arr[i];
      if(i!=N-1) cout << " ";
    }
    cout << endl;
    
    insSort(arr,N);
    return 0;
}




Measured memory_bytes: 3076
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
int main() {
	string a, b;
	cin >> a >> b;
	string c = a + b;
	double num = atoi(c.c_str());
	double s = pow(num, 0.5);
	int k = s;
	if (k*k == num) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 512
/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/6/27 20:02:22
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
const int maxx=2e5+10;
char s[maxx],t[maxx];
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	scanf("%s%s",s,t);
	int len=strlen(s),ans=0;
	For(i,0,len-1)
		if(s[i]!=t[i]) ++ans;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 4048
//#pragma GCC optimize(\"Ofast,no-stack-protector\")
//#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx\")
//#pragma GCC target(\"avx,tune=native\")
// Neil

#include<bits/stdc++.h>

using namespace std;

typedef complex<double> base;
typedef long double ld;
typedef long long ll;

#define endl "\n"
#define pb push_back
#define pii pair<int,int>
#define pll pair< ll , ll >
#define vi vector<int>
#define vvi vector< vi >
const int MAXN=(int)(2e5+5);
const ll MOD=(ll)(1e9+7);
int t;

ll func(ll b, ll n){
    if(n<b) return n;
    else return func(b, n/b) + n%b;
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n,s;
    cin>>n>>s;
    if(n==s){
        cout<<n+1<<endl;
        return 0;
    }
    ll ans = -1;
    for(ll b = 2;b*b<=n;b++){
        if(func(b, n) == s){
            cout<<b<<endl;
            return 0;
        }
    }

    // n = pb + q
    // s = p + q
    for(ll p = 1;p*p<n;p++){
        ll b = (n-s)/p + 1;
        if(b>=2 and func(b, n) == s){ ans = b;} 
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//constant
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9;
//Macro
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
//Debuging tools
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
///library
//@brief x^n
//@detail if MOD==0 then not modulo. 
template <typename T>
T power(T x,T n,long long MOD = MOD){
    T ret = 1;
    while(n>0){
        if(n%2==1) ret*=x;
        n/=2,x*=x;
        if(MOD!=0) x%=MOD,ret%=MOD;
    }
    return ret;
}

//aのMODbでの逆元
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
//@brief nCk (O(k))
template <typename T>
T combi_simple(T n,T k,long long MOD = MOD){
    k = min(n-k,k);
    T ret = 1;
    for(T i = n;i>n-k;i--) ret*=i,ret%=MOD;
    for(T i=1;i<=k;i++) ret*=modinv(i,MOD),ret%=MOD;
    return ret;
}
//DataStructure
int main(){
    long long n,a,b;
    cin >> n >> a >> b;
    long long ans = power(2LL,n) - combi_simple(n,a) - combi_simple(n,b) - 1;
    ans%=MOD;
    if(ans<0) ans+=MOD;
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(100000000)
MOD = 10**9+7
INF = 10 ** 9

def main():
    n = int(input())
    S = [[] for _ in range(n)]
    S[0] = ['a']
    
    dic = {i:j for i,j in zip(range(10),'abcdefghij')}
    for i in range(1,n):
        for st in S[i-1]:
            kind = 1
            while dic[kind] in st:
                kind += 1
            for j in range(kind+1):
                S[i].append(st+ dic[j])
    print(*S[-1],sep='\n')

if __name__=='__main__':
    main()

Measured memory_bytes: 16340
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            if j == 0 or j == W - 1 or i == 0 or i == H - 1:
                print("#", end = "")
            else:
                print(".", end = "")
        print()
    print()


Measured memory_bytes: 7004
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;

int main() {
 
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    int ans = 1;
    bool up = false,down = false;
    rep(i, 0, n-1){
        if(up && a[i] > a[i+1]){
            up = false;
            ans++;
        } else if(down && a[i] < a[i+1]) {
            down = false;
            ans++;
        } else if(!up && a[i] < a[i+1]) {
            up = true;
        } else if(!down && a[i] > a[i+1]) {
            down = true;
        }
    }
    cout << ans << endl;
    
    return 0;
}


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

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#define    boost        ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define    nl           "\n"
#define    ll           long long
#define    pb           push_back
#define    mpr          make_pair
#define    fr(i,a,n)    for(ll i=a;i<n;++i)
#define    fr0(i,n)     for(ll i=0;i<n;++i)
#define    pii          pair<int, int>
#define    FO           find_by_order
#define    OK           order_of_key
#define    mem(a)       memset(a,0,sizeof(a))
#define    ff           first
#define    ss           second


typedef tree <
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update >
set_t;


void fio()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
	double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
	time_taken *= 1e-9;
	cout << "\nExecuted in: " << fixed
	     << time_taken << setprecision(9);
	cout << " sec";
#endif
}

///----------------------------- | FUNCTIONS | --------------------------------------///

/*
const int N = 2e5 + 5;

vector<int> adj[N];
bool visited[N];
//int val[N];
//int depth[N];
//int parent[N];

void dfs(int v)
{
	visited[v] = true;
	for (int u : adj[v])
	{
		if (!visited[u])
		{
			//parent[u] = v;
			//depth[u] = depth[v] + 1;
			dfs(u);
		}
	}
}
*/

// left shift << multiply by 2
// right shift >> divide by 2

///----------------------------- | START FROM HERE | --------------------------------------///

#define int long long //change int main to int32_t main

const int N = 1e5 + 5;

int dp[105][N];

void solve()
{
	int n, fw; cin >> n >> fw;

	fr(j, 1, n + 1)
	{
		int x, y; cin >> x >> y;
		fr0(i, fw + 1)
		{
			if (i - x >= 0)
				dp[j][i] = max(dp[j - 1][i], dp[j - 1][i - x] + y);
			else
				dp[j][i] = dp[j - 1][i];
		}
	}
	cout << dp[n][fw] << nl;

}





int32_t main()
{
	auto start = chrono::high_resolution_clock::now();
	boost;
	fio();
	int t;
	t = 1;
	//cin >> t;
	while (t--) solve();
	auto end = chrono::high_resolution_clock::now();
	TIME(start, end);
	return 0;
}




Measured memory_bytes: 81704
//Date: 17 - 02 - 18	//Author : Rishabh Paul

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<float.h>
#include<math.h>
#include<inttypes.h>
#include<assert.h>
#include<ctype.h>
#include<limits.h>
#include<time.h>
#define ll long long
#define For(i,n)	for(int i=0;i<n;i++)
#define rep(i ,a ,b)	for(int i=(a);i<=(b);i++)
#define mset(a ,value)	memset(a ,value ,sizeof(a))
#define s(a)	scanf("%d" ,&a);
#define ls(a)	scanf("%ld" ,&a)
#define reg(i)	register int i
#define infinite INT_MAX
#define MAX 100005
#define NIL -1
ll min(ll a,ll b){	return (a<b?a:b);	}
ll max(ll a,ll b){	return (a>b?a:b);	}
int a[4][4] ,b[4];
int cmp(const void *a,const void *b){
	int *a1 = (int *)a;
	int *b1 = (int *)b;
	if((*a1) < (*b1))	return 1;
	if((*a1) == (*b1))	return 0;
	return -1;
	}
int main(){
	rep(i,1 ,3)	rep(j ,1 ,3)	s(a[i][j]);
	For(i ,101)	For(j ,101)	For(k ,101){
		b[1] = i ,b[2] = j ,b[3] = k;
		if((a[2][1] - b[1] == a[2][2] - b[2]) && (a[2][2] - b[2] == a[2][3] - b[3]) && (a[2][3] - b[3] == a[2][1] - b[1]) && (a[1][1] - b[1] == a[1][2] - b[2]) && (a[1][2] - b[2] == a[1][3] - b[3]) && (a[1][3] - b[3] == a[1][1] - b[1]) && (a[3][1] - b[1] == a[3][2] - b[2]) && (a[3][2] - b[2] == a[3][3] - b[3]) && (a[3][3] - b[3] == a[3][1] - b[1])){
			puts("Yes");	return 0;
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int t = sc.nextInt();
        int[] a = new int[t];
        int sum = 0;
        for (int i = 0; i < t; i++) {
            a[i] = sc.nextInt();
            sum += a[i];
        }
        Arrays.sort(a);
        sum -= a[t-1];
        int ans = a[t-1]-sum-1 < 0 ? 0 : a[t-1]-sum-1;
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 23252
// https://atcoder.jp/contests/abc106/tasks/abc106_c

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

string S;
ll K, r;

int main()
{
  cin >> S >> K;

  int i = 0;
  while (i < min(K - 1, (ll)S.length()) && '1' == S[i])
    i++;
  r = S[i] - '0';

  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>

namespace FastIO {
  
  inline int read() {
    char ch = getchar(); int r = 0, w = 1;
    while(!isdigit(ch)) {if(ch == '-') w = -1; ch = getchar();}
    while(isdigit(ch)) {r = r * 10 + ch - '0', ch = getchar();}
    return r * w;
  }

  void _write(int x) {
    if(x < 0) putchar('-'), x = -x;
    if(x > 9) _write(x / 10);
    putchar(x % 10 + '0');
  }

  inline void write(int x) {
    _write(x);
    puts("");
  }

  inline int min(int a, int b) {return a < b ? a : b;}
  inline int max(int a, int b) {return a > b ? a : b;}
}

using namespace FastIO;

const int N = 3e5 + 6;
const int M = 23;

int n, k, tot;
int x[N], v[N], l[M][N], r[M][N], val[N], ll[N], rr[N];

int main() {
  n = read();
  v[0] = read();
  while(v[k]) v[k + 1] = v[k] >> 1, k++;
  tot = (1 << k) - 1;
  for(register int i = 1; i <= n; i++) x[i] = read();
  for(register int i = 0; i <= k; i++) {
    l[i][1] = 1;
    for(register int j = 2; j <= n; j++) {
      if(x[j] - x[j - 1] <= v[i]) l[i][j] = l[i][j - 1];
      else l[i][j] = j;
    }
    r[i][n] = n;
    for(register int j = n - 1; j >= 0; j--) {
      if(x[j + 1] - x[j] <= v[i]) r[i][j] = r[i][j + 1];
      else r[i][j] = j;
    }
  }
  for(register int i = 1; i <= tot; i++) {
    ll[i] = 1, rr[i] = n;
  }
  ll[0] = 0, rr[0] = n + 1;
  for(register int i = 0; i <= tot; i++) {
    for(register int j = 1; j <= k; j++) {
      if(!((i >> (j - 1)) & 1)) {
        ll[i | (1 << (j - 1))] = max(ll[i | (1 << (j - 1))], r[j][ll[i] + 1]);
        rr[i | (1 << (j - 1))] = min(rr[i | (1 << (j - 1))], l[j][rr[i] - 1]);
      }
    }
  }
  for(register int i = 0; i <= n + 1; i++) val[i] = n << 1;
  for(register int i = 0; i <= tot; i++) val[ll[i]] = min(val[ll[i]], rr[tot ^ i]);
  for(register int i = n; i >= 0; i--) val[i] = min(val[i], val[i + 1]);
  for(register int i = 1; i <= n; i++) printf("%s\n", val[l[0][i] - 1] <= r[0][i] + 1 ? "Possible" : "Impossible");
  return 0;
}

Measured memory_bytes: 55424
#include<iostream>
#include<string.h>
using namespace std;

int coin[17];
int memo[301][17];

int calc(int n,int c) {
  if(memo[n][c] != 0) return memo[n][c];
  if(n==0) return 1;
  if(c>17 || n<0 || coin[c]>n) return 0;
  int a = calc(n-coin[c], c);
  int b = calc(n, c+1);
  memo[n-coin[c]][c] = a;
  memo[n][c+1] = b;
  return a+b;
}

int main() {
  memset(coin, 0, sizeof(coin));
  memset(memo, 0, sizeof(memo));
  for(int i=17; i>=0; --i)
    coin[i] = (i+1)*(i+1);

  int n;
  while(cin>>n, n) {
    cout<<calc(n,0)<<endl;
  }
}

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

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

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

    int a = H[0];

    for(int j=1;j<n;j++)
    {
        if(a <= H[j])
            a = H[j];
        else
        {
            b--;
        }
    }

    cout << b  << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

using namespace std;
#define ll long long int
#define MAX 1000
#define MOD 1000000007

vector<ll> primes;
ll pow(ll b, ll e) {
	if(e == 0) return 1;
	return b * pow(b, e-1);
}
void preproc() {
	ll noprime[MAX+1] = {};
	for(ll i = 2; i <= MAX; i++) {
		if(!noprime[i]) {
			primes.push_back(i);
			for(ll j = i*i; j <= MAX; j+=i)
				noprime[j] = 1;
		}
	}
}

int main () {
	preproc();
	// for(ll i = 0; i < 5; i++) prllf("%2d %d\n", i, primes[i]);

	ll n;
	scanf("%lld", &n);
	ll factors[MAX+1] = {};
	for(auto p : primes)
		for(ll i = 1; pow(p,i) <= n; i++)
			factors[p] += n / pow(p,i);

	ll divisors = 1;
	for(ll i = 0; i <= MAX; i++)
		if(factors[i])
			divisors = (divisors * (factors[i] + 1)) % MOD;

	printf("%lld\n", divisors);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
bool check_t(int a) {
	int b = 1;
	rep2(i,2,a) {
		b += i;
		if(a==b) return true;
	}
	return false;
}
bool check(vector<int> x) {
	rep(i,x.size()) {
		if(x[i] != i+1) {
			return false;
		}
	}
	return true;
}
int main() {
	int n,m;
	while(cin >> n, n) {
		int sum = 0;
		vector<int> v;
		rep(i,n) {
			cin >> m;
			v.push_back(m);
			sum += m;
		}
		if(!check_t(sum)) {
			cout << -1 << endl;
			continue;
		}
		int cnt = 0;
		while(!check(v)) {
			if(cnt > 10000) break;
			vector<int> nv;
			int sz = v.size();
			rep(i,sz) {
				if(v[i]-1==0) continue;
				else nv.push_back(v[i]-1);
			}
			nv.push_back(sz);
			v = nv;
			cnt++;
		}
		if(cnt > 10000) cout << -1 << endl;
		else cout << cnt << endl;
	}
}

Measured memory_bytes: 1248
import java.util.Scanner;
import java.lang.*;

public class Main{
 
	public static void main(String args[]){

      Scanner sc = new Scanner(System.in);
	int array[]  = new int[5];
	array[0] = sc.nextInt();
	array[1] = sc.nextInt();
	array[2] = sc.nextInt();
	array[3] = sc.nextInt();
	array[4] = sc.nextInt();



      for(int i = 0; i<5; i++){
      	if(array[i] == 0){
        	System.out.println(i+1);
        }
      
      
      }
      
      
      
    }      
}

Measured memory_bytes: 35776
k = int(input())
A = list(map(int, input().split()))
l, r = 2, 2
for a in reversed(A):
    l += (a - l%a) % a
    r -= r % a
    r += a - 1
    if l > r:
        print(-1)
        break
else:
    print("{} {}".format(l, r))


Measured memory_bytes: 14252
/*In The Name of ALLAH*/
#include <bits/stdc++.h>
#define mod 1000000007
#define inf 1000000000
#define ll long long 
const int MAX  = 2011 ;
using namespace std;

int cnt[30];
int main(){ 
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); 
	string s;
	cin>>s;
	for(int i = 0 ;i < s.size(); i++){
		memset(cnt,0,sizeof cnt);
		for(int j  = i ; j < min(i+3,(int) s.size()) ;j++){
			cnt[s[j] - 'a']++;
			if(cnt[s[j] - 'a'] == 2){
				cout<<i + 1<<" "<< min(i+3 , (int) s.size());
				return 0;
			}
		}
	}
	cout<<-1<<" "<<-1;
	return 0;
}

Measured memory_bytes: 512
//By Longqiang 2020-06-29
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
using namespace std;

#define MAX_N 100005
#define REP(i,a,b) for(int i=(a); i<(b); i++)

int N,Q;
int Head[MAX_N], Next[MAX_N*2], To[MAX_N*2], Color[MAX_N*2], Weight[MAX_N*2];
int tot, t;
int Fa[MAX_N][20], Dept[MAX_N], Dist[MAX_N];

void traceFa(){
	REP(i,1,N){
		printf("Point%d \n", i);
		REP(j,0,t+1) printf("Fa[%d][%d]=%d ",i,j,Fa[i][j]);
		printf("\n");
	}
}
void traceDist(){
	REP(i,1, N+1) printf("%d ",Dist[i]);
	printf("\n");
}

void add_edge(int u,int v, int c, int w){
	To[++tot]=v;
	Next[tot] = Head[u];
	Color[tot] = c;
	Weight[tot] = w;
	Head[u] = tot;
}
//预处理  bfs法
void bfs(){
	queue<int> q;
	q.push(1);
	Dept[1] = 1;
	while(q.size()){
		int x=q.front();
		q.pop();
		for(int i=Head[x]; i; i=Next[i]){
			int y = To[i];
			if(Dept[y]) continue;
			Dept[y] = Dept[x]+1;
			Dist[y] = Weight[i] + Dist[x];
			Fa[y][0] = x;
			for(int j=1; j<=t; j++){
				Fa[y][j] = Fa[Fa[y][j-1]][j-1];
			}
			q.push(y);
		}
	}
}
//预处理  dfs法
void dfs(int cur, int fa, int d){
 	Fa[cur][0] = fa;
	for(int i=1; i<=t; i++){
		Fa[cur][i] = Fa[Fa[cur][i-1]][i-1];
	}

	for(int i=Head[cur]; i; i=Next[i]){
		int y = To[i];
		if(y == fa) continue;
		Dept[y] = Dept[cur]+1;
		Dist[y] = Dist[cur] + Weight[i];
		dfs(y, cur, d+1);
	}
}

struct Query{
	int color, w, coe, id;
};
vector<Query> Que[MAX_N];
int ans[MAX_N];
int Num[MAX_N*2], Value[MAX_N*2];

int lca(int x, int y){
	if(Dept[x]>Dept[y]) swap(x,y);
	for(int i=t; i>=0; i--){
		if(Dept[Fa[y][i]]>=Dept[x]) y= Fa[y][i];
	}
	if(x==y) return x;
	for(int i=t; i>=0; i--){
		if(Fa[x][i] != Fa[y][i]){
			x = Fa[x][i];
			y = Fa[y][i];
		}
	}
	return Fa[x][0];
}

void dfs2(int u, int fa){
	for(int i=0; i<Que[u].size(); i++){
		Query query = Que[u][i];
		ans[query.id] += (Dist[u] + Num[query.color]*query.w - Value[query.color])*query.coe;
		/*
		printf("ans[%d]=Dist[%d](%d)+___ = %d\n", query.id, u, Dist[u],ans[query.id]);
		printf("Num[%d]=%d\n", query.color, Num[query.color]);
		printf("Value[%d]=%d\n", query.color, Value[query.color]);
		printf("query.w = %d\n", query.w);
		printf("\n");
		*/
	}

	for(int i=Head[u]; i; i=Next[i]){
		int y = To[i];
		if(y==fa) continue;
		Num[Color[i]]++;
		Value[Color[i]] += Weight[i];
		dfs2(y,u);
		Num[Color[i]]--;
		Value[Color[i]] -= Weight[i];
	}
}


int main() {
	cin>>N>>Q;
	t = (int)(log(N)/log(2))+1;
	
	REP(i,0,N-1){
		int u,v,c,w;
		cin>>u>>v>>c>>w;
		add_edge(u,v,c,w);
		add_edge(v,u,c,w);
	}
	
	//bfs();
	Dept[1] = 1;
	dfs(1,0,1);
	
	REP(i, 1, Q+1){
		int x,y,u,v;
		cin>>x>>y>>u>>v;
		
		Que[u].push_back(Query{x,y,1,i});
		Que[v].push_back(Query{x,y,1,i});
		Que[lca(u,v)].push_back(Query{x,y,-2,i});
		//printf("%d\n", Dist[u]+Dist[v] - 2*Dist[lca(u,v)]);
	}
	
	dfs2(1,0);
	
	REP(i, 1, Q+1){
		printf("%d\n", ans[i]);
	}
	return 0;
}

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

using namespace std;

string s;

void solve() {
    for (int i = 0; i < int(s.size()); i++) {
        if (i % 2 == 0) {
            printf("%c", s[i]);
        }
    }
    printf("\n");
}

int main() {
    cin >> s;
    solve();
    return 0;
}

Measured memory_bytes: 3756