akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
 
int main(){
    int n;
    while(cin>>n,n){
        int s[10000];
        long long int t[10000]={0},sum=0;
 
        for(int i=0;i<n;i++)
            cin>>s[i];
 
        sort(s,s+n);
 
        for(int i=0;i<n-1;i++){
            sum+=t[i+1]=t[i]+s[i];
        }
 
        cout<<sum<<endl;
 
    }
 
}


Measured memory_bytes: 3156
#include<stdio.h>
main()
{
  int w,n,i,temp;
  scanf("%d",&w);
  scanf("%d",&n);

  int a[n],b[n],ans[w];

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

  for(i=0;i<w;i++){
    ans[i]=i+1;
  }
  
  for(i=0;i<n;i++){
    temp=ans[a[i]-1];
    ans[a[i]-1]=ans[b[i]-1];
    ans[b[i]-1]=temp;
    }
  
  for(i=0;i<w;i++){
    printf("%d\n",ans[i]);
  }
  return 0;

}

Measured memory_bytes: 596
s = set(input())

t = 0
for _s in s:
    if _s == "N":
        t += 1
    if _s == "S":
        t -= 1
    if _s == "E":
        t += 2
    if _s == "W":
        t -= 2

print("Yes" if t == 0 else "No")


Measured memory_bytes: 2940
N = int(input())
A = [int(_) for _ in input().split()]

c1 = 0
c2 = 0
c4 = 0
for a in A:
    if a % 2 == 1:
        c1 += 1
    elif a % 4 == 0:
        c4 += 1
    else:
        c2 += 1

if c1 > c4 + 1:
    print("No")
elif c1 == c4 + 1:
    if c2 == 0:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")


Measured memory_bytes: 14252
import fs = require('fs');
const input = fs.readFileSync('/dev/stdin', 'utf8').trim();
const numbers = input.split('').map(Number);

let answer = 0;
for(let i=0; i<numbers.length-1; i++) {
	const n1 = numbers[i+0];
	const n2 = numbers[i+1];

	if(n1+n2 === 1) {
		numbers.splice(i, 2);
		answer += 2;
		i = Math.max(-1, i-2);
	}
}
console.log(answer);

Measured memory_bytes: 15168
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


class UnionFind {
public:
    vector<int> Parent;
    
    UnionFind(int N){
        Parent = vector<int>(N, -1);
    }
    
    int root(int A){
        if(Parent[A] < 0) return A;
        else return Parent[A] = root(Parent[A]);
    }
    
    int size(int A){
        return -Parent[root(A)];
    }
    
    bool unite(int A, int B){
        A = root(A);
        B = root(B);
        if(A==B) return false;
        
        if(size(A) < size(B)) swap(A, B);
        Parent[A] += Parent[B];
        Parent[B] = A;
        return true;
    }
};


int main() {
    int N; cin >> N;
    vector<pair<PII, int>> X(N);
    vector<pair<PII, int>> Y(N);
    for(int i=0; i<N; i++){
        int x, y; cin >> x >> y;
        X[i] = {{x, y}, i};
        Y[i] = {{y, x}, i};
    }
    
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());
    
    struct edge {
        int from, to, cost;
    };
    vector<edge> E;
    
    for(int i=0; i<N-1; i++){
        edge e;
        e.from = X[i].sc;
        e.to = X[i+1].sc;
        e.cost = abs(X[i+1].fs.fs-X[i].fs.fs);
        E.push_back(e);

        e.from = Y[i].sc;
        e.to = Y[i+1].sc;
        e.cost = abs(Y[i+1].fs.fs-Y[i].fs.fs);
        E.push_back(e);
    }
    
    
    
    sort(E.begin(), E.end(), [](const edge &a, const edge &b){return a.cost>b.cost;});
    
    UnionFind U(N);
    ll ans = 0;
    while(E.size()){
        edge e = E.back();
        E.pop_back();
        if(U.root(e.from)!=U.root(e.to)){
            ans += e.cost;
            U.unite(e.from, e.to);
        }
    }
    
    cout << ans << endl;
    
    return 0;
}



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

int main(){
    int h, w, k;
    cin>> h >> w >>k;

    vector<vector<char>> field(h, vector<char>(w));

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin>>field[i][j];
        }
    }
  
    int ans = 0;
    for(int i=0; i<(1<<h); i++){
        for(int j=0; j<(1<<w); j++){
            int black = 0;
            for(int s=0; s<h; s++){
                for(int t=0; t<w; t++){
                    //cout<<"s="<<s<<":"<<(i>>s)<<" "<<"t="<<t<<":"<<(j>>t)<<endl;

                    if(((i>>s) & 1) == 0 && ((j>>t) & 1) == 0 && field[s][t] == '#'){
                        //cout<<"black++"<<endl;
                        black++;
                    }
                }
            }
            //cout<<black<<endl;
            if(black == k){
                ans++;
            }
        }
    }
    cout<< ans <<endl;

    return 0;
}

Measured memory_bytes: 3476
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 1e5+5;

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

    string s;
    cin>>s;
    for(int i=0;i<3;i++)
    	if(s[i]==s[i+1]) {
    		cout<<"Bad";
    		return 0;
    	}
    cout<<"Good";
	return 0;
}

Measured memory_bytes: 256
N, K = map( int, input().split())
A = list( map( int, input().split()))
RA = sorted(A)
RA = RA[::-1]
s = 0
ans = 0
for i in range(N):
    a = RA[i]
    if s+a < K:
        s += a
        ans += 1
    else:
        ans = 0
print(ans)

Measured memory_bytes: 3572
N = int(input())
A = [0 for i in range(N)]
B = [0 for i in range(N)]

for i in range(N):
        A[i], B[i] = map(int, input().split())
        
max_a = max(A)
max_a_b = 0
for i in range(N):
    if A[i] == max_a:
        max_a_b = B[i]
        
print(max_a + max_a_b)

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int N;
string S;
int e[300010];

int main(){
	cin >> N;
	cin >> S;
	repp(i,0,N) e[i+1] = e[i] + (S[i]=='E');
	int ans = N;
	repp(i,1,N+1) ans = min(ans,e[N]-e[i]+i-1-e[i-1]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1796
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define MININF -1e18L
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> intint;

int main(void)
{
    int n,t;
    cin >> n >> t;
    int minv = 10000;
    REP(i, n){
        int ci,ti;
        cin >> ci >> ti;
        if(ti > t){
            continue;
        }
        minv = min(minv, ci);
    }
    if(minv == 10000){
        pr("TLE");
    }else{
        pr(minv);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<int>> graph;
vector<bool> flag;
vector<int> dp;

int f(int z) {
    if(flag.at(z)) return dp.at(z);
    flag.at(z) = true;
    int fans = 0;
    for(int k = 0; k < graph.at(z).size(); ++k) {
        fans = max(fans, f(graph.at(z).at(k))+1);
    }
    return dp.at(z) = fans;
}

int main() {
    cin >> n >> m;
    graph = vector<vector<int>>(n);
    for(int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        graph.at(x).push_back(y);
    }

    flag = vector<bool>(n, false);
    dp = vector<int>(n, 0);

    int ans = 0;
    for(int i = 0; i < n; ++i) {
        ans = max(ans, f(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pp;

ll n,k;

ll a[401];
ll maxN=1000000000000000000;

ll f(int i)
{
    ll res=0;
    for(int j=i+1;j<=n-1;j++)
    {
        res=max(res,(a[j]-a[i])*(a[j]-a[i])+f(j+1));
    }
    return res;
}

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


    ll n;
	cin>>n;
    ll sum[n+1];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(i==0)
        sum[i]=a[i];
        else
        sum[i]=sum[i-1]+a[i];
    }

    ll dp[n+1][n+1];

    for(int len=1;len<=n;len++)
    {
        for(int end=len-1;end<=n-1;end++)
        {
            int start=end-len+1;
            if(start==end)
            {
                dp[start][end]=0;continue;
            }

            if(start==end-1)
            {
                dp[start][end]=a[start]+a[end];
                continue;
            }

            ll res=maxN;
            for(int k=end;k>start;k--)
            {
                ll s1=0;
                if(start!=0)
                s1=sum[start-1];
                res=min(res,dp[start][k-1]+dp[k][end]+sum[end]-s1);
            }
            dp[start][end]=res;

        }
    }

    cout<<dp[0][n-1]<<"\n";




}


Measured memory_bytes: 1536
import java.util.ArrayDeque;
import java.util.HashSet;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;



public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Set<String> set = new HashSet<String> ();
		long N = sc.nextInt();
		Main main = new Main();
		Queue<String> queue = new ArrayDeque<String>();
		int count =0;
		char ch[] = {'3','5','7'};
		queue.add("357");
		queue.add("375");
		queue.add("537");
		queue.add("573");
		queue.add("735");
		queue.add("753");
		if (N<1000) {
			for (String s:queue) {
				if (Long.parseLong(s)<=N) {
					count ++;
				}
			}
			System.out.println(count);
			return ;
		}
		while(queue.size()>0) {
			String s = queue.poll();
			if (Long.parseLong(s)<=N) {
				count ++;
				for (int i=0;i<=s.length();i++) {
					for (int j=0;j<ch.length;j++) {
						String temp=main.addChar(s, i, ch[j]);
						if(set.contains(temp)==false) {
							set.add(temp);
							queue.add(temp);
						}
					}
				}
			}
		}
		System.out.println(count);
  	}

	private String addChar(String s,int location,char c) {
		StringBuffer sb = new StringBuffer();
		sb.append(s.substring(0,location));
		sb.append(c);
		if (location<s.length()) {
			sb.append(s.substring(location));
		}
		return sb.toString();
	}
}

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

typedef long long ll;

int main() {
  int N;
  int A, B;
  cin >> N >> A >> B;
  ll ans;
  if (A <= B) {
    if (N > 1) {
      ans = (ll)(N - 2) * (B - A) + 1;
    } else {
      if (A == B) ans = 1;
      else ans = 0;
    }
  } else {
    ans = 0;
  }
  // 解答
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <algorithm>
typedef long long LL;
using namespace std;
int main()
{
    char s[105];
    scanf("%s",s);
    int n=strlen(s);
    if(n==1) {
        cout<<"No"<<endl;
        return 0;
    }
    sort(s,s+n);
    //for(int i=0;i<n;i++)
    //cout<<s[i]<<endl;
    int hs=1,flg=1;
    for(int i=1;i<n;i++){
        if(s[i]==s[i-1]) hs++;
        else{
            if(hs%2==1) {
                flg=0;
                break;
            }
            else hs=1;
        }
    }
    if(flg) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  auto x = scanElem;
  auto a = scanElem-scanElem;
  if(a>=0)end("delicious");
  if(a+x>=0)end("safe");
  end("dangerous");
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <list>
#include <iterator>
#define long long long
using namespace std;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  cin.tie(nullptr), ios::sync_with_stdio(false);
  int q;
  list<int> ls;
  auto itr = ls.begin();

  cin >> q;
  while(q--) {
    int com, x;
    cin >> com;

    if (com == 0) {
      cin >> x;
      itr = ls.emplace(itr, x);
    } else if (com == 1) {
      cin >> x;
      advance(itr, x);
    } else {
      itr = ls.erase(itr);
    }
  }

  for(int e : ls) {
    cout << e << '\n';
  }

  return 0;
}




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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
const int N=1e5+5;
ll n,m;
vector<ll> adj[N];
vector<ll> h(N);
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    cin>>n>>m;
    repA(i,1,n) cin>>h[i];
    repA(i,1,m)
    {
        ll x,y;
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    ll ans=0;
    repA(i,1,n)
    {
        ll ht=h[i];
        int flag=1;
        for(auto u:adj[i])
        {
            if(h[u] >= ht) flag=0;
        }
        if(flag==1) ans++;
    }
    cout<<ans<<'\n';
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 9800
def main():
    X = input()
    S_COUNT = 0
    delete = 0
    for c in X:
        if c == "S":
            S_COUNT += 1
        else:
            if S_COUNT:
                delete += 2
                S_COUNT -= 1
                
    print(len(X)-delete)
if __name__ == "__main__":
    main()

Measured memory_bytes: 9208
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int N; cin >> N;
    if(N%2==0){
        cout << N/2 << endl;
    }else{
        cout << N/2 + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdint.h>
#include<stdlib.h>

#define SEGT_UNIT 0u

typedef struct{
    uint32_t *data;
    long btm_len;
    long data_arlen;
}seg_tree;

uint32_t bmask[26];
seg_tree segt;

void bmask_init(void){
    bmask[0] = 1u;
    for(int i = 1;i < 26;i++)bmask[i] = bmask[i-1] << 1;
}

void seg_init(long data_cnt,char *strdata){
    register long i;
    long nib = 1;
    while(nib < data_cnt)nib *= 2;
    segt.btm_len = nib;
    segt.data_arlen = nib * 2;
    segt.data = malloc(sizeof(uint32_t) * segt.data_arlen);
    for(i = segt.btm_len;i < segt.btm_len + data_cnt;i++)segt.data[i] = bmask[strdata[i-segt.btm_len] - 'a'];
    for(i = segt.btm_len + data_cnt;i < segt.data_arlen;i++)segt.data[i] = SEGT_UNIT;
    for(i = segt.btm_len-1;i >= 1;i--)segt.data[i] = segt.data[i*2] | segt.data[i*2+1];
}

void seg_assign(long index,char c){//!0-indexed
    index += segt.btm_len;
    segt.data[index] = bmask[c - 'a'];
    while(1){
        index /= 2;
        segt.data[index] = segt.data[index*2] | segt.data[index*2+1];
        if(index == 1)break;
    }
}

uint32_t rec_exi(const long inl,const long inr,long nwnode,long nwl,long nwr){
    if(inr >= nwr && inl <= nwl)return segt.data[nwnode];
    if(inr < nwl || inl > nwr)return SEGT_UNIT;
    long mid = (nwr+nwl)/2;
    return rec_exi(inl,inr,nwnode*2,nwl,mid) | rec_exi(inl,inr,nwnode*2+1,mid+1,nwr);
}

int seg_exi(long l,long r){// !(l,r) 1-indexed
    uint32_t rec_res = rec_exi(l,r,1,1,segt.btm_len);
    int res = 0;
    for(register int i = 0;i < 26;i++)if(rec_res & bmask[i])res++;
    return res;
}

int main(void){
    bmask_init();
    long n;
    int q;
    scanf("%ld",&n);
    char str[n];
    scanf("%s",str);
    scanf("%d",&q);
    seg_init(n,str);
    fflush(stdout);
    for(register int q_num = 0;q_num < q;q_num++){
        int kind;
        scanf("%d",&kind);
        if(kind == 1){
            long ind;
            char c;
            scanf("%ld %c",&ind,&c);
            seg_assign(ind-1,c);
        }
        else{
            long l,r;
            scanf("%ld %ld",&l,&r);
            int cnt = seg_exi(l,r);
            printf("%d\n",cnt);
        }
    }
    return 0;
}

Measured memory_bytes: 4864
//
// author  : Abhishek
//
#include <bits/stdc++.h>
#include<chrono>

#define ll long long
#define db double
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define all(x) x.begin(),x.end()
#define fo(i, n) for(i=0 ; i<n ; i++)
#define Fo(i, k, n) for(i=k ; i<n ; i++)

using namespace std;
using namespace chrono;

const ll MOD = 1000000007;
const ll N = 120;  // array size
const ll inf = 10000000000000000;


void print(vector<ll> v) {
    ll i;
    fo(i, v.size())cout << v[i] << " ";
    cout << "\n";
}

void print(vector<pair<ll, ll> > v) {
    ll i;
    fo(i, v.size()) {
        cout << v[i].first << " " << v[i].second << "\n";
    }
}

vector<ll> read(ll n) {
    ll i;
    vector<ll> arr(n, 0);
    fo(i, n)cin >> arr[i];
    return arr;
}

vector<ll> read(ll n, ll k) {
    ll i;
    vector<ll> arr(n + k, 0);
    Fo(i, k, n + k)cin >> arr[i];
    return arr;
}

bool isEven(ll n) {
    return n % 2 == 0;
}

bool isOdd(ll n) {
    return n % 2 != 0;
}


ll n, w;
int dp[100100][110];
vector<ll> wt(N), val(N);

ll get(ll cur_val, ll pos) {
    if (cur_val <= 0) {
        return 0;
    }
    if (pos == n)
        return INT_MAX;

    if (dp[cur_val][pos] != -1)
        return dp[cur_val][pos];

    ll op1 = get(cur_val, pos + 1);
    ll op2 = wt[pos] + get(cur_val - val[pos], pos + 1);

    dp[cur_val][pos] = min(op1, op2);

    return dp[cur_val][pos];
}


void solve() {
    ll t = 1;

    while (t--) {

        ll i, j, k, m, p, q, x, y, a, b, l, r;
        cin >> n >> w;
        fo(i, 100100) {
            fo(j, 110) {
                dp[i][j] = -1;
            }
        }

        fo(i, n) {
            cin >> wt[i] >> val[i];
        }


        ll mx = accumulate(all(val), 0);

        for (i = mx; i >= 0; i--) {
            if (get(i, 0) <= w) {
                cout << i << "\n";
                break;
            }
        }


    }
}

int main() {

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

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif

    auto start = high_resolution_clock::now();

    solve();

    ll i, j, k, n, m, p, q, x, y, a, b, l, r;


    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
#ifndef ONLINE_JUDGE
    cerr << "Time: " << duration.count() / 1000.0 << endl;
#endif


    return 0;
}




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

// Optimization

//#pragma GCC optimize("O3")
// #define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 1e5 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e18 + 7;
const ll infll = 1e18 + 7;

int n, m, k;
int ans, cnt, tmp, idx, sum, mx = -inf, mn = inf;
int x, y, z;
string s, t;
int a[N], b[N];

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> k;
    cout << min(n % k, k - n % k);
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 256
#include <iostream>


using namespace std;

long long dp[2001];

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

	dp[1] = 0;
	dp[2] = 0;
	dp[3] = 1;
	for (int i = 4; i <= 2000; i++)
	{
		dp[i] = 1;

		int temp = 3;
		while (i - temp >= 3)
		{
			dp[i] += dp[i - temp];
			dp[i] %= 1000000007;
			temp++;
		}
	}

	cout << dp[n] << endl;

	return 0;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    string a, b;
    cin >> a >> b;
    int v = stoi(a+b);
    bool flg = false;
    for(int i = 1; i*i <= v; i++){
        if(i*i == v) flg = true;
    }
    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3600
package main

import "fmt"

func main() {
	var n, m, x int
	fmt.Scan(&n, &m, &x)
	a := make([]int, m)
	for i := range a {
		fmt.Scan(&a[i])
	}

	l := 0
	r := 0
	for _, v := range a {
		if v < x {
			l++
		} else {
			r++
		}
	}

	if l <= r {
		fmt.Println(l)
	} else {
		fmt.Println(r)
	}
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

//関数宣言
//int func(int x, int y);

int main(void){

  //スカラー入力
  int K,N;

  scanf("%d %d", &N, &K);

  //文字列入力
  char str[N+1];
  scanf("%s", str);


  str[K-1] = str[K-1] + 32;
  printf("%s\n", str);

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
  int main(){
  int a,b,c,x;
   scanf("%d%d%d",&a,&b,&c);
    if(a>b){
     x=a;
     a=b;
     b=x;
    }
    if(b>c){
     x=b;
     b=c;
     c=x;
    }
    if(a>b){
     x=a;
     a=b;
     b=x;
    }
   printf("%d %d %d\n",a,b,c);
  return 0;
 }

Measured memory_bytes: 1860
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((b * 10 + c) % 4 == 0) {
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
def factorize(M):
  res=defaultdict(int)
  for i in range(2,int(M**0.5)+1):
    if M==1:
      break
    while M%i==0:
      M//=i
      res[i]+=1  
  if M!=1:
    res[M]=1
  return res

N=int(input())
fact=factorize(N)
#print(fact)

def times(n):
  ret=1
  for i in range(2,10**9):
    if n<i*(i+1)//2:
      return ret
    else:
      ret+=1

answer=0
for v in fact.values():  
  #print(v,times(v))
  answer+=times(v)
  
print(answer)

Measured memory_bytes: 66472
import sys
from io import StringIO
import unittest

import numpy as np

def resolve():
    a = np.array([list(map(int, input().split())) for _ in range(3)])
    n = int(input())
    b = set([int(input()) for _ in range(n)])
    flag = 0

    for i in range(3):
        if set(a[i]).issubset(b) or set(a[:, i]).issubset(b):
            flag = 1
            break

    if set([a[0][0], a[1][1], a[2][2]]).issubset(b) or set([a[0][2], a[1][1], a[2][0]]).issubset(b):
        flag = 1

    if flag == 1:
        print('Yes')
    else:
        print('No')



class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30"""
        output = """Yes"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """41 7 46
26 89 2
78 92 8
5
6
45
16
57
17"""
        output = """No"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34"""
        output = """Yes"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 12440
n = gets.to_i
a = gets.chomp.split.map(&:to_i).sort!

hs = Hash.new(0)
dp = Array.new(a[-1] + 1, true)

0.step(n - 1) do |i|
  hs[a[i]] += 1
  1.step(a[-1] / a[i]) do |c|
    if c == 1
      if !dp[c * a[i]]
        break
      else
        next
      end
    end
      
    dp[c * a[i]] = false
  end
end

puts a.count {|x| dp[x] && hs[x] <= 1 }

Measured memory_bytes: 49452
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
using namespace std;

const int MaxN = 1e5 + 5;
typedef long long LL;

int main(){
	int a,b;
	cin>>a>>b;
	if((a*b) % 2 == 1){
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
ans = 0

def calc(n,k):
    while(n%k==0):
        n = n//k
    n  %= k
    return n

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

divisors = make_divisors(n)
divisors += make_divisors(n-1)
divisors = set(divisors)
for i in divisors:
    if(i != 1):
        if( calc(n,i)==1 ):
            ans += 1

print(ans)

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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x)*(x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<char> vc;
typedef vector<vector<char>> vvc;

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

int H, W;

int main() {
    cin >> H >> W;
    vvc field(H, vc(W));
    vvll state(H, vll(W));
    REP(y, H) REP(x, W) {
        cin >> field[y][x];
    }

    vector<vector<pii>> char2pos(26, vector<pii>(2));
    vb seen(26);
    REP(y, H) REP(x, W) {
        if (field[y][x] != '.') {
            int c = field[y][x] - 'A';
            if (seen[c]) {
                char2pos[c][1] = {x, y};
                field[y][x] += 0x20;
            } else {
                char2pos[c][0] = {x, y};
                seen[c] = true;
            }
        }
    }

    int score = 0;
    bool redo;
    do {
        redo = false;

        REP(y, H) REP(x, W) {
            if (field[y][x] != '.') {
                ll s = 1LL << (field[y][x] - 'A');
                REP(i, 4) {
                    int sx = x + dx[i], sy = y + dy[i];
                    while (0 <= sx && sx < W && 0 <= sy && sy < H &&
                        field[sy][sx] == '.') {
                        state[sy][sx] |= s;

                        sx += dx[i];
                        sy += dy[i];
                    }
                }
            }
        }

        REP(y, H) REP(x, W) {
            if (field[y][x] == '.') {
                REP(c, 27) {
                    if (seen[c]) {
                        ll s = (1LL<<c) | (1LL<<(c+0x20));
                        if ((state[y][x] & s) == s) {
                            int sx, sy;
                            sx = char2pos[c][0].first;
                            sy = char2pos[c][0].second;
                            field[sy][sx] = '.';
                            sx = char2pos[c][1].first;
                            sy = char2pos[c][1].second;
                            field[sy][sx] = '.';
                            seen[c] = false;
                            score += 2;
                            redo = true;
                        }
                    }
                }
            }
        }
    } while (redo);
    cout << score << endl;
}

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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}
//* Mod int
const int mod = 1000000007;
struct mint {
  ll x;
  mint() : x(0) {}
  mint(ll x) : x((x % mod + mod) % mod) {}
  // mint(ll x):x(x){}
  mint &fix() {
    x = (x % mod + mod) % mod;
    return *this;
  }
  mint operator-() const { return mint(0) - *this; }
  mint &operator+=(const mint &a) {
    if((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint &a) {
    if((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint &a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint &a) const { return mint(*this) += a; }
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  bool operator<(const mint &a) const { return x < a.x; }
  bool operator==(const mint &a) const { return x == a.x; }
};
istream &operator>>(istream &i, mint &a) {
  i >> a.x;
  return i;
}
ostream &operator<<(ostream &o, const mint &a) {
  o << a.x;
  return o;
}
typedef vector<mint> vm;
typedef vector<vm> vvm;
//*/
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, k;
  cin >> n >> k;
  mint ans = 0;
  FOR(i, k, n + 2) {
    mint minNum = (i - 1) * i / 2ll;
    mint maxNum = minNum + (n + 1 - i) * i;
    ans += (maxNum - minNum + 1);
  }

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


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

#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)

ll dp[210][100010];
vector<ll> s;
ll rec(int i,int j){
  if(i==1){
    return dp[i][j] = j%s[i-1];
  }
  if(dp[i][j]>=0)return dp[i][j];
  else return dp[i][j] = ((rec(i-1,j)*(i-1))%MOD+rec(i-1,j%s[i-1]))%MOD;
}
int main(){
  int n,x;
  cin >> n >> x;
  s.assign(n,0);
  rep(i,n){
    cin >> s[i];
  }
  sort(all(s));
  rep(i,210){
    rep(j,100010){
      dp[i][j] = -1;
    }
  }
  cout << rec(n,x) << endl;
}

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

const double PI = acos(-1);
const double EPS = 1e-15;
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
const ll MOD1 = 998244353;
//typedef pair<int,int> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

map<pair<double,double>,int> mp;
int n;
pair<double,double> p[110];
double ans[110];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  REP(i,n) {
    cin >> p[i].fi >> p[i].se;
    mp[{p[i].fi,p[i].se}] = i;
  }

  sort(p,p+n);

////debug-----------
//  cout << "p" << endl;
//  REP(i,n) cout << p[i].fi << " " << p[i].se << endl;
//  cout << endl;
////----------------

  if (n == 2) {
    cout << "0.5\n0.5\n";
    return 0;
  }

  vector<pair<double,double>> v;
  v.pb(p[0]);
  v.pb(p[1]);

  //下の辺
  int k = 1;
  for (int i = 2; i < n; i++) {
    while (k > 0) {
      double x1 = v[k].fi - v[k-1].fi;
      double y1 = v[k].se - v[k-1].se;
      double x2 = p[i].fi - v[k-1].fi;
      double y2 = p[i].se - v[k-1].se;
      //逆の場合
      if (x1 * y2 - x2 * y1 <= 0) {
        k--;
      } else break;
    }
    k++;
    if (k == sz(v)) v.pb(p[i]);
    else v[k] = p[i];
  }

////debug-----------
//  cout << "v:" << endl;
//  REP(i,k+1) cout << v[i].fi << " " << v[i].se << endl;
//  cout << endl;
////----------------

  vector<pair<double,double>> v1;
  v1.pb(p[0]);
  v1.pb(p[1]);

  //上の辺
  int k1 = 1;
  for (int i = 2; i < n; i++) {
    while (k1 > 0) {
      double x1 = v1[k1].fi - v1[k1-1].fi;
      double y1 = v1[k1].se - v1[k1-1].se;
      double x2 = p[i].fi - v1[k1-1].fi;
      double y2 = p[i].se - v1[k1-1].se;
      //逆の場合
      if (x1 * y2 - x2 * y1 >= 0) {
        k1--;
      } else break;
    }
    k1++;
    if (k1 == sz(v1)) v1.pb(p[i]);
    else v1[k1] = p[i];
  }

////debug-----------
//  cout << "v1:" << endl;
//  REP(i,k1+1) cout << v1[i].fi << " " << v1[i].se << endl;
//  cout << endl;
////----------------

  vector<pair<double,double>> r;
  REP(i,k+1) r.pb(v[i]);
  for (int i = k1 - 1; i > 0; i--) r.pb(v1[i]);

////debug-----------
//  cout << "r:" << endl;
//  REP(i,sz(r)) cout << r[i].fi << " " << r[i].se << endl;
//  cout << endl;
////----------------

  k = k + k1;

////debug-----------
//  cout << k << endl;
////----------------

  REP(i,k) {
    double px = r[(i+1)%k].fi;
    double py = r[(i+1)%k].se;
    double x1 = r[i].fi - px;
    double y1 = r[i].se - py;
    double x2 = r[(i+2)%k].fi - px;
    double y2 = r[(i+2)%k].se - py;
    //cout << r[i].fi << "," << r[i].se << " -> " << r[(i+2)%k].fi << "," << r[(i+2)%k].se << endl;

    double a1 = atan2(y1,x1);
    double a2 = atan2(y2,x2);
    //cout << a1 << " " << a2 << endl;
    if (a1 < 0 && a2 > 0) a1 += 2 * PI;
    //cout << a1 << " " << a2 << endl;
    ans[mp[{px,py}]] = (PI - a1 + a2) / 2 / PI;
  }

  REP(i,n) {
    cout << setprecision(20) << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    const int a[] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int k;
    cin >> k;
    cout << a[k - 1] << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [ int(i) for i in input().split() ]
tot = sum(s)
pre = [ 0 for i in range(n+1) ]
for i in range(n):
  pre[i+1] = pre[i]
  pre[i+1] += s[i]

mm = 10**9+7
for i in range(n+1):
  s1 = pre[i]
  s2 = tot - s1
  mm = min(mm, abs(s1-s2))
print(mm)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(S: str):
    c = 'R'
    ci = 0
    counter = 1
    S += 'R'
    A = [0] * len(S)

    for i, s in enumerate(S):
        if i == 0:
            continue
        if s == 'R' and c == 'R':
            counter += 1
        elif (s == 'L' or i == len(S)-1) and c == 'R':
            if counter % 2 == 0:
                A[i] += counter // 2
                A[i-1] += counter // 2
            else:
                A[i] += (counter-1) // 2
                A[i-1] += (counter+1) // 2
            counter = 1
            ci = i
            c = 'L'
        elif (s == 'R' or i == len(S) - 1) and c == 'L':
            if counter % 2 == 0:
                A[i-counter-1] += counter // 2
                A[i-counter] += counter // 2
            else:
                A[i-counter-1] += (counter-1) // 2
                A[i-counter] += (counter+1) // 2
            counter = 1
            ci = i
            c = 'R'
        elif s == 'L' and c == 'L':
            counter += 1
    print(' '.join([str(a) for a  in A[:-1]]))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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

typedef long long ll;

int cou;
int m;
ll g[1000000];

int setg(int n){
    int ret=0;
    bool flg=true;
    for(int i=2;i<1000000;i++){
        g[i]=3*g[i-1]+1;
        if(g[i]>=n&&flg){
            ret=i-1;
            flg=false;
            break;
        }
    }
    return ret;
}

void insertsort(vector<int> &v,int n, int h){
    for(int i=0;i<h;i++){

        for(int j=i+h;j<n;j+=h){
            for(int k=j;k>=h;k-=h){
                if(v[k]<v[k-h])swap(v[k],v[k-h]);
                else break;
                cou++;
            }
        }

    }
}

void shell(vector<int> &v,int n){
    cou=0;
    for(int i=m;i>=1;i--){
        insertsort(v,n,g[i]);
    }
}

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> vc(n);
    for(int i=0;i<n;i++)cin >> vc[i];

    g[1]=1;
    m=setg(n);
    shell(vc,n);

    cout << m << endl;
    for(int i=m;i>=1;i--)cout << g[i] << (i!=1?" ":"\n");
    cout << cou << endl;
    for(int i=0;i<n;i++){
        cout << vc[i] << endl;
    }

}



Measured memory_bytes: 6796
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define l1 long
#define ld long double
#define lld long long double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(x) cout<<"$ "<<x<<" $"<<endl
#define bug(x) cout<<"& "<<x<<" &"<<endl
#define all(v) v.begin(),v.end()
#define lop1(i,j,n) for(int i=j; i<n; ++i)
#define lop2(i,j,n) for(int i=j; i<=n; ++i)
#define lop3(i,n,j) for(int i=n; i>j; --i)
#define lop4(i,n,j) for(int i=n; i>=j; --i)
#define view(v) for(auto i: v) cout<<i<<" "
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
const ll M=1e9+7;
const ld PI=3.1415926536;
//int p[N];
//int find(int k){ return p[k]==k ? k : p[k]=find(p[k]); }
using namespace std;

void solve()
{
    string s, t;
    cin>>s>>t;
    ll ans=0;
    lop1(i,0,(int)s.size())
    {
        if(s[i]!=t[i]) ans++;
    }
    cout<<ans<<endl;
    return;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    fast
    int t=1;
	//cin>>t;
    while(t--) solve();
	return 0;
}


Measured memory_bytes: 3884
x_1,y_1,x_2,y_2 = map(int,input().split())
x_3 = x_2 - (y_2 - y_1)
y_3 = y_2 + (x_2 - x_1)
x_4 = x_1 - (y_2 - y_1)
y_4 = y_1 + (x_2 - x_1)
print(x_3, y_3, x_4, y_4)

Measured memory_bytes: 9116
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin>> N;
    vector<ll> A, B, C;
    rep(i,0,N) {
        ll a;
        cin>> a;
        A.push_back(a);
    }
    rep(i,0,N) {
        ll a;
        cin>> a;
        B.push_back(a);
    }
    rep(i,0,N) {
        ll a;
        cin>> a;
        C.push_back(a);
    }
    sort(A.begin(), A.end()); sort(C.begin(), C.end());
    ll res=0;
    rep(i,0,N){
        res+=(lower_bound(A.begin(), A.end(), B[i])-A.begin())*(C.end()-upper_bound(C.begin(), C.end(),B[i]));
    }
    cout << res<<"\n";
}


Measured memory_bytes: 3316
N = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
    for j in range(1,105):
        for k in range(1,105):
            v = i*i + j*j + k*k + k*j + i*k + i*j
            if v < 10050:
                ans[v] += 1

for i in range(N):
    print(ans[i+1])

Measured memory_bytes: 9240
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

h, w = map(int, readline().split())
n = int(readline())
a = list(map(int, readline().split()))
idx = 0
for i in range(h):
    ans = []
    for j in range(w):
        if a[idx] == 0:
            idx += 1
        a[idx] -= 1
        ans.append(idx + 1)
    if i % 2 == 1:
        ans = ans[::-1]
    print(*ans)


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

#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int mod = (int)1e9+7;
#define REP0(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<=n;i++)
#define F first
#define S second
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define setbits(x) __builtin_popcountll(x)
#define inf (int)(1e18)
#define prec(x) fixed<<setprecision(x)<<x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(x) x.begin(),x.end()


const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};

void solve(){
   string s,t;
   cin>>s>>t;
   int m = s.size();
   int n = t.size();
   int ml = INT_MAX;  
   for(int i=0;i<m-n+1;i++){
       int len = 0;
       for(int j=0;j<n;j++){
           if(s[i+j] != t[j]){
               ++len;
           }
       }
       ml = min(ml,len);
   }
   cout<<ml<<endl;
}


int main(){
    fastio;
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif
    int tc = 1;
    // cin>>tc;
    for(int i=1;i<=tc;i++){
        solve();
    }
    return 0;
}


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

int main()
{
  int N, M; cin >> N >> M;
  vector<int> count(M, 0);
  for(int i = 0; i < N; i++)
  {
    int K; cin >> K;
    for(int j = 0; j < K; j++)
    {
      int A; cin >> A; A -= 1;
      count.at(A) += 1;
    }
  }
  int ans = 0;
  for(int i = 0; i < M; i++)
  {
    if(count.at(i) == N)
    {
      ans += 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256