akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
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;
}
vector<ll> sieve(int N){
  vector<bool> is_prime(N+1,true);
  vector<ll> P;
  for(int i=2;i<=N;i++){
    if(is_prime[i]){
      for(int j=2*i;j<=N;j+=i)is_prime[j] = false;
      P.emplace_back(i);
    }
  }
  return P;
}
int main(){
    ll n;cin >> n;
    ll res=0;
    repl(i,1,n+1){
        ll t=n/i;
        t=t*(t+1)/2;
        res+=i*t;
    }
    cout << res <<endl;
}   

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

max_L = -1
min_R = 10**5 + 1
for _ in range(M):
    L, R = map(int, input().split())
    max_L = max(max_L, L)
    min_R = min(min_R, R)

print(max(min_R - max_L + 1, 0))


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

map<int, int>mp;
//約数の個数
void calc(long long N) {
	for (long long i = 2; i*i <= N; i++) {
		int m = 0;
		while (N%i == 0) { // 素数で割り切れなくなるまで割っていく
			m++;//割った個数を配列に足す
			N /= i;
		}
		if (0 != m) {
			mp[i]++;
		}
		if (1 == N) {
			break;
		}
	}
	if (1 != N) {
		mp[N]++;
	}
	return;
}

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		calc(A[i]);
	}
	bool b1 = true;
	bool b2 = false;
	for (auto p :mp) {
		if (1 != p.second) {
			b1 = false;
		}
		if (N == p.second) {
			b2 = true;
		}
	}
	if (b1) {
		cout << "pairwise coprime"<<endl;
	}
	else if (!b2) {
		cout << "setwise coprime" << endl;
	}
	else {
		cout << "not coprime" << endl;
	}
	return 0;
}

Measured memory_bytes: 10740
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

N = int(input())

def rec(i, m, ar) :
  if i == N :
    print(''.join(chr(s + 97) for s in ar))
    return 
  for j in range(min(m + 1, N)) :
    rec(i + 1, max(m, j + 1), ar + [j])


rec(0, 0, [])

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define yes() cout << "Yes"<< endl;
#define no() cout << "No"<< endl;

int main() {
	int a,b;
	cin >> a>>b;
	if (a < 10 && b < 10) {
		cout << a*b << endl;
	}
	else {
		cout << -1 << endl;
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[]str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int M = int.Parse(str[1]);
		int X = int.Parse(str[2]);
		int[,]A = new int[N,M+1];
		for(var i=0;i<N;i++){
			string[]str2 = Console.ReadLine().Split();
			for(var j=0;j<M+1;j++){
				A[i,j] = int.Parse(str2[j]);
			}
		}
		long ans = -1;
		for(var i=0;i<Math.Pow(2,N);i++){
			int a = 1;
			long sum = 0;
			int[]C = new int[M];
			for(var j=0;j<N;j++){
				if(i/a%2==1){
					sum += A[j,0];
					for(var k=0;k<M;k++){
						C[k] += A[j,k+1];
					}
				}
				a *= 2;
			}
			bool flag = true;
			for(var k=0;k<M;k++){
				if(C[k] < X){
					flag = false;
				}
			}
			if(flag){
				if(ans == -1){
					ans = sum;
				} else {
					ans = Math.Min(ans,sum);
				}
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 18704
n, m = gets.chomp.split(" ").map(&:to_i)

like_food = []
n.times do
  hoge = gets.chomp.split(" ").map(&:to_i)
  hoge.shift
  like_food << hoge
end

a = like_food.inject([*1..m]) {|master, nums| master & nums}


p a.size

Measured memory_bytes: 1788
# https://atcoder.jp/contests/abc054/tasks/abc054_c

from itertools import permutations

N,M = map(int, input().split())

edges = set()
for _ in range(M):
    a, b = map(int, input().split())
    edges.add((a,b))
    edges.add((b,a))



res = 0
for a in permutations(range(2,N+1),N-1):
    j = 1
    k = 0
    for i in a:
        if (j,i) in edges:
            k += 1
        if k == N-1:
            res += 1
        j = i

print(res)

Measured memory_bytes: 70024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A >= B && A >= C){
    cout << B*C/2 << endl;
  }
  if(B > A && B >= C){
    cout << A*C/2 << endl;
  }
  if(C > B && C > A){
    cout << A*B/2 << endl;
  }
  return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define esort(s) sort((s).begin(),(s).end())

typedef long long ll;
typedef pair<int,int> ipair;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;


int N;

void solve(){
    cin>>N;
    string ans="No\n";
    rrep(i,1,10){
        if(N%i!=0) continue;
        if((N/i)>9) continue;
        ans="Yes\n";
    }
    cout<<ans;
    return;
}

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

    solve();
    return 0;
}

Measured memory_bytes: 256
#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

int main()
{
    int A, B;
    cin >> A >> B;

    if (A <= 5)
        cout << 0;
    else if (A >= 13)
        cout << B;
    else
        cout << B / 2;
}

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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(v) sort(all(v)),v.erase(unique(all(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
  #endif // LOCAL
  int k, a, b;
  cin >> k >> a >> b;
  int tot = b/k - (a - 1)/k;
  if (tot) cout << "OK" << endl;
  else cout << "NG" << endl;
  return 0;
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<ar<ll,2> > v[n];
	for(int i = 0; i<n-1; i++)
	{
		int j,k,c;
		cin>>j>>k>>c, --j,--k;
		v[j].push_back({k,c});
		v[k].push_back({j,c});
	}
	int q,k;
	cin>>q>>k, --k;
	ll dist[n];
	memset(dist,0x3f, sizeof(dist));
	dist[k] = 0;
	priority_queue<ar<ll,2> , vector<ar<ll,2>>, greater<ar<ll,2>>> pq;
	pq.push({0,k});
	while(!pq.empty())
	{
		auto y = pq.top();
		pq.pop();
		for(auto it:v[y[1]])
		{
			if(dist[it[0]]>dist[y[1]]+it[1])
			{
				dist[it[0]] = dist[y[1]] + it[1];
				pq.push({dist[it[0]],it[0]});
			}
		}
	}
	// for(auto it:dist)
	// 	cout<<it<<endl;
	while(q--)
	{
		int x,y;
		cin>>x>>y, --x, --y;
		cout<<dist[x]+dist[y]<<endl;
	}
	return 0;
}

Measured memory_bytes: 11120
import collections
import itertools
N = int(input())
S = [input().split() for i in range(N)]
S1 = list(itertools.chain.from_iterable(S))
cnt = collections.Counter(S1)

print('AC x ' + str(cnt['AC']))
print('WA x ' + str(cnt['WA']))
print('TLE x ' + str(cnt['TLE']))
print('RE x ' + str(cnt['RE']))


Measured memory_bytes: 33052
//#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

//ifstream cin("x.in"); ofstream cout("x.out");

int main() {
    cin.sync_with_stdio(false);
    cin.tie(); cout.tie();
    int a, b, c;
    cin >> a >> b >> c;

    int ans = 0;

    while (a + 2 <= b || a + 2 <= c) {
        a += 2;
        ++ ans;
    }

    while (b + 2 <= a || b + 2 <= c) {
        b += 2;
        ++ ans;
    }

    while (c + 2 <= a || c + 2 <= b) {
        c += 2;
        ++ ans;
    }

    if (a > b)
        swap(a, b);
    if (a > c)
        swap(a, c);
    if (b > c)
        swap(b, c);
    if (a > b)
        swap(a, b);
    if (a > c)
        swap(a, c);
    if (b > c)
        swap(b, c);

    if (a == b && b < c)
        ans ++;
    if (a < b && b == c)
        ans += 2;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<"------\n"<<#a<<" = "<<a<<endl<<"------"<<endl
#define debug2(a,b) cout<<"--------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<endl<<"--------------"<<endl
#define debug3(a,b,c) cout<<"----------------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<" ; "<<#c<<" = "<<c<<endl<<"----------------------"<<endl
#define sz(a) (ll)(a.size())
#define debug4(a) cout<<"chu "<<a<<endl
#define endl "\n"

string s;
vector <ll> v;
ll ans[100005];

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  cin>>s;
  v.pb(1);
  forn(i,0,sz(s)-1){
    ll j=i,cnt=0;
    while(s[j]=='R') {cnt++;j++;}
    ll index=j-1;
    while(s[j]=='L') {cnt++;j++;}
    if(cnt%2==0){
      ans[index]=cnt/2;
      ans[index+1]=cnt/2;
    }else{
      if((index-i+1)%2==1){
        ans[index]=cnt/2+1;
        ans[index+1]=cnt/2;
      }else{
        ans[index]=cnt/2;
        ans[index+1]=cnt/2+1;
      }
    }
    i=j-1;
  }
  forn(i,0,sz(s)) cout<<ans[i]<<" ";
  cout<<endl;
  return 0;
}


Measured memory_bytes: 1488
#include <stdio.h>

int a,i,x,y,z=0;
int num[100000];
int min = 1000006;
int result[100000];


int main(void) {
  while(scanf("%d",&a) && a!=0){
  num[i]=a;
  i++;
}

for(int k=0;k<i;k++){
  //printf("y\n");
  for(int y=0;y*y<=num[k];y++){
    //printf("y\n");
    for(int z=0;z*z*z <= num[k];z++){
      //printf("y\n");
      x = num[k]-y*y-z*z*z;
      //printf("%d\n",x);
      if(x>=0){
        if(x+y+z<=min) min=x+y+z;
        else;
      }
      else;
    }
  }
  result[k]=min;
  min=1000006;
}

//printf("%d\n",result[3]);
//  printf("%d\n",i);
for(int k=0;k<i;k++){
  printf("%d\n",result[k]);
}

  return 0;
}



Measured memory_bytes: 2028
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int A = sc.nextInt();
		int num = 0;

		while (H > 0) {
			H -= A;
			num += 1;
		}
		System.out.println(num);
		
		}
}


Measured memory_bytes: 23764
bingo = []
for i in range(3):
    bingo.append(list(map(int, input().split())))
n = int(input())
b = [int(input()) for _ in range(n)]

result = [[False, False, False] for _ in range(3)]

for i in range(n):
    for j in range(3):
        if b[i] in bingo[j]:
            result[j][bingo[j].index(b[i])] = True

# 横
for i in result:
    if all(i):
        print('Yes')
        exit()
# 縦
for i in range(3):
    if all([result[0][i], result[1][i], result[2][i]]):
        print('Yes')
        exit()
# 斜め
if all([result[0][0], result[1][1], result[2][2]]) or all([result[0][2], result[1][1], result[2][0]]):
    print('Yes')
    exit()

print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

int main(){
  int N, K; cin >> N >> K;
  vector<int> h(N + 1);
  for(int i = 1; i <= N; i++){
    cin >> h[i];
  }
  vector<int> dp(1e6, INF);
  dp[1] = 0;
  for(int i = 1; i <= N; i++){
    for(int k = 1; k <= K; k++){
      dp[i + k] = min(dp[i] + abs(h[i + k] - h[i]), dp[i + k]);
    }
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 4608
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] ab = new int[m][2];
		for(int i = 0; i < m; i++){
		    ab[i][0] = sc.nextInt();
		    ab[i][1] = sc.nextInt();
		}
		Arrays.sort(ab, (s, t) -> Integer.compare(s[1], t[1]));
		
		// 計算
		int result = 0;
		int now = 0;
		for(int i = 0; i < m; i++){
		    if(now < ab[i][0]){
		        result++;
		        now = ab[i][1] - 1;
		    }
		}
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 91292
#include<cstdio>
#include<algorithm>
int n,s[101],g,f,i;
int main()
{
	using namespace std;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&s[i]);
		if((s[i]%10)!=0){
			f=1;
		}
		g+=s[i];
	}
	
	if(f==0){
		g=0;
	}else{
		if((g%10)==0){
			sort(s,s+n);
				for(i=0;i<n;i++){
					//printf("%d\n",s[i]);
					if(((g-s[i])%10)!=0){
						g-=s[i];
						break;
					}
				}
		}
	}
	printf("%d\n",g);
	return 0;
}

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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  int aa,bb,cc;
  aa=b;
  bb=a;
  cc=c;
  a=cc;
  b=bb;
  c=aa;
  cout<<a<<" "<<b<<" "<<c<<endl;
}



Measured memory_bytes: 256
n, p = map(int, input().rstrip().split())
s = input().rstrip()

if p == 2 or p == 5:
    ans = 0
    s = map(int, s)
    for i, c in enumerate(s):
        if c % p == 0:
            ans += i + 1
    print(ans)
else:
    s = s[::-1]
    cnt = [0] * p
    k = 0
    cnt[k] = 1
    w = 1
    for i, c in enumerate(map(int, s)):
        k = c * w + k
        w *= 10
        while k >= p:
            k -= p
        while w >= p:
            w -= p
        cnt[k] += 1

    ans = 0
    for i in range(p):
        ans += cnt[i] * (cnt[i] - 1) // 2
    print(ans)


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

int main(){
	int N, T; cin >> N >> T;
	vector<int> c(N), t(N); for(int i = 0; i < N; ++i) cin >> c[i] >> t[i];

	int min_n = 1000007;
	for(int i = 0; i < N; ++i) {
		if(T >= t[i]) {
			if(min_n > c[i]) {
				min_n = c[i];
			}
		}
	}

	if(min_n == 1000007) {
		cout << "TLE" << endl;
	} else {
		cout << min_n << endl;
	}
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9+1)
#define MAXX (int)1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (ll)(1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
//printf("myco\n");//for debug
/*--------------------------------------------*/
int main(){
    int n;cin>>n;
    int half=n/2;
    half++;
    double ans=0.0;
    vector<double> p(n);rep(i,n)cin>>p[i];
    //dp[i][j]:i番目までにj個の奇数をもつ
    vector<vector<double>>dp(n+1,vector<double>(n+1));
    dp[0][0]=1;
    rep(i,n){
        for(int j=0;j<=i;j++){//前回全部でj個持っていた
            dp[i+1][j]+=dp[i][j]*(1-p[i]);
            dp[i+1][j+1]+=dp[i][j]*p[i];  
        }
    }
    for(int j=half;j<=n;j++){
        //printf("dp[n][%d]=%f\n",j,dp[n][j]);
        ans+=dp[n][j];
    }
    printf("%.10f\n",ans);
}

Measured memory_bytes: 70656
#include <iostream>
#include <sstream>
#include <cctype>
#include <deque>
#include <map>
#include <algorithm>
using namespace std;

struct yaml
{
  string str;
  map<string, yaml> obj;
  yaml(const string& s) : str(s) {}
  yaml(const map<string, yaml>& m) : obj(m) {}

  string query(deque<string>& q) const
  {
    if (q.empty()) {
      if (str.empty()) {
        return "object";
      } else {
        return "string \"" + str + "\"";
      }
    } else {
      if (str.empty()) {
        map<string, yaml>::const_iterator it = obj.find(q.front());
        if (it == obj.end()) {
          return "no such property";
        } else {
          q.pop_front();
          return it->second.query(q);
        }
      } else {
        return "no such property";
      }
    }
  }
};

typedef string::const_iterator Iterator;

int indent(Iterator& it, const Iterator& last)
{
  int n = 0;
  while (it != last && *it == ' ') {
    ++n;
    ++it;
  }
  return n;
}

string key(Iterator& it, const Iterator& last)
{
  string s;
  while (it != last && (islower(*it) || isdigit(*it))) {
    s += *it;
    ++it;
  }
  return s;
}

string string_(Iterator& it, const Iterator& last)
{
  string s;
  while (it != last && (islower(*it) || isdigit(*it) || *it == ' ')) {
    s += *it;
    ++it;
  }
  return s;
}

yaml mapping(Iterator& it, const Iterator& last);

pair<string, yaml> mapping_item(Iterator& it, const Iterator& last)
{
  string k = key(it, last);
  if (*it != ':') {
    throw __LINE__;
  }
  ++it;
  if (*it == ' ') {
    ++it;
    string s = string_(it, last);
    if (*it != '\n') {
      throw __LINE__;
    }
    ++it;
    return make_pair(k, yaml(s));
  } else if (*it == '\n') {
    ++it;
    const yaml y = mapping(it, last);
    return make_pair(k, y);
  } else {
    throw __LINE__;
  }
}

yaml mapping(Iterator& it, const Iterator& last)
{
  map<string, yaml> obj;
  const int n = indent(it, last);
  obj.insert(mapping_item(it, last));
  while (it != last) {
    const Iterator saved = it;
    if (n != indent(it, last)) {
      it = saved;
      break;
    }
    obj.insert(mapping_item(it, last));
  }
  return yaml(obj);
}

int main()
{
  string q;
  getline(cin, q);
  deque<string> v;
  replace(q.begin(), q.end(), '.', ' ');
  for (istringstream iss(q); iss >> q;) {
    v.push_back(q);
  }

  string src;
  for (string s; getline(cin, s);) {
    src += s + "\n";
  }

  Iterator it = src.begin(), last = src.end();
  try {
    yaml y = mapping(it, last);
    cout << y.query(v) << endl;
  } catch (int n) {
    cerr << "Error at " << n << endl;
  }
  return 0;
}

Measured memory_bytes: 1528
#include<stdio.h>
#include<stdlib.h>

int main(void){
  struct{
    int A,B;
  }data[200000];

  unsigned *board[2][4097]; 
  unsigned **calc,*center[4097],ans=0;
  int i,j,k,N;
  const unsigned mod=(unsigned)1E9+7;

  for(i=0;i<2;i++){
    for(j=0;j<4097;j++){
      board[i][j]=(unsigned *)calloc(4097,sizeof(unsigned));
      if(i==1) center[j]=board[1][j]+2049;
    }
  }
  calc=&center[2049];

  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d%d",&data[i].A,&data[i].B);

  for(i=0;i<4097;i++) for(j=0;j<4097;j++) board[0][i][j]=(i==0 || j==0)?1:(board[0][i][j-1]+board[0][i-1][j])%mod;
 
 for(i=0;i<N;i++) calc[-data[i].A][-data[i].B]++;
 for(i=0;i<4097;i++){
   for(j=0;j<4097;j++){
     if(i!=0) board[1][i][j]+=board[1][i-1][j];
     if(j!=0) board[1][i][j]+=board[1][i][j-1];
     board[1][i][j]%=mod;
   }
 }

 for(i=0;i<N;i++){
   ans+=calc[data[i].A][data[i].B];
   if(ans>=board[0][2*data[i].A][2*data[i].B]) ans-=board[0][2*data[i].A][2*data[i].B];
   else ans+=mod-board[0][2*data[i].A][2*data[i].B];
   ans%=mod;
 }
 
 if(ans%2) ans+=mod;
 ans/=2;
 printf("%u\n",ans%mod);

 //for(i=0;i<2;i++) for(j=0;j<4097;j++) free(board[i][j]);

  return 0;
}


Measured memory_bytes: 133120
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z, S;
ll ans = 0;

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

signed main() {
    cin >> N >> K >> S;
    for (int i = 0; i < N; i++) {
        if (i < K) {
            cout << S << " ";
        } else {
            if (S == 1) {
                cout << 2 << " ";
            } else
                cout << S - 1 << " ";
        }
    }
}

Measured memory_bytes: 1280
n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))

sum_A = sum(A)

def solve(i, m):
    if m == 0:
        return True
    if i >= n:
        return False
    res = solve(i + 1, m) or solve(i + 1, m - A[i])
    return res

for m in M:
    if m > sum_A:
        print("no")
        continue
        
    if solve(0, m):
        print("yes")
    else:
        print("no")


Measured memory_bytes: 5620
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

typedef long long int lli;

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

#ifdef LOCAL
	#define eprintf(...) printf(__VA_ARGS__)
#else 
	#define eprintf(...) 1
#endif

#define ROUNDUP(a, b) 		( ((a) + ((b) - 1) ) / b)
#define SET_ZERO(a)	 		( memset((a), 0, sizeof(a)))
#define SET_NUM_ARRAY(a,b)	( memset((a), b, sizeof(a)))

const int MAX_K = 1000*100;
int dist[MAX_K];
typedef pair<int, int> node;
int BFS01(int k) {
	for (int i = 0; i < k; i++) {
		dist[i] = 1001001001;
	}
	deque<node> deq;
	deq.push_front(node(1,1));

	while (!deq.empty()) {
		node v = deq.front();
		deq.pop_front();
		if (v.first == 0) return v.second;
		dist[v.first] = 1;

		int next = (v.first + 1) % k;
		if (dist[next] > dist[v.first] + 1) {
			deq.push_back(node(next,v.second+1));
		}

		next = (v.first * 10) % k;
		if (dist[next] > dist[v.first]) {
			deq.push_front(node(next, v.second));
		}
	}
}

int main() {
	int K;
	scanf("%d", &K);
	printf("%d\n", BFS01(K));
}


Measured memory_bytes: 1152
z=list(map(int,input().split()))
n,m,b,c=z[0],z[1],[1],0
a=[int(input()) for i in range(m)]
if len(a)>=1:
    if a[0]==1:
        b.append(0)
        c=1
    else:
        b.append(1)
        c=0
else:
    b.append(1)
for i in range(n-1):
    if c<len(a):
        if i+2==a[c]:
            b.append(0)
            c+=1
        else:
            b.append(b[i]+b[i+1])
    else:
        b.append(b[i]+b[i+1])
print(b[-1]%1000000007)

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

int main(){
	int x,y;
	cin >> x >> y;
	while(!(x==0&&y==0)){
		if(x<y) cout << x << " " << y << endl;
		else cout << y << " " << x << endl;
		cin >> x >> y;
	}
	return 0;
}


Measured memory_bytes: 3088
# include <iostream>
# include <stdint.h>
# include <stdio.h>
# include <math.h>
using namespace std;


int main(){
	int a ,b ;
	
	do{
cin >>a >>b;
		if(a !=0 ||b!=0)
		{for(int i =1;i<a+1;i++){
			int x =i%2;
					if(x ==1){
						for(int j=1;j<b+1;j++){
							int y =j%2;
							if(y ==1){
								cout <<"#";
							}
							else{
								cout <<".";
							}
						}cout <<"\n";
						
				}
					else{
						for(int j=1;j<b+1;j++){int y =j %2;
							if(y ==1){
								cout <<".";
							}
							else{
								cout <<"#";
							}
					
					}cout <<"\n";
			}			}}		
		else break;
		cout <<"\n";
	}while(a !=0 ||b!=0);

return 0;
}



Measured memory_bytes: 3092
N = int(input())
data = [list(map(int,input().split())) for l in range(N-1)]

for i in range(1,N+1):
    if i == N:
        print('0')
    else:
        time = 0
        for j in range(i,N):
            if time < data[j-1][1]:
                waitTime = data[j-1][1] - time
            else:
                waitTime =(data[j-1][2]-(time % data[j-1][2]))%data[j-1][2]
            time += waitTime + data[j-1][0]
        else:
            print(time)
                

Measured memory_bytes: 3188
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String str = sc.next();
		
		int counter = 0;
		int currentHighestLength = 0;
		
		while (counter < str.length()) {
			int testLength = 1;
			currentHighestLength = 0;
			if (str.charAt(counter) == 'A') {
				while (counter + testLength < str.length()) {
					if (str.charAt(counter + testLength) == 'Z' && testLength + 1 > currentHighestLength) {
						currentHighestLength = testLength + 1;
						testLength++;
					} else {
						testLength++;
					}
				}
				counter = str.length();
			} else {
				counter++;
			}
		}
		System.out.println(currentHighestLength);
	}

}

Measured memory_bytes: 27824
#include <iostream>
#include <string>
#include <sstream>
#include <math.h>
#include<string>
using namespace std;
int main(){
    int k,s;
    int count = 0;
    cin >> k >> s;
    for (int i = 0; i <= k; i ++){
        for (int j = 0; j <= k ; j++){
            if(0 <= s-i-j && s-i-j <= k)    count ++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 888
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
int main()
{
    fastio;
    ll n,k,i,sum=0;
    cin>>n>>k;
    vector<ll>v(n);
    for(i=0;i<n;i++)
        cin>>v[i];
    sort(v.begin(),v.end());
    for(i=0;i<k;i++)
    {
        sum+=v[i];
    }
    cout<<sum<<endl;
}


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

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

	int count = 0;
	for (int i = 0; i < n; ++i) {
		int h;
		cin >> h;

		if (h >= k) {
			++count;
		}
	}

	cout << count;

	return 0;
}


Measured memory_bytes: 256
local mmi, mma = math.min, math.max
local n, c = io.read("*n", "*n")
local x, y = {}, {}
local xm, ym = {}, {}
for i = 1, n do
  x[i], y[i] = io.read("*n", "*n")
  xm[x[i]], ym[y[i]] = true, true
end
local xuniq, yuniq = {}, {}
for k, v in pairs(xm) do
  table.insert(xuniq, k)
end
for k, v in pairs(ym) do
  table.insert(yuniq, k)
end
table.sort(xuniq)
table.sort(yuniq)
local jpos = 1
local xc, yc = #xuniq, #yuniq

local function solve(xl, xr, yl, yr)
  local z = 0
  for i = 1, n do
    if xl <= x[i] and x[i] <= xr
    and yl <= y[i] and y[i] <= yr then
      z = z + 1
    end
  end
  return c <= z
end
local ret = (xuniq[xc] - xuniq[1]) * (yuniq[yc] - yuniq[1])
for i = 1, xc do
  local ival = xuniq[i]
  for j = i, xc do
    local jval = xuniq[j]
    local lpos, lval = 1, yuniq[1]
    for k = 1, yc do
      local kval = yuniq[k]
      while not solve(ival, jval, kval, lval) do
        lpos = lpos + 1
        if yc < lpos then break end
        lval = yuniq[lpos]
      end
      if yc < lpos then break end
      ret = mmi(ret, (jval - ival) * (lval - kval))
    end
  end
end
print(ret)


Measured memory_bytes: 2784
import java.lang.*;
public class Main {
	
		
		public static void main(String[] args) {
			java.util.Scanner scan = new java.util.Scanner(System.in);
		int x = scan.nextInt();
			
//			BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
//			String str = br.readLine();
//			int x = Integer.parseInt(str);
//			
		if(1<=x && x<=100){;
		System.out.println(x*x*x);// TODO ?????????????????????????????????????????????
		}
			
			
		}
	
	}
	

Measured memory_bytes: 26104
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;

int n;
int a[2][128];
int r[2];

int main(){
	scanf("%d",&n);
	fore(k,0,2)fore(i,0,n)scanf("%d",&a[k][i]);
	r[0]=r[1]=0;
	fore(i,0,n){
		r[0]+=a[0][i];
		r[1]=max(r[1],r[0])+a[1][i];
	}
	printf("%d\n",r[1]);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		int temp = x;
		for (int i = 0; i < 10; i++) {
			System.out.println(r * temp - d);
			temp = r * temp - d;
		}
	}
}


Measured memory_bytes: 22996
X,Y = map(int,input().split())

if X * 4 < Y:
    print("No")
elif Y % 2 != 0:
    print("No")
else:
    for i in range(X+1):
        if i*2 + (X-i)*4 == Y:
            print("Yes")
            break
    else:
        print("No")

Measured memory_bytes: 9176
#include<stdio.h>

long long gcd(long long a, long long b){
    if(a == 0)return b;
    return gcd(b % a, a);
}

long long lcm(long long *a, long long *b, long long x, long long y){
    long long d = gcd(x, y);
    x /= d;y /= d;
    *a = *a / gcd(*a, x) * x;
    *b = gcd(*b, y);
}

int main(){
    long long  d[15], v[15], i;
    int n;
    while(scanf("%d", &n), n){
	long long ga = 1, gb = 0;
	for(i = 0;i < n;i++){
	    scanf("%lld%lld", d + i, v + i);
	    lcm(&ga, &gb, d[i], v[i]);
	}
	for(i = 0;i < n;i++){
	    printf("%lld\n", v[i] * ga / gb / d[i]);
	}
    }
    return 0;
}

Measured memory_bytes: 1028
n,*c=map(int,open(0).readlines())
l=[-1]*2**18
b=[]
for i in range(n):
  b.append(l[c[i]])
  l[c[i]]=i
dp=[1]+[0]*n
for i in range(1,n):
  dp[i]=dp[i-1]
  if c[i]!=c[i-1]and b[i]>-1:
    dp[i]=(dp[i]+dp[b[i]])%(10**9+7)
print(dp[-2])

Measured memory_bytes: 28660
#include <iostream>
#include <string>

using namespace std;

int main() {
	string str;
	int ans = 0, buf1=0, buf10=0, buf50=0, buf100=0;
	bool a=false, b=false, c= false, d=false;
	while(cin>>str){
		ans = 0;
		if(cin.eof()) break;
		for(int i=0; i<str.size(); i++){
			switch(str.at(i)){
				case 'I':
					buf1 += 1;
					break;
				case 'V':
					buf1 == 0 ? ans += 5 : ans += 5-buf1;
					buf1 = 0;
					break;
				case 'X':
					buf1 == 0 ? buf10 += 10 : ans += 10-buf1;
					buf1 = 0;
					break;
				case 'L':
					buf10 == 0 ? ans  += 50 : ans += 50-buf10;
					buf10 = 0;
					break;
				case 'C':
					buf10 == 0 ? buf100 += 100 : ans += 100-buf10;
					buf10 = 0;
					break;
				case 'D':
					buf100 == 0 ? ans += 500 : ans += 500-buf100;
					buf100 = 0;
					break;
				case 'M':
					buf100 == 0 ? ans += 1000 : ans += 1000-buf100;
					buf100 = 0;
					break;
			}
		}
		ans += (buf1+buf10+buf100);
		buf1 = buf10 = buf100 = 0;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1180
#include <stdio.h>
int main(void)
{
	int i,n;
	long long int kicount=0,gucount=0;
	long long int kisum=0,gusum=0,a;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lld",&a);
		kisum+=a;
		gusum+=a;
		if(i%2==0){
			if(kisum<=0){
				kicount+=1-kisum;
				kisum=1;
			}
			if(gusum>=0){
				gucount+=1+gusum;
				gusum=-1;
			}
		}else{
			if(kisum>=0){
				kicount+=1+kisum;
				kisum=-1;
			}
			if(gusum<=0){
				gucount+=1-gusum;
				gusum=1;
			}
		}
	}
	if(kicount<gucount){
		printf("%lld",kicount);
	}else{
		printf("%lld",gucount);
	}
	return 0;
}
		

Measured memory_bytes: 128
import copy
N = int(input())
A = input().split()
B = copy.copy(A)
boo = 1
while boo:
    boo = 0
    for i in range(N-1):
        if A[i][1] > A[i+1][1]:
            A[i], A[i+1] = A[i+1], A[i]
            boo = 1
print(*A)
print("Stable")
for i in range(N):
    mi = i
    for j in range(i,N):
        if B[mi][1] > B[j][1]:
            mi = j
    B[i], B[mi] = B[mi], B[i]
if A==B:
    print(*B)
    print("Stable")
else:
    print(*B)
    print("Not stable")



Measured memory_bytes: 6336
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    my_putchar_unlocked(c[i]);
  }
}
int N;
int M;
int A[100];
int main(){
  int i;
  int res = 0;
  int sm;
  rd(N);
  rd(M);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  {
    int e98WHCEY;
    int cTE1_r3A;
    if(N==0){
      cTE1_r3A = 0;
    }
    else{
      cTE1_r3A = A[0];
      for(e98WHCEY=(1);e98WHCEY<(N);e98WHCEY++){
        cTE1_r3A += A[e98WHCEY];
      }
    }
    sm =cTE1_r3A;
  }
  for(i=(0);i<(N);i++){
    if(A[i]*4*M >= sm){
      res++;
    }
  }
  if(res >= M){
    wt_L("Yes");
    wt_L('\n');
  }
  else{
    wt_L("No");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20200404-1

// --- original code ---
// int N, M, A[100];
// {
//   int res = 0, sm;
//   rd(N,M,A(N));
//   sm = sum(A(N));
//   rep(i,N) if(A[i]*4*M >= sm) res++;
//   wt(if[res >= M, "Yes", "No"]);
// }


Measured memory_bytes: 256
/*
   Author : tarang
*/
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
const int MOD = 1000000007;
#define PI = acos(-1)
using namespace std ;
int main(){
   ll n ; cin >> n ;
   n-=1;
   ll ans =0;
   for(int i = 1 ; i <= n ; i++){
   	   ans += n/i;
   }
   cout << ans << endl;
}


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

int main() {
  int A,B,C,D;
  cin >>A>>B>>C>>D;
  if (A+B > C+D)
    cout <<"Left"<<endl;
  else if(A+B == C+D)
    cout <<"Balanced"<<endl;
  else
    cout <<"Right"<<endl;
}

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

ll comb(ll a, ll b){
    ll up = 1;
    ll down = 1;
    ll c = b;
    for(ll i = 0; i < b; i++){
        up *= a;
        down *= c;
        c--;
        a--;

        if(up % down == 0){
            up /= down;
            down = 1;
        }
    }

    return up;
}

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

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

    sort(a, a + n);

    ll s = a[n - 1];
    ll ans = a[0];
    int k = s / 2;
    int t = k + 1;
    if(n % 2 == 0){
        for(int i = 0; i < n - 1; i++){
            if(a[i] == k){
                ans = k;
                break;
            }else if(a[i] > k){
                int l = a[i] - k;
                int m = k - a[i - 1];
                if(l >= m){
                    ans = a[i - 1];
                }else{
                    ans = a[i];
                }
                break;
            }else{
                ans = a[i];
            }
        }
    }else{
        for(int i = 0; i < n - 1; i++){
            if(a[i] == k || a[i] == t){
                if(a[i] == k){
                    ans = k;
                }else{
                    ans = t;
                }
                break;
            }else if(a[i] > t){
                int l = a[i] - k;
                int m = k - a[i - 1];
                if(l >= m){
                    ans = a[i - 1];
                }else{
                    ans = a[i];
                }
                break;
            }else{
                ans = a[i];
            }
        }
    }

    cout << s << " " << ans << endl;
}

Measured memory_bytes: 1024
N, W = map(int, input().split())
INF = 10**10
dp = [INF]*(N*1000+1)
dp[0] = 0
for i in range(N):
  w, v = map(int, input().split())
  for j in range(N*1000, v-1, -1):
    dp[j] = min(dp[j], dp[j-v]+w)

for i in range(N*1000+1)[::-1]:
  if dp[i]>0 and dp[i]<=W:
    print(i)
    break

Measured memory_bytes: 41580
#include <stdio.h>
int main(void){

  int n, q, i, left, right, mid;
  int m = 0;

  scanf("%d", &n);

  int S[n];

  for(i = 0; i < n; i++) {
    scanf("%d", &S[i]);
    }

  scanf("%d", &q);

  int T[q];

  for(i = 0; i < q; i++) {
    scanf("%d", &T[i]);
    }


  for(i = 0; i < q; i++) {
  left = 0;
  right = n;
  while(left < right){
    mid = (left + right) / 2;
      if (S[mid] == T[i]){
        m++;
        break;
        }
   else if (T[i] < S[mid]){
     right = mid;
        }
    else {
      left = mid + 1;
        }
   }

   }

   printf("%d\n", m);

   return 0;

}


Measured memory_bytes: 2372
import java.util.Scanner;

public class Main {

	public void main() {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			System.out.println(new StringBuilder(sc.next()).reverse()
					.toString());
		}
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.main();
	}
}

Measured memory_bytes: 17116
n = int(input())
if n == 1:
    print(0)
    exit()
    
def fact(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(cnt)

    if temp!=1:
        arr.append(1)

    if arr==[]:
        arr.append(1)

    return arr

l = [0] + [1]*2+[2]*3+[3]*4+[4]*5+[5]*6+[6]*7+[7]*8+[8]*9+[9]*10
ls = fact(n)
ans = 0
for v in ls:
    ans += l[v]
print(ans)

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

template<typename T>
class vector{
private:
    int idx = 0,sz = 1;
    T *arr;
public:
    
    void push_back(T val)
    {
        if(sz-1==idx)
        {
            T *a = new T[2*sz];
            sz = 2*sz + 1;
            for(int i=0;i<idx;i++) a[i] = arr[i];
            arr = a;
        }
        arr[idx++] = val;
    }
    
    void pop_back()
    {
        if(idx)
           idx--;
    }
    
    T operator[](const int k) const
    {
        return arr[k];
    }
    
    int size()
    {
        return idx;
    }
    
    void clear()
    {
        delete arr;
        idx = 0;
        sz = 1;
    }
};

int vis[100002];
vector<int>graph[100002];
int f;

void dfs(int u)
{
    if(vis[u]==1) return;
    vis[u] = 1;
    for(int i=0;i<graph[u].size();i++)
    {
        int v = graph[u][i];
        if(vis[v]==0) dfs(v);
        else if(vis[v]==1) f = 1;
    }
    vis[u] = 2;
}


int main() {
	int n,e;
	cin >> n >> e;
	
    f = 0;
   
    for(int i=0;i<e;i++)
    {
        int u,v;
        cin >> u >> v;
        graph[u].push_back(v);
    }
    for(int i=0;i<n;i++)
    {
        if(vis[i]==0)
        {
            dfs(i);
        }
    }
    cout << f << endl;
	    

	
	return 0;
}


Measured memory_bytes: 4684
'''input
10
0 1 2 3 4 5 6 7 8 9
'''
n = input()
arr = map(int,raw_input().split())
cou = [0]*(10**5+10)
for i in range(n):
	cou[arr[i]]+=1
	cou[arr[i]+1] += 1
	cou[arr[i]-1] += 1
print max(cou)





Measured memory_bytes: 42476
#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;
 
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define int ll
#define mpp make_pair
#define endl '\n'
#define ff first 
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
 
const int N = 5e5 + 5;
const int mod = 1e9 + 7;
const int INF = 1e15;

int arr[N];
int n, k;
int query = 1;
void print(int ret)
{
    cout << "Case #" << query++ << ": " << ret << endl;
}

void solve()
{
	int n;
	cin >> n;
	map<int, int> mp;
	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
		mp[arr[i]]++;
	}
	int tot = 0;
	for(auto x : mp)
	{
		tot += ((x.second) * (x.second - 1)) / 2;
	}
	for(int i = 0; i < n; i++)
	{
		int temp = (mp[arr[i]] * (mp[arr[i]] - 1)) / 2;
		tot -= temp;
		int save = ((mp[arr[i]] - 1) * (mp[arr[i]] - 2)) / 2;;
		tot += save;
		cout << tot << endl;
		tot -= save;
		tot += temp;
	}
}

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

	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    vector<ll>b(n+1);
    rep(i,n)cin>>a[i];
    b[0]=0;
    for(int i=1; i<=n; ++i){
        b[i]=b[i-1]+a[i-1];
    }
    map<ll,ll>mp;
    rep(i,n+1)mp[b[i]]++;
    ll ans=0;
    for(auto&p:mp){
        if(p.second>=2){
            ll cnt=p.second*(p.second-1)/2;
            ans+=cnt;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 15104
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();
    int[,] a;

    List<int[]> ans = new List<int[]>();
    int H;
    int W;

    public void Solve() {
        H = sc.nextInt();
        W = sc.nextInt();
        a = new int[H, W];

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                a[i, j] = sc.nextInt();
            }
        }
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (a[i, j] % 2 == 1) {
                    if (j + 1 < W && Sub(i, j + 1)) {
                        ans.Add(new int[] { i, j, i, j + 1 });
                        a[i, j + 1]++;
                        continue;
                    }

                    if (i + 1 < H && Sub(i + 1, j)) {
                        ans.Add(new int[] { i, j, i + 1, j});
                        a[i + 1, j]++;
                        continue;
                    }

                    if (j + 1 < W) {
                        ans.Add(new int[] { i, j, i, j + 1 });
                        a[i, j + 1]++;
                        continue;
                    }

                    if (i + 1 < H) {
                        ans.Add(new int[] { i, j, i + 1, j });
                        a[i + 1, j]++;
                        continue;
                    }

                }
            }
        }

        WriteLine(ans.Count);
        foreach (var s in ans) {
            WriteLine(string.Join(" ", s.Select(i => (i + 1).ToString())));
        }
    }

    bool Sub(int i, int j) {
        return a[i, j] % 2 == 1;
    }


}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {


        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}

Measured memory_bytes: 26028
import Data.List
dropLast n l = take ((length l) - n) l

x -: f = f x

getInt = (fmap read) getLine :: IO Int
getInts = ((fmap ((fmap read) . words)) getLine) :: IO [Int]
main = do
  n <- getInt
  a <- getInts
  let (cash, stock) = foldl step (1000, 0) (dropLast 1 a `zip` drop 1 a)
  print $ cash + stock * (last a)

step (cash,stock) (today,tomorrow) =
  if (stock > 0) && (today > tomorrow)
    then (cash + stock * today, 0)
    else if (stock == 0) && (today < tomorrow)
      then (cash `mod` today, cash `div` today)
      else (cash,stock)


Measured memory_bytes: 4292