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

int N;

int mod(int a){
    if(a < 0) return a + N;
    if(a == N) return 0;
    return a;
}

int main(){
    cin >> N;
    vector<ll> A(N), B(N);
    priority_queue<pair<ll,ll>> PQ;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];
    for(int i = 0; i < N; i++ ) PQ.push({B[i],i});
    ll ans = 0;
    bool flag = 1;
    
    while(!PQ.empty()){
        auto e = PQ.top(); PQ.pop();
        if(B[e.second] == A[e.second]) continue;
        ll sum = B[mod(e.second-1)] + B[mod(e.second + 1)];
        ll cnt =  (B[e.second]-A[e.second])  / sum;
        if(cnt == 0) continue;
        
        B[e.second] -= cnt * sum;
        ans += cnt;

        if(B[e.second] < A[e.second]){flag = 0; break; }
        else if(B[e.second] == A[e.second]) continue;
        else PQ.push({B[e.second], e.second});
    }
    for (int i = 0; i < N; ++i) {
        if (A[i] != B[i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    //else cout << -1 << endl;
}

Measured memory_bytes: 9584
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	string s, t, r;
	int n, a, b;
	cin >> s >> n;
	while (n--) {
		cin >> t >> a >> b;
		if (t == "print")
			cout << s.substr(a, b - a + 1) << endl;
		else if (t == "reverse")
			reverse(s.begin() + a, s.begin() + b + 1);
		else {
			cin >> r;
			s.replace(a, b - a + 1, r);
		}
	}
}

Measured memory_bytes: 1220
import java.util.*;

class Main{
  
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    sc.close();
    String ans = "A";
    sc = new Scanner(s);
    String tmp = "";
    for(int i = 0; i < 2; ++i){
      tmp = sc.next();
    }
    sc.close();
    ans += tmp.charAt(0) + "C";
    System.out.println(ans);
  }
}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  if(a==b){
    cout << a+b <<endl;
    return 0;
  }
  
  else{
    if(a>b){
      cout << a+(a-1) <<endl;
      return 0;
    }
    else{
      cout << b+(b-1) << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int nextInt();

int N, M, K, ans, i, j;
char P[31], F[31];

int main(){
	N=nextInt();
	M=nextInt();
	for(i=1; i<=M; i++){
		F[i] = 1;
	}
	for(i=0; i<N; i++){
		for(j=1; j<=M; j++){
			P[j] = 0;
		}
		K=nextInt();
		for(j=0; j<K; j++){
			P[nextInt()] = 1;
		}
		for(j=1; j<=M; j++){
			if(P[j]==0){F[j] = 0;}
		}
	}
	for(i=1; i<=M; i++){
		ans += F[i];
	}
	printf("%d\n", ans);
	return 0;
}

int nextInt(){
	int f=0; char c=getchar();
	while((c<'0')||('9'<c)){c=getchar();}
	while((c>='0')&&(c<='9')){f=f*10+(c-'0'); c=getchar();}
	return f;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>

using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;

ll f(ll x){
    if(x==1)return 1;
    ll a=f(x/2);
    return a*2+1;
}


int main(){

    ll h; cin >> h;

    cout << f(h) << endl;

     return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  int a,b,c;
  cin >> a >> b;
  if(a == 1){
    a = 14;
  }
  if(b == 1){
    b = 14;
  }
  if(a > b){
    cout <<"Alice" << endl;
  } else if(a < b){
    cout <<"Bob" << endl;
  }else{
    cout <<"Draw" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

		Scanner in = new Scanner(System.in);
		long n = in.nextLong();
		long m = in.nextLong();

		long ans = 0;
		if (2 * n <= m) {
			ans += n;
			m -= (2 * n);
			ans += (long)m/4;
		} else {
			ans += (long)m/2;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 23124
fun main() {
    val k = nextInt()
    val s = next()
    println(if (s.length <= k) s else s.substring(0, k) + "...")
}

val sc = java.util.Scanner(System.`in`)
fun next(): String = sc.next()
fun nextInt() = sc.nextInt()
fun next2Int() = Pair(nextInt(), nextInt())
fun next3Int() = Triple(nextInt(), nextInt(), nextInt())
fun nextIntArray(size: Int) = IntArray(size) { nextInt() }
fun nextLong() = sc.nextLong()
fun nextLine(): String = sc.nextLine()
fun nextList() = nextLine().split(" ")
fun printYesNo(isYes: Boolean) = println(if (isYes) "Yes" else "No")
fun printString(action: StringBuilder.() -> Unit) = println(buildString(action))


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

using namespace std;

int main()
{
    vector<int> a(3);
    for (int i = 0; i < 3; i++) {
        cin >> a[i];
    }

    sort(a.begin(), a.end());

    cout << (a[0] + a[1] == a[2] ? "Yes" : "No") << endl;
    
    return 0;
}


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

ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c*d/gcd(c,d);}
int main(){
   int n,k;
   cin>>n>>k;
   vector<ll> a(n);
  ll check=0;
   for(int i=0;i<n;i++){
       cin>>a.at(i);
       check=max(a.at(i),check);
   }
   if(check<k){cout<<"IMPOSSIBLE"<<endl;return 0;}
   ll g=a.at(0);
   for(int i=1;i<n;i++)g=gcd(g,a.at(i));
   if(k%g==0)cout<<"POSSIBLE"<<endl;
   else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

int main()
{
	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);
	if((A==5 && B==5 && C==7) || (A==5 && B==7 && C==5) || (A==7 && B==5 && C==5))
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
	return 0;
}

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

struct Point {
    int x, y;
};

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

    Point p[50], r[50];
    for (int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y;
    }

    sort(p, p + n, [](const Point& p0, const Point& p1) {
        return p0.x < p1.x;
    });

    int q[50];
    for (int i = 0; i < n; i++) {
        q[i] = i;
    }
    sort(q, q + n, [&p](const int& i0, const int& i1) {
        return p[i0].y < p[i1].y;
    });

    int64_t m = 1LL << 62;
    for (int i = 0; i < n; i++) {
        for (int j = i + k - 1; j < n; j++) {
            int c = 0;
            for (int h = 0; h < n; h++) {
                if (i <= q[h] && q[h] <= j) r[c++] = p[q[h]];
            }

            for (int h = k - 1; h < c; h++) {
                int64_t t = (int64_t)(p[j].x - p[i].x) * (r[h].y - r[h - (k - 1)].y);
                if (t < m) m = t;
            }
        }
    }

    cout << m << endl;

    return 0;
}

Measured memory_bytes: 384
from collections import defaultdict, Counter
from heapq import heapify, heappop, heappush
from sys import stdin

def main():
    n = int(input())
    A = [int(x) for x in input().split()]
    A.sort(reverse=True)
    is_alice_turn = True
    ans = 0
    for i in range(n):
        if is_alice_turn:
            ans += A[i]
        else:
            ans -= A[i]
        is_alice_turn = not is_alice_turn
    print(ans)

input = lambda: stdin.readline().rstrip()
main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
const double eps=1e-9;
typedef vector<int> vi;
typedef long long ll;
int n;
struct Word {
    string word;
    int count;
    Word(){}
    Word(string _word,int _count){
        word=_word,count=_count;
    }
    bool operator < (const Word &a) const {
        if(a.count!=count)
        {
            return a.count<count;
        } else{
            return a.word>word;
        }
    }
};

int main(void)
{
    string s;
	string n;
    while(getline(cin,n) && n!="0") {
        vector<set<string> > appear(26);
        vector<vector<Word> > dict(26);
        for(int line=0;line<stoi(n);line++)
        {
            //if(line==0)cin.ignore();
            getline(cin,s);
            //cout << "OUT" << endl;
            //cout << s << endl;
            string nowword="";
            int len=s.size();
            //cout << s << endl;
            for(int i=0;i<len;i++) {
                if (s[i] != ' ') nowword += s[i];
                else if (s[i] == ' ') {
                    int index = int(nowword[0] - 'a');
                    auto it = appear[index].find(nowword);
                    if (it == appear[index].end()) {
                        dict[index].push_back(Word(nowword, 0));
                        appear[index].insert(nowword);
                    } else {
                        for (int j = 0; j < dict[index].size(); j++) {
                            if (dict[index][j].word == nowword)dict[index][j].count++;
                        }
                    }
                    //cout << nowword << endl;
                    nowword = "";
                }
                if (i == len - 1) {
                    int index = int(nowword[0] - 'a');
                    auto it = appear[index].find(nowword);
                    if (it == appear[index].end()) {
                        dict[index].push_back(Word(nowword, 0));
                        appear[index].insert(nowword);
                    } else {
                        for (int j = 0; j < dict[index].size(); j++) {
                            if (dict[index][j].word == nowword)dict[index][j].count++;
                        }
                    }
                    //cout << nowword << endl;
                    nowword = "";
                }
            }
        }
        string k;
    	getline(cin,k);
        int index=int(k[0]-'a');
        sort(dict[index].begin(),dict[index].end());
        int out=min(5,int(dict[index].size()));
        //cout << out << endl;
        if(out==0)
        {
            cout << "NA" << endl;
        } else {
            for (int i = 0; i < out; i++) {
                if (i != out - 1)
                {
                    cout << dict[index][i].word << ' ';
                }
                else
                {
                    cout << dict[index][i].word << endl;
                }
            }
        }
    }

  return 0;
}



Measured memory_bytes: 3176
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
signed main() {
    IOS;
    #ifdef LOCAL
        freopen("input.txt","r", stdin);
        freopen("output.txt","w",stdout);
    #endif
    string s, t;
    cin >> s >> t;
    int c = 0;
    for(int i = 0; i < 3; i++)
        if(s[i] == t[i])
            c++;
    cout << c;   
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define  M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar (char ch){
    if(ch=='A')return 1;
    else if(ch=='C')return 2;
    else if(ch=='G')return 3;
    else if(ch=='T')return 4;
    else return 0;
}

long long getKey(char str[]){
    long long sum=0,p=1,i;
    for( i=0;i<strlen(str);i++){
        sum+=p*(getChar(str[i]));
        p*=5;
    }
    return sum;
}

int h1(int key){return key%M;}
int h2(int key){return 1+(key%(M-1));}

int find(char str[]){
    long long key,i,h;
    key=getKey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0)return 1;
       else  if(strlen(H[h])==0)return 0;
    }
    return 0;
}

int insert(char str[]){
    long long  key,i,h;
    key=getKey(str);
    for(int i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0)return 1;

        else if(strlen (H[h])==0){
            strcpy(H[h],str);
            return 0;
        }
    }
    return 0;
}

int main(){
   int i,n,h;
   char str[L],com[9];
   for(i=0;i<M;i++)H[i][0]='\0';
   scanf("%d",&n);
   for(int i=0;i<n;i++){
    scanf("%s %s",com,str);
   if(com[0]=='i'){
       insert(str);
     }else {
      if(find(str)){
        printf("yes\n");
       }else {
      printf("no\n");
      }
     }
   }
   return 0;
}

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

int main(){
	int n, m;
	cin >> n >> m;
	
	int mal = 0;
	int mir = n;
	rep(i, m){
		int l, r;
		cin >> l >> r;
		mal = max(mal, l);
		mir = min(mir, r);
	}

	cout << max(0, mir - mal+1) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll l,r,d,count=0;
    cin>>l>>r>>d;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0)
        {
            count++;
        }
    }
    cout<<count<<'\n';
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
long long a[200000],b[200000],x[200000];
int main(void)
{
	int n,i,j,p,k;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(a,a+n);
	p=a[n/2];
	k=a[n/2-1];
	for(i=0;i<n;i++){
		if(b[i]>k) x[i]=k;
		else x[i]=p;
	}
	for(i=0;i<n;i++) printf("%d\n",x[i]);
	return 0;
}

Measured memory_bytes: 6912
import java.util.Scanner;

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

int i=0;  
int sum=0;
for(i=0;i<n;i++){
    a[i]=scan.nextInt();
    sum=sum+a[i];
}
  
if(sum<h){
  System.out.println("No");
}else{
  System.out.println("Yes");
}
  
}
}

Measured memory_bytes: 51096
import java.awt.geom.*;
import java.util.*;
public class Main {
	//2142 start
	//2202 stop
	//2346 restart
	
	HashMap<String, Integer> table;
	ArrayList<C> list;
	
	class C implements Comparable<C>{
		int value, len;
		String s;
		public C( String s, int value) {
			this.value = value;
			this.s = s;
			this.len = s.length();
		}
		@Override
		public int compareTo(C o) {
			if(this.len < o.len) return 1;
			if(this.len > o.len) return -1;
			return 0;
		}
		
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		table = new HashMap<String, Integer>();
		list = new ArrayList<Main.C>();
		while(true){
			String s = sc.next();
			if(s.equals("END_OF_FIRST_PART")) break;
			int num = sc.nextInt();
			table.put(s, num);
			C temp = new C(s, num);
			list.add(temp);
		}
		Collections.sort(list);
		
		while(true){
			String s = sc.next();
			if(s.equals("0")) break;
			int res = eval(s);
			if(res < 0) System.out.println("UNKNOWN");
			else{
				System.out.println(res);
			}
		}
	}

	private int eval(String str) {
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < str.length(); i++){
			char c = str.charAt(i);
			if(i == 0 || str.charAt(i -1) == '(' || c == ')'){
				
			}
			else if('a' <= c && c <= 'z'){
				
			}
			else if(Character.isDigit(c)){
				sb.append('*');
				for(; i+1 < str.length(); i++){
					if(Character.isDigit(str.charAt(i+1))){
						sb.append(str.charAt(i));
					}
					else{
						break;
					}
				}
			}
			else {
				
				sb.append('+');
			}
			sb.append(str.charAt(i));
		}
		String s = sb.toString();
		for(int i = 0; i < list.size(); i++){
			s = s.replaceAll(list.get(i).s, list.get(i).value + "");
		}
		for(int i = 0; i < s.length(); i++){
			char c = s.charAt(i);
			if(Character.isLetter(c)){
				return -1;
			}
		}
		return new Parse(s+"#").exp();
	}
	
	class Parse{
		String str;
		int pos;
		public Parse(String str){
			this.str = str;	pos = 0;
		}
		
		private int exp() {
			int res = term();
			while(true){
				char op = str.charAt(pos);
				if((op == '+') || (op == '-')){
					int old = res;
					pos++;
					res = term();
					switch(op){
					case '+': 
						res = old + res;
						break;
					case '-':
						res = old - res;
						break;
					}
				}
				else break;
			}
			return res;
		}

		private int term() {
			int res = fact();
			while(true){
				char op = str.charAt(pos);
				if((op == '*') || (op == '/')){
					int old = res;
					pos++;
					res = fact();
					switch(op){
					case '*':
						res = old * res;
						break;
					case '/':
						res = old / res;
						break;
					}
				}
				else break;
			}
			return res;
		}

		private int fact() {
			if(Character.isDigit(str.charAt(pos))){
				int t = str.charAt(pos) - '0';
				pos++;
				while(Character.isDigit(str.charAt(pos))){
					t = t * 10 + (str.charAt(pos) - '0');
					pos++;
				}
				return t;
			}
			else if(str.charAt(pos) == '('){
				pos++;
				int res = exp();
				pos++;
				return res;
			}
			return 0;
		}
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
N = int(input())
dp = [0]
for i in range(N):
    P = int(input())
    dp_p = list(map(lambda x:x + P,dp))
    dp = list(set(dp + dp_p))

P_List = [0] + [i for i in dp if i % 10 != 0]
print(max(P_List))

Measured memory_bytes: 10208
#include <iostream>
#include <vector>

using namespace std;

int main() {
    while(true) {
        int N, K;
        cin >> N >> K;
        if(!N && !K) break;

        vector<int> s(K);
        for(int i = 0; i < K; ++i) cin >> s[i];
        bool ok = true;
        while(N--) {
            for(int i = 0; i < K; ++i) {
                int b;
                cin >> b;
                s[i] -= b;
                if(s[i] < 0) ok = false;
            }
        }
        cout << (ok?"Yes":"No") << endl;
    }
    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <map>

int main() {
  long long N;
  std::cin >> N;

  std::map<long long, long long> B_map, C_map;
  for (long long i = 0; i < N; ++i) {
    long long a;
    std::cin >> a;
    B_map[i + a] += 1;
    C_map[i - a] += 1;
  }

  unsigned long ans = 0;
  for (auto x : B_map) {
    const long long B_num = x.second;
    const long long C_num = C_map[x.first];
    ans += B_num * C_num;
  }

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


Measured memory_bytes: 37928
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        private static long mod = 1000000007;

        static void Main(string[] args)
        {
            var n = Read().Int();
            var al = new int[100001];
            var r1 = ReadSplit();
            var sum = 0L;
            for (int i = 0; i < n; i++)
            {
                al[r1[i].Int()] += 1;
                sum += r1[i].Long();
            }
            var q = Read().Int();
            var ansl = new List<long>();
            for (int i = 0; i < q; i++)
            {
                var r2 = ReadSplit();
                var b = r2[0].Int();
                var c = r2[1].Int();
                al[c] += al[b];
                sum -= (long)b * (long)al[b];
                sum += (long)al[b] * (long)c;
                al[b] = 0;
                ansl.Add(sum);
            }
            for (int i = 0; i < ansl.Count; i++)
            {
                Write(ansl[i]);
            }
            Read();
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 31284
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitsf(n) __builtin_popcount(n)
#define in_edges(M) repp(I, 1, M){ll A, B, C; cin >> A >> B >> C; v[A].pb(B, C&1), v[B].pb(A, C&1);}
#define in_edges2(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"
ll power(ll x, ll y); 

const ll MOD = 1000000007;
const int MX = 1e5 + 5;

vector<pair<int, int> > v[MX];
int col[MX], vis[MX];

void dfs(int s, int sum){
	vis[s] = 1;
	col[s] = sum & 1; 
	for(auto i : v[s]) if(!vis[i.ff]){
		dfs(i.ff, sum + i.ss);
	}
}
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
	int n;
	cin >> n;
	in_edges(n - 1);
	dfs(1, 0);
	repp(i, 1, n) cout << col[i] << endl;
}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

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

class unionfind {
  vector<int> par;
  
public:
  unionfind(int n) {
    for (int i = 0; i < n; i++) {
      par.push_back(i);
    }
  }
  
  int find(int n) {
    if (n == par.at(n)) return n;
    return par.at(n) = find(par.at(n));
  }
  
  void merge(int m, int n) {
    m = find(m); n = find(n);
    par.at(m) = n;
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(n), x(m), y(m);
  for (int i = 0; i < n; i++) {
    cin >> p.at(i);
    p.at(i)--;
  }
  for (int i = 0; i < m; i++) {
    cin >> x.at(i) >> y.at(i);
    x.at(i)--;
    y.at(i)--;
  }
  unionfind t(n);
  for (int i = 0; i < m; i++) {
    t.merge(x.at(i), y.at(i));
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (t.find(i) == t.find(p.at(i))) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

ll N,M;
cin >> N >> M;
vl a(M);
rep(i,M) cin >> a[i];

//数え上げの問題なのでdp配列は0で初期化する
vl dp(N+1);

//初期条件として0段目にたどり着く方法は１通りと考える
dp[0] = 1;
//壊れている段のdp値を-1にしておく
rep(i,M) dp[a[i]] = -1;

// i=1~i=Nまで動かす
rrep(i,N) {
    // dp値が-1になっている段は何もしない
    if(dp[i] == -1) continue;

    //dp値が-1でない段ついて
    if(dp[i-1] != -1) dp[i] += (dp[i-1] % MOD),dp[i] %= MOD;
    if(i > 1) {
        if(dp[i-2] != -1) dp[i] += (dp[i-2] % MOD),dp[i]%= MOD;
    }
}

cout << dp[N] << endl;


return 0;
}

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

int arr[200050], ans;

int main() {
	int N, T;
	scanf("%d%d", &N, &T);
	for (int i = 0; i < N; i++) scanf("%d", &arr[i]);
	for (int i = 0; i < N - 1; i++) {
		if (arr[i] + T <= arr[i+1]) {
			ans += T;
		} else {
			ans += (arr[i+1] - arr[i]);
		}
	}
	printf("%d", ans + T);
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

//??§?¬??????§?§£??????
int main(void){
	int n, a, b;
	double kizi;
	cin >> n >> a >> b >> kizi;
	vector<int> debu(n + 1);//?????????????????\????????????
	rep(i, n) cin >> debu[i];
	sort(debu.begin(), debu.end());
	reverse(debu.begin(), debu.end());//??§???????????????????????????
	vector<double> ans(n + 1);
	//?????????????????????????????????????????????????????§??????
	rep(i, n + 1){//i????????????????????°????????¶??¨???
		double nedan = (double)a + (double)i * (double)b;//??????????¨????
		double karori = kizi;//?????°?????????????????????????????¨??????
		rep(j, i) karori += debu[j];//i????????????????????°????????????????????????????????????????????????i???????????§??????
		ans[i] = karori / nedan;//???????????\????????????
	}
	sort(ans.begin(), ans.end());
	reverse(ans.begin(), ans.end());
	printf("%d\n", (int)floor(ans[0]));//????????§?????????????????????
	return 0;
}

Measured memory_bytes: 3300
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll MOD = 1e9+7;
const ll inf = (LLONG_MAX>>2);
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin >> n;
  cout << n*n*n;
  return 0;
}

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

#define ipair pair<int,int>
#define rep(n) for(int i=0;i<n;i++)

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

int main() {
	string s;
	int i, j;

	cin >> s;

	j = s.length();

	for (i = 0; i < j; i += 2) {
		cout << s[i];
	}

	return 0;
}

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

int main(){
  int n;
  cin >> n;
  
  for(int i=1; i<=n; i++){
     if(i%10==3 || i%3==0 || (i/10)%10==3|| (i/100)%10==3 || (i/1000)%10==3){
        cout<<" "<<i;
     }
  }
  
  cout<<endl;
  
  return 0;
}


Measured memory_bytes: 3120
import collections
n=int(input())
S=input()
alphabet=[chr(ord('a') + i) for i in range(26)]
kaisu=collections.Counter(S)
ans=1
for i in alphabet:
	if kaisu[i]!=0:
		ans*=kaisu[i]+1
	ans=ans%(10**9+7)
ans-=1
print(ans)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const ll mod = 1e9+7;

map<ll,ll> test(ll n, ll k){
    map<ll,ll> m;
    for(int i=n; i>=1; --i){
       ll x = n/i;
       m[x] = i;
    }
    // for(const auto &q:m) dbg(q);
    return m;
}

int main(){
    ll n,k;
    cin >>n >>k;

    map<ll,ll> m;
    for(int i=1; i*i<=n; ++i){
       ll x = n/i;
       m[x] = i;
    }

    for(int x=2; (x-1)*(x-1)<=n; ++x){
        ll i = n/x + 1;

        if(!m.count(x-1)) m[x-1] = i;
        m[x-1] = min(m[x-1],i);
    }

    vector<int> v;
    for(const auto &p:m){
        v.pb(p.fi+1);
        v.pb(p.se);
    }
    v.pb(n+1);

    sort(all(v));
    v.erase(unique(all(v)), v.end());
    int V = v.size();

    vector<ll> dp(V-1);
    rep(i,V-1) dp[i] = v[i+1]-v[i];

    rep(loop,k-1){
        vector<ll> pre(dp);
        for(int i=1; i<V-1; ++i) (pre[i] += pre[i-1]) %= mod;

        vector<ll> nx(V-1);

        rep(i,V-1){
            ll x = n/v[i];
            int idx = upper_bound(all(v), x) - v.begin();
            --idx;

            // dbg(i);
            // dbg(idx);
            // dbg(pre[idx]);

            ll num = v[i+1]-v[i];
            nx[i] = (pre[idx]*num)%mod;
        }
        dp = nx;
    }

    ll ans = 0;
    for(ll i:dp) (ans += i) %= mod;
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N; 
  cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
	  cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  if(N%2==0){
	  int anser,tiisai=0,ookii=0;
	  for(int j=0;j<N/2;j++){
		  ookii+=vec.at(2*j+1);
		  tiisai+=vec.at(2*j);
	  }
	  anser=ookii-tiisai;
	  cout<<anser<<endl;
  }
  else{
	  int anser,tiisai=0,ookii=0;
	  for(int j=0;j<N/2+1;j++){
		  ookii+=vec.at(2*j);
	  }
	  for(int j=0;j<N/2;j++){
		  tiisai+=vec.at(2*j+1);
	  }
	  anser=ookii-tiisai;
	  cout<<anser<<endl;
  }
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;

struct edge {
    int u, v;
    int64_t cost;
    edge(int u=0, int v=0, int64_t cost=0):u(u), v(v), cost(cost) {} 
};

struct Edge {
    int to;
    int64_t cost;
    Edge(int x=0, int64_t y=0):to(x), cost(y) {}
};

vector<vector<Edge> > G; // resizeの必要あり
map<P, bool> checked;

int dfs(int i, int j, Edge& X) {
    //cout << i << endl;
    if(i == X.to) {
        return 0;
    }
    bool flag = false;
    int cou = 0;
    for(auto next:G[i]) {
        if(next.to == j) continue;
        int v = dfs(next.to, i, X);
        if(v == -1) continue;
        flag = true;
        cou += v;
        if(next.cost == X.cost && !(checked[P(i, next.to)]))  {
            checked[P(next.to, i)] = checked[P(i, next.to)] = true;
            cou++;
        }
    }
    if(flag) return cou;
    else return -1;
}

struct UnionFind {
    vector<int> par; // 親を指すvector,-par[親]は木のサイズ
    UnionFind(int n):par(n, -1) {} // uniteで親を埋め込んでいく必要あり
    int root(int x) { // 親をたどる&データの整理
        if(par[x] < 0) {
            return x;
        }
        return par[x] = root(par[x]);
    }
    bool unite(int x, int y) { // データの結合
        x = root(x);
        y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    bool same(int x, int y) {
        x = root(x);
        y = root(y);
        return (x == y);
    } // 所属判定
    int size(int x) {return -par[root(x)];} // 木のサイズ
};



bool comp(const edge& e1, const edge& e2) {
    return e1.cost < e2.cost;
}

int ans=0;

vector<edge> es; // 辺の数でresize
//最小全域木
int64_t kruskal(int V) { // Vは頂点数
    int E = es.size();
    sort(es.begin(), es.end(), comp);
    UnionFind uft(V);
    int64_t res = 0;
    for(int i = 0; i < E; ++i) {
        edge e = es[i];
        //cout << e.u << ' ' << e.v << endl;
        G[e.u].push_back(Edge(e.v, e.cost));
        G[e.v].push_back(Edge(e.u, e.cost));
        if(!uft.same(e.u, e.v)) {
            uft.unite(e.u, e.v);
            res += e.cost;
            ++ans;
            
        } else {
            Edge X = Edge(e.u, e.cost);
            int gg = dfs(e.v, e.u, X);
            G[e.u].pop_back();
            G[e.v].pop_back();
            ans -= gg;
            res -= gg*e.cost;
        }
    }
    return res;
}






int main() {
    int n, m;
    cin >> n >> m;
    es.resize(m);
    G.resize(n);
    rep(i, m) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        --a;
        --b;
        es[i] = edge(a, b, c);
    }
    int kk = kruskal(n);
    cout << ans << ' ';
    cout << kk << endl;
}


Measured memory_bytes: 3624
day_num, homework_num = map(int, input().split(" "))

requ_day = list(map(int, input().split()))
sum_day = 0

for day in requ_day:
  sum_day += day
  
activ_day = day_num - sum_day

if activ_day >= 0:
  print(activ_day)
else:
  print(-1)
  

Measured memory_bytes: 10168
N = gets.to_i
t_list = gets.split.map(&:to_i)
M = gets.to_i
px_list = M.times.map { gets.split.map(&:to_i) }

sum = t_list.reduce(&:+)
px_list.each.with_index do |(p, x), i|
  ans = sum + (x - t_list[p - 1])
  puts ans
end


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


ll h, w, n;
ll sr, sc;
string s, t;
vector<ll> rem(4, 1e9);
char dc[4] = {'U', 'R', 'D', 'L'};

bool solve(){
  vector<ll> sente(4, 0);
  vector<ll> gote(4, 0);

  rem[0] = sr;
  rem[1] = w-sc-1;
  rem[2] = h-sr-1;
  rem[3] = sc;

  rep(times, n){
    rep(dir, 4){
      if(dc[dir] == t[times]) gote[dir]++;
    }
 
    rep(dir, 4){
      if(rem[dir] < gote[dir]-sente[(dir+2)%4]){
        gote[dir] = min(gote[dir], rem[dir]+sente[(dir+2)%4]);//gote[dir]-sente[(dir+2)%4];
        if(dc[(dir+2)%4] == s[times]) gote[dir]++;
      }
    }
 
    rep(dir, 4){
      if(dc[dir] == s[times]) sente[dir]++;
    }
 
    rep(dir, 4){
      if(sente[dir] == 0) continue;
      ll op = 0;
      if(dc[dir] == s[times] && dc[(dir+2)%4] == t[times]){
        op = 1;
      }

      if(rem[dir] < sente[dir]-gote[(dir+2)%4]+op){
        return false;
      }
    }
  }
  
  return true;
}

int main(){
  
  cin >> h >> w >> n;
  cin >> sr >> sc;
  cin >> s >> t;
  sr--; sc--;

  cout << (solve()? "YES":"NO") << endl;


  return 0;
}


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

int main(){
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  bool one_start = (S.at(0) == '1');
  vector<int> arr(1000000);
  int idx = 0;
  char pre = '1';
  if (S.at(0) == '0') { // 0スタートだった
    idx++;
    arr.at(0) = 0; // 1が0個あることにする
    pre = '0';
  }
  for (int i = 0; i < S.size(); i++) {
    if (pre == S.at(i)) {
      arr.at(idx)++;
    } else {
      idx++;
      arr.at(idx)++;
    }
    pre = S.at(i);    
  }
  
  int max_lensum = 0;
  for (int i = 0; i < arr.size(); i = i+2) {
    int lensum = accumulate(arr.begin()+i, arr.begin()+i+2*K+1, 0);
    if (lensum > max_lensum) max_lensum = lensum;
    if (i != 0 && arr.at(i) == 0) break;
  }
  cout << max_lensum << endl;
}


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

int main(){
        string day;
        map<string, int> m;
        m["SAT"] = 1;
        m["FRI"] = 2;
        m["THU"] = 3;
        m["WED"] = 4;
        m["TUE"] = 5;
        m["MON"] = 6;
        m["SUN"] = 7;
        cin >> day;
        cout << m[day] << endl;
        return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int num1,num2,num3;
 scanf("%d",&num1);
 scanf("%d",&num2);
 scanf("%d",&num3); 
  if(num1==5&&num2==7&&num3==5){
  printf("YES");
  }else if(num1==7&&num2==5&&num3==5){
  printf("YES");
   }else if(num1==5&&num2==5&&num3==7){
  printf("YES");
  }else{
  printf("NO");
  }
  return 0;
}

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

int main(void){

    char S[11];

    scanf("%s", S);

    for(int i = 0; i < 10; i++){
        if(i == 3){
            printf("8");
        }else{
            printf("%c", S[i]);
        }
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 1608
n = int(input())
t = list(map(int,input().split()))
m = int(input())
a = []
for _ in range(m):
    a.append(list(map(int,input().split())))
for i in range(m):
    j = a[i][0]-1
    print('{}'.format(sum(t)- t[j] + a[i][1]))



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

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int ans = 1e9;
    for (int i = 0; i < 202020; i++) {
        int A = x - i / 2;
        int B = y - i / 2;
        if (A < 0) A = 0;
        if (B < 0) B = 0;
        int money = i * c + A * a + B * b;
        ans = min(ans, money);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int A[2000000];
int B[2000000];
int C[10001];

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

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

    for(int i=1; i<=10000; i++){
        C[i] += C[i-1];
    }

    for(int j=n-1; j>=0; j--){
        B[--C[A[j]]] = A[j];
    }

    for(int i=0; i<n; i++){
        cout << B[i];
        if(i==n-1){
            cout << endl;
        } else {
            cout << ' ';
        }
    }
}

Measured memory_bytes: 18680
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(" ", $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int)$this->next();
    }

    public function nextDouble()
    {
        return (double)$this->next();
    }
}

class out
{
    public static function printIn($str = "")
    {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner;

$N = $sc->nextInt();
$A = $sc->nextInt();
$B = $sc->nextInt();
$res = 0;

for ($i = 1; $i <= $N; $i++) {
    $num = str_split($i);
    $sum = array_sum($num);
    if ($A <= $sum && $B >= $sum) {
        $res += $i;
    }
}

echo $res;

Measured memory_bytes: 4604
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int T[25],n,ans,rans,a;
vector<int>v;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        T[a]++;
        T[24-a]++;
        if(a==12)T[a]--;
    }
    if(T[0]){cout<<0<<endl;return 0;}
    for(int i=0;i<(1<<11);i++){
        v={0,24};
        for(int j=0;j<12;j++){
            if(T[j+1]>2){
                cout<<0<<endl;
                return 0;
            }
            if(T[j+1]==2){
                if(j==11){
                    cout<<0<<endl;
                    return 0;
                }
                v.push_back(j+1);
                v.push_back(23-j);
            }
            if(T[j+1]==1){
                if(((i>>j)&1)==1){
                    v.push_back(j+1);
                }
                else v.push_back(23-j);
            }
        }
        ans=30;
        sort(v.begin(),v.end());
        //for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
        //cout<<endl;
        for(int i=0;i<v.size()-1;i++){
            ans=min(ans,v[i+1]-v[i]);
        }
        //cout<<ans<<endl;
        rans=max(ans,rans);
    }
    cout<<rans<<endl;
}


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

using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    while (n>0)
    {
        if(n%10==9){
            cout << "Yes" << endl;
            return 0;
        }
        n /= 10;
    }
    cout << "No" << endl;
}


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

int main () {
  long int a, b, c, d;
  cin >> a >> b >> c >> d;
  long int ans;
  
  if (a >= 0) {
    if (c >= 0) {
      ans = b * d;
    }
    else if (d < 0) {
      ans = a * d;
    }
    else {
      ans = b * d;
    }
  }
  else if (b < 0) {
    if (c >= 0) {
      ans = b * c;
    }
    else if (d < 0) {
      ans = a * c;
    }
    else {
      ans = a * c;
    }
  }
  else {
    if (c >= 0) {
      ans = b * d;
    }
    else if (d < 0) {
      ans = a * c;
    }
    else {
      if (-a >= b && -c >= d) {
      ans = a * c;
      }
      else if (-a < b && -c < d) {
      ans = b * d;
      }
      else if (a * c >= b * d) {
      ans = a * c;
      }
      else {
      ans = b * d;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int,Int> P;

int main(){
    int L, R, d;
    cin >> L >> R >> d;

    int ans = 0;
    for(int i=L; i<=R; i++){
        if (i % d == 0) ans++;
    }

    cout << ans << endl;
}  

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std ;
int main () {
    int a[100005];
    int n=3;
    for (int i=0;i<n;i++)
    cin>>a[i];
    int x = sizeof(a);
    sort(a,a+n) ;
    for (int i=0;i<n;i++){
    if(i==2)
        cout<<a[i]<<endl;
    else cout<<a[i]<<" ";}
    return 0 ;
}



Measured memory_bytes: 3168
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, y, z; cin >> x >> y >> z;
    swap(x, y); swap(x, z);
    cout << x << " " << y << " " << z << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  if(a*b%2==1) co("Yes");
  else co("No");
  return 0;
}


Measured memory_bytes: 256
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial
from bisect import bisect_left # bisect_left(list, value)
#from fractions import gcd

sys.setrecursionlimit(10**7)
A, B, C, X, Y = map(int, input().split())

val1 = A*X + B*Y
minXY = min(X, Y)
val2 = C*2*minXY + A*(X-minXY) + B*(Y-minXY)
maxXY = max(X, Y)
val3 = C*2*maxXY

print(min(val1, val2, val3))


Measured memory_bytes: 38384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

// ----------- VECTOR ------------
template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}
// ----------- VECTOR ------------

int main() {
  int N, M; cin >> N >> M;
  vector<LL> H(N); cin >> H;

  vector<vector<int>> G(N);
  vector<bool> B(N, true);
  for (int i = 0; i < M; ++i) {
    int a, b; cin >> a >> b; --a, --b;
    if (H[a] >=  H[b]) B[b] = false;
    if (H[b] >=  H[a]) B[a] = false;
    G[a].push_back(b);
    G[b].push_back(a);
  }

#if 0
  for (int i = 0; i < N; ++i) {
    cout << H[i] << ":";
    for (int j : G[i]) {
      cout << H[j] << " ";
    }
    cout << endl;
  }
#endif
  int cnt = 0;
  for (bool x : B) if (x) ++cnt;
  cout << cnt << endl;
}


Measured memory_bytes: 9332
n,k,*a=map(int,open(i:=0).read().split())
a.sort()
p=a.pop
s=b=~k%2or p()
j=1
for _ in k//2*'_':
 if(x:=a[i]*a[i+1])*b>(y:=a[-j]*a[~j])*b:s*=x;i+=2
 else:s*=y;j+=2
 s%=10**9+7
print(s)

Measured memory_bytes: 31660
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#define N 110
using namespace std;

char s[N],ss[N];

int main()
{
	char c;
	int j,k,temp,n,i,ans,flag;
	
	while (scanf("%d",&n)!=EOF)
	{
		c=getchar();
		fgets(s,sizeof(s),stdin);
		s[n]='\0';
		ans=0;
		
		for (i=1;i<n;i++)
		{
			strcpy(ss,s);
			temp=0;
			
			for (j=0;j<i&&j<n;j++)
			{
				flag=1;
				
				for (k=i;k<n;k++)
				{
					if (ss[k]==s[j])
					{
						if (flag)
						{
							flag=0;
							temp++;
						}
						
						ss[k]='#';
					}
				}
			}
			
			ans=max(ans,temp);
		}
		
		printf("%d\n",ans);
	}
	
	return 0;
 } 

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = atan(1.0) * 4.0;
// const int MOD = 998244353;
const ll LINF = 9e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

signed main() {
    LCIN(K, X);
    REP(i, K) { cout << X - K + 1 + i << " "; }
    REP(i, K - 1) { cout << X + 1 + i << " "; }
    cout << "\n";
}

Measured memory_bytes: 256