akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include <math.h>
#include <stdlib.h>
#define P 10000

#define N 1001
#define M 501

int LCSLength(char *, char *);

int main()
{
  int data, i, r[M];
  char X[N], Y[N];

  scanf("%d", &data);

  for(i = 0; i < data; i++){
    scanf("%s", X);
    scanf("%s", Y);

    r[i] = LCSLength(X, Y);
  }

  for(i = 0; i < data; i++){
    printf("%d\n", r[i]);
  }
  
  return 0;
}

int LCSLength(char *X, char *Y)
{

  int a,b, i, j;
  int c[N][N];

  a = (int)strlen(X);
  b = (int)strlen(Y);

  for(i = 1; i <= a; i++) {
    c[i][0] = 0;
  }
  for(j = 0; j <=b; j++){ c[0][j] = 0;
  }

  for(i = 1; i <= a; i++){
    for(j = 1; j <= b;j++){
      
      if(X[i-1] == Y[j-1]){
	c[i][j] = c[i-1][j-1] + 1;
      }
      else if(c[i-1][j] >= c[i][j-1]){ c[i][j] = c[i-1][j]; }
      else {c[i][j] = c[i][j-1];
      }
    }
  }

  return c[a][b];
}



Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long n,k;
    cin >> n >> k ;
    vector<long long >h(n);
    vector<long long >dp(n+1,1e13);
    for(long long  i=0;i<n;i++) cin >> h[i];
    
    dp[0]=0;
    for(long long  i=0;i<n;i++){
        for(long long  j=1;j<=k&&i+j<n;j++){
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout << dp[n-1];
    //for(long long  i=0;i<n;i++) cout << dp[i]<<" ";
    
}

Measured memory_bytes: 4840
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    static int inf = 10000000;
    static Scanner sc = new Scanner(System.in);
    static final int h = sc.nextInt();
    static final int w = sc.nextInt();
    static char[][] maze = new char[h][w];
    static int[][] distance = new int[h][w];
    static final int[] dx = {1, 0, -1, 0};
    static final int[] dy = {0, 1, 0, -1};
    static class Pair {
        public int x;
        public int y;
        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }
    public static void main(String[] args) {
        for (int i = 0 ; i < h ; i++) {
            maze[i] = sc.next().toCharArray();
        }
        for (int[] dis : distance) Arrays.fill(dis, inf);

        Queue<Pair> que = new ArrayDeque<>();

        que.add(new Pair(0, 0));
        distance[0][0] = 0;

        while (!que.isEmpty()) {
            Pair p = que.poll();

            if (p.x == h - 1 && p.y == w - 1) break;
            for (int i = 0 ; i < 4 ; i++) {
                int nx = p.x + dx[i];
                int ny = p.y + dy[i];
                if (inRange(nx, ny) && maze[nx][ny] != '#' && distance[nx][ny] == inf) {
                    que.add(new Pair(nx, ny));
                    distance[nx][ny] = distance[p.x][p.y] + 1;
                }
            }
        }

        int wCount = 0;
        for (int i = 0 ; i < h ; i++) {
            for (int j = 0 ; j < w ; j++) {
                if (maze[i][j] == '.') wCount++;
            }
        }

        if (distance[h - 1][w- 1] == inf) {
            System.out.println(-1);
        } else {
            System.out.println(wCount - distance[h - 1][w- 1] - 1);
        }
    }
    static boolean inRange(int x, int y) {
        return x >= 0 && x < h && y >= 0 && y < w;
    }
}

Measured memory_bytes: 23764
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> P;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n)  for(int i=0; i<(n); i++)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second > secondElof.second;
}
int main(){
    vector<P> l;
    int n;
    cin >> n;
    map<string, int> ans;
    REP(i,n){
        string s;
        cin >> s;
        ans[s]+=1;
    }
    int maxv=0;
    for (const auto& x : ans) {  
        int v = x.second; 
            if (v > maxv) maxv = v;  
        }
    for (auto i = ans.begin(); i != ans.end(); i++) { 
        if (i->second == maxv) { 
            cout << i->first << endl;
            
        }
    } 
}


Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
int main(){
  long n ,d,count;
  
  count=0;
  cin >> n >> d;
  
  vector<long> x(n),y(n);
  vector<double> dis(n);
  for(int i=0;i<n;i++){
    cin >> x.at(i) >> y.at(i);
  }
  for(int l=0;l<n;l++){
    dis.at(l)=sqrt(x.at(l)*x.at(l)+y.at(l)*y.at(l));
      if(dis.at(l)<=d)
        count++;
  }
  cout << count << endl;
}

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

using namespace std;

int main()                                                                      {
  int N;
  cin >> N;
  vector<int> A(N, 0);                                                            for (int i = 0; i < N; ++i) cin >> A[i];
  sort(A.begin(), A.end());
  cout << A[A.size() - 1] - A[0] << endl;
  return 0;                                                                     }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    bool ans = false;
    cin >> a >> b >> c;
    for(int i = 1; i <= b ; i++){
        if( ( a * i ) % b == c){
            ans = true;
            break;
        }
    }
    cout << (ans ? "YES" : "NO") << endl;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	if (n % 2 == 0) cout << "0.5" << endl;
	else {
		cout << (double)(n + 1) / (2 * n) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int w = 0;
int a = 0;
int b = 0;
int main() {
    cin >> w >> a >> b;
    int end = a + w;
    int bed = b + w;
    int ans = 0;
    if(b + w < a){
        ans = a - bed;
    } else if (a + w < b){
        ans = b - end;
    } else{
        ans = 0;
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
import numpy


def main():
    n, m = map(int, input().split())
    if n < m:
        n, m = m, n

    if m == 1 and n == 1:
        return 1

    if m == 1:
        return n - 2

    return (n - 2) * (m - 2)


if __name__ == '__main__':
    print(main())

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

int main() {
    int n, m;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s.at(i);
    cin >> m;
    vector<string> t(m);
    rep(i, m) cin >> t.at(i);

    int ans = 0;
    string say;
    rep(i, n) {
        int rwd = 0;
        say = s.at(i);
        rep(i, n) {
            if(say == s.at(i)) rwd++;
        }
        rep(i, m) {
            if(say == t.at(i)) rwd--;
        }
        if(rwd > ans) ans = rwd;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define mod2 1000000000
#define mod1 998244353
#define lol ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define F(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define ss second
ld pi  = 3.141592653589793238;
//KUCH NAHI AATA YAAR
int main()
{
    ll n;cin >> n;
    ll arr[n];
    for(ll i=0;i<n;i++)
    {
        cin >> arr[i];
    }
    map<ll,ll> m2;
    for(ll i=0;i<n;i++)
    {
        m2[i-arr[i]]++;
    }
    ll cnt = 0;
    for(ll i=0;i<n;i++)
    {
        ll r1 = m2[arr[i]+i];
        cnt = cnt + r1;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 27752
s = list(input())

N = 15
n = len(s)
rest_n = N - n

win_n = sum([1 if s[i] == 'o' else 0 for i in range(len(s))])

remaining_win_n = 8 - win_n

if rest_n >= remaining_win_n:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
from sys import stdin, stdout
import math,sys,heapq
from itertools import permutations, combinations
from collections import defaultdict,deque,OrderedDict
from os import path
import bisect as bi
def yes():print('YES')
def no():print('NO')
if (path.exists('input.txt')): 
    #------------------Sublime--------------------------------------#
    sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');
    def I():return (int(input()))
    def In():return(map(int,input().split()))
else:
    #------------------PYPY FAst I/o--------------------------------#
    def I():return (int(stdin.readline()))
    def In():return(map(int,stdin.readline().split()))

def dict(a):
    d={}
    for x in a:
        if d.get(x,-1)!=-1:
            d[x]+=1
        else:
            d[x]=1
    return d

def find_gt(a, x):
    'Find leftmost value greater than x'
    i = bi.bisect_right(a, x)
    if i != len(a):
        return i
    else:            
        return -1

def main():
    try:
        a,b,c=In()
        k=I()
        t1,t2=0,0
        if a>=b:
            t1=0
            while b<=a:
                b*=2
                t1+=1
        if b>=c:
            t2=0
            while c<=b:
                c*=2
                t2+=1

        #print(a,b,c)
        if a<b and b<c:
            if t1+t2<=k:
                print('Yes')
            else:
                print('No')
        else:
            print('No')

    except:
        pass
        
M = 998244353
P = 1000000007
 
if __name__ == '__main__':
    #for _ in range(I()):main()
    for _ in range(1):main()




Measured memory_bytes: 9468
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
int cal[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    vector<int> val;

    for(int i=1;i<=n;i++){
        cin>>A[i];
        val.push_back(A[i]);
    }

    sort(val.begin(),val.end());
    val.erase(unique(val.begin(),val.end()),val.end());

    int sz = val.size();

    for(int i=1;i<=n;i++){
        idx = lower_bound(val.begin(),val.end(),A[i])-val.begin();
        cal[idx]++;
    }

    int res = 0;

    for(int i=0;i<sz;i++){
        if(cal[i]>=val[i])res+=(cal[i]-val[i]);
        else res+=cal[i];
    }

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 1528
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005
ll rem[20],sum[20],dp[100005][20],n;
string s;
ll f(ll idx,ll rem){
	if(idx==s.size())return (rem==5);
	if(dp[idx][rem]!=-1)return dp[idx][rem];
	ll ans=0;
	if(s[idx]=='?'){
		for(int j=0;j<10;j++){
			ll r=rem;
			r=(r*10+j)%13;
			ans+=f(idx+1,r);
			ans%=hell;
		}
	}else{
		ll r=(rem*10+s[idx]-'0')%13;
		ans+=f(idx+1,r);
		ans%=hell;
	}
	return dp[idx][rem]=ans%hell;
}
int main()
{
	ios
	ll i,j;
	cin>>s;
	n=s.size();
	memset(dp,-1,sizeof dp);
	// ll ans=0;
	// if(s[0]!='?')ans=f(0,)
	ll ans=f(0,0);
	cout<<ans%hell;
	return 0;
}

Measured memory_bytes: 22352
#include <stdio.h>

int main() {
  int N, total[4] = {0};
  scanf("%d", &N);

  for(int i = 0; i < N; i++) {
    char str[5];
    scanf("%s", str);
    
    switch(str[0]) {
      case 'A':
        total[0]++;
        break;
      case 'W':
        total[1]++;
        break;
      case 'T':
        total[2]++;
        break;
      case 'R':
        total[3]++;
        break;
    }
  }

  printf("AC x %d\n", total[0]);
  printf("WA x %d\n", total[1]);
  printf("TLE x %d\n", total[2]);
  printf("RE x %d\n", total[3]);

  return 0;
}

Measured memory_bytes: 1732
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // double
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using in6 = int64_t;
using ind = double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ios::sync_with_stdio(false);
  int n,m;
  cin >> n >> m;
  vii matrixa (n,vi(m));
  rep(i,n) {
      rep(j,m) cin >> matrixa[i][j];
  }
  vi b (m);
  rep(i,m) cin >> b[i];
  rep(i,n) {
      int ans = 0;
      rep(j,m) ans += matrixa[i][j] * b[j];
      cout << ans << "\n";
  }
}


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

#define ll long long
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}


int main(){
    IOS;
    int n;
    cin >> n;
    string s;
    cin >> s;

    if (n & 1){
        cout << "No" << endl;
        return 0;
    }

    if (s.substr(0, n/2) == s.substr(n/2, n/2)){
        cout << "Yes" << endl;
    }else cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    static boolean normal(int n) {
        for (int i = 2; i < n; i++) {
            if (n % i == 0) {
                return false;
            }
        }

        return true;
    }

    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int x = std.nextInt();
        int ans;
        if (normal(x)) {
            ans = x;
        } else {
            while (!normal(x)) {
                x++;
            }
            ans = x;
        }

        System.out.println(ans);
    }
}


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

int N;

int main(void) {
	string ans = "No";
	int o, p, q, r = 0;


	cin >> N;

	o = N / 1000;
	p = (N - (o * 1000)) / 100;
	q = (N - ((o * 1000) + (p * 100))) / 10;
	r = N - ((o * 1000) + (p * 100) + (q * 10));


	if (p == q){
		if (o == p || p == r) {
			ans = "Yes";
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main(void){
    int k,s,count = 0,p = 0;
    cin >> k >> s;
    for(int x = 0;x < k+1;x++){
        for(int y = 0;y < k+1;y++){
            p = s - y - x;
            if(p >= 0 && p <= k)count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
/*

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

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

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

	int n;
	cin>>n;
	vvi in(n);
	int out=0;
	vi t;
	rep(i,n){
		int a,b;
		cin>>a>>b;
		out+=a;
		t.pb(-a-b);
	}
	sort(all(t));
	rep(i,n)if(i%2)out+=t[i];
	cout<<out<<endl;
}


Measured memory_bytes: 3704
n=int(input())
def gcd(a,b):
  while b:a,b=b,a%b
  return a
def lcm(a,b):return a*b//gcd(a,b)
ans=int(input())
for i in range(n-1):
  a=int(input())
  ans=lcm(ans,a)
print(ans)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        ArrayList<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {
            mylist.add(strinput);
            strinput = reader.readLine();
        }

        String arr01[] = mylist.get(0).split(" ");
        int k = Integer.valueOf(arr01[0]);
        String s = mylist.get(1);

        if (s.length() <= k) {
            System.out.println(s);
        } else {
            System.out.println(s.substring(0, k) + "...");
        }

    }

}


Measured memory_bytes: 36172
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define fi first
#define se second
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
constexpr int mod = 1e9 + 7;
int dp[11][11][11];
int main()
{
	for(int i=0; i<=9; i++) dp[1][i][i] = 1;
	for(int i=2; i<=10; i++)
		for(int j=0; j<=9; j++)
			for(int k=0; k<=9; k++)
			{
				if(k) dp[i][j][k] = dp[i-1][j][k-1] + dp[i-1][j][k] + dp[i-1][j][k+1];
				else dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j][k+1];
			}
	int k;
	cin >> k;
	int cur = 0, pre = 1;
	string res;
	for(int bit=10; bit>=1; bit--)
	{
		if(pre)
		{
			int tmp = 0;
			for(int i=bit-1; i>=1; i--)
				for(int j=1; j<=9; j++)
					for(int k=0; k<=9; k++)
						tmp += dp[i][j][k];
			//debug(tmp);
			if(tmp>=k) continue;
			else cur = tmp;
		}
		for(int j=(pre ? 1 : 0); j<=9; j++)
		{
			if(!pre && abs(res.back()-'0'-j)>1) continue;
			int tmp = 0;
			for(int k=0; k<=9; k++) tmp += dp[bit][j][k];
			//debug(cur);
			if(cur+tmp<k)
			{
				cur += tmp;
				continue;
			}
			res += j + '0';
			pre = 0;
			break;
		}
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 100005
#define M 200005
#define seed 23333

using namespace std;
const int inf=(int)1e9;
int i,j,m,n,p,k,A[N],B[N],l;
map<pair<int,int>,int>mp;
vector<int>v[M];
int f[2][N],ans,sum[N],size[2],now,last;
int RE()
{
		puts("-1");
		exit(0);
}
int main()
{
		scanf("%d",&n); ans=2*n-2;
		for (i=1;i<=n;++i) 
		{
				scanf("%d%d",&A[i],&B[i]);
				mp[mk(A[i],B[i])]=1;
				if (i!=1&&!A[i]) RE();
				if (i!=2&&!B[i]) RE();
		}
		for (i=1;i<=n;++i)
		{
				if (i!=1&&mp.find(mk(A[i]-1,B[i]))==mp.end()&&
						mp.find(mk(A[i]-1,B[i]-1))==mp.end()&&
						mp.find(mk(A[i]-1,B[i]+1))==mp.end()) RE();
				if (i!=2&&mp.find(mk(A[i],B[i]-1))==mp.end()&&
						mp.find(mk(A[i]-1,B[i]-1))==mp.end()&&
						mp.find(mk(A[i]+1,B[i]-1))==mp.end()) RE();
				v[A[i]+B[i]].pb(A[i]);
		}
		for (i=1;i<=2*n;++i)
				if (v[i].size())
				{
						A[0]=B[0]=0;
						for (j=0;j<(int)v[i].size();++j) A[++A[0]]=v[i][j],B[++B[0]]=v[i][j]; 
						sort(B+1,B+B[0]+1); B[0]=unique(B+1,B+B[0]+1)-(B+1);
						for (j=1;j<=B[0];++j) sum[j]=0;
						for (j=1;j<=A[0];++j) sum[lower_bound(B+1,B+B[0]+1,A[j])-B]++;
						size[0]=size[1]=now=last=0; now=1;
						size[1]=sum[1];
						if (mp.find(mk(B[1]-1,i-B[1]-1))!=mp.end())
						for (j=0;j<=size[now];++j) f[now][j]=size[now]-j;
						else for (j=0;j<=size[now];++j) f[now][j]=0;
						for (j=2;j<=B[0];++j)
						{
								now^=1; last=now^1;
								size[now]=sum[j];
								for (l=0;l<=size[now];++l) f[now][l]=0;
								if (mp.find(mk(B[j]-1,i-B[j]-1))==mp.end())
								{
									  for (l=0;l<=size[last];++l)
									  	 f[now][sum[j]]=max(f[now][sum[j]],f[last][l]+(B[j]-B[j-1]==1)*min(sum[j],l));
								}
								else 
								{
									 int Max=-inf;
									 for (l=0;l<=size[now];++l)
									{
											if (l<=size[last]) Max=max(Max,f[last][l]+(B[j]-B[j-1]==1)*l);
											f[now][l]=Max;
									}
									 Max=-inf;
									 for (l=max(size[last],size[now]);l>=0;--l)
									 {
									 		if (l<=size[last]) Max=max(Max,f[last][l]);
									 		if (l<=size[now])
									 		f[now][l]=max(f[now][l],Max+(B[j]-B[j-1]==1)*l);
									 }
									 for (l=0;l<=size[now];++l)
									 	f[now][l]+=(size[now]-l);
								}
						}
						int Max=0;
						for (j=0;j<=size[now];++j) Max=max(Max,f[now][j]);
						ans-=Max;
				}
		printf("%d\n",ans);
}


Measured memory_bytes: 15104
// iostream のscanf, printf では間に合わなかった
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

#define INF (1<<29)
#define mp make_pair
#define pb push_back

typedef pair<int,int> pii;

int main(){
	int n, m;
	cin >> n >> m;
	vector<pii> treasure;
	for( int i = 0; i < n; i++ ){
		int x, y;
		//cin >> x >> y;
		scanf("%d %d", &x, &y);
		treasure.pb( mp(x,y) );
	}
	sort(treasure.begin(), treasure.end());
	for( int i = 0; i < m; i++ ){
		int x1, y1, x2, y2;
		//cin >> x1 >> y1 >> x2 >> y2;
		scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
		// search
		int ans = 0;
		vector<pii>::iterator it = lower_bound(treasure.begin(),treasure.end(),mp(x1,y1));
		vector<pii>::iterator ite = upper_bound(treasure.begin(),treasure.end(),mp(x2,y2));
		while( 1 ){
			if( it == ite ) break;
			if( x1 <= (*it).first && (*it).first <= x2 && y1 <= (*it).second && (*it).second <= y2 ) ans++;
			it++;
		}
		//cout << ans << endl;
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1336
/*
THE BEST IS YET TO COME
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define r(i,s,l) for(int i=s;i<l;i++)
#define mod 1000000007
#define INT_BITS 32
#define ld long double
#define pp pair<long long,long long>
#define ss second
#define ff first
#define N 2000005
#define all(a) a.begin(),a.end()
#define pb push_back
using namespace std;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

int main()
{
    fast();
    int a;
    string s;
    cin>>a;
    cin>>s;
    if(a<3200)
        cout<<"red";
    else
        cout<<s;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
typedef long long int ll;
#define loop(a,b) for(int i=a;i<b;i++)
#define say(a) cout<<a<<endl
#define say2(a,b) cout<<a<<" "<<b<<endl;
ll mod =1e9+7;
using namespace std;

int main()
{
    int n;
    cin>>n;
   map<string,int>mp;
   ll ans=0;
   for(int i=0;i<n;i++)
   {
       string s;
       cin>>s;
       sort(s.begin(),s.end());
       ans+=mp[s];
       mp[s]++;
   }say(ans);
}


Measured memory_bytes: 11136
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <tuple>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

void print(){ std::cout << std::endl; }
template <typename H> void print(H head) { std::cout << head << std::endl; }
template <typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

std::vector< ll > va;
std::vector< ll > vb;
std::vector< ll > vc;

std::priority_queue<ll, std::vector<ll>, std::greater<ll> > que;

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

  ll X, Y, Z, K;
  std::cin >> X >> Y >> Z >> K;
  va = std::vector< ll >(X, 0LL);
  vb = std::vector< ll >(Y, 0LL);
  vc = std::vector< ll >(Z, 0LL);

  for (ll i = 0; i < X; i++) { std::cin >> va[i]; }
  for (ll i = 0; i < Y; i++) { std::cin >> vb[i]; }
  for (ll i = 0; i < Z; i++) { std::cin >> vc[i]; }

  std::vector< ll > vd(X * Y, 0LL);
  for (ll i = 0; i < X; i++) {
    for (ll j = 0; j < Y; j++) {
      vd[i * Y + j] = va[i] + vb[j];
    }
  }
  std::sort(vc.begin(), vc.end(), std::greater<>());
  std::sort(vd.begin(), vd.end(), std::greater<>());

  ll max_i = std::min(X*Y, K);
  std::vector< ll > vans(K * Z, 0LL);
  for (ll i = 0; i < max_i; i++) {
    for (ll j = 0; j < Z; j++) {
      vans[i * Z + j] = vd[i] + vc[j];
    }
  }
  std::sort(vans.begin(), vans.end(), std::greater<>());

  for (ll i = 0; i < K; i++) {
    print(vans[i]);
  }
  return 0;
}


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

int	main() {
	int	a, b, c;
  	cin >> a >> b >> c;
  
  	if (a==b && b==c && c==a) cout << "No" << endl;
  	else if (a!=b && b!=c && c!=a) cout << "No" << endl;
  	else cout << "Yes" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
string s;
vector<int> v;

ll calc(ll x, ll y) {
  if(x < y) swap(x,y);
  return x*(x+1)/2 + y*(y-1)/2;
}

int main() {
  cin>>s;
  int N = s.size();
  int cnt = 0;
  
  if(s[0] != '<') {
    v.pb(0);
  }
  
  for(int i=0;i<N;++i) {
    ++cnt;
    if(i == N-1 || s[i] != s[i+1]) {
      v.pb(cnt);
      cnt = 0;
    }
  }
  if(s[N-1] != '>') {
    v.pb(0);
  }
  ll sum = 0;

  for(int i=0;i<v.size();i+=2) {
    sum += calc(v[i], v[i+1]);
  }

  cout<<sum<<"\n";
  return 0;
}

Measured memory_bytes: 5268
Num = 10 ** 9 + 7
N, M = map(int, input().split())
danger = -1
if M != 0:
  danger = int(input())
count = 1
l = [1, 1]
for i in range(1, N):
  if i == danger:
    l[1] = 0
    if count < M:
      danger = int(input())
      count += 1
  l = [l[1] % Num, l[0] + l[1]]
  if l == [0, 0]:
    break
if N == danger:
  l[1] = 0
print(l[1] % Num)

Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int n, s;
        while((n = scan.nextInt()) != 0) {
            int max = 0, min = 1000, sum = 0;
            for(int i = 0; i < n; i++) {
                s = scan.nextInt();
                sum += s;
                if(s > max) max = s;
                if(s < min) min = s;
            }
            System.out.println((sum - max - min)/(n - 2));
        }
    }
}


Measured memory_bytes: 29304
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 2e7 + 9, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
int n,l;
string array1[100];
scanf("%d %d",&n,&l);
for(int i=0;i<n;++i){
    cin>>array1[i];
}
sort(array1,array1+n);
for(int i=0;i<n;++i){
    cout<<array1[i];
}



    return 0;
}


Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int , input().split())
    print(t[r-1] - t[l-1])
    

Measured memory_bytes: 7748
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include<list>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<set>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),a.end()
using namespace std;

int main()
{
	int a, b, c, d ;
	cin >> a >> b >> c >> d;
	if (a + b == c + d)cout << "Balanced" << endl;
	else if(a + b > c + d)cout << "Left" << endl;
	else cout << "Right" << endl;
}



Measured memory_bytes: 256
main = do
  li <-getLine
  let [l,r] = map read $ words li
  let ans = compute l r
  print ans

compute :: Int -> Int -> Int
compute l r = minimum
    [ (i*j) `mod` 2019
    | i <- [l..r1-1]
    , j <- [i+1..r1]
    ]
  where
    r1 = min (l + 2019) r

Measured memory_bytes: 892
#include <iostream>

int main()
{
    int n = 0;
    int x = 0;

    while (1)
    {
        std::cin >> n;
        std::cin >> x;

        if (0 == n && 0 == x)
        {
            break;
        }

        if (n < 3 || n > 100 || x < 0 || x > 300)
        {
            std::cout << "Error : out of range!" << std::endl;
            return -1;
        }

        int count = 0;

        for (int i = 1; i < n + 1; ++i)
        {
            for (int j = i + 1; j < n + 1; ++j)
            {
                for (int k = j + 1; k < n + 1; ++k)
                {
                    if (x == i + j + k)
                    {
                        ++count;
                    }
                }
            }
        }

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

    return 0;
}


Measured memory_bytes: 3084
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 1e5 + 10;

int main() {
	fast_cin();
	int n; cin >> n;
	string s[3];
	for (int i = 0; i < 3; ++i) {
		cin >> s[i];
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		set<char> st;
		for (int j = 0; j < 3; ++j) {
			st.insert(s[j][i]);
		}
		if (st.size() == 2) {
			++ans;
		} else if (st.size() == 3) {
			ans += 2;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            String s = sc.next();
            int sum = 0;
            if(s.equals("0"))
                break;
            for(int i=0;i<s.length();i++){
                int n = Character.getNumericValue(s.charAt(i));
                sum += n;
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 26600
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		if (a == b) {
			System.out.println(a + b);
		} else if (a > b) {
			System.out.println(a + a - 1);
		} else {
			System.out.println(b + b - 1);
		}
	}
}


Measured memory_bytes: 22228
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define emp empty()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
    ll n , k ;
    cin >> n >> k ;
    vl v;
    forn (i ,  1,  n ) {
       ll x;
       cin >> x;
       v.pb(x) ;
    }
    sort(all(v));
    set<ll> s;
    forn(i , 0 ,  k - 1 ) {
       s.insert(v[i]);
    }
    ll ans = 3e18 ;
    if(k == 1){
        forn(i , 0 , n - 1 ) {
           ans = min(ans , abs(v[i]));
        }
        cout << ans << el ;
        ro ;
    }
    forn(i , k -  1 ,  n -1 ){
      if(i == k - 1) {
         ll left = *s.begin();
         ll right= *s.rbegin();
         if(right <= 0 ){
            ll dis = abs(left) ;
            ans = min(ans , dis);
         }
         else if(left <= 0 and right >= 0){
            ll dl = abs(left) ;
            ll dr =  right ;
            ans = min(ans, min(2*dr + dl , 2*dl + dr));
         }
         else if(left >= 0 and right >= 0){
            ll dis = right ;
            ans = min(ans , dis) ;
         }
      }
      else {
         s.erase(*s.begin());
         s.insert(v[i]);
         ll left = *s.begin() ;
         ll right= *s.rbegin();
         if(right <= 0){
            ll dis = abs(left) ;
            ans = min(ans , dis) ;
         }
         else if(left <= 0 and right >= 0 ){
            ll dl  = abs(left) ;
            ll dr = abs(right);
            ans = min(ans , min(2 * dr + dl ,  2 * dl + dr )) ;
         }
         else if(left >= 0 and right >= 0 ){
            ll dis = right ;
            ans = min(ans , right) ;
         }
      }
    }
    cout << ans << el ;
    ro;
}































Measured memory_bytes: 5748
#include <iostream>

int main(void){
    int a,b,c;
    char op;
    while(1){
        std::cin >> a >> op >> b;
        if(op=='+'){
            c=a+b;
        }else if(op=='-'){
            c=a-b;
        }else if(op=='*'){
            c=a*b;
        }else if(op=='/'){
            c=a/b;
        }else{
            break;
        }
        std::cout << c << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3112
import sys

input = sys.stdin.readline


def main():
    H, W = map(int, input().split())

    ans = H * W
    ans = min(ans, int(H % 3 > 0) * W, int(W % 3 > 0) * H)

    q, r = divmod(W, 2)
    W_1 = q
    W_2 = q + r
    for y in range(1, H):
        S_1 = y * W
        S_2 = (H - y) * W_1
        S_3 = (H - y) * W_2
        S_max = max(S_1, S_2, S_3)
        S_min = min(S_1, S_2, S_3)
        ans = min(ans, S_max - S_min)

    q, r = divmod(H, 2)
    H_1 = q
    H_2 = q + r
    for x in range(1, W):
        S_1 = x * H
        S_2 = (W - x) * H_1
        S_3 = (W - x) * H_2
        S_max = max(S_1, S_2, S_3)
        S_min = min(S_1, S_2, S_3)
        ans = min(ans, S_max - S_min)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9112
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int x = in.nextInt();
            int sum = 0;
            int t = x;
            while (t > 0) {
                sum += (t % 10);
                t /= 10;
            }
            if (x % sum == 0) out.println("Yes");
            else out.println("No");
        }

    }

    static class FastReader {
        BufferedReader reader;
        StringTokenizer st;

        public FastReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String line = reader.readLine();
                    if (line == null) {
                        return null;
                    }
                    st = new StringTokenizer(line);
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

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

    }
}



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

int main()
{
    string s;
    vector<int> diff;
    cin >> s;
    for (int i = 0; i + 2 < s.length(); i++)
    {
        string sub = s.substr(i, 3);
        int n = stoi(sub);
        diff.push_back(abs(753 - n));
    }
    sort(diff.begin(), diff.end());
    cout << *diff.begin();
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i) cin >> vec[i];

    vector<int> itr(N);
    for (int i = 0; i < N; ++i) itr[vec[i] - 1] = i + 1;
    for (int x : itr) {
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 1536
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <list>
#include <map>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
#define LL long long
const int MAX = 1e6 + 10;
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int k;
        cin >> k;
        if (k % 2 && i % 2)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			int count = Integer.parseInt(br.readLine());
			String aun[] = new String[count];
			for (int i = 0; i < count; i++) {
				aun[i] = br.readLine();
			}
			if (aun[0].equals("Un")) {
				System.out.println("NO");
			} else {
				int aCount = 0;
				int unCount = 0;
				boolean aStart = true;
				boolean no = false;
				for (int i = 0; i < count; i++) {
					if (aun[i].equals("A") && aStart) {
						aCount++;
						if (aCount < unCount || aCount == unCount) {
							no = true;
							break;
						}
						aStart = false;
					} else if (aun[i].equals("A")) {
						if (aCount < unCount) {
							no = true;
							break;
						}
						aCount++;
					} else if (aun[i].equals("Un")) {
						aStart = true;
						unCount++;
					}
				}
				if (aCount != unCount)
					no = true;
				if (no) {
					System.out.println("NO");
				} else {
					System.out.println("YES");
				}
			}
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}


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

using namespace std;

const int maxn = 1e5 + 5;

int a, b;

inline int read(){
	char ch = getchar(); int u = 0, f = 1;
	while(!isdigit(ch)){if(ch == '-')f = -1; ch = getchar();}
	while(isdigit(ch)){u = u * 10 + ch - 48; ch = getchar();} return u * f; 
}

int main(){
	a = read(); b = read();
	for(register int i = 1; i <= 3; i++)
		if((a * b * i) & 1){cout << "Yes"; return 0;}
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    S = list(map(lambda c : ord(c) - ord('a'), input()))
    n = len(S)
    sigma = 26

    # next[i][c] : i 文字目以降で c が現れる最小の index
    next = [[-1] * sigma for _ in range(n + 1)]
    for i in range(n - 1, -1, -1):
        for c in range(sigma):
            next[i][c] = i if S[i] == c else next[i + 1][c]

    # dp[i] : S[i:] に対する答えの長さ
    dp = [INF] * (n + 1)
    dp[n] = 1
    # character[i] : S[i:] に対する答えに対して採用する先頭の文字
    character = [None] * (n + 1)
    character[n] = 0
    for i in range(n - 1, -1, -1):
        for c in range(sigma):
            length = 1 if next[i][c] == -1 else 1 + dp[next[i][c] + 1]
            if dp[i] > length:
                dp[i] = length
                character[i] = c

    # 経路復元
    res = []
    now = 0
    while 1:
        res.append(character[now])
        now = next[now][character[now]] + 1
        if now == 0:
            break
    res = ''.join(map(lambda x : chr(x + ord('a')), res))
    print(res)
resolve()

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

int main() {
    int N;
    int d[110];
    cin >> N;
    for (int i = 0; i < N; i++) cin >> d[i];

    int num[110] = {0};
    for (int i = 0; i < N; i++) {
        num[d[i]]++;
    }

    int res = 0;
    for (int i = 1; i <= 100; i++) {
        if (num[i]) res++;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define lli long long int
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
    int N;
    int a[20];
    cin >> N;
    for(int i = 0; i < N; i++){
      cin >> a[i];
    }
    int b = 0;
    int c = 0;
    for(int i = 0; i < N; i++){
      if(b <= a[i]){
        c++;
        b = a[i];
      }
    }
    cout << c;
    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main() {
    string s; int w; cin >> s >> w;
    rep(i, s.size()){
        if(i % w == 0) cout << s[i];
    }
    cout << endl;
    return;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>
#include <queue>
#include <stack>

using namespace std;


int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 1; i < n; i++) {
		int ai;
		cin >> ai;
		a[ai-1]++;
	}
	for (auto x : a) {
		cout << x << endl;
	}

	return 0;
}


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

using namespace std;

int N;

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
for (int i=N; i>=1; i--)
    if (1LL * (i - 1) * i / 2 < N) N -= i, printf ("%d\n", i);
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

void selectionSort(int *,int );

int main(){

  int A[100];

  int N;

  int i;

  scanf("%d",&N);

  for(i=0;i<N;i++){

    scanf("%d",&A[i]);

  }

  selectionSort(A,N);

  return 0;
}

void selectionSort(int *A,int N){

  int i,j,min,cnt=0,temp;

  for(i=0;i<=N-1;i++){

    min=i;

    for(j=i;j<=N-1;j++){
      
      if(A[j]<A[min]){

	min = j;

      }

    }

    if(A[i]!=A[min]){

      temp=A[i];
      A[i]=A[min];
      A[min]=temp;
      cnt++;
  }

  }

  for(j=0;j<N;j++){

    if(j==N-1)printf("%d\n",A[j]);

    else printf("%d ",A[j]);

  }

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

}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
using namespace std;
int main() {
	int n, t;
	int a, b;
	int min = 1000000007;
	cin >> n >> t;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		if (b <= t) {
			if (min > a) {
				min = a;
			}
		}
	}
	if (min == 1000000007) {
		cout << "TLE" << endl;
		return 0;
	}
	cout << min << endl;
	return 0;
}



Measured memory_bytes: 384