akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

vector<int>edge[200004];
int vis[200005],num;

void dfs(int node)
{
    vis[node]=1;
    num++;
    for(int i=0;i<edge[node].size();i++)
    {
        int temp=edge[node][i];
        if(!vis[temp])
        {
            dfs(temp);
        }
    }
    return;
}

int main()
{
    int n,t,x,y;
    cin>>n>>t;
    if(t==0) cout<<1<<endl;
    else
    {
    while(t--)
    {
        cin>>x>>y;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }
    int maxv=0;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            num=0;
            dfs(i);
            maxv=max(maxv,num);
        }
    }
    cout<<maxv<<endl;
    }
}


Measured memory_bytes: 21492
n, m = map(int, input().split())
c = sorted([int(i) for i in input().split()])
dp = [[0 for j in range(n+1)] for i in range(m+1)]
dp[1] = [int(i) for i in range(n+1)]
for i in range(2, m+1):
    for j in range(n+1):
        if j - c[i-1] > -1:
            dp[i][j] = min(dp[i-1][j], dp[i][j-c[i-1]]+1)
        else:
            dp[i][j] = dp[i-1][j]
print(dp[m][n])


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

int main() {
    set<int> s;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            s.insert(i * j);
        }
    }
    int n;
    cin >> n;
    if(s.count(n) > 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from collections import deque
INFTY = 10**10
def update(i,a):
    j = i+N
    T[j] = a
    j = j//2
    while j>=1:
        T[j]=max(T[2*j],T[2*j+1])
        j = j//2
def find(l,r):
    que = deque([(1,0,N)])
    A = []
    while que:
        j,x,D = que.popleft()
        y = x+D
        if y<=l or x>=r:
            A.append(-INFTY)
        elif l<=x and y<=r:
            A.append(T[j])
        else:
            que.append((2*j,x,D//2))
            que.append((2*j+1,x+D//2,D//2))
    return max(A)
n,K = map(int,input().split())
A = [int(input()) for _ in range(n)]
k = 0
while 2**k<3*10**5:
    k += 1
N = 2**k
T = [-INFTY for _ in range(2*N)]
dp = [0 for _ in range(n)]
dp[0]=1
update(A[0],dp[0])
for i in range(1,n):
    a = A[i]
    l = max(0,a-K)
    r = min(a+K,N-1)+1
    dp[i] = max(1,find(l,r)+1)
    update(a,dp[i])
dmax = 0
for i in range(n):
    dmax = max(dmax,dp[i])
print(dmax)

Measured memory_bytes: 167124
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    char op;
    // scanf("%d %d",r);
    cin >> a >> op >> b;
    while (op != '?' ){
        if (op == '+'){
        cout << a+b << endl;
        }else if (op == '-')
        {
            cout << a-b << endl;
        }else if (op == '*')
        {
            cout << a*b << endl;
        }else if (op == '/')
        {
            cout << a/b << endl;
        }
        cin >> a >> op >> b;
    }
    return 0;
}


Measured memory_bytes: 3080
import java.util.*; 
import java.io.*;

public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));

        int N = nextInt();
 
        long sum = 0;
        for (int i=1; i<=N; i++) { 
            if(i %3 ==0 || i % 5 ==0){

            }
            else {
                sum += i;
            }
        }

        System.out.println(sum);
 
    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 32764
# https://atcoder.jp/contests/abc153/tasks/abc153_b
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    h, n = map(int, input().split())
    al = list(map(int, input().split()))
    print('Yes' if h <= sum(al) else 'No')
    return 


if __name__ == '__main__':
    main()


Measured memory_bytes: 52292
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	unsigned size_; 
	std::vector<unsigned> par, rank;
public:
	UnionFind() : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	//unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	unsigned root(unsigned x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};


__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}

int main()
{
	
	int H, W, K;
	
	cin >> H >> W >> K;

	int dp[H+1][W];
	memset(dp, 0, sizeof(dp));

	dp[0][0] = 1;

	rep(i, H)
	{
		rep(j, W)
		{
			
			rep(k, 1ll << (W-1))
			{
				bool ok = true;

				rep(l, W-2)
				{
					if (((k>>l) & 1) && (k>>(l+1)) & 1)
					{
						ok = false;
						break;
					}
				}
				if (ok)
				{
					if (j >= 1 && ((k >> (j-1)) & 1))
					{
						dp[i+1][j-1] += dp[i][j];
						dp[i+1][j-1] %= MOD;
					}
					else if ((j < W - 1) && ((k >> j ) & 1))
					{
						dp[i+1][j+1] += dp[i][j];
						dp[i+1][j+1] %= MOD;
					}
					else
					{
						dp[i+1][j] += dp[i][j];
						dp[i+1][j] %= MOD;
					}
				}
			}
		}
	}
	

	cout << dp[H][K-1] << endl;
	
	return 0;
}


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

using namespace std;

int main(){
    int n, x;
    while(cin >> n >> x){
        vector<int> a(n);
        for(int& t : a) cin >> t;
        sort(a.begin(), a.end());
        long long sum = 0;
        int res = 0;
        for(auto& t : a){
            sum += t;
            if(sum <= x) ++res;
        }
        if(res == n && sum != x) --res;
        cout << res << endl;
    }
}

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

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

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

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

int main(){
	int n,x;
	cin>>n>>x;
	if(n==2){
		if(x==2){
			cout<<"Yes"<<endl;
			cout<<1<<endl<<2<<endl<<3<<endl;
		}else cout<<"No"<<endl;
		return 0;
	}
	if(x==1||x==2*n-1){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	vector<int> v(2*n,0);
	if(x>n){
		v[n-1]=x;
		v[n]=2*n-1;
		v[n-2]=1;
		v[n+1]=2;
		int id=3;
		FOR(i,0,2*n-1){
			if(id==x)id++;
			if(v[i]==0)v[i]=id++;
		}
	}else{
		v[n-1]=x;
		v[n]=1;
		v[n-2]=2*n-1;
		v[n+1]=2*n-2;
		int id=2*n-3;
		FORD(i,2*n-1,0){
			if(id==x)id--;
			if(v[i]==0)v[i]=id--;
		}
	}
	FOR(i,0,2*n-1)cout<<v[i]<<endl;
    return 0;
}


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



int main(){
  long long N,T;
  cin>>N>>T;
  
  vector<long long> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  long long sum=0;
  long long tmp=0;
  for(int i=0;i<N;i++){
    sum+=T-max(0LL,tmp-vec.at(i));
    tmp=vec.at(i)+T;
  }
  cout<<sum<<endl;
    
}

Measured memory_bytes: 4788
# B-81

# 標準入力 N

N = int(input())
num_list = [1, 2, 3, 4, 5, 6, 7, 8, 9]
j = 0

for i in range(1, 9 + 1):
    if (N / i) in num_list:
        j += 1

if j == 0:
    print('No')
else:
    print('Yes')



Measured memory_bytes: 9104
#include <iostream>
#include <vector>
#include <unordered_map>
#include <utility>
#include <algorithm>
//#include "../cxx-prettyprint/prettyprint.hpp"

// unordered_map用のハッシュ関数
namespace std {
    template <>
    class hash<std::pair<int, int>> {
    public:
        size_t operator()(const std::pair<int, int>& x) const{
            return x.first * 10000L + x.second;
        }
    };
}

std::vector<int> values;
std::vector<int> weights;
std::unordered_map<std::pair<int, int>, int> memo;

int get_maximum_value(int i, int w) {
    if (i < 0 || w == 0) {
        return 0;
    } else if (memo.find({i, w}) != memo.end()) {
        return memo[{i, w}];
    } else {
        int max_value;
        if (weights[i] <= w) {
            max_value = std::max(get_maximum_value(i, w - weights[i]) + values[i],
                                 get_maximum_value(i - 1, w));
        } else {
            max_value = get_maximum_value(i - 1, w);
        }
        memo[{i, w}] = max_value;
        return max_value;
    }
}

int main() {
    int N, W;
    std::cin >> N >> W;

    values.resize(N);
    weights.resize(N);
    for (int i = 0; i < N; i ++) {
        std::cin >> values[i] >> weights[i];
    }

    std::cout << get_maximum_value(N - 1, W) << std::endl;
}



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

int main()
{
	string S;
	cin >> S;

	string w[] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
	map<string, int> mp;
	for( int i = 7; i > 0; i-- ) mp[ w[7 - i] ] = i;
	int ans = mp[S];

	cout << ans << endl;
}


Measured memory_bytes: 256
N,L=map(int,input().split())
a=list(map(int,input().split()))
suma=sum(a)
flag=0
for i in range(1,N):
    if a[i]+a[i-1]>=L:
        flag=1
        idx=i
        break
if flag:
    print("Possible")
    for i in range(1,N):
        if idx==i:
            break
        else:
            print(i)
    for i in range(N-1,0,-1):
        if idx==i:
            break
        else:
            print(i)
    print(idx)
else:
    print("Impossible")


Measured memory_bytes: 63984
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

n = int(input())
t,a = map(int, input().split())
import math
for i in range(n-1):
    tt,aa = map(int, input().split())
    if t<=tt and a<=aa:
        t,a = tt,aa
    else:
        t1,a1 = tt*(t//tt + int(t%tt!=0)), aa*(t//tt + int(t%tt!=0))
        t2,a2 = tt*(a//aa + int(a%aa!=0)), aa*(a//aa + int(a%aa!=0))
#         print(t1,a1, t2,a2)
        if (t1<t2 and t1>=t and a1>=a) or (t2<t or a2<a):
            t,a = t1,a1
        else:
            t,a = t2,a2
ans = t+a
print(ans)

Measured memory_bytes: 66312
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  int h,w,H,W;
  cin >> H >> W >> h >> w;
  cout << H*W-h*W-w*H+h*w << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
int max(const void *a, const void *b){return *(int*)b - *(int*)a;}

int main(void)
{
    int n,t;
    scanf("%d",&n);

    t = 0;
    for(int i=0;i<n;i++)
    {
        int next;
        scanf("%d",&next);
        if (next < t )
        {
            printf("No\n");
            return 0;
        }else if(next == t)
        {
            continue;
        }else 
        {
            t = next-1;
        }
    }
     printf("Yes\n");

    
    return 0;
}


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

vector<int> levelup(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        //cout << j << endl;
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    /*for(j=0;j<N;j++){
        cout << "v" << v[j];
    }
    cout << endl;*/
    return v;
}

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> k(M);
    vector<vector<int>> ks(M,vector<int>(N,0));
    vector<int> p(M);
    for(int i=0;i<M;i++){
        cin >> k[i];
        for(int j=0;j<k[i];j++){
            cin >> ks[i][j];
        }
    }
    for(int i=0;i<M;i++){
        cin >> p[i];
    }
    int inde = 1;
    for(int i=0;i<N;i++){
        inde *= 2;
    }
    vector<int> vec(N,0);
    int countans=0;
    int count = 0;
    for(int i=0;i<inde;i++){
        for(int j=0;j<M;j++){
            int countt=0;
            for(int l=0;l<k[j];l++){
                if(vec[ks[j][l]-1]==1){
                    //cout << ks[j][l]-1 << endl;
                    countt++;
                    //cout << j <<countt << endl;
                }
                //cout << "j" << j << " " << p[j] << " " <<count << endl;
            }
            if(countt%2==p[j]){
                    count++;
                    //cout << count << endl;
            }
        }
        if(count==M){
            countans++;
        }
        if(i==inde-1){
            break;
        }
        count = 0;
        vec = levelup(vec,N);
    }
    cout << countans << endl;
}

Measured memory_bytes: 3628
import math

def main():
    A, B, H, M = map(int, input().split())
    m_x = B * math.cos(2*math.pi*M/60)
    m_y = B * math.sin(2*math.pi*M/60)
    h = H / 12 + M/60/12
    h_x = A * math.cos(2*math.pi*h)
    h_y = A * math.sin(2*math.pi*h)
    # print(m_x, m_y, h_x, h_y, h)
    ans = math.sqrt((m_x - h_x)**2 + (m_y - h_y)**2)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9476
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main(){
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> to(n);
    REP(i, m){
        ll ai, bi;
        cin >> ai >> bi;
        ai--; bi--;
        to.at(ai).push_back(bi);
        to.at(bi).push_back(ai);
    }

    vector<bool> vis(n, false);
    ll ans = 0;
    REP(i, n){
        if(vis.at(i) == true){ continue; }

        ll count = 1;
        queue<ll> que;
        vis.at(i) = true;
        que.push(i);
        while(!que.empty()){
            ll cur = que.front(); que.pop();
            for(ll nxt : to.at(cur)){
                if(vis.at(nxt)){ continue; }
                vis.at(nxt) = true;
                count++;
                que.push(nxt);
            }
        }
        ans = max(ans, count);
    }
    cout << ans << endl;
    return 0;
}


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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
const double PI  = acos(-1.0);

//-------------------------------------------


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int A,B;
    cin >> A >> B;
    int cnt=0;
    for ( int i = A; i < B+1; i++){
        string s = toString(i);
        if(s[0] == s[4] && s[1] == s[3]) cnt++;
    }
    cout << cnt;


    return 0;

}


Measured memory_bytes: 384
//B - An Odd Problem
//Hiia
#include <stdio.h>
#include <stdlib.h>//rannsuu, zettaichi(absolute)
#include <time.h>
//srand((unsigned int) time(0));
#include <math.h>//koudona keisann
#include <string.h>//hairetsu
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
typedef long long ll;
//#define N 998244353
#define pi 3.1415926535897932384626433832

int gcd(int m,int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
int lcm(int m,int n){if((0==m)||(0==n))return 0;return(m*n/gcd(m, n));}
int fact(int x){if(x==1) return(x);else return(x*fact(x-1));}//Kaijou x!
int ruijou(int base,int exponent){int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

long long int llgcd(long long int m,long long int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
long long int lllcm(long long int m,long long int n){if((0==m)||(0==n))return 0;return(m*n/llgcd(m, n));}
long long int llfact(long long int x){if(x==1) return(x);else return(x*llfact(x-1));}//Kaijou
int llruijou(long long int base,long long int exponent){long long int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

int main()
{
  int n,x[10010],i,c=0;
  scanf("%d", &n);
  for(i = 1; i <= n; i++) {
    scanf("%d", &x[i]);
  }

  for(i = 1; i <= n; i+=2) {
    if(x[i]%2==1){
      c++;
    }
  }

  printf("%d\n", c);
  return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define mn(a, b) (a < b ? a : b)
#define mx(a, b) (a > b ? a : b)
#define f first
#define s second
#define all(v) (v).begin(), (v).end()
#define base 331

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int const MAXn = 1e4 + 2, MOD = 1e9 + 7;

ll dp[MAXn][102][11];

int main(){

    //freopen(".in","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string k;
    int d;
    cin>>k>>d;
    dp[0][0][0] = 1;
    reverse(all(k));
    int ts = k.size();
    k = "0" + k;
    for(int i = 1; i <= ts; i++){
        for(int m = 0; m < d; m++){
            for(int l = 0; l <= 9; l++){
                for(int o = 0; o <= 9; o++)
                    dp[i][(m + l) % d][l] = (dp[i][(m + l) % d][l] + dp[i - 1][m][o]) % MOD;
            }
        }
    }
    ll sol = 0;
    int sum = 0;
    for(int i = ts; i >= 1; i--){
        for(int y = 0; y < k[i] - '0'; y++){
            sol = (sol + dp[i][(d - sum) % d][y]) % MOD;
        }
        sum = (sum + k[i] - '0') % d;
    }
    if(sum){
        sol = (sol - 1 + MOD) % MOD;
    }
    cout<<sol;
    return 0;
}


Measured memory_bytes: 87936
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scanf("%s", &s)

	_s := strings.Split(s, "")

	var ans string
	for i := 0; i < len(_s); i++ {
		if _s[i] == "B" {
			if len(ans) > 0 {
				ans = ans[0:len(ans) - 1]
			}
			continue
		}
		ans = ans + _s[i]
	}

	fmt.Println(ans)
}


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

const int N = 1e5 + 7;

long long n, m;
pair <long long, long long> par[N];

pair <long long, long long> findpar(int v) {
	if (par[par[v].first].first == par[v].first)
		return par[v];
	findpar(par[v].first);
	par[v] = {par[par[v].first].first, par[v].second + par[par[v].first].second};
}

int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		par[i].first = i;
	while (m--) {
		int x, y, d;
		cin >> x >> y >> d;
		par[x] = findpar(x);
		par[y] = findpar(y);
		if (par[x].first == par[y].first) {
			if (par[y].second - par[x].second != d) {
				cout << "No";
				return 0;
			}
		}
		else {
			if (d + par[x].second >= par[y].second)
				par[par[y].first] = {par[x].first, d + par[x].second - par[y].second};
			else
				par[par[x].first] = {par[y].first, par[y].second - d - par[x].second};
		}
	}
	cout << "Yes";

	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main (){
	
	int a; 
	long long int ans = 1;
	scanf ("%d", &a);
	long long arr[a + 10];
	long long int batas = 1e18;
	for (long long int i = 0 ; i < a ; i++){
		scanf ("%lld", &arr[i]);
	}
	
	for (long long int i = 0 ; i < a ; i++){
		if (arr[i] == 0){
			printf ("0\n");
			return 0;
		}
	}
	
	for (long long int i = 0 ; i < a ; i++){
		if (batas/ans < arr[i]){
			printf ("-1\n");
			return 0;
		}
		ans *= arr[i];
	}
	printf ("%lld\n", ans);
	
	
	return 0;
}


Measured memory_bytes: 2504
[n,m]=list(map(int,input().split()))
hight=list(map(int,input().split()))
road=[]
for i in range(m):
    road.append(sorted(list(map(int,input().split()))))

check=[1]*n #1ならok,0ならng
for i in range(m):
    if hight[road[i][0]-1]>hight[road[i][1]-1]:
        check[road[i][1]-1]=0
    if hight[road[i][0]-1]<hight[road[i][1]-1]:
        check[road[i][0]-1]=0
    if hight[road[i][0]-1]==hight[road[i][1]-1]:
        check[road[i][0]-1]=0
        check[road[i][1]-1]=0

ans=0
for i in range(n):
    if check[i]==1:
        ans+=1

print(ans)

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

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

  int ans = 0;

  for(int i = N; i > 0; i--){
    int b = i;
    int div = 0;
    while(b > 0){
      b /= 10;
      div++;
    }

    if(div % 2 != 0){
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include<complex>

using namespace std;

typedef long long            ll;
typedef unsigned             ui;
typedef unsigned long long   ull;
typedef pair<int,int>        i_i;
typedef pair<ll,int>         ll_i;
typedef pair<ll,ll>          ll_ll;
typedef pair<double,int>     d_i;
typedef pair<double,double>  d_d;
typedef vector<int>          vi;
typedef vector<vector<int> > vii;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long
#ifndef int
#define INF __INT32_MAX__
#else
#define INF __INT64_MAX__
#endif

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

signed main(void)
{
  in(int,n);
int i;
int a[112345];
rep(i,n)cin>>a[i];
 sort(a,a+n);
int A=0;
int B=0;
rep(i,n)
{
if(i%2)B+=a[i];
else A+=a[i];
}
putv(abs(A-B));
  return 0;
}


Measured memory_bytes: 256
import bisect

N, D = map(int, input().split())
Xss = []
for i in range(N):
    Xss.append(list(map(int, input().split())))

def distance2(p1, p2):
    ddt = 0
    for i in range(D):
        r = (p1[i] - p2[i])
        ddt += (r * r)

    return ddt

class SquareRoot(object):
    def __init__(self, n):
        self.n = n
    def __getitem__(self, index):
        return index * index
    def __len__(self):
        return self.n

def try_square_root(n2):
    n = bisect.bisect_left(SquareRoot(n2), n2)
    return n if n*n == n2 else None

result = []
lss = len(Xss)
r = 0
for i in range(lss):
  for j in range(i + 1, lss):
      p1 = Xss[i]
      p2 = Xss[j]
      d = distance2(p1, p2)
      if try_square_root(d) is not None:
          r += 1
print(r)


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

using namespace std;
using int64 = long long;
//const int mod = 1e9 + 7;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

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); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int A, B;
  cin >> A >> B;
  for(int k = 1; k <= 10000; k++) {
    if(k * 8 / 100 == A && k * 10 / 100 == B) {
      cout << k << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<int, int, int> T;
// get<K>(tuple型の変数)

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

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

    int N, M; cin >> N >> M;
    vector<int> c(M, 0);
    vector<int> a(M, 0);
    rep(i, M){
        cin >> a[i];
        int b; cin >> b;
        rep(j, b){
            int d; cin >> d;
            --d;
            c[i] |= (1<<d);
        }
    }

    const ll inf = 1LL<<60;
    vector<vector<ll>> dp(M+5, vector<ll>(1<<N, inf));
    dp[0][0]=0;

    rep(i, M) rep(S, 1<<N){
        //if(dp[i][S]==inf) continue;
        // not use
        chmin(dp[i+1][S], dp[i][S]);
        // use
        chmin(dp[i+1][S|c[i]], dp[i][S]+a[i]);
    }

    
    ll ans = dp[M][(1<<N)-1];
    if(ans == inf) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
} 

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

int main(){
	string S;
	int k, s;
	cin >> k >> S;
	s = S.length();
	if (s <= k) cout << S << endl;
	else {
	    cout << S.erase(k)+"..." << endl;
	}
	return 0;
}

Measured memory_bytes: 3632
a = input().split()
n = int(a[0])
q = int(a[1])

N = [] #プロセス名
T1 = [] #必要時間


for i in range(n):
    a = input().split()
    N.append(a[0])
    T1.append(int(a[1]))

t = 0 #経過時間
f = 0 #処理対象
l = len(N)-1 #最後尾

while len(N) > 0:
    if T1[f] <= q: #処理が完了する
        t += T1[f]
        if f == len(N)-1:
            print(N.pop(f), t)
            del T1[f]
            f = 0
        elif f == 0:
            print(N.pop(f), t)
            del T1[f]
            l -= 1
        else:
            print(N.pop(f), t)
            del T1[f]
        
        if len(N) == 0: break

    else: #処理が完了しない
        t += q
        T1[f] -= q

        i = N[f]
        j = T1[f]

        if f+1 == len(N): f = 0
        else: f += 1
        if l+1 == len(N): l = 0
        else: l += 1
        
        N[l] = i
        T1[l] = j


Measured memory_bytes: 9476
n=int(input())
h=list(map(int, input().split()))
count = 0
def mizu(h):
    global count
    if len(h) == 0:
        return
    if len(h) == 1:
        count += h[0]
        return
    m = min(h)
    count += m
    for i in range(len(h)):
        h[i] -= m
    while 0 in h: #[1,1,0,1,0,1]の場合[1,1]と[1,0,1]に分かれるから
        mizu(h[:h.index(0)])
        h = h[h.index(0)+1:]
    mizu(h)

mizu(h)
print(count)
        
          

Measured memory_bytes: 3064
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
orders = sorted([a, b, c, d, e], key=lambda x: 10 if x % 10 == 0 else x % 10, reverse=True)
total = 0
for o in orders[:-1]:
    total += ((o + 9) // 10) * 10
total += orders[-1]
print(total)


Measured memory_bytes: 9068
#! /usr/bin/env python3

from fractions import gcd
# from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

A = input()
B = input()
C = input()

ABC = {"a":deque(A), "b":deque(B), "c":deque(C)}
ABC_H = {"a":"A", "b":"B", "c":"C"}

ind = A[0]
while True:

    if len(ABC[ind]) == 0:
        break 
    ind = ABC[ind].popleft()

print(ABC_H[ind])


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    string a; cin>>a;
    rep(i,4) a[i]-='0';
    for(int i=0;i<(1<<3);i++){
        ll sum=a[0];
        string t;
        t += (char)(a[0]+'0');
        for(int j=0;j<3;j++){
            if(i & (1<<j)){
                sum+=a[j+1];
                t+='+';
                t+=(char)(a[j+1]+'0');
            }else{
                sum-=a[j+1];
                t+='-';
                t+=(char)(a[j+1]+'0');
            }
        }
        if(sum==7){
            t+="=7";
            cout<<t<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3596
n,m=map(int,input().split())
if n%2==1:
  for i in range(m):
    print(str(i+1)+" ",str(n-i))
else:
  k=n//4
  for i in range(m):
    if i<k:
      print(str(i+1),str(n-i))
    else:
      print(str(i+2),str(n-i))


Measured memory_bytes: 9288
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,count1=1,j=0,k=1,l=1;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    while(l<n)
    {
        if(a[j]>a[l])
        {
            count1++;
            j=l;
        }
        else
        {
            l++;
        }

    }
    cout<<count1<<endl;
}


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

using namespace std;

int main(void) {
  int n;
  string s, t;
  cin >> n >> s >> t;

  int tmp = 0;
  for(int i = n; i >= 1; i--) {
    string ss, tt;
    for(int j = 0; j < i; j++) {
      ss.push_back(s[(s.length() - i) + j]);
      tt.push_back(t[j]);
    }
    if(ss == tt) {
      tmp = ss.length();
      break;
    }
  }
  cout << 2 * n - tmp << endl;
}

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

#define ios  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll n;

int main() {
    ios;

    string s,t;
    cin>>s>>t;
    ll ls=s.length();
    ll lt=t.length();

    ll dp[ls+1][lt+1];

    for(ll i=0;i<=ls;i++)
    {
        for(ll j=0;j<=lt;j++)
        {
            if(i==0||j==0)
                dp[i][j]=0;
            else if(s[i-1]==t[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }




    ll i=ls;
    ll j=lt;
    string st="";
    ll ans=dp[ls][lt];
    while(i>0&&j>0)
    {
        if(s[i-1]==t[j-1])
        {
        i--;
        j--;
        char c=s[i];
        st.push_back(c);
        }
        else if(dp[i][j]==dp[i-1][j])
        {
            i--;
        }
        else
            j--;
    }
reverse(st.begin(), st.end());
    cout<<st;
    return 0;
}


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

int main(void){
    
    unsigned int a = 0;
    unsigned int b = 0;
    unsigned char op = 0;
    
    for(int i = 0; i < 20001 ; i++){
        cin >> a >> op >> b;
    
        int c = 0;
        switch(op){
        case '+':
            c = a + b;
            break;
        case '-':
            c = a - b;
            break;
        case '*':
            c = a * b;
            break;
        case '/':
            c = a / b;
            break;
        default:
            break;
        }
        if(op == '?'){
            break;
        }
        cout << c << endl;
    }

    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a>> b;
    string u;
    cin >> u;
    if(s == u) --a;
    else --b;
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 1e5 + 10;
int N, M;
int A[MAXN];
int cnt;

int main() {
	register int i, j = 0, k = 0;
	scanf("%d%d", &N, &M);
	for(i = 1; i <= M; ++i)
		scanf("%d", A + i),
		A[i] & 1 ? (++cnt, !j ? j = i : k = i) : 0;
	if(cnt > 2) return puts("Impossible"), 0;
	if(M == 1) {
		printf("%d\n", A[1]);
		printf("%d\n", A[1] == 1 ? 1 : 2);
		A[1] == 1 ? printf("%d\n", A[1]) : printf("1 %d\n", A[1] - 1);
		return 0;
	}
	if(j) swap(A[1], A[j]); if(k) swap(A[k], A[M]);
	for(i = 1; i <= M; ++i)
		printf("%d%c", A[i], " \n"[i == M]);
	++A[1], --A[M];
	if(A[M] == 0) --M;
	printf("%d\n", M);
	for(i = 1; i <= M; ++i)
		printf("%d%c", A[i], " \n"[i == M]);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int ttt[5000000];
void merge(int *,int,int);
int co=0;

int main(){
  int i,q,n,m;
  int t[2500050],u[2500050];

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&t[i]);
  }

  merge(t, 0, q-1);

  for(i=0;i<q;i++){
    if(i!=q-1){
      printf("%d ",t[i]);
    }
    else printf("%d",t[i]);
  }
  printf("\n%d\n",co);
}


void merge(int t[ ],int left,int right){
  int md,i,j,o;

  if(left>=right){
    return;
  }

  md=(left+right)/2;
  merge(t, left, md);
  merge(t, md+1, right);

  for(i=left;i<=md;i++)
    ttt[i]=t[i];
  

  for(i=md+1,j=right; i<=right; i++,j--){
    ttt[i]=t[j];
  }

  i=left;
  j=right;

  for(o=left;o<=right;o++)
    if(ttt[i]<=ttt[j]){
      co++;
      t[o]=ttt[i++];
    }
    else{
      co++;
      t[o]=ttt[j--];
    }

}




Measured memory_bytes: 5712
n, m = map(int, input().split())
Ps = [ input().split() for _ in range(m)]
Prb = [[-1, -1] for _ in range(n)]
wa, ac = 0, 0
for ps in Ps:
    p, s = int(ps[0])-1, ps[1]
    if Prb[p][0] == -1:
        Prb[p][0] = 0
    if Prb[p][1] == -1:
        if s == 'WA':
            Prb[p][0] += 1
        else:
            Prb[p][1] = 1
            wa += Prb[p][0]
            ac += 1
print(ac, wa)

Measured memory_bytes: 82136
#include <bits/stdc++.h>
using namespace std;
static const int MAX = 200000;

int main()
{
    vector<long int> R(MAX, 0);

    int n = 0;
    cin >> n;

    for (int i = 0; i < n; ++i)
    {
        cin >> R[i];
    }

    // int maxv = numeric_limits<int>::min();
    long int maxv = - 2000000000;
    long int minv = R[0];

    for (int i = 1; i < n; ++i)
    {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
}


Measured memory_bytes: 4240
#include <iostream>
#include <algorithm>
using namespace std;
int main(int argc, char const *argv[]) {

        int N, K, sum = 0;
        cin >> N >> K;
        int fruits[N] = {};

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

        sort(&fruits[0], &fruits[N]);
        for(int i = 0; i < K; i++) {
                sum += fruits[i];
        }

        cout << sum << endl;
        return 0;
}


Measured memory_bytes: 3520
import std.stdio, std.algorithm, std.string;

string S;

void main(){
	init;
	writeln(solve);
}

void init(){
	S = readln.chomp;
}

long fact(int n){
	return n == 0 ? 1 : n * fact(n-1);
}

long solve(){
	int[char] cnts;
	foreach(w; S){
		++cnts[w];
	}
	if(count!"a&1"(cnts.values) > 1){
		return 0;
	}
	long ans = fact(cast(int)S.length / 2);
	foreach(val; cnts.values){
		ans /= fact(val/2);
	}
	return ans;
}

Measured memory_bytes: 968
#include<iostream>

using namespace std;

int main(void)
{
	int n,x;
	cin >> n >> x;
	if(x==1 || x>=2*n-1)
	{
		cout << "No" << endl;
		return 0;
	}
	else
		cout << "Yes" << endl;

	int ans[200005];
	for(int i=1;i<=2*n-1;i++)
		ans[i-1]=0;

	ans[n-1]=x;

	if(x==2)
	{
		ans[n+1-1]=x-1;
		ans[n-1-1]=x+1;
		ans[n+2-1]=x+2;
		int rest=1;
		for(int i=1;i<=2*n-1;i++)
		{
			if(x-1<=rest && rest<=x+2)
				rest=x+3;
			if(i==n-1)
				i=n+3;
			ans[i-1]=rest;
			rest++;
		}
	}
	else
	{
		ans[n+1-1]=x+1;
		ans[n-1-1]=x-1;
		ans[n+2-1]=x-2;
		int rest=1;
		for(int i=1;i<=2*n-1;i++)
		{
			if(x-2<=rest && rest<=x+1)
				 rest=x+2;
			if(i==n-1)
				i=n+3;
			ans[i-1]=rest;
			rest++;	
		}
	}



	for(int i=1;i<=2*n-1;i++)
		cout << ans[i-1] << endl;

}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    string s;
    cin >> s;
    cout << s << (s[s.size()-1] == 's' ? "es" : "s") << endl;
}


Measured memory_bytes: 3640
#089_D
h, w, d = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
idx = {}
for x in range(0, h):
    for y in range(0, w):
        idx[a[x][y]] = (x, y)
        
dp = [0 for _ in range(h*w+1)]
for i in range(0, h*w+1):
    if i <= d:
        continue
    x, y = idx[i]
    x_, y_ = idx[i-d]
    dp[i] = dp[i-d] + abs(x-x_) + abs(y-y_)
        
q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(dp[r] - dp[l])

Measured memory_bytes: 23376
#include <stdio.h>

int main(void) {
	int a1, a2, x, y, i;
	int amari;
	
	while(1){
		scanf("%d %d", &a1, &a2);	//1. 2number
		if(a1==0 && a2==0) break;
		x=a1;
		y=a2;
	
		if(a1<a2){
			x = a2;
			y = a1;
		}
	
		for(i = 0; y > 0; i++){
			amari = x % y;
			x = y;
			y = amari;
	
		}
	
		printf("%d %d\n", x, i);
	}
		return 0;
}


Measured memory_bytes: 2028
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    int n;
    cin >> n;
    vector<int> cnt(n + 1);
    for (int i = 1; i <= n; i++)
    {
        int num = i;
        while (num)
        {
            cnt[i]++;
            num /= 2;
        }
    }
    std::vector<int>::iterator iter = std::max_element(cnt.begin(), cnt.end());
    size_t index = std::distance(cnt.begin(), iter);

    cout << index << endl;

    return 0;
}


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;


int arr[N];

#define ld long double
void solve()
{
      ld d , t, s;
      cin >> d >> t >> s;

      ld y = d / s;

      if ( y <= t ) cout << "Yes" << endl;
      else cout << "No" << endl;

}

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

      int test = 1;
      // cin >> test;
      while (test--)solve();


}





















Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;


int main(){	
	string s;
	cin >> s;
	rep(i, s.length()-1) {
		if (s[i] == s[i+1]) {
			cout << i+1 << " " << i+2 << endl;
			return 0;
		}
		if (i+2 < s.length() && s[i] == s[i+2]) {
			cout << i+1 << " " << i+3 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
	return 0;
}



Measured memory_bytes: 512
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

fn main() {
    let n: usize = util::get();
    let mut a: Vec<usize> = util::gets();

    let mut c = 0;
    let mut updated = true;
    while updated {
        updated = false;
        for i in 0..n {
            if a[i] >= n {
                let d = a[i] / n;
                a[i] = a[i] % n;
                c += d;
                for k in 0..i {
                    a[k] += d;
                }
                for k in (i + 1)..n {
                    a[k] += d;
                }
                updated = true;
            }
        }
    }

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


Measured memory_bytes: 4352
n=int(input())
xyh=[list(map(int,input().split())) for _ in range(n)]
hs=[xyh[i][-1] for i in range(n)]
mh=max(hs)
if mh==0:
    mh=1
for cx in range(101):
    for cy in range(101):
        for h in range(mh,mh+101):
            j=True
            for i in range(n):
                if max(h-abs(xyh[i][0]-cx)-abs(xyh[i][1]-cy),0)!=xyh[i][2]:
                    j=False
            if j:
                print(cx,cy,h)
                break


Measured memory_bytes: 48220
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

#include <bits/stdc++.h>
 
using namespace std;

//Ordered Set Implementaton:

/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;

typedef tree<
    int,
    null_type,
    less_equal<int>,
    rb_tree_tag,
    tree_order_statistics_node_update>
ordered_set;*/

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair 
 
typedef long long ll;
typedef long double ld;

void solve(){
    ll h, w;
    cin >> h >> w;
    ll res = h * w;
    res = (res + 1LL) / 2LL;
    if(h == 1 || w == 1) res = 1;
    cout << res << "\n";
    return;
}
 
int main(){
    IOS;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256