akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
N, W = [int(x) for x in stdin.readline().rstrip().split()]

V = 10**3+1
baggage = [0]*N

for l in range(N):
    w, v = [int(x) for x in stdin.readline().rstrip().split()]
    baggage[l] = (w, v)

dp = [[10**9+1]*(N*V+1) for _ in range(N+1)]
dp[0][0] = 0  # 最初の要素が0でないと更新が開始しない

for i in range(N):
    for v in range(N*V+1):
        if v - baggage[i][1] >= 0:
            dp[i+1][v] = min(dp[i][v],dp[i+1][v], baggage[i][0]+dp[i][v-baggage[i][1]])

        else:
            dp[i+1][v] = min(dp[i][v], dp[i+1][v])
ans = 0
for K in range(N*V+1):
    if dp[N][K] <= W:
        ans = max(ans, K)
print(ans)

Measured memory_bytes: 119276
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,K;
    cin >> N >> K;
    while(N != 0){
        vector<int> A(K);
        for(int i=0; i<K; i++){
            cin >> A[i];
        }
        sort(A.begin(),A.end());
        bool can = false; 
        if(A[0] == 0) can = true;
        vector<pair<pair<int,int>,int>> vec;
        for(int i=0; i<K; i++){
            if(A[i] == 0) continue;
            if(!vec.size()){
                vec.push_back(make_pair(make_pair(A[i],A[i]),1));
            }else{
                if(vec.back().first.second+1 == A[i]){
                    vec.back().first.second++;
                    vec.back().second++;
                }else{
                    vec.push_back(make_pair(make_pair(A[i],A[i]),1));
                }
            }
        }
        int ans = 0;
        for(int i=0; i<vec.size(); i++){
            if(can and i < vec.size()-1){
                if(vec[i+1].first.first - vec[i].first.second == 2){
                    chmax(ans,vec[i].second + vec[i+1].second + 1);
                }
            }else{
                chmax(ans,vec[i].second);
            }
        }
        cout << ans << enld;
        cin >> N >> K;
    }
    return 0;
}


Measured memory_bytes: 3520
import java.util.*;
public class Main{
	public static void main(String args[]){  
  		Scanner sc = new Scanner(System.in);
      	int N = sc.nextInt();
      	int[] d = new int[N];
      
      	for(int i=0; i<N; i++){
        	d[i] = sc.nextInt();
        }
      
      	Arrays.sort(d);
      
      	int cnt = 1;
      
      	for(int i=0; i<N-1; i++){
          if(d[i] != d[i+1]){
          	cnt += 1;  
          }
        }
      
      	System.out.println(cnt);
    }  
}  

Measured memory_bytes: 23124
#include <algorithm>
#include <iostream>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

#define INF 1000000000

using namespace std;

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

    string s;
    cin >> s;

    for (int i = 0; i < min(K, (int) s.size()); ++i) {
        cout << s[i];
    }

    if (K < s.size()) {
        cout << "...";
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 3628
def input_li():
    return list(map(int, input().split()))


def input_int():
    return int(input())


def prime_factorization(n):
    table = []
    for x in range(2, int(n ** 0.5) + 1):
        while n % x == 0:
            table.append(x)
            n //= x
    if n > 1:
        table.append(n)
    return table


A, B = input_li()
A_SET = set(prime_factorization(A))
B_SET = set(prime_factorization(B))
print(len(A_SET & B_SET) + 1)


Measured memory_bytes: 63032
N = int(input())
cntAB = 0
A, B = [], []
for i in range(N):
  s = input()
  cntAB += s.count('AB')
  if s[0] == 'B': B.append(i)
  if s[-1] == 'A': A.append(i)

setAB = set(A).intersection(B)
len_setAB = len(setAB)
if len_setAB > 0:
  if len_setAB == len(A) and len_setAB == len(B):
    print(cntAB+len_setAB-1)
  elif len_setAB == len(A) or len_setAB == len(B):
    print(cntAB+len_setAB)
  else:
    print(cntAB+min(len(A),len(B),N-1))
else:
  print(cntAB+min(len(A),len(B),N-1))

Measured memory_bytes: 48104
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;
const int N_MAX=1e5*2+1;

signed main(){
  int d;
  cin>>d;
  if(d==22)cout<<"Christmas Eve Eve Eve"<<endl;
  if(d==23)cout<<"Christmas Eve Eve"<<endl;
  if(d==24)cout<<"Christmas Eve"<<endl;
  if(d==25)cout<<"Christmas"<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >


using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=2e5+10,mod=1e9+7;


int main ()
{
    FASTIO
    ll k , x;
    cin >> k >> x;
    if(x<=k*500){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}
/**

*/


Measured memory_bytes: 256
def solve():
  S = input()
  ans = 0
  now = ''
  i = 0
  while i<len(S)-1:
    if S[i]==now:
      now += S[i+1]
      i += 1
    else:
      now = S[i]
    i += 1
    ans += 1
  if i==len(S)-1 and now!=S[i]:
    ans += 1
  return ans
print(solve())

Measured memory_bytes: 9284
var n,m,i,cnt,sum  :int64;
    a:array[1..1000]of int64;
begin
  readln(n,m);
  for i:=1 to n do read(a[i]);
  sum:=0; cnt:=0;
  for i:=1 to n do sum:=sum+a[i];
  for i:=1 to n do begin
    if a[i]*4*m>=sum then cnt:=cnt+1;
  end;
  if cnt>=m then writeln('Yes')
  else writeln('No');  
end. 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
#define NIL -1


struct Node {int parent,left,right;};
struct Node T[100];
int D[100],H[100];

int getSibling(int u){
    if(T[u].parent == NIL)return -1;
    else if(T[T[u].parent].left != NIL && T[T[u].parent].left != u){
        return T[T[u].parent].left;
    }
    else if(T[T[u].parent].right != NIL && T[T[u].parent].right != u){
        return T[T[u].parent].right;
    }
    else return -1;
}

void setDepth(int u,int p){      //根の接点番号をuとする
    if(u == NIL)return;
    D[u] = p;
        setDepth(T[u].right,p+1);
        setDepth(T[u].left,p+1);
}

int getDegree(int u){
    int res=0;
    if(T[u].left != NIL)res++;
    if(T[u].right != NIL)res++;
    return res;
}

int setHeight(int H[],int u){
    int h1 = 0, h2 = 0;
    if(T[u].right != NIL)
        h1 = setHeight(H,T[u].right)+1;
    if(T[u].left != NIL)
        h2 = setHeight(H,T[u].left)+1;

    return H[u]=max(h1, h2);
}

int printType(int u){
    if(T[u].parent == NIL)cout <<"root";
    else if(getDegree(u))cout << "internal node";
    else cout << "leaf";
}



int main() 
{
    int n;
  	cin >> n;
    //構造体配列の初期化
    rep(i,n){
        T[i].parent = T[i].left =T[i].right =NIL;
    }

    //親、子の設定
    rep(i,n){
        int id,l,r;
        cin >> id;
            cin >> l;
                T[id].left = l;
                T[l].parent =id;
            cin >> r;
                T[id].right = r;
                T[r].parent = id;
    }

    //根の接点番号の設定
    int r;
    rep(i,n){
        if(T[i].parent == NIL)r=i;
    }

    //各ノードの深さ
    setDepth(r,0);

    //各ノードの高さ
    rep(i,n){
        setHeight(H,i);
    }

    //出力
    rep(i,n){
        cout << "node " << i 
        << ": parent = "<< T[i].parent 
        <<", sibling = "<< getSibling(i)
        <<", degree = " << getDegree(i)
        << ", depth = " << D[i]
        <<", height = " << H[i] << ", ";
        printType(i);
        cout << endl;
    }

    

}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C){
    cout << (A+B >= C ? YES : NO) << endl;
}

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


Measured memory_bytes: 256
from math import ceil

def is_ok(m):

    tmp = h[:]

    for i in range(N):
        tmp[i] -= m*B

    if not any(tmp):
        return True

    rem = 0
    for i in tmp:
        if i > 0:
            rem += ceil(i/(A-B))

    if rem > m:
        return False

    return True

N,A,B = map(int,input().split())
h = list(int(input()) for _ in range(N))
s = sum(h)
##二分散策

r = 10**10
l = 0

while abs(l-r) > 1:

    m = (r+l)//2

    if is_ok(m):
        r = m
    else:
        l = m

print(r)

Measured memory_bytes: 18256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  int N; cin >> N;
  int X[N], M[N];
  for (int i = 0; i < N; i++) {
    scanf("%d", &X[i]); M[i] = X[i];
  }
  sort(M, M + N);
  int m1 = M[N / 2 - 1], m2 = M[N / 2];
  for (int i = 0; i < N; i++){
    if (X[i] <= m1) cout << m2 << endl;
    else cout << m1 << endl;
  }

  return 0;
}


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

int main() {
  char C;
  cin >> C;
  
  if (C == 'a' || C == 'i' || C == 'u' || C == 'e' || C == 'o') {
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include <string>
#include <cstdlib>
#include <vector>
#include <iostream>
#include <cmath>

using namespace std;
using v = vector<unsigned int>;

int main(int argc, char **argv){
  unsigned int  N=0;
  cin >> N;
  vector<vector<unsigned long long>> c(9, vector<unsigned long long>(9, 0));
  for(unsigned int i=0;i<=N;i++){
    if(i%10){
      unsigned int l = i%10;
      unsigned int s = i;
      while(s>=10){
        s /= 10;
      }
      c[s-1][l-1]++;
    }
  }

  unsigned int count = 0;
  for(size_t i=0;i<9;i++){
    for(size_t j=0;j<9;j++){
      count += c[i][j]*c[j][i];
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 888
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static Dictionary<Tuple<string, string>, long> MakeDictionary(string S)
        {
            int N = S.Length;
            var dict = new Dictionary<Tuple<string, string>, long>();
            for (int i = 0; i < 1 << N; ++i)
            {
                var a = new StringBuilder();
                var b = new StringBuilder();
                for (int j = 0; j < N; ++j)
                {
                    if ((i & (1 << j)) == 0) { a.Append(S[j]); } else { b.Append(S[j]); }
                }
                var key = new Tuple<string, string>(a.ToString(), b.ToString());
                if (!dict.ContainsKey(key)) { dict[key] = 0; }
                ++dict[key];
            }
            return dict;
        }
        static long Solve(int N, string S)
        {
            var T = new string(S.Reverse().ToArray());
            var a = MakeDictionary(S.Substring(0, N));
            var b = MakeDictionary(T.Substring(0, N));
            long sum = 0;
            foreach (var pair in a)
            {
                if (b.ContainsKey(pair.Key)) { sum += pair.Value * b[pair.Key]; }
            }
            return sum;
        }

        static void Main(string[] args)
        {
            int N = ReadInt();
            string S = Read();
            Console.WriteLine(Solve(N, S));
        }
    }
}


Measured memory_bytes: 100380
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


int main(){
    int n; cin >> n;
    vector<int> p(n),q(n),v(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    rep(i,n) v[i] = i+1;
    
    int a = 0,b = 0,A,B;

    do{
        bool ok = false;
        rep(i,n){
            if(p[i] == v[i]){
                ok = true;
                continue;
            }else{
                ok = false;
                break;
            }
        }
        if(!ok) a++;
        else  A = a;
    }while(next_permutation(v.begin(),v.end()));

    rep(i,n) v[i] = i+1;

    do{
        bool ok = false;
        rep(i,n){
            if(q[i] == v[i]){
                ok = true;
                continue;
            }else{
                ok = false;
                break;
            }
        }
        if(!ok) b++;
        else  B = b;
    }while(next_permutation(v.begin(),v.end()));


    cout << abs(A-B) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <unordered_map>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <deque>
#include <map>
using namespace std;

typedef long long ll;

int main(void)
{
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	int sum_a = 0;
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
		sum_a += a[i];
	}

	int pop = 0;

	for (size_t i = 0; i < n; i++)
	{
		if (4 * m * a[i] >= sum_a)
		{
			pop++;
		}
	}

	if (pop >= m)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int w[201000], c1, c2, n, K, ck = 0;
char p[201000];
int Get(int pv){
    if(ck && pv==1)return 1;
    int t = pv + c2;
    if(t > n) return (pv+n)&1;
    return (p[t-1]-'A') ^ (c2&1);
}
int main(){
    int i;
    scanf("%d%d",&n,&K);
    scanf("%s",p);
    if(K > 4*n){
        K = 4*n + (K&1);
    }
    for(i=1;i<=K;i++){
        if(!Get(1)){
            ck = 1;
            c1++;
        }
        else{
            ck = 0;
            c2++;
        }
    }
    for(i=1;i<=n;i++)printf("%c",'A'+Get(i));
}

Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
#include <limits>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
const int inf = 1000000000; //10^9

int main(){
    int X, Y;
    cin >> X >> Y;
    for (int i = 0; i <= X; i++)
    {
        int leg = Y;
        // かめ
        if (4 * i <= Y)
        {
            leg -= 4 * i;
        }else
        {
            break;
        }
        // cout << leg << endl;
        // つる
        if (2*(X-i) == leg)
        {
            // cout << i << endl;
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main()
    {
        StringBuilder sb = new StringBuilder();
        Stack<string> stk = new Stack<string>();
        string s = "";
        while ((s = Console.ReadLine()) != null)
        {
            if (s == "0")
            {
                sb.AppendLine(stk.Pop());
            }
            else
            {
                stk.Push(s);
            }
        }
        Console.Write(sb);
    }
}


Measured memory_bytes: 14264
#include <iostream>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if (a+b == c || a+c == b || b+c == a) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  MAX 1000
int seq[MAX+10];
int seqlen[MAX+10];
int main() {
	int i,j,k,N,max,maxlen=1;
	for(i=1; i<=9; i++)
		seqlen[i]=1;
	scanf("%d",&N);
	for(i=1; i<=N; i++)
		scanf("%d",&seq[i]);
	sort(seq+1,seq+N+1);
	for (i=2; i<=N; i++) {
		max=0;
		for (j=1; j<=i-1; j++) {
			if(seq[j]<seq[i]&&seqlen[j]>max)
				max=seqlen[j];
		}
		seqlen[i]=max+1;
		if(seqlen[i]>maxlen)
			maxlen=seqlen[i];
	}
	printf("%d\n",maxlen);
	return 0;
}

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

query = []
bridge = [1 for _ in range(N-1)]

for _ in range(M):
    a, b = map(int, input().split())
    query.append((a, b))

#街が左にある方を優先
query = sorted(query, key=lambda x: x[1])
#喧嘩する街が近い方を優先
# query = sorted(query, key=lambda x: x[2])

ans = 0
left = 0
for i, j in query:
    if left < i:
        left = j-1
        ans += 1

# print(bridge)
print(ans)

Measured memory_bytes: 19752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
using pl = pair<ll,ll>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;

const int M=10000;

int main(int argc,char* argv[])
{
    int a,b;
    cin>>a>>b;
    cout<<((b%a)?b-a:a+b)<<endl;
    return 0;
}




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

#define rep(i,n) for (int i =0;i<(n);i++)
#define LL long long 

using namespace std;

int main(){
    int x,y,a,b,c,d,hi,ke,xh,yh;
    cin >>xh>>yh;
    
    cin >>x>>y;
    
    cin>>a>>b>>c>>d;

    xh=(xh/10)*c+xh*a;
    yh=(yh/20)*d+yh*b;
    hi=xh+yh;

    x=(x/10)*c+(x)*a;
    y=(y/20)*d+(y)*b;
    ke=x+y;
    string ans;
    if(hi>ke)ans="hiroshi";
    else if(hi<ke)ans="kenjiro";
    else ans="even";
    cout <<ans<<endl;

    return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n;
    cin >> n;
    vector<int> t(n),x(n),y(n);
    int sx = 0, sy = 0,st = 0;
    rep(i, n)
    {
        cin >> t[i] >> x[i] >> y[i];
        int num = abs(x[i] - sx) + abs(y[i] - sy);
        st = t[i] - st;
        num = st - num;
        if(num < 0 || num % 2 == 1){
            cout << "No" << endl;
            return 0;
        }else{
            sx = x[i];
            sy = y[i];
            st = t[i];
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1408
use ascii::{AsciiStr, AsciiString};
use proconio::input;

fn main() {
    input! {
        k: usize,
        mut s: AsciiString,
    }

    if s.len() > k {
        s.truncate(k);
        s += AsciiStr::from_ascii(b"...").unwrap();
    }

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


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

int main()
{
    int s, s1, s2, s3;

    cin >> s;

    s1 = s / 100;
    s2 = (s - s1 * 100) / 10;
    s3 = s - s1 * 100 - s2 * 10;

    cout << s1 + s2 + s3;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<map>

#define f first
#define s second

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int main(){
  int a,b,n;
  while(cin>>a>>b>>n){
    int ans = 0;
    a = a % b;
    REP(i,n){
      a *= 10;
      ans += a/b;
      a = a%b;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
w,h,n=map(int,input().split())
xl=[0]
xr=[w]
yu=[h]
yd=[0]

for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        xl.append(x)
    elif a==2:
        xr.append(x)
    elif a==3:
        yd.append(y)
    else:
        yu.append(y)
if max(xl)>=min(xr) or max(yd)>=min(yu):
    print(0)
else:
    xb=max(xl)+w-min(xr)
    yb=max(yd)+h-min(yu)
    print(h*w-xb*h-yb*w+xb*yb)
        


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n,k;
    cin >> n >> k;
    vector<ll>x(n);
    vector<ll>mx;
    vector<ll>px;
    for(ll i=0;i<n;i++){
        cin >> x[i];
        if(x[i]<0) mx.push_back(x[i]);
        else px.push_back(x[i]);
    }
    ll mcnt=mx.size();
    ll pcnt=px.size();
    reverse(mx.begin(),mx.end());
    ll ans=1e18;
    if(k>1){
        for(ll i=0;i<mcnt;i++){
            if(k<i-1) break;
            ll dx=0;
            dx+=(mx[i]*(-2));
            if(pcnt<k-i-1||k-i-2<0) continue;
            dx+=px[k-i-2];
            ans=min(ans,dx);
        }
        for(ll i=0;i<pcnt;i++){
            ll dx=0;
            dx+=px[i]*2;
            if(mcnt<k-i-1||k-i-2<0) continue;
            dx+=(-1)*mx[k-i-2];
            ans=min(ans,dx);
        }
    }
    if(k<=pcnt) ans=min(ans,px[k-1]);
    if(k<=mcnt) ans=min(ans,((-1)*mx[k-1]));
    cout << ans << endl;
}


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

int main() {
    int N,C;
    cin >> N >> C;
    vector<vector<int>> D(C, vector<int>(C, 0));
    for(int i = 0; i < C; i++)
    {
        for(int j = 0; j < C; j++)
        {
            cin >> D.at(i).at(j);
        }
        
    }
    vector<vector<int>> coler(N, vector<int>(N, 0));
    vector<vector<int>> cnt(3, vector<int>(C + 1, 0));
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N; j++)
        {
            cin >> coler.at(i).at(j);
            cnt.at(((i + 1) + (j + 1)) % 3).at(coler.at(i).at(j))++;
        }
        
    }

    int ans = INT_MAX;
    int sum = 0;
    for(int i = 1; i <= C; i++)
    {
        for(int j = 1; j <= C; j++)
        {
            if (i == j) continue;
            for(int k = 1; k <= C; k++)
            {
                if (i == k || j == k) continue;
                
                sum = 0;
                
                for(int p = 1; p <= C; p++)
                {
                    if (i == p) continue;

                    sum += cnt.at(0).at(p) * D.at(p - 1).at(i - 1);
                }

                for(int p = 1; p <= C; p++)
                {
                    if (j == p) continue;

                    sum += cnt.at(1).at(p) * D.at(p - 1).at(j - 1);
                }
                
                for(int p = 1; p <= C; p++)
                {
                    if (k == p) continue;

                    sum += cnt.at(2).at(p) * D.at(p - 1).at(k - 1);
                }

                ans = min(ans, sum);
            }
            
        }
        
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1280
import java.io.*;
import java.util.StringTokenizer;

public class Main {
static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter pw =new PrintWriter(new OutputStreamWriter(System.out));
static StringTokenizer st;
static int N,K =0;
static int INF = (int) (1e9+5);
    public static void main(String[] args) throws IOException {
	// write your code here
        st = new StringTokenizer(br.readLine());
        N = Integer.parseInt(st.nextToken());
        K = Integer.parseInt(st.nextToken());
        st = new StringTokenizer(br.readLine());
        int [] arr =new int[N];
        for (int i=0;i<N;i++)
            arr[i]  = Integer.parseInt(st.nextToken());
        int [] dp =new int[N];
        for (int i=0;i<N;i++)
            dp[i] = INF;
        dp[0] = 0;
     //   pw.println(INF+1000);
        for (int i=0;i<N;i++){
           for (int j=1;j<=K;j++) {
               int k= j+i;
               if (k<N) {
                   int u = dp[i] + Math.abs(arr[i] - arr[k]);
                   int v = dp[k];
                   //System.out.println(u+ " "+v);
                   dp[k] = Math.min(u, v);
               }
           }

        }
        pw.println(dp[N-1]);
        pw.flush();
    }
}


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

int a[10010];
int ans[101][101];
int main(){
	int h, w, n;
	scanf("%d%d%d", &h, &w, &n);
	for(int i = 0;i < n;i++)scanf("%d", &a[i]);
	
	int d = 0, cnt = 0;
	for(int i = 0;i < h;i++){
		if(i % 2 == 0)d = 0;
		else d = w-1;
		for(int j = 0;j < w;j++){
			ans[i][d] = cnt+1;
			if(--a[cnt] == 0)cnt++;
			if(i % 2 == 0)d++;
			else d--;
		}
	}
	
	for(int i = 0;i < h;i++){
		printf("%d", ans[i][0]);
		for(int j = 1;j < w;j++)printf(" %d", ans[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if (a<=c && a+b>=c) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;



int main(void){
    ll N, M;
    ll a, b, ma[200000];
    cin>>N>>M;
    MEMSET(ma, 0);
    rep(i, M){
        cin>>a>>b;
        ma[b]=max(a, ma[b]);
    }
    ll cutpoint=0, cutcount=0;
    rep1(i, N){
        if(cutpoint<ma[i]){
            cutcount++;
            cutpoint=i-1;
        }
    }
    cout<<cutcount<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
  int n;
  scanf("%d",&n);
  int h[n];
  int i;
  i = 0;
  while (i < n)
  {
    scanf("%d",&h[i]);
    i++;
  }
  i = 0;
  int cnt;
  cnt = 1;
  int highest;
  highest = h[0];
  while (i < n)
  {
    if (i > 0 && h[i] >= highest)
    {
      cnt++;
      highest = h[i];
    }
    i++;
  }
  printf("%d",cnt);
}

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


int main(){
    int a,p;
    cin >> a >> p;
    int x=a*3+p;

    cout << x/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
#sys.setrecursionlimit(150000)

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: "List[int]", N: int, b: "List[int]"):
    for i in range(N):
        for j in range(9):
            if A[j]==b[i]:
                A[j]=0
    ans=NO
    #tate
    for i in range(3):
        if A[i]==A[i+3]==A[i+6]==0: ans=YES
    #yoko
    for i in range(3):
        if A[i*3]==A[i*3+1]==A[i*3+2]==0: ans=YES
    #naname
    if A[0]==A[4]==A[8]==0: ans=YES
    if A[2]==A[4]==A[6]==0: ans=YES

    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [int(next(tokens)) for _ in range(3*3)]  # type: "List[int]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(A, N, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  string s[200005];
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  sort(s,s+n);
  int f=0;
  for(int i=0;i<n-1;i++){
    if(s[i]==s[i+1]){
      f++;
    }
  }
  cout<<n-f;

}


Measured memory_bytes: 9912
N = int(input())
arr = sorted(list(map(int, input().split())))

import math
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

ans_list = sorted(make_divisors(arr[0]),reverse=True)

for i in ans_list:
    flg =True
    for j in arr:
        if j%i != 0:
            flg =False
            break
    if flg:
        print(i)
        exit()

Measured memory_bytes: 86768
#include <stdio.h>
int main(void){
    // Your code here!
    int n, i, j, d[1000], s=0;
    
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&d[i]);
    
    for(i=0;i<n;i++){
        for(j=1;j<n;j++) s+=d[i]*d[i+j];
    }
    printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 128
/*                                  deepyadav442 --> :     c++14     <--                                */
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
/*                                           input                    */
#define si(i) scanf("%d",&i)
#define sii(i,j) scanf("%d%d",&i,&j)
#define siii(i) scanf("%lld",&i)
#define sss(s) scanf("%s",s)
/*                                           output                   */
#define pi(i) printf("%d",i)
#define pii(i,j) printf("%d%d",i,j)
#define piii(i) printf("%lld",i)
#define space printf(" ")
#define newline printf("\n")
/*                                          loops &stls                      */
#define loop(i,s,n) for(i=s;i<n;i++)
#define looprev(i,s,n) for(i=s;i>=n;i--)
#define itervec vector<int>::iterator itv
#define iterrev vector<int>::reverse_iterator it
#define itermap map<string,int>::iterator itm
#define pb(S) push_back(S)
#define mp(i,j) make_pair(i,j)
#define f first
#define s second
#define MAX(a,b) 	(a>b) ? (a) : (b)
#define MIN(a,b) 	(a<b) ? (a) : (b)
using namespace std;
int main()
{
    int a,b,c,d;
    si(a),si(b),si(c),si(d);
    int lower=MAX(a,c);
    int upper=MIN(b,d);
    int ans=MAX(0,upper-lower);
    pi(ans),newline;
    return 0;
}
/*   fast input output
inline ll input() //for input integers call it long long int n=input();
{
    ll n=0;
    char ch=getchar_unlocked();
    while( ch < '0' || ch > '9' )
    {
        ch=getchar_unlocked();
    }
    while( ch >= '0' && ch <= '9' )
    {
        n = (n<<3)+(n<<1) + ch-'0', ch=getchar_unlocked();
    }
    return n;
}
inline void output(ll n)     //for output call output(count) and then for space use put('\n');
{
    char b[35];
    ll i=0;
    do
    {
        b[i++]=n%10+48;
        n=n/10;
    }while(n!=0);
    --i;
    while(i>=0)
    putchar_unlocked(b[i--]);
}
inline void faststring(char *str)  //for entering a string use faststring(p);
{
    register char c = 0;
    register long long i = 0;
    while (c < 33)
    c = getchar_unlocked();
    while (c != '\n')
    {
        str[i] = c;
        c = getchar_unlocked();
        ++i;
    }
    str[i] = '\0';
}


*/


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

int main()
{
	int a[6];
	cin>>a[1]>>a[2]>>a[3]>>a[4]>>a[5];
	
	for(int i=1;i<=5;i++)
	   if(a[i]==0)
	   {
	   	 cout<<i;
	   	 return 0;
	   }
	   
	return 0;
	
}

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

int main(){
  int a, b, ans;
  cin >> a >> b;
  ans=max(max(a+b, a-b), a*b);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3532
#include <iostream>

using namespace std;

int comp(int,int);

int main(){
    int a,b;
    cin>>a>>b;
    
    switch(comp(a,b)){
        case 0:
        cout<<"a == b"<<endl;
        break;
        case 1:
        cout<<"a > b"<<endl;
        break;
        case 2:
        cout<<"a < b"<<endl;
        break;
    }
    
    return 0;
    
}
int comp(int a,int b){
    
   if(a == b) return 0;
   else if(a > b) return 1;
   else if(a < b) return 2;
}


Measured memory_bytes: 3092
import sys
import math
import bisect
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
B = list(map(int, sys.stdin.readline().split()))
C = list(map(int, sys.stdin.readline().split()))

A.sort()
B.sort()
C.sort()

ans = 0
for b in B:
    a = bisect.bisect_left(A, b)
    c = bisect.bisect_right(C, b)
    ans += a * (N - c)


print(ans)

Measured memory_bytes: 118368
n,m = gets.split.map(&:to_i)
arr = gets.split.map(&:to_i).sort
ls = m.times.map{gets.split.map(&:to_i)}.sort_by{|i| i[1]}.reverse

sum = 0
ls.each do |j|
  j[0].times do |i|
    if arr.size == 0
      break
    elsif arr[0] < j[1]
      sum += j[1]
      arr.shift
    else
      break
    end
  end
end

if arr.size != 0
  p arr.inject(:+) + sum
else
  p sum
end

Measured memory_bytes: 23072
N = int(input())
A = input().split()

c = 1
i = 1

while i <= N-1:
	if int(A[i])-int(A[i-1]) == 0:
		del A[i-1]
		N -= 1
	else:
		i += 1

i = 1

while i <= N-2:
	if int(A[i])-int(A[i-1]) > 0:
		if int(A[i+1])-int(A[i]) < 0:
			c += 1
			i += 2
		else:
			i += 1
	else:
		if int(A[i+1])-int(A[i]) > 0:
			c += 1
			i += 2
		else:
			i += 1
 
print(c)

Measured memory_bytes: 11448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> v;
int main(){
    ll num;scanf("%lld",&num);
    while(num--){
        v.push_back(num%26);
        num/=26;
    }
    for(int i=v.size()-1;i>=0;i--) printf("%c",(char)(v[i]+'a'));
    return 0;
}

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

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        
        if(a>b) System.out.println("a > b");
        else if(a<b) System.out.println("a < b");
        else System.out.println("a == b");
    }

}



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

static int gcd(int x, int y)
{
    return (y==0) ? x : gcd(y, x%y);
}

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> a(n), a1(n+1,0), a2(n+1,0);
    for (int i = 0; i < n; i++) { std::cin >> a[i]; }

    for (int i = 0; i< n; i++) { a1[i+1] = gcd(a[i], a1[i]); }
    for (int i = n-1; i > 0; i--) { a2[i-1] = gcd(a[i], a2[i]); }

    // for (int i = 0; i < n; i++) { std::cout << a1[i] <<","; } std::cout << std::endl;
    // for (int i = 0; i < n; i++) { std::cout << a2[i] <<","; } std::cout << std::endl;

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int val = gcd(a1[i], a2[i]);
        if (ans < val) ans = val;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<cmath>
 
#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 all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9
#define MOD 1000000007
 
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; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}

typedef std::pair<ll, ll> P;

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}
 
using namespace std;

int main()
{
    ll n;
    cin >> n;
    vector<ll> h(n);

    rep(i, n) cin >> h[i];

    ll ans = 0;
    ll cnt = 0;

    rep(i, n-1){
        if(h[i] >= h[i+1]){
            cnt ++;
            ans = max(ans, cnt);
        }else{
            cnt = 0;
        }
    }

    cout << ans;


}

Measured memory_bytes: 1024
for i in range(10000):
    a,op,b=input().split()
    if op=="?":
        break
    if op=="+":
        print(int(a)+int(b))
    if op=="-":
        print(int(a)-int(b))
    if op=="*":
        print(int(a)*int(b))
    if op=="/":
        print(int(int(a)/int(b)))


Measured memory_bytes: 5596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] str=new String[2];
		Deque<String> list=new ArrayDeque<>();
		StringBuffer ans =new StringBuffer();
		
		int n;
		try {
			n = Integer.parseInt(br.readLine());
			
			for(int i=0;i<n;i++){
				str=br.readLine().split("\\s+");
				if(str[0].equals("insert"))
					list.addFirst(str[1]);
				else if(str[0].equals("delete"))
					list.remove(str[1]);
				else if(str[0].equals("deleteFirst"))
					list.removeFirst();
				else if(str[0].equals("deleteLast"))
					list.removeLast();
			
			}
			
		} catch (NumberFormatException | IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		if(!list.isEmpty()){
			ans.append(list.getFirst());
			list.removeFirst();
		}
		while(!list.isEmpty()){
			ans.append(" ").append(list.getFirst());
			list.removeFirst();
		}
		System.out.println(ans.toString());
		
	}

}



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

char s[1010];
int d[1010][10], n;

int main()
{
    while(~scanf("%d", &n))
    {
        scanf("%s", s+1);
        memset(d, 0, sizeof(d));
        d[0][1] = 1;
        for(int i = 1; i <= n; i++)
        {
            int t;
            if(s[i] == 'J') t = 0;
            else if(s[i] == 'O') t = 1;
            else if(s[i] == 'I') t = 2;
            for(int j = 1; j < 8; j++)
                for(int k = 1; k < 8; k++)
                    if(j & (1 << t) && k & j)
                        d[i][j] = (d[i - 1][k] + d[i][j]) % 10007;
        }
        int sum = 0;
        for(int i=1;i<8;i++) sum = (sum + d[n][i]) % 10007;
        printf("%d\n",sum);
    }
}

Measured memory_bytes: 1236
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();
	        String ans = "No";
			
			for (int i=1; i<=9; i++){
				if (N % i == 0 && N / i <= 9){
					ans = "Yes";
				}
			}
			
			System.out.println(ans);
	}
}

Measured memory_bytes: 21332
import numpy as np

A ,B ,C, K = map(int, input().split())

q0 = np.matrix([A, B, C]).T
mat = np.matrix([[0, 1, 1], [1, 0, 1], [1, 1, 0]])

q1 = mat**K * q0
ans = q1[0, 0] - q1[1, 0]
if ans > 1E18:
    print('Unfair')
else:
    print(ans)

Measured memory_bytes: 12504
x,n=map(int,input().split())
p=list(map(int,input().split()))
a=[0 for i in range(102)]
for i in range(n):
    a[p[i]]+=1
k=0
while True:
    if a[x-k]==0:
        print(x-k)
        break
    
    if a[x+k]==0:
        print(x+k)
        break
    k+=1

Measured memory_bytes: 9192
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#include <set>
#pragma GCC optimize(3 , "Ofast" , "inline")
using namespace std ;
#define ios ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define x first
#define y second
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e6 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
ll in()
{
  ll x = 0 , f = 1 ;
  char ch = getchar() ;
  while(!isdigit(ch)) {if(ch == '-') f = -1 ; ch = getchar() ;}
  while(isdigit(ch)) x = x * 10 + ch - 48 , ch = getchar() ;
  return x * f ;
}
int main()
{
  int n = in() , ans = 0 ;
  for(int i = 1; i <= n ;i ++ )
   {
     int x ;
     cin >> x;
     if(i % 2 && x % 2) ans ++ ;
   }
   cout << ans << endl ;
  return 0 ;
}
/*
*/


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

int main()
{
	int n,t[100],m,p[100],x[100];
	cin>>n;
	int sum=0;
	for(int i=0;i<n;i++){
		cin>>t[i];
		sum+=t[i];
	}
	cin>>m;
	for(int i=0;i<m;i++) cin>>p[i]>>x[i];
	
	for(int i=0;i<m;i++){
		cout<<sum-t[p[i]-1]+x[i]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long in;
typedef pair<in,in> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (in)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(in i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

int main(){
    IOS;
    in n,y;
    cin >> n >> y;
    rep(i,0,n+1){
        rep(j,0,n+1){
            if(i+j > n) continue;
            in k = n - i - j;
            if(i*10000+j*5000+k*1000 == y){
                cout << i << " " << j << " " << k << "\n";
                return 0;
            }
        }
    }
    cout << "-1 -1 -1\n";
}

Measured memory_bytes: 256
import java.util.*

class Drink(value: Long, count: Long) {
    val value = value
    val count = count
}
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextInt()
    val m = cin.nextLong()

    val arr: MutableList<Drink> = mutableListOf()

    for (i in 0..n-1) {
        val a = cin.nextLong()
        val b = cin.nextLong()
        arr.add(Drink(a, b))
    }

    arr.sortBy { it.value }

    var sum_value: Long = 0
    var sum_count: Long = 0

    for (i in 0..n-1) {
        val tt = m - (sum_count + arr[i].count)
        if (0 > tt) {
            sum_value += arr[i].value * (m-sum_count)
            break
        }
        sum_count += arr[i].count
        sum_value += arr[i].value * arr[i].count
    }

    println(sum_value)
}

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

int main() {
  int A,B;
  cin >> A >> B;
  string S;
  cin >> S;
  for (int i = 0; i < A; i++) {
    if (i == B - 1) {
      if (S.at(i) == 'A')
        cout << 'a';
      if (S.at(i) == 'B')
        cout << 'b';
      if (S.at(i) == 'C')
        cout << 'c';
    }
    else
      cout << S.at(i);
  }
  cout << endl;  
 
}

Measured memory_bytes: 3516
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;

namespace NTL
{
    class NTL_1_E
    {
        static void Main(string[] args)
        {
            var init = ReadLine().Split()
                .Select(n => long.Parse(n)).ToArray();
            var A = init[0];
            var B = init[1];

            long X;
            long Y;

            var nt = new NumberTheory();
            var d = nt.extGCD(A, B, out X, out Y);           

            WriteLine("{0} {1}", X, Y);
            ReadKey();
        }
    }

    class NumberTheory
    {
        internal long extGCD(long A, long B, out long X, out long Y)
        {
            var curR = new List<long>();
            var curX = new List<long>();
            var curY = new List<long>();
            curR.Add(A);
            curX.Add(1);
            curY.Add(0);
            
            curR.Add(B);
            curX.Add(0);
            curY.Add(1);

            while (curR[curR.Count() - 2] % curR[curR.Count - 1] != 0)
            {
                var idxA = curR.Count() - 2;
                var idxB = curR.Count() - 1;

                var curA = curR[idxA];
                var curB = curR[idxB];

                curR.Add(curA % curB);
                var Q = curA / curB;

                curX.Add(curX[idxA] - Q * curX[idxB]);
                curY.Add(curY[idxA] - Q * curY[idxB]);
            }

            X = curX.Last();
            Y = curY.Last();
            return curR.Last();
        }
    }
}



Measured memory_bytes: 18504
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>

using namespace std;


int main(){
    int n,m;
    cin >> n >> m;
    vector<int> l(m);
    vector<int> r(m);
    int max_value = 0;
    int min_value = 1e7;
    for(int i = 0; i < m; i++) {
        cin >> l[i] >> r[i];
        max_value = max(max_value, l[i]);
        min_value = min(min_value,r[i]);
    }

    if(max_value == min_value) cout << 1;
    else if(max_value > min_value) cout << 0;
    else cout << min_value - max_value + 1;

}



Measured memory_bytes: 1024
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int w=sc.nextInt();
		int n=sc.nextInt();
		int a,b,tmp;
		int[] num=new int[w];
		for(int i=0;i<w;i++){
			num[i]=i+1;
		}
		for(int i=0;i<n;i++){
			String str=sc.next();
			String[] s=str.split(",");
			a=Integer.parseInt(s[0]);
			b=Integer.parseInt(s[1]);
			tmp=num[a-1];
			num[a-1]=num[b-1];
			num[b-1]=tmp;
		}
		for(int i=0;i<w;i++){
			System.out.println(num[i]);
		}
	}
}	


Measured memory_bytes: 26172
s=input()
n=len(s)
mo=""
ans=0
for i in range(2**(n-1)):
  mo=""
  for j in range(n-1):
    mo+=s[j]
    if  (i>>j)&1:
      mo+="+"
  mo+=s[-1]
  ans+=eval(mo)
print(ans)
  
      

Measured memory_bytes: 3060
# coding: utf-8
# Your code here!
YEAR = 2019
ans_list = []

def main():
    l,r = map(int, input().split(" "))
    
    if l is 0:
        return l
    
    for i in range(l, r):
        for j in range(i+1, r+1):
            _i = i % YEAR
            _j = j % YEAR
            if ((_i * _j) % YEAR) is 0:
                return 0
            ans_list.append((_i * _j) % YEAR)
    
    if ans_list:
        return min(ans_list)
    else:
        return (r * l) % YEAR
    
if __name__ == "__main__":
    print(main())

Measured memory_bytes: 6892