akhauriyash/Code-Regression huggingface dataset:
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

n = int(input())
w = list(map(int, input().split()))
sumv = sum(w)
rui = 0
sa = []
for i in range(n):
    rui += w[i]
    sa.append(abs(sumv - rui*2))
print(min(sa))

Measured memory_bytes: 5076
#include <iostream>
//#include <numeric>
//#include <vector>
#include<math.h>
//#include <cstdint>
//#include <string>
#include <cstdlib>
using namespace std;

int main() {
	uint64_t a;
	cin >> a;

	uint64_t x = sqrt(a);

	for (uint64_t i = x; i > 0; i--) {
		if (a % i == 0) {
			uint64_t y = a / i;
			cout << i + y - 2;
			break;
		}
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;

const long long MOD = 1000000007;

int main(){
    int n;
    cin >> n;
    vll a(n);
    rep(i, n){
        cin >> a[i];
    }

    ll accum = accumulate(a.begin(), a.end(), 0LL);
    ll ans = 0;
    for(auto x : a){
        accum -= x;
        ll tmp = (accum % MOD) * x;
        ans += tmp;
        ans %= MOD;
    }

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

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

typedef long long ll;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF (1<<30)

int main() {
	int N, M, C;
	cin >> N >> M >> C;
	vector<int> B(M);
	vector<vector<int> > A(N, vector<int>(M));

	for(int i=0; i<M; i++) cin >> B[i];
	for(int i=0; i<N; i++) for(int j=0; j<M; j++) cin >> A[i][j];

	int cnt=0;
	for (int i = 0; i < N; i++) {
		int ans=0;
		for (int j = 0; j < M; j++) {
			ans += A[i][j]*B[j];
		}
		if(ans+C > 0) cnt++;
	}

	cout << cnt << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

import java.util.*;

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

		int D = in.nextInt();
		int[] c = new int[26];
		int[][] s = new int[D][26];
		for (int i=0;i<26;i++) {
			c[i] = in.nextInt();
		}
		for (int i=0;i<D;i++) {
			int max_val = 0;
			int max_ind = 0;
			for (int j=0;j<26;j++) {
				s[i][j] = in.nextInt();
				if (max_val <= s[i][j]) {
					max_val = s[i][j];
					max_ind = j;
				}
			}
			out.println(max_ind+1);
		}
		// long tmp = 0L;
		// int[] before_ind = new int[26];
		// Arrays.fill(before_ind, -1);
		// for (int i=0;i<D;i++) {
		// 	int t = in.nextInt()-1;
		// 	for (int j=0;j<26;j++) {
		// 		if (j != t) tmp -= (long)c[j]*(i-before_ind[j]);
		// 		else {
		// 			tmp += s[i][j];
		// 			before_ind[j] = i;
		// 		}
		// 	}
		// 	out.println(tmp);
		// }
		out.close();
	}

	static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}


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

int main() {
    ll N, u, v;
    cin >> N >> u >> v;
    u--;
    v--;
    vector<vector<ll>> E(N);
    ll a, b;
    rep(i, N) {
        cin >> a >> b;
        E[a - 1].push_back(b - 1);
        E[b - 1].push_back(a - 1);
    }

    queue<ll> to;
    unordered_set<ll> visited;
    vector<ll> tstep(N, -1), astep(N, -1);
    to.push(u);
    visited.insert(u);
    tstep[u] = 0;
    ll s = 1;
    while (to.size() > 0) {
        ll t = to.front();
        to.pop();
        for (auto e : E[t]) {
            if (visited.count(e) > 0) continue;
            to.push(e);
            visited.insert(e);
            tstep[e] = tstep[t]+1;
        }
        s++;
    }

    visited.clear();
    to.push(v);
    visited.insert(v);
    astep[v] = 0;
    s = 1;
    bool end = true;
    ll ans = 0;
    while (to.size() > 0) {
        end = true;
        ll t = to.front();
        to.pop();
        for (auto e : E[t]) {
            if (visited.count(e) > 0) continue;
            end = false;
            to.push(e);
            visited.insert(e);
            astep[e] = astep[t] +1;
        }
        if (end) {
            if (tstep[t] <= astep[t]) {
                ans = max(ans, astep[t]-1);
            }
        }
        s++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 12072
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
vector<LL> a;

int lis2(vector<LL> &v) {
	vector<LL> ans(v.size(), HINF<LL>());
	for (int i = 0; i < v.size(); i++) {
		(*upper_bound(ans.begin(), ans.end(), v[i])) = v[i];
	}
	return lower_bound(ans.begin(), ans.end(), HINF<LL>()) - ans.begin();
}

int main(){
    cin >> n;
    a.resize(n);
    REP(i, n){
        cin >> a[i];
    }
    reverse(ALL(a));
    cout << lis2(a) << endl;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
static const int MAX=100;
static const int INF=1<<21;
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,A[MAX][MAX];

void dijkstra(){
  int color[MAX],mincost,k,p[MAX],d[MAX];

  for(int i=0;i<n;i++){
    color[i]=WHITE;
    d[i]=INF;
  }
  d[0]=0;
  p[0]=-1;
  color[0]=GRAY;

  while(1){
    mincost=INF;
    for(int i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<mincost){
	mincost=d[i];
	k=i;
      }
    }
    if(mincost==INF) break;
    color[k]=BLACK;

    for(int i=0;i<n;i++){
      if(color[i]!=BLACK && A[k][i]!=INF){
	if(d[k]+A[k][i]<d[i]){
	  d[i]=d[k]+A[k][i];
	  p[i]=k;
	  color[i]=GRAY;
	}
      }
    }
  }
  for(int i=0;i<n;i++){
    cout<<i<<" "<<(d[i]==INF ? -1:d[i])<<endl;
  }
}


int main(){
  int i,j,k,c,u,v;
  cin>>n;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j]=INF;
    }
  }
  for(i=0;i<n;i++){
    cin>>u>>k;
    for(j=0;j<k;j++){
      cin>>v>>c;
      A[u][v]=c;
    }
  }

  dijkstra();
}

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

int main(){

    int N, W; cin >> N >> W;
    vector<int> v(N);
    vector<int> w(N);
    vector<int> m(N);

    vector<int> vv;
    vector<int> ww;

    for(int i = 0; i < N; i++){
        cin >> v[i] >> w[i] >> m[i];
    }

    for(int i = 0; i < N; i++){
        int k = 1;
        while(1){
            if(k < m[i]){
                vv.push_back(v[i] * k);
                ww.push_back(w[i] * k);
                m[i] -= k;
                k *= 2;
            }else{
                vv.push_back(v[i] * m[i]);
                ww.push_back(w[i] * m[i]);
                break;
            }
        }
    }

    int nn = (int)vv.size();

    vector<vector<int> > dp(nn + 1, vector<int> (W + 1, 0));
    for(int i = 0; i < nn; i++){
        for(int j = 0; j <= W; j++){

            //take
            if(j + ww[i] <= W) dp[i + 1][j + ww[i]] = max(dp[i + 1][j + ww[i]], dp[i][j] + vv[i]);
        
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        }
    }

    int ans = 0;
    for(int j = 0; j <= W; j++){
        ans = max(ans, dp[nn][j]);
    }

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


Measured memory_bytes: 57692
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = a + b;
        int d = a - b;
        int e = a * b;
        System.out.println(Math.max(c, Math.max(d, e)));
    }
}

Measured memory_bytes: 21844
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        long N, A, B;
        Scanner sc = new Scanner(System.in);
        N = sc.nextLong();
        A = sc.nextLong();
        B = sc.nextLong();
      long n1 = N/(A+B);
        long n2 = N%(A+B);
        
        System.out.println(A*n1+(n2>=A?A:n2));
    }
}

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

int main(void)
{
	long long n, q;
	cin >> n >> q;
	vector<list<long long> >res(n);
	while (q--)
	{
		int op;
		cin >> op;
		if (op == 0)
		{
			long long t, x;
			cin >> t >> x;
			res[t].push_back(x);
		}
		else if (op == 1)
		{
			long long t;
			cin >> t;
			for (list<long long >::iterator it = res[t].begin(); it != res[t].end(); it++)
				if (it == res[t].begin())cout << *it;
				else cout << " " << *it;
			cout << endl;
		}
		else if (op == 2)
		{
			long long s, t;
			cin >> s >> t;
			list<long long >::iterator it = res[t].end();
			res[t].splice(it, res[s]);
		}
	}
	return 0;
}


Measured memory_bytes: 18632
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    ll n;
    cin>>n;
    ll x;
    ll a[100008]={0};
    ll sum=0;
    for(ll i=0;i<n;i++)
      {
          cin>>x;
          a[x]++;
        sum+=x;
      }
     
     ll q;
     cin>>q;
     while(q--)
     {
         ll b,c;
         cin>>b>>c;
         
         ll tmp=a[b]*(c-b);
         
         a[c]+=a[b];
         a[b]=0;
         
         sum+=tmp;
         
         cout<<sum<<"\n";
         
     }
     
     
    return 0;
}


Measured memory_bytes: 4400
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    int M;
    cin >> M;
    vector<int> A(M);
    for(int i = 0;i < M;i++) {
        cin >> A.at(i);
    }
    for(int i = 0;i < M;i++) {
        if((A.at(i) == N && vec.at(A.at(i) - 1) != 2019) || (A.at(i) != N && vec.at(A.at(i) - 1) + 1 != vec.at(A.at(i)))) {
            vec.at(A.at(i) - 1)++;
        }
    }
    for(int i = 0;i < N;i++) {
        cout << vec.at(i) << endl;
    }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int a,b;cin>>a>>b;
  int ans=a+b;
  
  if(ans>=10){
      cout("error");
  }
  else cout(ans);
  
  return 0;
}

Measured memory_bytes: 125568
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
typedef long long i64;
int main(){
    int N;
    cin >> N;
    int a[N];
    rep(i,N) cin >> a[i];
    int i=N-1,j=0;
    for(int i=N-1;i>(N%2==0 ? 0:-1);i-=2){
        cout << a[i];
        if(j!=N-1) cout <<  " ";
        else cout << endl;
    }
    for(int j=(N%2==0 ? 0:1);j<N-1;j+=2){
        cout << a[j];
        if(j!=N-2) cout <<  " ";
        else cout << endl;
    }
    return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int p=0;
  int ans=0;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='p') p++;
  }
  ans=(s.size()/2)-p;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
map<ll,int>mp;
int f(ll n){
	int x=0;
	while(n){
		x++,n/=10;
	}
	return x;
}
int main(){
	ll n,m;
	cin>>n;
	ll ans=1e9;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			ll x=max(f(i),f(n/i));
			ans=min(ans,x);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3568
#include<stdio.h>
 
void visit(int);
int dequeue(void);
void enqueue(int);
 
int map[101][101];
int Q[101],n,head=0,tail=0,color[101],d[101];
int main()
{
  int i,j,v,vv,m,u,k;
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    color[i]=0;
    for(j=0;j<n;j++){
      map[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&m);
    for(j=0;j<m;j++){
      scanf("%d",&vv);
      map[v-1][vv-1]=1;
    }
  }
 
  for(j=0;j<n;j++){
    if(map[0][j]==1){
      color[j]=0;
    }
  }
  color[0]=1;
  d[0]=0;
  enqueue(0);
  while(head!=tail){
    u=dequeue();
    for(k=0;k<n;k++){
      if(map[u][k]==1 && color[k]==0){
    color[k]=1;
    d[k]=d[u]+1;
    enqueue(k);
      }
      color[u]=2;
    }
  }
   
 
   
  for(i=0;i<n;i++){
    if(color[i]==2)printf("%d %d\n",i+1,d[i]);
    else printf("%d -1\n",i+1);
  }
  return 0;
}
 
int dequeue()
{
  int x;
  x=Q[head];
  if(head+1==100)head=0;
  else head=head+1;
  return x;
}
 
void enqueue(int x)
{
  Q[tail]=x;
  if(tail+1==100)tail=0;
  else tail=tail+1;
}


Measured memory_bytes: 2104
## https://atcoder.jp/contests/abc170/submissions/14416787
class SegmentTree():
    def __init__(self,n,init):
        self.offset=2**((n-1).bit_length())
        self.tree=[init]*(2*self.offset)
        self.init=init
    def update(self,pos,val):
        pos+=self.offset
        self.tree[pos]=val
        while pos>1:
            pos=pos//2
            self.tree[pos]=max(self.tree[2*pos],self.tree[2*pos+1])
    def query(self,l,r):
        l+=self.offset
        r+=self.offset
        ret=self.init
        while l<=r:
            ret=max(ret,self.tree[r])
            r=(r-1)//2
            ret=max(ret,self.tree[l])
            l=(l+1)//2
        return ret

import sys
input=sys.stdin.readline
n,k=map(int,input().split())
a=[int(input()) for _ in range(n)]

st=SegmentTree(300001,0)
##queryが開区間でない
for ai in a:
    l=max(0,ai-k)
    r=min(300001,ai+k)
    m=st.query(l,r)
    st.update(ai,m+1)

print(st.query(0,300001))
  

Measured memory_bytes: 111268
using System;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            int maxTypes = 0;

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

                var X = S.Substring(0, i);
                var Y = S.Substring(i, N - i);

                for(int j = 0; j < X.Length; j++)
                {
                    bool Xcontain = false;

                    for(int k = 0; k < j; k++)
                    {
                        if (X.Substring(j, 1) == X.Substring(k, 1)) Xcontain = true;
                    }
                    if (Xcontain) continue;

                    for(int k = 0; k < Y.Length; k++)
                    {
                        if (X.Substring(j, 1) == Y.Substring(k, 1))
                        {
                            maxCount++;
                            break;
                        }
                    }
                }

                if (maxCount > maxTypes) maxTypes = maxCount;
            }

            Console.WriteLine(maxTypes);
        }    
    }
}

Measured memory_bytes: 15184
#include<stdio.h>

int main(void){

	int a=0,b=0,wa,i,keta;

	while(scanf("%d %d",&a,&b)!=EOF){
		keta=0;
		wa=a+b;

		if(wa!=0){
			while(wa>0){
				wa=wa/10;
				keta++;
			}
		}
		else{
			keta=1;
		}
	
		printf("%d\n",keta);
	}
	return 0;
}

Measured memory_bytes: 600
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt(), B = cin.getIntArray(N);
    let ans = [];
    while (B.length > 0) {
        let f = false;
        for (let n = N - 1; n >= 0; n--) {
            if (B[n] == n + 1) {
                ans.push(B[n]);
                B.splice(n, 1);
                f = true;
                break;
            }
        }
        if (!f) {
            console.log(-1);
            return;
        }
    }
    console.log(ans.reverse().join('\n'));
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<iostream>

using namespace std;

int main(){
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  if(a+b<=2*c){
    cout << a*x + b*y << endl;
  }
  else{
    int ans=0, mn=min(x, y);
    ans += c*2*mn;
    x -= mn;
    y-=mn;
    ans += x*min(a, 2*c) + y*min(b,2*c);
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
long long int f(long long int a){
  return a<0?-1*a:a;
}
int main(){
  long long int a,b=999,c;
  scanf("%lld",&a);
  while(a>0){
    c=f(753 - (a%1000));
    if(b>c){
      b=c;
    }
    a=a/10;
  }
  printf("%lld",b);
  return 0;}


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

int main() {

  int N;
  cin >> N;
  
  vector<ll> c(N);
  set<ll> d;
  rep(i, N) {
    ll a;
    cin >> a;
    c[i] = a;
    d.insert(a);
  }

  string ans = c.size() == d.size() ? "YES" : "NO";
  cout << ans << endl;
}

Measured memory_bytes: 11136
#include<stdio.h>
int main(){
  int b,c,i,j,k,d=0;
  scanf("%d",&b);
  int a[b];
  for(k=0;k<b;k++){
    scanf("%d",&a[k]);
  }
  for(i=0;i<b-1;i++){
    for(j=b-1;j>i;j--){
      if(a[j-1]>a[j]){
	c=a[j];
	a[j]=a[j-1];
	a[j-1]=c;
	d=d+1;
      }
    }
  }
    for(k=0;k<b-1;k++){
      printf("%d ",a[k]);
  }
    printf("%d\n",a[b-1]);
    printf("%d\n",d);
    return 0;
  }



Measured memory_bytes: 2052
#include <bits/stdc++.h>
 
#define fto(i, x, y) for(auto i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(auto i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(auto i = (x); i <= (y); i += a)
#define ftoit(it, var) for (auto it = var.begin(); it != var.end(); ++it)
 
#define ii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
 
#define vi vector<int>
#define vii vector<ii>
#define ll long long
#define vll vector<ll>
 
#define eb emplace_back
#define ef emplace_front
#define lb lower_bound
#define ub upper_bound
 
#define oo 1000000007
#define OO 1000000000000000007LL
 
using namespace std;
 
#define Pro "tmp"
#define maxN 1000007

int cnt[maxN];
vi adj[maxN];

bool visited[maxN];
vii ans;

map <int, bool> check[maxN];
int parent[maxN];

void DFS(int u) {
    visited[u] = 1;
    fto(i, 0, (int)adj[u].size()-1) {
        int v = adj[u][i];
        if (parent[u] == v) continue;
        if (!visited[v]) {
            parent[v] = u;
            DFS(v);
        }

        if (check[u][v] || check[v][u]) continue;
        check[u][v] = check[v][u] = 1;
        if (cnt[v]%2) {
            ++cnt[v];
            ans.eb(v, u);
        }
        else {
            ++cnt[u];
            ans.eb(u, v);
        }  
    }
    return;
}
int main() {
 
    int n, m;
    scanf("%d%d", &n, &m);


    if (m%2) {
        puts("-1");
        return 0;
    }

    fto(i, 1, m) {
        int u, v;
        scanf("%d%d", &u, &v);
        adj[u].eb(v);
        adj[v].eb(u);
    }

    DFS(1);
    fto(i, 0, (int)ans.size()-1) printf("%d %d\n", ans[i].ff, ans[i].ss);

    return 0;
} 

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

using namespace std;

int main() {
    int n,k;
    cin>>n>>k;
    int A[n];
    for(int i=0;i<n;i++) cin>>A[i];
    sort(A,A+n);
    int sum=0;
    for(int i=0;i<k;i++) sum+=A[i];
    cout<<sum;
}

Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main(){
  char b;
  if(cin >> b and b == 'A') cout << 'T' << endl;
  else if(b == 'T') cout << 'A' << endl;
  else if(b == 'C') cout << 'G' << endl;
  else cout << 'C' << endl;
  return 0;
}


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

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<int>> wall_y(h);
    vector<vector<int>> wall_t(w);
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            char c;
            cin >> c;
            if(c == '#'){
                wall_y.at(i).push_back(j);
                wall_t.at(j).push_back(i);
            }
        }
    }
    vector<vector<int>> yoko(h, vector<int>(w,0));
    vector<vector<int>> tate(h, vector<int>(w,0));
    for(int i=0; i<h; i++){
        if(wall_y.at(i).size() == 0){
            for(int j=0; j<w; j++){
                yoko.at(i).at(j) = w;
            }
        }
        else if(wall_y.at(i).size() == 1){
            int k = wall_y.at(i).at(0);
            for(int j=0; j<w; j++){
                if(j < k) yoko.at(i).at(j) = k;
                else if(j==k) yoko.at(i).at(j) = 0;
                else yoko.at(i).at(j) = w-k-1;
            }
        }
        else{
            int s = wall_y.at(i).size();
            int first,end;
            first = wall_y.at(i).at(0);
            end = wall_y.at(i).at(s-1);
            for(int j=0; j<first; j++){
                yoko.at(i).at(j) = first;
            }
            for(int j=end+1; j<w; j++){
                yoko.at(i).at(j) = w-end-1;
            }
            for(int j=0; j<=s-2;j++){
                int p,q;
                p = wall_y.at(i).at(j);
                q = wall_y.at(i).at(j+1);
                for(int l=p+1; l<q; l++){
                    yoko.at(i).at(l) = q-p-1;
                }
            }
        }
    }

    for(int i=0; i<w; i++){
        if(wall_t.at(i).size() == 0){
            for(int j=0; j<h; j++){
                tate.at(j).at(i) = h;
            }
        }
        else if(wall_t.at(i).size() == 1){
            int k = wall_t.at(i).at(0);
            for(int j=0; j<h; j++){
                if(j < k) tate.at(j).at(i) = k;
                else if(j==k) tate.at(j).at(i) = 0;
                else tate.at(j).at(i) = h-k-1;
            }
        }
        else{
            int s = wall_t.at(i).size();
            int first,end;
            first = wall_t.at(i).at(0);
            end = wall_t.at(i).at(s-1);
            for(int j=0; j<first; j++){
                tate.at(j).at(i) = first;
            }
            for(int j=end+1; j<h; j++){
                tate.at(j).at(i) = h-end-1;
            }
            for(int j=0; j<=s-2;j++){
                int p,q;
                p = wall_t.at(i).at(j);
                q = wall_t.at(i).at(j+1);
                for(int l=p+1; l<q; l++){
                    tate.at(l).at(i) = q-p-1;
                }
            }
        }
    }
    ll ans=0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            ll light = tate.at(i).at(j) + yoko.at(i).at(j) -1;
            ans = max(ans, light);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 68892
n,m,k=map(int,input().split())
ab=[list(map(int,input().split()))for _ in range(m)]
cd=[list(map(int,input().split()))for _ in range(k)]
import sys;sys.setrecursionlimit(10**9)
class UnionFind():
  def __init__(self,n):
    self.n=[-1]*n
    self.r=[0]*n
  def Find_Root(self,x):
    if self.n[x]<0:
      return x
    else:
      self.n[x]=self.Find_Root(self.n[x])
      return self.n[x]
  def Unite(self,x,y):
    x=self.Find_Root(x)
    y=self.Find_Root(y)
    if x==y:return
    elif self.r[x]>self.r[y]:
      self.n[x]+=self.n[y]
      self.n[y]=x
    else:
      self.n[y]+=self.n[x]
      self.n[x]=y
      if self.r[x]==self.r[y]:
        self.r[y]+=1
  def Root_Same(self,x,y):
    return self.Find_Root(x)==self.Find_Root(y)
  def Count(self,x):
    return -self.n[self.Find_Root(x)]
u=UnionFind(n)
for a,b in ab:u.Unite(a-1,b-1)
ans=[u.Count(i)-1for i in range(n)]
for a,b in ab:
  if u.Root_Same(a-1,b-1):
    ans[a-1]-=1
    ans[b-1]-=1
for c,d in cd:
  if u.Root_Same(c-1,d-1):
    ans[c-1]-=1
    ans[d-1]-=1
print(*ans)

Measured memory_bytes: 59812
import math
def isPrime(n):
  if n < 2:
    # 2未満は素数でない
    return False
  if n == 2:
    # 2は素数
    return True
  for p in range(2, n):
      if n % p == 0:
        # nまでの数で割り切れたら素数ではない
        return False
  # nまでの数で割り切れなかったら素数
  return True

X = int(input())
ans = X
n = math.sqrt(X)
for i in range(int(n)):
  if isPrime(ans):
    break
  else:
    ans += 1
print(ans)
  


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

using namespace std;

typedef long long ll;

const ll linf=1e15;
const int inf=1e9+10;
const int N=2e2+10;
const int M=2e4+10;


int n,a[N];
struct flow{
    vector <int> e[N];
    int v[M][2];
    int n,st,en,m;

    int t[N],q[N];
    ll f[N];
    ll flow[M][2],cap[M];

    void build(int _n,int _st,int _en){
        n=_n,st=_st,en=_en;
        m=0;
        for(int i=1;i<=n;i++) e[i].clear();
    }
    void add_edge(int x,int y,ll wei){
        ++m;
        v[m][0]=x;v[m][1]=y;
        e[x].push_back(m);
        e[y].push_back(m);
        flow[m][0]=0;
        flow[m][1]=cap[m]=wei;
    }

    bool BFS(){
        memset(t,0,sizeof(t));
        int top=1,bot=1;

        t[st]=-1;
        f[st]=linf;
        q[1]=st;

        while (top<=bot){
            int x=q[top++];
            for(auto i:e[x]){
                int dir=x==v[i][1];
                int y=v[i][dir^1];
                if (flow[i][dir]==cap[i]) continue;
                if (t[y]) continue;
                t[y]=i;
                q[++bot]=y;
                f[y]=min(f[x],cap[i]-flow[i][dir]);
            }
        }
        return t[en];
    }
    ll inc_flow(){
        int cur=en;
        while (cur!=st){
            int idx=t[cur];
            int dir=(cur!=v[idx][1]);
            flow[idx][dir]+=f[en];
            flow[idx][dir^1]-=f[en];
            cur=v[idx][dir];
        }
        return f[en];
    }
    ll answer(){
        ll ans=0;
        while (BFS()) ans+=inc_flow();
        return ans;
    }
}mflow;

int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    mflow.build(n,n+1,n+2);


    ll ans=0;
    for(int i=1;i<=n;i++) ans+=a[i];
    for(int i=1;i<=n;i++) {
        if (a[i]<0) {
            mflow.add_edge(n+1,i,-a[i]);
            ans+=-a[i];
        }else mflow.add_edge(i,n+2,a[i]);
    }
    for(int i=1;i<=n;i++)
        for(int j=i+i;j<=n;j+=i) mflow.add_edge(i,j,linf);
    cout<<ans-mflow.answer();
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
long long a[200005],f,ans;
int main()
{
	scanf("%d",&n);for(int i=1;i<=n;++i) {scanf("%lld",&a[i]);a[i]-=i;}
	sort(a+1,a+1+n);
	f=a[n/2+1];
	for(int i=1;i<=n;++i) ans+=abs(f-a[i]);
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    map<char, int> cnts;
    for (char ch: s) {
        cnts[ch]++;
    }
    long long ans = 1;
    for (auto ch: string("RGB")) {
        ans *= cnts[ch];
    }
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            auto k = j + (j-i);
            if (s[i] != s[j] && k < n && s[i] != s[k] && s[j] != s[k]) {
                ans--;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3656
x1, x2, x3, x4, x5 = map(int, input().split())

if x1 == 0:
    print(1)
elif x2 == 0:
    print(2)
elif x3 == 0:
    print(3)
elif x4 == 0:
    print(4)
elif x5 == 0:
    print(5)

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

int S[1000];
int top=0;

void push(int);
int pop(void);

int main(){
  int a, b, x;
  char s[100];

  while(scanf("%s", s) != EOF){
    if(s[0] == '+'){
      a=pop();
      b=pop();
      push(a+b);
    }
    else if(s[0] == '-'){
      b=pop();
      a=pop();
      push(a-b);
    }
    else if(s[0] == '*'){
      a=pop();
      b=pop();
      push(a*b);
    }
    else{
      x=atoi(s);
      push(x);
    }
  }

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

  return 0;
}

void push(int n){
  top++;
  S[top]=n;
}

int pop(){
  int n;
  n=S[top];
  top--;
  return n;
}


  



Measured memory_bytes: 2108
from operator import itemgetter
n,m=map(int,input().split())
l=[]
for i in range(n):
  a,b=map(int,input().split())
  l.append([a,b])
l.sort(key=itemgetter(0))
s=0
for j in range(n):
  s=s+l[j][0]*min(l[j][1],m)
  m=m-l[j][1]
  if m<0:
    break
print(s) 

Measured memory_bytes: 21272
S = input()
a = S[0]
b = S[1]
c = S[2]
d = S[3]
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

if A+B+C+D==7:
    print(a+"+"+b+"+"+c+"+"+d+"=7")
elif A-B+C+D==7:
    print(a+"-"+b+"+"+c+"+"+d+"=7")
elif A+B-C+D==7:
    print(a+"+"+b+"-"+c+"+"+d+"=7")
elif A+B+C-D==7:
    print(a+"+"+b+"+"+c+"-"+d+"=7")
elif A-B-C+D==7:
    print(a+"-"+b+"-"+c+"+"+d+"=7")
elif A-B+C-D==7:
    print(a+"-"+b+"+"+c+"-"+d+"=7")
elif A+B-C-D==7:
    print(a+"+"+b+"-"+c+"-"+d+"=7")
else:
    print(a+"-"+b+"-"+c+"-"+d+"=7")


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
using namespace std;

int main() {
	IOS;

	ll n, m, v, p, a[100005], used[100005];
	cin >> n >> m >> v >> p;
	for(ll i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	sort(a+1, a+n+1);
	ll store=n+1, low = 1, high = n;

	while(low <= high) {
		ll mid = (low+high)/2;
	
		// code start
		ll pos = 0;
		if(mid >= v) {
			if(a[mid] + m >= a[n-p+1]) pos = 1;
		}
		else {
			ll left = m*v - mid*m, great = 0, val = a[mid] + m;
			for(ll i = n; i >= mid+1; --i) {
				if(a[i] > val) {
					left -= m;
					++great;
					continue;
				}
				used[i] = min(m, val - a[i]);
				left -= used[i];
			}
			if(great < p && left <= 0) pos = 1;
			else if(great < p) {
				for(ll i = n; i >= mid+1; --i) {
					if(a[i] > val) {
						continue;
					}
					if(used[i] != m) ++great;
					left -= (m - used[i]);
					if(left <= 0) break;
				}	
				if(great < p && left <= 0) pos = 1;
			}
		}
		// code over
	
		if(pos) {
			high = mid-1;
			store = mid;
		}
		else low = mid+1;
	}
	cout << n-store+1;
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cstdio>

using namespace std;

#define MAX 110

int N;
long B[MAX];

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N - 1; ++i) {
    scanf("%ld", &B[i]);
  }

  long ans = B[0];
  for (int i = 1; i < N - 1; ++i) {
    ans += min(B[i - 1], B[i]);
  }
  ans += B[N - 2];

  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
QごとにNみたら間に合わない
種類数を高速判断
26種類の有無
lower26回で個数判断できるかも
setに入れるかsortするか
最大500000文字はsortがいいか
NlogNって500000*10くらい？間に合う？

setのほうが早い、なんで

絶対あってるはずなのに。何が違うんだ。見つからない。
upperは、指定値以上のいてれーたを返すからlowerじゃないと不適か
でもWAなんですが

*/
int main(){
  ll N,Q;
  string S; cin>>N>>S>>Q;
  vector<set<ll>> A(26,set<ll>());
  for(ll i=0; i<N; i++){
    ll n=S[i]-'a';
    A[n].insert(i+1);
  }
  for(ll i=0; i<Q; i++){
    ll a; cin>>a;
    if(a==1){
      ll b; cin>>b;
      char c; cin>>c;
      if(S[b-1]==c) continue;
      ll n=S[b-1]-'a';
      ll m=c-'a';
      S[b-1]=c;
      A[n].erase(b);
      A[m].insert(b);
    }
    else{
      ll x,y,ans=0; cin>>x>>y;
      for(ll i=0; i<26; i++){        
        auto IT1=A[i].lower_bound(x);
        if(*IT1<=y && IT1!=A[i].end()) ans++;
      }
      cout<<ans<<endl;
    }
  }
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

const int MAX_N = 4;
const int n = MAX_N;

int main()
{
  while(true){
    int a[MAX_N], b[MAX_N];
    rep(i, n) if(!(cin >> a[i])) return 0;
    rep(i, n) if(!(cin >> b[i])) return 0;
    int sa = 0;
    int sb = 0;
    rep(i, n) sa += a[i];
    rep(i, n) sb += b[i];
    cout << max(sa, sb) << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
/**
    why I'm too lazy?
**/
#include <bits/stdc++.h>

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define pp pop_back
#define ll long long
#define ld long double
#define OK puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

inline int min(int a, int b)
{
    return (a > b) ? b : a;
}
inline int max(int a, int b)
{
    return (a > b) ? a : b;
}

const int N = 2e5 + 10;
const int inf = 1e9 + 7;
const ll linf = 1e17 + 7;

int n, x, y;
double ans[N], d[N];
vector <int> g[N];

void dfs(int v, int p)
{
    double ans = 0;
    for(auto to : g[v])
    {
        if(to == p) continue;
        dfs(to, v);
        if(v == p)
            d[v] += (d[to] + 1.0) / sz(g[v]);
        else
            d[v] += (d[to] + 1.0) / (sz(g[v]) - 1);
    }
}

void Dfs(int v, int p)
{
    int t = sz(g[v]);
    int pt = sz(g[p]);
    int pp = sz(g[p]) - 1;

    if(v > 1) {
        ans[v] = d[v] * (t - 1) / t;
        ans[v] += ( (ans[p] - (d[v] + 1.0) / pt) * pt / (pp ? pp : 1) + 1.0 ) / t;
    }

    for(int to : g[v])
        if(to != p)
            Dfs(to, v);
}

main()
{
    scanf("%d", &n);
    for(int i = 1; i < n; i++)
        scanf("%d%d", &x, &y), g[x].pb(y), g[y].pb(x);
    dfs(1, 1);
    ans[1] = d[1];
    Dfs(1, 1);

    for(int i = 1 ; i <= n; i++)
        cout << fixed << setprecision(7) << ans[i] << endl;
}


Measured memory_bytes: 19584
#include <cstdio>
#include <queue>
#include <iostream>
#include <algorithm>
#include<cstring>
using namespace std;
int a[300010];
int cnt[300010];
int ans[300010];
int main()
{
    int n;
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin >> x;
        a[x] ++ ;
    }
    for(int i=1;i<=n;i++)
    {
        cnt[a[i]]++;
    }
    for(int i=n;i>1;i--)
    {
        cnt[i-1] += cnt[i]; 
    }
    int Ans = 0;
    long long sum=0;
    for(int i=n;i>=1;i--)
    {
        while(sum+cnt[Ans+1]>=1ll*i*(Ans+1))
            sum+=cnt[++Ans];
        ans[i] = Ans;
    }
    for(int i=1;i<=n;i++)
    {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 7104
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static class Edge {
		int src;
		int dst;
		int cost;

		public Edge(int src, int dst, int cost) {
			this.src = src;
			this.dst = dst;
			this.cost = cost;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		ArrayList<Edge> es = new ArrayList<>();

		int[][] d = new int[N][N];
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				if (i == j)
					continue;
				d[i][j] = Integer.MAX_VALUE / 10;
			}
		}
		for (int i = 0; i < M; ++i) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			int c = sc.nextInt();
			d[a][b] = c;
			d[b][a] = c;
			es.add(new Edge(a, b, c));
			es.add(new Edge(b, a, c));
		}
		for (int m = 0; m < N; ++m) {
			for (int i = 0; i < N; ++i) {
				for (int j = 0; j < N; ++j) {
					d[i][j] = Math.min(d[i][m] + d[m][j], d[i][j]);
				}
			}
		}
		int ans = 0;
		out: for (Edge e : es) {
			for (int i = 0; i < N; ++i) {
				for (int j = 0; j < N; ++j) {
					if (d[i][e.src] + e.cost + d[e.dst][j] == d[i][j])
						continue out;
				}
			}
			++ans;
		}
		System.out.println(ans / 2);
	}
}


Measured memory_bytes: 15228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 250;
int main()
{
    std::ios::sync_with_stdio(false);
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll cnt = x / d;
    if(k > cnt){
        x -= cnt * d;
        k -= cnt;
        if(k % 2 == 0){
            cout << x << endl;
        }
        else cout << abs(x - d) << endl;
    }
    else{
        cout << (x - k * d) << endl;
    }
    return 0;
}


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

long long read_num(string s) {
    long long count = 0;
    long long buf = 0;
    bool prev_is_num = false;
    int len = s.size();
    for (int i = 0; i < len; i++) {
        if (isdigit(s[i])) {
            if (prev_is_num) {
                buf = buf * 10 + s[i] - '0';
            } else {
                buf = s[i] - '0';
            } 
            prev_is_num = true;
        } else {
            if (prev_is_num) {
                count += buf;
                buf = 0;
            }
            prev_is_num = false;
        }
    }
    if (prev_is_num) count += buf;
    return count;
}

int main() {
    string s;
    long long count = 0;
    while (cin >> s) {
        count += read_num(s);
    }
    cout << count << endl;
}

Measured memory_bytes: 0
from heapq import heapify,heappop,heappush

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

a = []
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

ans = 0

for i in range(A):
    heappush(a,(-1*p[i],0))
for i in range(B):
    heappush(a,(-1*q[i],1))
for i in range(C):
    heappush(a,(-1*r[i],2))

c_r = c_g = c_all = 0
while c_all<X+Y:
    v,col = heappop(a)
    if c_r < X and c_g < Y:
        ans += -1*v
        c_all += 1
        if col == 0:
            c_r += 1
        if col == 1:
            c_g += 1
    elif c_r<X and c_g == Y:
        if col == 0 or col == 2:
            ans += -1*v
            c_all += 1
            if col == 0:
                c_r += 1
    elif c_r==X and c_g<Y:
        if col == 1 or col == 2:
            ans += -1*v
            c_all += 1
            if col == 1:
                c_g += 1
#    print("c_r:",c_r,"c_g:",c_g,"c_all:",c_all,"v:",v,"col:",col,"ans:",ans)
print(ans)

Measured memory_bytes: 125036
//#include <cmath>
//#include <ctime>
#include <cstdio>
//#include <cstdlib>
//#include <cstring>

//#include <map>
//#include <set>
//#include <queue>
//#include <string>
//#include <vector>
//#include <sstream>
//#include <iostream>
#include <algorithm>
//#include <functional>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

const int MAXN = 200005;
const int P = 1000000007;
const int INF = 1000000007;
const double eps = 1e-6;

inline int getint() {
    int r = 0; bool b = true; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') b = false; c = getchar(); }
    while (c >= '0' && c <= '9') { r = (r<<1)+(r<<3) + c - '0'; c = getchar(); }
    return b ? r : -r;
}

LL L;
int n;
int a[MAXN];
int b[MAXN];
LL pa[MAXN], pb[MAXN];

inline int rev(int x) { return n-x+1; }

//left: 0 b
//right: 1 a
LL calc(int dir, int l, int r) {
    int mid = (l+r)>>1;
    if (r-mid == mid-l) {
        LL ret = (pa[mid-1] - pa[l-1] + pb[rev(mid+1)] - pb[rev(r+1)]) * 2ll;
        if (dir) ret += a[mid];
        else ret += b[rev(mid)];
        return ret;
    }
    else {
        LL ret = (pa[mid] - pa[l-1] + pb[rev(mid+1)] - pb[rev(r+1)]) * 2ll;
        if (dir) ret -= b[rev(mid+1)];
        else ret -= a[mid];
        return ret;
    }
}

int main() {
    L = getint();
    n = getint();
    for (int i = 1; i <= n; ++i) {
        a[i] = getint();
        b[rev(i)] = L - a[i];
    }
    for (int i = 1; i <= n; ++i) {
        pa[i] = pa[i-1] + a[i];
        pb[i] = pb[i-1] + b[i];
    }
    LL ans = 0, tmp;
    for (int i = 1; i <= n; ++i) {
        tmp = max(max(calc(1, i, n), calc(0, i, n)), max(calc(1, 1, rev(i)), calc(0, 1, rev(i))));
        ans = max(ans, tmp);
    }
    printf("%lld", ans);
}


Measured memory_bytes: 4864
#include<cstdio>
#include<cmath>
#include<iostream>
#include<string>
using namespace std;

int main(void) {
	long long N;
	scanf("%lld",&N);

	string ans;
	for (int i = 1; i < 99; i++) {
		if (N <= pow(26, i)) {
			N -= 1;
			for (int j = 0; j < i; j++) {
				ans = (char)('a' + N % 26) + ans;
				N = N / 26;
			}
			break;
		} else {
			N -= pow(26, i);
		}
	}
	cout << ans << "\n";

	return 0;
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef pair<int, int> p;

int main(){
  int x, y;
  cin >> x >> y;
  cout << x + y / 2 << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    constexpr i64 lim = 10000000000;
    std::vector<i64> cubes, sq;
    for (i64 i = 1; ; i++) {
        i64 s = i * i, c = s * i;
        if (c > lim) break;
        sq.push_back(s);
        cubes.push_back(c);
    }
    
    int len = sq.size();

    int n;
    std::cin >> n;
    std::map<i64, int> cnt;
    for (int i = 0; i < n; i++) {
        i64 s;
        std::cin >> s;
        int from = std::upper_bound(cubes.begin(), cubes.end(), s) - cubes.begin() - 1;
        for (int j = from; j >= 0; j--) if (s % cubes[j] == 0) {
            cnt[s / cubes[j]]++;
            break;
        }
    }

    int ret = cnt[1] > 0;
    std::map<i64, bool> done;
    done[1] = true;
    for (auto e : cnt) {
        i64 m = e.first;
        int c = e.second;
        if (done[m]) continue;
        for (i64 x = 0; x < len; x++) {
            if (m % sq[x]) continue;
            i64 y = m / sq[x];
            if (x + 1 >= y) break;
            if ((x + 1) * y > lim / y) break;
            i64 other = (x + 1) * y * y;
            auto it = cnt.find(other);
            if (it == cnt.end()) continue;
            ret += std::max(it->second, c);
            done[m] = true;
            done[other] = true;
            break;
        }
    }

    for (auto e : cnt) if (!done[e.first]) ret += e.second;
    
    std::cout << ret << std::endl;
    
    return 0;
}

Measured memory_bytes: 12800
import math
import os
import random
import re
import sys
from collections import defaultdict

# sys.stdin = open('input.in', 'r')
# sys.stdout = open('output.out', 'w') 

def onezero(a):
	count = 0
	for i in range(0, len(a), 2):
		if a[i] == 0:
			count += 1
	for i in range(1, len(a), 2):
		if a[i] == 1:
			count += 1
	return count

def zeroone(a):
	count = 0
	for i in range(0, len(a), 2):
		if a[i] == 1:
			count += 1
	for i in range(1, len(a), 2):
		if a[i] == 0:
			count += 1
	return count


def count(n):
	return min(onezero(n),zeroone(n))

if __name__ == '__main__':
	N = [int(d) for d in input()]
	print(count(N))

Measured memory_bytes: 4976