akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main()
{
    ll n;
    cin >> n;
    if(n % 2) {
        cout << 0 << endl;
        return 0;
    }
    vector<ll> div;
    ll k = 10;
    while(k <= n) {
        div.push_back(k);
        k *= 5;
    }
    ll ans = 0;
    for(ll x : div) {
        ans += n / x;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def factorization(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([i, cnt])

    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])

    return arr


def main():
    a, b =MAP()
    g = gcd(a, b)
    soi = factorization(g)
    #print(soi)
    if soi == [[1, 1]]:
        print(1)
    else:
        print(len(soi) + 1)

if  __name__=='__main__':
    main()


Measured memory_bytes: 5144
import java.util.*;
public class Main{   
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int h = sc.nextInt();
      int w = sc.nextInt();
      int n = sc.nextInt();
      int max = Math.max(h,w);
      if(n%max==0)
      System.out.println(n/max);
      else System.out.println(n/max+1);
    }
    public static int lcm(int x, int y){
      return x*y/gcd(x,y);
    }
    public static int gcd(int x, int y){
      if(x < y)return gcd(y,x);
      if(y==0)return x;
      return gcd(y,x%y);
    }
}
class Pair{
    int a,b;

    Pair(int a, int b){
      this.a = a;
      this.b = b;
    }
}


Measured memory_bytes: 21972
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int> n(4);
  for(int i=0;i<4;i++) cin >> n[i]; 
  sort(n.begin(),n.end());
  if(n[0]==1&&n[1]==4){
    if(n[2]==7&&n[3]==9) cout << "YES\n";
    else cout << "NO\n";
  }
  else cout << "NO\n";
  return 0;
}


Measured memory_bytes: 256
import itertools
N,C=map(int,input().split())
D=[[int(i) for i in input().split()] for i in range(C)]
c=[[int(i)-1 for i in input().split()] for i in range(N)]
X=[[] for i in range(3)]
for i in range(N):
    for j in range(N):
        X[(i+j)%3].append(c[i][j])
for i in range(3):
    X[i].sort()
Z=[[0 for i in range(C)] for j in range(3)]
for i in range(3):
    for j in X[i]:
        Z[i][j]+=1
#iwakan
I=[[0 for i in range(C)] for j in range(3)]
for i in range(3):
    for j in range(C):
        for k in range(C):
            I[i][j]+=Z[i][k]*D[k][j]
S=itertools.permutations(range(C),3)
ans=10**9
for sg in S:
    tmp=0
    for i in range(3):
        tmp+=I[i][sg[i]]
    if ans>tmp:
        ans=tmp
print(ans)


Measured memory_bytes: 7920
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<math.h>
#include<utility>
#include<iomanip>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b;
	cin >> a >> b;
	cout << a * b;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
vector<int> G[N];
int dep[N],maxson[N],f[N];
void dfs(int u,int fa) {
	f[u]=fa;
	for(auto v:G[u]) {
		if(v==fa) continue;
		dep[v]=dep[u]+1;
		dfs(v,u);
		maxson[u]=max(maxson[u],maxson[v]);
	}
	maxson[u]++;
}
int main() {
	int n,s,e;
	scanf("%d%d%d",&n,&s,&e);
	for(int i=1,u,v;i<n;i++) {
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(e,-1);
	for(int i=1;i<=n;i++) maxson[i]--;
	int t=(dep[s]+1)/2,ans=0;
	for(int i=s;t;t--,i=f[i]) {
		ans=max(ans,dep[i]+maxson[i]-1);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  string S;
  cin >> S;
  int N = S.size();
  
  if (S.at(N-1) == 's'){
    cout << S << "es" << endl;
  }
  else {
    cout << S << 's' << endl;
  }
}
  
  

Measured memory_bytes: 3624
while s = gets do
  hu = s.split(',').map(&:to_i)
  cc = Array.new(13){0}
  hu.each { |c| cc[c-1] += 1 }
  st = cc.join
  cc.delete(0)

  scr='null'
  case cc.sort
    when [1,4]
      scr='four card'
    when [2,3]
      scr='full house'
    when [1,1,1,1,1]
      scr='straight' if st =~ /1{5}/ or st =~ /10{8}1{4}/
    when [1,1,3]
      scr='three card'
    when [1,2,2]
      scr='two pair'
    when [1,1,1,2]
      scr='one pair'
  end
  puts scr
end

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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) //cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}

int maxn = 6;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, k, i, j;
    cin >> n >> m >> k;
    vvi g(n, vi(m));
    vi smr(n, 0), smc(m, 0);
    int T = 0;
    for(i=0;i<n;i++){
        string s; cin >> s;
        for(j=0;j<m;j++){
            g[i][j] = s[j] == '.' ? 0 : 1;
            if(g[i][j]){
                smr[i]++;
                smc[j]++;
                T++;
            }
        }
    }
    //debug(T);
    //debug(smr);
    //debug(smc);
    int N = 1<<n; int M = 1<<m;
    int ans = 0;
    for(i=0;i<N;i++){
        for(j=0;j<M;j++){
            int a,b;
            int cnt = 0;
            for(a=0;a<n;a++){
                if(((1<<a) & i) == 0) continue;
                cnt += smr[a];
            }
            for(b=0;b<m;b++){
                if(((1<<b) & j) == 0) continue;
                cnt += smc[b];
            }
            for(a=0;a<n;a++){
                if(((1<<a) & i) == 0) continue;
                for(b=0;b<m;b++){
                    if(((1<<b) & j) == 0) continue;
                    if(g[a][b]){
                        cnt--;
                    }
                }
            }
            //debug(bitset<10>(i));
            //debug(bitset<10>(j));
            //debug(cnt);
            if(T - cnt == k) ans++;
        }
    }
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
 
int main(){

	int n;
	string s, st;
	cin >> n >> s;
	for(int i=0; i<n-1; i++){
		cin >> st;
		string sth;
		for(int j=0; j<s.length(); j++){
			for(int k=0; k<st.length(); k++){
				if(s[j]!=' ' && s[j]==st[k]){
					sth+=s[j];
					s[j]=' ';
					st[k]=' ';
				}
			}
		}
		s=sth;
	}
	sort(s.begin(), s.end());
	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        while(s.hasNextInt()){
            int h = s.nextInt();
            int w = s.nextInt();
            if(h == 0 && w == 0) break;
            for(int i = 0; i < h; ++i) {
                for(int j = 0; j < w; j++) {
                    System.out.print(((i != 0) && (i != h - 1) && (j != 0) && (j != w - 1))?'.':'#' );
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 26708
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
  	var arrSum = arr => arr.reduce((a,b) => a + b, 0);
    var N = parseInt(input[0], 10);
    var vec_A = [ ];
    var ary_xy = [ ];
    var ans = 0;
    var nHonest = 0;
    var tmpLine = 1;
    var tmpXy = [];
    var vec_honest = Array.from({ length: N }, () => 0);
    var vec_liar = Array.from({ length: N }, () => 0);
    for (var Ai = 1; Ai <=N; Ai++){
    	vec_A.push(parseInt(input[tmpLine], 10));
    	tmpLine ++;
    	for (var Li = 1; Li <= vec_A[Ai-1]; Li++){
          	tmpXy.push(input[tmpLine].map(e => parseInt(e, 10)));
            tmpLine++;
    	}
		ary_xy.push(tmpXy);
      	tmpXy = [];
    }
    for (var i = Math.pow(2, N); i <  Math.pow(2, N) * 2; i++){
    	tmpAry = i.toString(2).substr(1).split('').map(e => parseInt(e, 10));
    	vec_honest = VO(vec_honest, [0], '*');
	    vec_liar = VO(vec_liar, [0], '*');
    	tmpAry_loop:
    	for (var Ai = 1; Ai <=N; Ai++){
    		if (tmpAry[Ai - 1] == '1'){
    			for (var j =  1; j <= vec_A[Ai-1]; j++){
    				vec_honest[ary_xy[Ai-1][j-1][0]-1] = Math.max(vec_honest[ary_xy[Ai-1][j-1][0]-1],ary_xy[Ai-1][j-1][1]);
    				vec_liar[ary_xy[Ai-1][j-1][0]-1] = Math.max(vec_liar[ary_xy[Ai-1][j-1][0]-1],(1 - ary_xy[Ai-1][j-1][1]));
    			}
    		}
    	}
    	if (VO(vec_honest, vec_liar, '+').indexOf(2) == -1){
    			if (VO(vec_honest, tmpAry, '-').indexOf(1) == -1){	

    				if (VO(vec_liar, tmpAry, '+').indexOf(2) == -1){	
    					nHonest = arrSum(tmpAry);
    					ans = Math.max(ans, nHonest);
    				}
    			}
    	}		
    }
    console.log(ans);
}

function VO(v1, v2, op){
	var ans = []
	if (v1.length !== v2.length) {
      if (v2.length == 1){
        v2 = Array.from({ length: (v1.length) }, () => v2);
      } else {
      	return null;
      }
    }
	for (var i = 0; i < v1.length; i++){
		if (op == '+') {
			ans.push(v1[i] + v2[i]);
		} 
		if (op == '-') {
			ans.push(v1[i] - v2[i]);
		} 
		if (op == '*') {
			ans.push(v1[i] * v2[i]);
		} 
		if (op == '/') {
			ans.push(v1[i] / v2[i]);
		} 
		if (op == '%') {
			ans.push(v1[i] % v2[i]);
		} 
		if (op == '||') {
			ans.push(Math.max(v1[i],v2[i]));
		} 
	}
	return ans;	
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11224
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int taro[101];
int hanako[101];

int main(){ _;
  int n,m;
  while(cin>>n>>m,!(n==0&&m==0)){
    int taroSum=0,hanakoSum=0;
    REP(i,n){cin>>taro[i];taroSum+=taro[i];}
    REP(i,m){cin>>hanako[i];hanakoSum+=hanako[i];}
    int diff=taroSum-hanakoSum;
    if((diff > 0 ? diff : -diff)%2!=0){cout<<"-1"<<endl;continue;}
    diff/=2;
    REP(i,n){
      REP(j,m){
	if(taro[i]-hanako[j]==diff){
	  cout<<taro[i]<<" "<<hanako[j]<<endl;
	  goto res;
	}
      }
    }
    cout<<"-1"<<endl;
  res:;
  }
}

Measured memory_bytes: 1192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int main() {

	ll A, B, C;
	cin >> A >> B >> C;
	ll a, b, c;
	a = A/2, b=B/2, c=C/2;
	ll aa, bb, cc;
	aa = abs(a - (A-a));
	bb = abs(b - (B-b));
	cc = abs(c - (C-c));

	ll ret = INT64_MAX;
	ret = min(ret, aa * B * C);
	ret = min(ret, bb * C * A);
	ret = min(ret, cc * A * B);
	cout << ret << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    string S;
    cin >> S;
    int N=S.length();
    bool nine=true;
    for(int i=1;i<N;i++){
        if(S[i]-'9'!=0)nine=false;
    }
    ll sum=(S[0]-'0')+(N-1)*9-1;
    if(nine)sum++;
    cout << sum;

}

/*



 */



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

int n;
string order, str;
set<string> dic;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> order >> str;
		if (order == "insert") {
			dic.insert(str);
		}
		else if (order == "find") {
			cout << (dic.find(str) != dic.end() ? "yes" : "no") << endl;
		}
	}

	return 0;
}

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

using db = double;
using ll = long long;
using vi = vector <int>;
#define op operator
#define pb push_back

int main() {
	ios :: sync_with_stdio(0);

	for(int n; cin >> n && n; ) {
		int ans = 0;
		for(n /= 5; n; n /= 5)
			ans += n;
		cout << ans << '\n';
	}

	return 0;
}

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

ll ar[100005];

int main()
{
 

    int N;

    scanf("%d", &N);

    for(int i = 0; i < N; i++)
    {
        scanf("%lld", &ar[i]);
    }

    ll cursum;
    ll prevsum;

    ll ans = 0;

    prevsum = ar[0];

    if(prevsum == 0)
    {
        prevsum++;
        ans++;
    }
    else
    {
        if(ar[0] < 0)
        {
            ans = abs(ar[0]) + 1;
            prevsum = 1;
        }
    }

    for(int i = 1; i < N; i++)
    {
        cursum = prevsum + ar[i];

        if(!cursum)
        {
            if(prevsum > 0)
            {
                cursum--;
            }
            else
            {
                cursum++;
            }
            prevsum = cursum;
            ans++;
            continue;
        }

        if(cursum > 0 && prevsum > 0)
        {
            ans = ans + cursum + 1;
            cursum = -1;
        }
        else
        {
            if(cursum < 0 && prevsum < 0)
            {
                ans = ans + abs(cursum) + 1;
                cursum = 1;
            }
        }
        prevsum = cursum;
    }

    ll ansi = 0;

    prevsum = ar[0];
    if(prevsum == 0)
    {
        prevsum--;
        ansi++;
    }
    else
    {
        if(ar[0] > 0)
        {
            ansi = abs(ar[0]) + 1;
            prevsum = -1;
        }
    }

    for(int i = 1; i < N; i++)
    {
        cursum = prevsum + ar[i];

        if(!cursum)
        {
            if(prevsum > 0)
            {
                cursum--;
            }
            else
            {
                cursum++;
            }
            prevsum = cursum;
            ansi++;
            continue;
        }

        if(cursum > 0 && prevsum > 0)
        {
            ansi = ansi + cursum + 1;
            cursum = -1;
        }
        else
        {
            if(cursum < 0 && prevsum < 0)
            {
                ansi = ansi + abs(cursum) + 1;
                cursum = 1;
            }
        }
        prevsum = cursum;
    }
    cout<<min(ans, ansi)<<endl;

    //cout<<ans<<" "<<ansi<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include<vector>
#include<list>
#include<map>
#include<set>
#include<deque>
#include<queue>
#include<stack>
#include<bitset>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<iostream>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<string>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<climits>
#include<complex>
#define sz(x) (int)((x).size())
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define clr(x) memset((x),0,sizeof(x))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
struct Seg
{
    int s[4];
    int val;
}seg[120000*20];
int tot=0,root=-1;
void insert(int x,int y,int val,int minx,int maxx,int miny,int maxy,int &v)
{
    if (x<minx||x>=maxx||y<miny||y>=maxy)
    {
        return;
    }
    if (v==-1)
    {
        v=tot++;
        memset(seg[v].s,-1,sizeof(seg[v].s));
        seg[v].val=INT_MAX;
    }
    if (minx+1==maxx&&miny+1==maxy)
    {
        seg[v].val=min(seg[v].val,val);
        return;
    }
    int midx=(minx+maxx)>>1;
    int midy=(miny+maxy)>>1;
    insert(x,y,val,minx,midx,miny,midy,seg[v].s[0]);
    insert(x,y,val,minx,midx,midy,maxy,seg[v].s[1]);
    insert(x,y,val,midx,maxx,miny,midy,seg[v].s[2]);
    insert(x,y,val,midx,maxx,midy,maxy,seg[v].s[3]);
    seg[v].val=INT_MAX;
    int i;
    for (i=0;i<4;i++)
    {
        if (seg[v].s[i]!=-1)
        {
            seg[v].val=min(seg[v].val,seg[seg[v].s[i]].val);
        }
    }
}
int find(int ax,int bx,int ay,int by,int minx,int maxx,int miny,int maxy,int v)
{
    if (v==-1)return INT_MAX;
    if (ax>=maxx||bx<=minx||ay>=maxy||by<=miny)
    {
        return INT_MAX;
    }
    if (ax<=minx&&bx>=maxx&&ay<=miny&&by>=maxy)
    {
        return seg[v].val;
    }
    int midx=(minx+maxx)>>1;
    int midy=(miny+maxy)>>1;
    int tmp=find(ax,bx,ay,by,minx,midx,miny,midy,seg[v].s[0]);
    tmp=min(tmp,find(ax,bx,ay,by,minx,midx,midy,maxy,seg[v].s[1]));
    tmp=min(tmp,find(ax,bx,ay,by,midx,maxx,miny,midy,seg[v].s[2]));
    tmp=min(tmp,find(ax,bx,ay,by,midx,maxx,midy,maxy,seg[v].s[3]));
    return tmp;
}
char buf[100];
int main()
{
    int stt;
    int r,c,q,i,j,k;
    while (scanf("%d%d%d",&r,&c,&q)!=EOF)
    {
    	if (r==0&&c==0&&q==0)break;
    	root = -1;
    	tot= 0;
    	for (i=1;i<=r;i++)
    	{
    		for (j=1;j<=c;j++)
    		{
    			scanf("%d",&k);
    			insert(i, j, k, -1, r+10, -1, c+10, root);
    		}
    	}
        while (q--)
        {
           // else
            {
                int minx, maxx, miny, maxy;
                scanf("%d %d %d %d", &minx, &miny, &maxx, &maxy);
                printf("%d\n", find(minx+1, maxx + 2, miny+1, maxy + 2, -1, r+10, -1, c+10,
                                    root));
            }
        }
    }
    return 0;
}

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

int main() {
  int64_t N,A,B;
  cin>>N>>A>>B;
  if((B-A)%2==0){
    cout<<(B-A)/2<<endl;
  }
  else{
    cout<<min((A+B-1)/2,(1-A-B)/2+N)<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

#include <cstring>

#include <vector>

#include <string>

#include <algorithm>

using namespace std;

int main()

{
	
	int x,a,b;
	
	cin>>x>>a>>b;
	
	int ans1,ans2;
	
	if(x>=a)
	
	ans1=x-a;
	
	else
	
	ans1=a-x;
	
	if(x>=b)
	
	ans2=x-b;
	
	if(b>x)
	
	ans2=b-x;
	
	if(ans1<=ans2)
	
	cout<<"A";
	
	else
	
	cout<<"B";
	
	return 0;
	
 } 

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

bool b[100001];

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) {
        cin >> a[i];
        a[i]--;
    }

    b[0] = true;
    int cnt = 0;
    int prev = 0;
    while (cnt < N and !b[1]) {
        b[prev] = 0;
        b[a[prev]] = 1;
        prev = a[prev];
        ++cnt;
    }

    if (b[1]) cout << cnt << endl;
    else cout << -1 << endl;

}


Measured memory_bytes: 768
using System;
using System.Collections.Generic;
					
public class my
{
	public static void Main()
	{
		var n = my.GetInt();
		var A = my.GetIntArray(n);
		
		var pivotIdx = my.Partition(A, 0, n-1);
		
		for(int i = 0; i<n; i++) {
			if(i == pivotIdx)	Console.Write("[");
			Console.Write(A[i]);
			if(i == pivotIdx)	Console.Write("]");
			
			if(i != n-1)	Console.Write(" ");
			else	Console.WriteLine();
		}
		
	}
	
	private static int Partition(int[] A, int p, int r)
	{
		var x = A[r];
		var i = p-1;
		
		for(int j = p; j < r; j++) {
			if(A[j] <= x) {
				my.Swap(A, ++i, j);
			}
		}
		my.Swap(A, i+1, r);
		
		return i+1;	// pivot index
	}
	
	private static void Swap(int[] A, int i, int j)
	{
		int tmp = A[i];
		A[i] = A[j];
		A[j] = tmp;
	}
	
	private static int GetInt()
	{
		return int.Parse(Console.ReadLine());
	}
	
	private static int[] GetIntArray()
	{
		return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
	}

	private static int[] GetIntArray(int n)
	{
		var A = new int[n];
		var s = Console.ReadLine().Split(' ');

		for(int i = 0; i < n; i++) {
			A[i] = int.Parse(s[i]);
		}
		return A;
	}
	
	private static int[] GetIntArray(int n, string t)
	{
		var A = new int[n];
		var s = t.Split(' ');

		for(int i = 0; i < n; i++) {
			A[i] = int.Parse(s[i]);
		}
		return A;
	}

	private static int[] GetIntArray(char c)
	{
		return Array.ConvertAll(Console.ReadLine().Split(c), int.Parse);
	}
	
	private static int[] GetIntArray(char c, string s)
	{
		return Array.ConvertAll(s.Split(c), int.Parse);
	}
	
	private static int[] GetIntArray(string s)
	{
		return Array.ConvertAll(s.Split(' '), int.Parse);
	}
	
	private static double[] GetDoubleArray()
	{
		return Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
	}
	
	public static string Reverse(string s)
	{
		var c = s.ToCharArray();
		Array.Reverse(c);
		
		return new String(c);
	}
	
	private static void WriteArray(int[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}

	private static void WriteArray(long[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}
	
	private static void WriteVector(Vector v)
	{
		Console.WriteLine(string.Format("{0:f8} {1:f8}", v.X, v.Y));
	}
}

public struct Vector
{
	public double X,Y;
}

Measured memory_bytes: 15832
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	string s,t,ans="",tmp;
	string aa="UNRESTORABLE";
	int f=0;
	cin>>s>>t;
	int tl=t.length();
	FORD(i,s.length()-tl+1,0){
		FOR(j,0,tl){
			if(s[i+j]!=t[j]&&s[i+j]!='?')break;
			if(j==tl-1){
				tmp=s;
				FOR(k,0,i){
					if(tmp[k]=='?')tmp[k]='a';
				}
				FOR(k,0,tl){
					if(tmp[k+i]=='?')tmp[k+i]=t[k];
				}
				FOR(k,i+tl,s.length())if(tmp[k]=='?')tmp[k]='a';
				if(f==0)ans=tmp;
				else if(ans>tmp)ans=tmp;
				f=1;
			}
		}
		//if(f)break;
	}
	if(f==0)ans=aa;
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdlib>

const int MAX_W = 100;
const int MAX_H = 100;
int H, W;
char field[MAX_H][MAX_W] = {'.'};

void solve(int y, int x) {
    int dx[4] = {-1, 0, 1, 0};
    int dy[4] = {0, 1, 0, -1};
    char c = field[y][x];
    field[y][x] = '.';

    for(int i = 0; i < 4; i++) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(nx >= 0 and ny >= 0 and nx < W and ny < H and field[ny][nx] == c) {
            solve(ny, nx);
        }
    }


}

void print(int w, int h) {
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            std::cout << field[i][j];
        }
        std::cout << std::endl;
    }

    std::cout << std::endl;
}

int main() {
    while (std::cin >> H >> W, H) {
        for (int i = 0; i < H; i++) {
            std::cin >> field[i];
        }

        int count = 0;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (field[i][j] != '.') {
                    solve(i, j);
                    count++;
                }
            }
        }
        std::cout << count << std::endl;
    }

    return 0;
    return 0;
}

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

int main() {
  int n, m, x; cin >> n >> m >> x;
  vector<int> arr(m);
  for (auto &a : arr) cin >> a;
  int cost = lower_bound(arr.begin(), arr.end(), x) - arr.begin();
  cout << min(cost, m-cost) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
signed main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int ans=0;
	for(int i=0;i<3001;i++){
		for(int j=0;j<3001;j++){
			if((d-(a*i)-(b*j))%c==0&&d-(a*i)-(b*j)>=0){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
}			

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;
constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
#ifndef LOCAL
struct osd{template<class T>osd&operator<(const T&t){return*this;}template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;template<class...T>void _print(osd&a,T&&...t){}
#define cerr cer_
#endif
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}template<class T>istream&operator>(istream&i,T&t){return i>>t;}
void _print(ostream&s){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<t<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}template<class...T>void dprint(T&&...t){_print(cerr,t...);}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<p.F<' '<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>p.F>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>queue<T>&operator<<(queue<T>&q,const T&t){q.push(t);return q;}template<class T>queue<T>&operator<<(T&t,queue<T>&q){t=q.front();q.pop();return q;}
template<class T>deque<T>&operator>>(const T&t,deque<T>&q){q.push_front(t);return q;}template<class T>deque<T>&operator<<(T&t,deque<T>&q){t=q.front();q.pop_front();return q;}
template<class T>deque<T>&operator<<(deque<T>&q,const T&t){q.push_back(t);return q;}template<class T>deque<T>&operator>>(deque<T>&q,T&t){t=q.back(t);q.pop_back();return q;}
template<class T>stack<T>&operator<<(stack<T>&s,const T&t){s.push(t);return s;}template<class T>stack<T>&operator>>(stack<T>&s,T&t){t=s.top();s.pop();return s;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int l,r;
    cin>l>r;
    chmin(r,l+2019);
    ll mi=INF;
    REP(i,l,r+1){
        REP(j,i+1,r+1){
            chmin(mi,1ll*i*j%2019);
        }
    }
    cout<mi<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(long long i=(a);((a)<(b)?i<=(b):i>=(b));((a)<(b)?++i:--i))
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

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

template<class Type_a,class Type_b> inline bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> inline bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}

bool jud(int y,int x,int h,int w){//グラフないか判断.
	return (0<=y and y<h)and(0<=x and x<w);
}

int main(){//BFSで解く! //Refering other editorials.
	using type=tuple<int,int,int>;//tuple(y,x,dp).
	
	int h,w;
	cin>>h>>w;
	
	int ch,cw,dh,dw;
	cin>>ch>>cw>>dh>>dw;
	ch--, cw--, dh--, dw--;
	
	vector<string> s(h);
	REP(i,h) cin>>s[i];
	
	vvi dp(h,vi(w,INF));
	dp[ch][cw]=0;
	deque<type> que;//コストが少ないものを優先的に探索する.
	que.push_front(type(ch,cw,0));
	while(!que.empty()){
		int y,x,value;
		tie(y,x,value)=que.front();
		que.pop_front();
		if(value>dp[y][x]) continue;
		
		FOR(i,-2,2)FOR(j,-2,2){
			int ny=y+i, nx=x+j;//移動先.
			if(jud(ny,nx,h,w)){
				bool flag=false;//移動Aでいけるか.
				REP(k,4){
					if(i==dy[k] and j==dx[k]) flag=true;
				}
				
				if(s[ny][nx]=='.'){
					if(chmin(dp[ny][nx],dp[y][x]+(flag?0:1))){
						if(flag) que.push_front(type(ny,nx,dp[ny][nx]));
						else que.push_back(type(ny,nx,dp[ny][nx]));
					}
				}
			}
		}
	}
	
	if(dp[dh][dw]==INF) cout<<-1<<endl;
	else cout<<dp[dh][dw]<<endl;
}

Measured memory_bytes: 9516
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())

N = int(input())
S = str(input())

r = 0
b = 0
for i in range(N) :
  if S[i] == "R" :
    r += 1
  else :
    b += 1

if r > b :
  print ("Yes")
else :
  print ("No")
  



Measured memory_bytes: 3436
A, B = map(int, input().split())

print(100, 100)

a = A-1
b = B-1

a,b = b,a

qa = a//50
qb = b//50
ra = a%50
rb = b%50
for i in range(50):
  if i%2 == 1:
    print("."*100)
  else:
    if qa == 0:
      if ra == 0:
        print("."*100)
      else:
        print("#."*ra+".."*(50-ra))
        ra = 0
    else:
      print("#."*50)
      qa -= 1
for i in range(50):
  if i%2 == 0:
    print("#"*100)
  else:
    if qb == 0:
      if rb == 0:
        print("#"*100)
      else:
        print(".#"*rb+"##"*(50-rb))
        rb = 0
    else:
      print(".#"*50)
      qb -= 1

Measured memory_bytes: 3192
#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 - 1; 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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  int n;
  cin >> n;

  while(1){
    int tmp = n;
    int c3 = tmp / 100;
    tmp %= 100;
    int c2 = tmp / 10;
    tmp %= 10;
    if(c3 == c2 && c2 == tmp){
      cout << n;
      return 0;
    }
    n++;
  }
}


Measured memory_bytes: 256
Str = input().split()
N = int(Str[0]) #参加人数
K = int(Str[1]) #持ち点
Q = int(Str[2]) #問題数
li = [0 for i in range(N)]

for num in range(Q):
  i = int(input())
  li[i-1] += 1
  
for a in range(N):
  if li[a]>=Q-K+1:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 4708
# -*- coding: utf-8 -*-

[N, M] = [int(i) for i in input().split()]
LR = []
for m in range(M):
    LR.append((int(i) for i in input().split()))

max_l = 0
min_r = 100000
for m in range(M):
    (l, r) = LR[m]
    if l > max_l:
        max_l = l
    if r < min_r:
        min_r = r

if max_l > min_r:
    print(0)
else:
    print(min_r - max_l + 1)


Measured memory_bytes: 89356
#include<bits/stdc++.h> 
using namespace std;
 
#define ll long long int
#define absdiff(a,b) (a>b)?a-b:b-a
#define debug cout<<"debug";
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);
#define MOD 1000000007
#define ll_MAX 19223372036859
#define endl "\n"
ll fast_expo(ll x,ll p){if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
ll gcd(ll a,ll b){if(a==0||b==0) return a+b;  else return gcd(b%a,a); }


int main()
{
    ll t;t=1;
    // cin>>t;
    for(ll x=0;x<t;++x){
        string str;cin>>str;
        ll val=0;
        ll n=str.size();
        for(ll i=0;i<n/2;++i){
            if(str[i]!=str[n-1-i]) val++;
        }

        cout<<val;
    }
    return 0;
}

Measured memory_bytes: 256
n,t = map(int,input().split())
A = list(map(int,input().split()))
inf = float('inf')
m = [0]*n
m[0] = A[0]
M = [0]*n
M[n-1] = A[n-1]
for i in range(n-1):
    m[i+1] = min(m[i],A[i+1])
    M[n-i-2] = max(M[n-i-1],A[n-2-i])

delta = [M[i+1] - m[i] for i in range(n-1)]
can = max(delta)
ans = 0
for i,a in enumerate(A):
    if a == m[i] + can:
        ans += 1
print(ans)


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

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

int main()
{
    long long int a,b,k,i;
    scanf("%lld %lld %lld",&a,&b,&k);
    if(k<=a)
    {
        printf("%lld %lld\n",a-k,b);
    }
    else if(k>a && k<a+b )
    {
        printf("0 %lld\n",a+b-k);
    }
    else if(k>=a+b)
    {
        printf("0 0\n");
    }
}

Measured memory_bytes: 128
import sys
n = int(input())
a = list(map(int, input().split()))
for i in range(1, n):
  if a[i] - 1 >= a[i - 1]:
    a[i] -= 1
for i in range(1, n):
  if a[i - 1] > a[i]:
    print("No")
    sys.exit()
print("Yes")

Measured memory_bytes: 63856
h, w = gets.split.map(&:to_i)

s = []
h.times do |i|
  s[i] = gets.split('')
end

h.times do |i|
  w.times do |j|
    if s[i][j] == '#'
      result = false
      result = true if i != 0 && s[i-1][j] == '#'
      result = true if j != 0 && s[i][j-1] == '#'
      result = true if i != h-1 && s[i+1][j] == '#'
      result = true if j != w-1 && s[i][j+1] == '#'
      unless result
        puts 'No'
        exit
      end
    end
  end
end
puts 'Yes'


Measured memory_bytes: 2172
#include <stdio.h>
#include <string.h>
int main()
{
	char taro[101],hanako[101];
	int i,n;
	int tpt=0,hpt=0;

	//何ターンにするか
	scanf("%d",&n);
	for(i=0;i<n;i++){
	//両者のカードの情報を入力
	    scanf("%s %s",taro,hanako);
	//カードを比較する(名前の辞書順)
		//大きいものに3pt、引き分けで両者1pt
        if ( strcmp(taro, hanako) == 0 ){
           // printf("taro == hanako\n");
            tpt++;
            hpt++;
        }
  	    else if(strcmp(taro,hanako)>0){
  	      //  printf("taro > hanako\n");
  	        tpt += 3;
  	    }
  	    else if(strcmp(taro,hanako)<0){
  	       // printf("taro < hanako\n");
  	        hpt += 3;
  	    }
	}
	//両者の得点を出力する
	printf("%d %d\n",tpt,hpt);
	return 0;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>dp(n+1,100000);
    dp[0]=0;
    for(int i=0;i<n;i++){
        int nine=1,six=1;
        for(int j=(n-i)/9;j>0;j/=9)nine*=9;
        for(int j=(n-i)/6;j>0;j/=6)six*=6;
        dp[i+nine]=min(dp[i+nine],dp[i]+1);
        dp[i+six]=min(dp[i+six],dp[i]+1);
    }
    cout<<dp[n]<<endl;
    return 0;
}

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

#define ll long long int
#define INFTY (1<<21)

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    int r;
    cin>>r;
    if(r<2800)
        if(r<1200) cout<<"ABC"<<endl;
        else cout<<"ARC"<<endl;
    else cout<<"AGC"<<endl;
    return 0;
}

Measured memory_bytes: 256
/*
 this->author = Fuad Ashraful Mehmet, CSE-UAP
 ToDo--
 https://codeforces.com/contest/707/problem/D
*/
#include<bits/stdc++.h>
#define forn(i,n) for(int i=0;i<(int)n;++i)
#define all(o) (o).begin(),(o).end()
#define dbg(o)  cerr<<"at "<<__LINE__<<" response = "<<o<<endl;

using namespace std;

typedef long long ll;
int n,m,k;

void HalfDead()
{
      cin>>n;
      vector<int>v(n);
      for(int &x:v)cin>>x;
      sort(all(v));

      ll res=v[n-1];
      int run=n-2;
      int idx=n-2;
      while(run)
      {
            if(run==1)
            {
                  res+=(v[idx]);
                  idx--;
                  run--;
            }
            else
            {
                  res+=(v[idx]+v[idx]);
                  idx--;
                  run-=2;
            }
            
      }
      cout<<res<<"\n";

}
int main()
{
      ios_base::sync_with_stdio(0); cin.tie(nullptr);
      HalfDead();

      return 0;
}

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

int main() {
  int H, W, A, B, N;
  int y=0;
  long int x=0;
  string S;
  cin >> N;
  vector<int> vec(N);

  for ( int i=0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for (int i=0; i < N; i++) {
    for (int j=1; j< N-i; j++) {
      for (int k=1; k< N-i-j; k++) {
        if (vec.at(i)+vec.at(i+j)>vec.at(i+j+k))
          x++;
      }
    }
  }

  cout << x << endl;

    
}

Measured memory_bytes: 256
(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let () = Scanf.sscanf (read_line ()) "%s %s" (
        fun a b -> 
                let n = float_of_string (a ^ b) in
                let h = floor (sqrt n) in
                        if (h ** 2.0) = n then
                                "Yes"
                        else
                                "No"
) |> Printf.printf "%s\n"


Measured memory_bytes: 1152
#include <cmath>
#include <deque>
#include <iostream>
#include <string>
#include <utility>

using namespace std;

int main()
{
    int X = 0;
    int ans = 0;

    cin >> X;

    if (400 <= X && X <= 599)
        ans = 8;
    else if (600 <= X && X <= 799)
        ans = 7;

    else if (800 <= X && X <= 999)
        ans = 6;
    else if (1000 <= X && X <= 1199)
        ans = 5;
    else if (1200 <= X && X <= 1399)
        ans = 4;
    else if (1400 <= X && X <= 1599)
        ans = 3;
    else if (1600 <= X && X <= 1799)
        ans = 2;
    else if (1800 <= X && X <= 1999)
        ans = 1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	char str[101];
	int s, t, count=0;

	while(scanf("%s", str) != EOF){

		s = 0;
		t = strlen(str) - 1;

		while(1){
			if(s == t || s - t == 1)
				count++;
			if(str[s] == str[t]){
				s++;
				t--;
			} else
				break;
		}

	}

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

	return 0;
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
using namespace std;
    
int main() {
    int Time[5];
    int num,i,amari,select,matome;
    num = 5;
    matome = 0;
    for (i=0;i<5;i++) {
        cin >> Time[i];
    }
    while (num > 1) {
        num=0;
        for (i=0;i<5;i++) {
            amari = Time[i] % 10;
            if (amari != 0) {
                num++;
            }
            if (amari > Time[select] % 10) {
                select = i;
            }
        }
        if (num > 1) {
            Time[select] += 10 - Time[select] % 10;
        }
    }
    for (i=0;i<5;i++){
        matome += Time[i];
    }
    cout << matome;
}





Measured memory_bytes: 256
N,W = map(int,input().split())
WV = [tuple(map(int,input().split())) for i in range(N)]
w0 = WV[0][0]
a = [[],[],[],[]]
for w,v in WV:
    i = w-w0
    a[i].append(v)
for i in range(4):
    a[i].sort(reverse=True)
c = [[0] for _ in range(4)]
for i in range(4):
    for b in a[i]:
        c[i].append(c[i][-1] + b)

ans = 0
for i,v0 in enumerate(c[0]):
    for j,v1 in enumerate(c[1]):
        for k,v2 in enumerate(c[2]):
            for l,v3 in enumerate(c[3]):
                w = w0*(i+j+k+l) + j + k*2 + l*3
                if w>W: break
                ans = max(ans, v0+v1+v2+v3)
print(ans)

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

int mod = 1e9+7;
long long f(int a){
	long long x = 1;
	for(int i = a;i>=2;i--){
		x*=i;
		x%=mod;
	}
	return x;
}

int main(){
	int n,m;
	
	cin >> n >> m;
	if(n-m>1||m-n>1) cout << 0;
	else{
		long long ans = 0;
		if(m==n){
			ans = f(n);
			ans*=ans;
			ans%=mod;
			ans*=2;
			ans%=mod;
		}
		else{
			ans=f(m)*f(n);
			ans%=mod;
		}
		cout << ans;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
int x,y,z;
  int a;
  int b;
  scanf("%d", &x);
  scanf("%d", &y);
  scanf("%d", &z);
  
  a=x;
  x=y;
  y=a;
  b=x;
  x=z;
  z=b;
  printf("%d %d %d", x,y,z);
  return 0;
}
  

Measured memory_bytes: 1728
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main(){
	
	string str;
	cin >> str;
	
	int a = 0;
	int b = 0;
	int c = 0;
	int N = str.size();
	
	for(int i = 0; i < str.size(); i++){
		if(str[i] == 'a'){
			a++;
		}else if(str[i] == 'b'){
			b++;
		}else{
			c++;
		}
	}
	
	bool flag = true;
	if(a != N / 3 && a != N / 3 + 1){
		flag = false;
	}
	if(b != N / 3 && b != N / 3 + 1){
		flag = false;
	}
	if(c != N / 3 && c != N / 3 + 1){
		flag = false;
	}
	
	if(flag){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	
	return 0;
}

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

const int MAX_N = 1e7 + 1;

vector<bool> is_prime;

vector<bool> hurui() {
    vector<bool> res(MAX_N, true);
    res[0] = res[1] = false;
    for (int i = 2; i < MAX_N; i++) {
        if (!res[i]) continue;
        int idx = i * 2;
        while (idx < MAX_N) {
            res[idx] = false;
            idx += i;
        }
    }
    return res;
}

void M(int n, int p) {
    vector<int> primes;
    int cnt = 100;
    for (int i = n + 1; i < MAX_N; i++) {
        if (is_prime[i]) {
            primes.push_back(i);
            cnt--;
        }
        if (cnt == 0) break;
    }
    vector<int> prime_sum;
    for (int i = 0; i < primes.size(); i++) {
        for (int j = i; j < primes.size(); j++) {
            prime_sum.push_back(primes[i] + primes[j]);
        }
    }
    sort(prime_sum.begin(), prime_sum.end());
    cout << prime_sum[p - 1] << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, P;
    is_prime = hurui();
    while (true) {
        cin >> N >> P;
        if (N < 0 && P < 0) break;
        M(N, P);
    }
    return 0;
}


Measured memory_bytes: 5072
n,m=map(int,input().split())
import math
def ncr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

ans=0
if n>1:
    ans+=ncr(n,2)
if m>1:
    ans+=ncr(m,2)
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>                                
                                                 
signed main()                                    
{                                                
  int a,b;                                       
  scanf("%d %d",&a,&b);                          
                                                 
  if( a + b >= 24 )printf("%d\n",(a + b)-24);    
  else printf("%d\n",a + b);                     
                                                 
  return 0;                                      
                                                 
}                                                
                                                 

Measured memory_bytes: 128
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=2*1e3+2;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	// freopen("out10.txt","w",stdout);
	#endif
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	int p[a],q[b],r[c];
	for(int i=0;i<a;i++) cin>>p[i];
	for(int i=0;i<b;i++) cin>>q[i];
	for(int i=0;i<c;i++) cin>>r[i];
	int wow=0;
	multiset<int> lol;
	for(int i=0;i<b;i++)
	{
		lol.insert(q[i]);
	}
	while(lol.size()>y)
	{
		auto o=lol.begin();
		lol.erase(o);
	}
	int sum=0;
	for(auto ok:lol)
	{
		sum+=ok;
	}
	// cout<<sum<<"\n";
	int ans[c+1];
	ans[0]=sum;
	sort(r,r+c);
	for(int i=0;i<c;i++)
	{
		sum+=r[i];
		lol.insert(r[i]);
		auto o=lol.begin();
		sum-=*o;
		lol.erase(o);
		ans[i+1]=sum;
		// cout<<ans[i+1]<<" ";
	}
	sort(p,p+a);
	reverse(p,p+a);
	sort(q,q+b);
	reverse(q,q+b);
	reverse(r,r+c);
	int pref[c+1];
	pref[0]=0;
	for(int i=1;i<=c;i++)
	{
		pref[i]=pref[i-1]+r[i-1];
		// cout<<pref[i]<<" ";
	}
	int ans1=0;
	int sum_t=0;
	for(int i=0;i<=x;i++)
	{
		if(i!=0){
			sum_t+=p[i-1];
		}
		// cout<<sum_t<<"\n";
		int temp=sum_t;
		int left=(x-i);
		if(left>c)
		{
			continue;
		}
		temp+=pref[left];
		// cout<<i<<" "<<pref[left]<<"\n";
		int kek=(c-left);
		temp+=ans[kek];
		// cout<<temp<<" ";
		ans1=max(ans1,temp);
	}
	cout<<ans1<<"\n";
}
// 
// Don't be afraid to fail. Be afraid not to try.
// "Become grindian instead of greendian" - aryanc403
// When you want to succeed as bad as you want to breathe, only then you’ll Be Successful!
// No Matter,How Fast You Are Driving If You Are Driving in a Wrong Direction You Will Never Reach Your Destination
// When failures hit you, you hit the failures back with Bounce Back!
// When you face failures, Don’t change your goal, Change your strategy!

Measured memory_bytes: 8832
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

X = i_i()

ans = 0
ans = int(X / 500) * 1000

ans += int((X % 500) / 5) * 5

print(ans)

Measured memory_bytes: 3060