akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

bool isMatch(int x, int y, vector<vector<char>> a, vector<vector<char>> b) {
  int size = b.size();
  for (int i = 0; i < size; i++) {
    for (int j = 0; j < size; j++) {
      if (a[i + x][j + y] != b[i][j]) return false;
    }
  }
  return true;
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<char>> a(N, vector<char>(N));
  vector<vector<char>> b(M, vector<char>(M));
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < M; i++) {
    cin >> b[i];
  }
  if (N == 1) {
    if (a[0][0] == b[0][0]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
    return 0;
  }
  char hidariue = b[0][0];
  for (int i = 0; i <= N - M; i++) {
    for (int j = 0; j <= N - M; j++) {
      debug(a[i][j]);
      if (a[i][j] != hidariue) continue;
      if (isMatch(i, j, a, b)) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3592
//
//  main.cpp
//  B - Two Colors Card Game
//
//  Created by 谢威宇 on 2018/3/17.
//  Copyright © 2018年 Ervin's Studio. All rights reserved.
//

#include <iostream>
#include <set>
#include <string>
#include <algorithm>
using namespace std;
int main(int argc, const char * argv[]) {
    multiset<string> red;
    multiset<string> blue;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        string a;
        cin>>a;
        red.insert(a);
    }
    cin>>n;
    for(int i=0;i<n;i++)
    {
        string a;
        cin>>a;
        blue.insert(a);
    }
    multiset<string> :: iterator it = red.begin();
    int ans=0;
    for(;it!=red.end();it++)
    {
        int c=(red.count(*it)-blue.count(*it));
        if(ans<c)
            ans=c;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int i,n,c=0;
	char s[4];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",s);
		if(s[0]=='A'){
			c++;
		}else{
			c--;
		}
		if(c<0){
			printf("NO\n");
			return 0;
		}
	}
	if(c==0){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	return 0;
}



Measured memory_bytes: 2700
n=gets.to_i
s=gets.chomp
x=Array.new(3,0)
k=0
ans=0
0.upto(999) do |i|
  k=0
  x=sprintf("%03d",i).split("").map(&:to_s)
  if p1=s.index(x[0])
    if p2=s.index(x[1],p1+1)
      if p3=s.index(x[2],p2+1)
        ans+=1
      end
    end
  end
end
puts ans


Measured memory_bytes: 14408
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        sc.close();
        if(S.replace("A", "").length() == 0 || S.replace("A", "").length() == 3){
            System.out.println("No");            
        }else{
            System.out.println("Yes");
        }
        
        
    }

}


Measured memory_bytes: 22996
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		Array.Sort(A);
		Array.Reverse(A);
		
		int ans = 0;
		for(int i=0;i+1<2*N;i+=2){
			ans += A[i+1];
		}
		
		Console.WriteLine(ans);
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 2776
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define iter(a, b, c) for(auto(a) = (b); (a) < (c); ++(a))

using namespace std;
using namespace __gnu_pbds; 

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pp;
typedef vector<pp> vpp;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef tree<int, null_type, less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int fpower(int x, unsigned int y, int p)  
{  
    int res = 1; 
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}  

int minimum(int x,int y){
    if(x<y)
        return x;
    else return y;
}

int maximum(int x,int y){
    if(x>y)
        return x;
    else return y;
}

int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

int lcm(int a,int b){
    return (a*b/gcd(a,b));
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    char c;
    cin>>c;
    if(c>='A' && c<='Z')
        cout<<'A';
    else
        cout<<'a';
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s; cin >> s;
    int count = 0, s_size = s.size();

    for(int i = 2; i < s_size - 1; ++i) {
        if(s[i] == 'C') ++count;
    }
    if(s[0] != 'A') { cout << "WA"; return 0; }

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

    if(s[1] == 'C' && count == 1) {
        for(int i = 2; i < s_size; ++i) {
            if(int(s[i]) < int('a')) {
                cout << "WA"; return 0;
            }
        }cout << "AC";
    } else cout << "WA";
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun May 19 21:11:48 2019

@author: Yamazaki Kenichi
"""

S = input()

a = int(S[:2])
b = int(S[2:])

if a > 0 and a <= 12:
    if b > 0 and b <= 12:
        ans = 'AMBIGUOUS'
    else:
        ans = 'MMYY'
else:
    if b > 0 and b <= 12:
        ans = 'YYMM'
    else:
        ans = 'NA'
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int x;
    cin >> x;
    if(x%100<=x/100*5)cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		ArrayList<Integer> ary = new ArrayList<>();
		for(int i=0; i<6; i++) {
			ary.add(sc.nextInt());			
		}
		
		long countTown1 = ary.stream().filter(t -> t == 1).count();
		long countTown2 = ary.stream().filter(t -> t == 2).count();
		long countTown3 = ary.stream().filter(t -> t == 3).count();
		long countTown4 = ary.stream().filter(t -> t == 4).count();


		if(countTown1 > 2 || countTown2 > 2 || countTown3 > 2 || countTown4 > 2 ) {
			System.out.print("NO");			
		} else {
			System.out.print("YES");
		}
	}
}


Measured memory_bytes: 28756
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#define ll long long int
#define MOD 1000000007LL
using namespace std; 

int main() {
    string s,t;
    cin>>s>>t;
    int sl=s.length();
    int tl=t.length();
    if(sl<tl){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }
    for(int i=sl-tl;i>=0;i--){
        int f=0;
        for(int j=0;j<tl;j++){
            if((s[j+i]==t[j])||(s[j+i]=='?')){
                continue;   
            }else{
                f=1;
                break;
            }
        }
        if(f==0){
            for(int j=0;j<tl;j++){
                if(s[j+i]=='?'){
                    s[j+i]=t[j];
                }
            }
            break;
        }else if(i==0){
            cout<<"UNRESTORABLE"<<endl;
            return 0;
        }
    }
    for(int i=0;i<sl;i++){
        if(s[i]=='?'){
            cout<<'a';
        }else{
            cout<<s[i];
        }
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

signed main(void) {
    int N, K;
    cin >> N >> K;

    int ans=0;
    for(int M=N; M>=1; M--) {
        if ((M*2)%K != 0) continue;
        int s = (M-1)/K;
        //パターン1
        ans += s*(s-1)*6/2;
        //パターン2, 3
        ans += s * 3 * 2;
        //パターン4
        ans += 1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        System.setOut(new PrintStream(new BufferedOutputStream(System.out)));

        List<Integer> numberList = new ArrayList<>();
        for (int i = 1; i <= 100000; i += 2) {
            if (isPrime(i) && isPrime((i + 1) / 2)) {
                numberList.add(i);
            }
        }
        int[] numbers = numberList.stream().mapToInt(i -> i).toArray();
        // System.out.println(numbers.size());

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int q = Integer.parseInt(reader.readLine());
        for (int i = 0; i < q; i++) {
            String[] words = reader.readLine().split(" ");
            int l = Integer.parseInt(words[0]);
            int r = Integer.parseInt(words[1]);
            int count = count(numbers, r) - count(numbers, l - 1);
            System.out.println(count);
        }
        System.out.flush();
    }

    private static int count(int[] xs, int x) {
        int returnValue = Arrays.binarySearch(xs, x);
        if (returnValue >= 0) {
            return returnValue + 1;
        } else {
            return -returnValue - 1;
        }
    }

    private static boolean isPrime(int x) {
        return BigInteger.valueOf(x).isProbablePrime(100);
    }
}


Measured memory_bytes: 107308
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>
#include <list>

using namespace std;
 int main(){
     long long s;
     cin >> s;
     long long n=(s-1)/1000000000+1;
     cout <<"0 0 1 1000000000 " << n << ' ' << n*1000000000-s << endl;
 }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

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

    int former = s / 100;
    int latter = s % 100;

    string ans;
    if (1 <= former && former <= 12)
    {
        if (1 <= latter && latter <= 12)
        {
            ans = "AMBIGUOUS";
        }
        else
        {
            ans = "MMYY";
        }
    }
    else
    {
        if (1 <= latter && latter <= 12)
        {
            ans = "YYMM";
        }
        else
        {
            ans = "NA";
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

class Program
{
    void Run()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int x = sc.NextInt();
        int[] l = new int[n];
        for (int i = 0; i < n;i++)
        {
            l[i] = sc.NextInt();
        }

        int res = 1;
        int d = 0;
        for (int i = 1; i <= n; i++)
        {
            d = d + l[i - 1];
            if (d <= x) res++;
        }
        Console.WriteLine(res);
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)

    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 13140
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.math;
import core.time;

void main()
{
	int n = readln.chomp.to!int;
	int[] a = 0 ~ readln.chomp.split.map!(to!int).array ~ 0;
	int sum = 0;
	int prev = 0;
	foreach (v; a) {
		sum += abs = prev - v;
		prev = v;
	}
	foreach (i; iota(1,a.length-1)) {
		int v = a[i];
		int sub = sum;
		sub -= abs = v - a[i - 1];
		sub -= abs = v - a[i + 1];
		sub += abs = a[i - 1] - a[i + 1];
		sub.writeln;
	}
}


Measured memory_bytes: 5368
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int count = sc.nextInt();
    String str = sc.next();

    count = count -2;

    int out = 0;

    for (int i = 0; i < count; i++) {
      if ('A' == str.charAt(i)) {
        if ('B' == str.charAt(i + 1)) {
          if ('C' == str.charAt(i + 2)) {
            out++;
          }
        }
      }
    }
    System.out.println(out);
  }
}


Measured memory_bytes: 21972
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int h,w,a,b;
int f[2000000];
const int base=1e9+7;
int pw(int n, int m, int base) {
    if (m==0) return 1;
    if (m%2==0) {
        int g=pw(n,m/2,base);
        return (1ll*g*g)%base;
    }
    else {
        int g=pw(n,m-1,base);
        return (1ll*n*g)%base;
    }
}
int cnk(int n, int k) {
    int a=f[n];
    int b=(1ll*f[k]*f[n-k])%base;
    a=(1ll*a*pw(b,base-2,base))%base;
    return a;
}
int get_path(int h, int w) {
    int moves=h+w-2;
    return cnk(moves,w-1);
}
int main() {
    ios_base::sync_with_stdio(0);
    cin >> h >> w >> a >> b;
    f[0]=1;
    for (int i=1;i<=h+w;i++) f[i]=(1ll*f[i-1]*i)%base;
    int ans=get_path(h,w);
    int last=0;
    for (int i=1;i<=b;i++) {
        int wy=get_path(h-a+1,i);
        wy-=last;
        wy=wy%base;
        last=get_path(h-a+1,i);
        ans-=(1ll*wy*get_path(a,w-i+1))%base;
        ans=ans%base;

    }
    if (ans<0) ans+=base;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

// 1-indexed
template <typename T=int>
struct BIT {
    vector<T> v;
    const int n;

    BIT(int n): n(n), v(n+1,0) {}

    void add(int i, int x) {
        while (i <= n) {
            v[i] += x;
            i += i & -i;
        }
    }
    T sum(int i) {
        T ret = 0;
        while (i > 0) {
            ret += v[i];
            i -= i & -i;
        }
        return ret;
    }
    T sum(int l, int r) {
        return sum(r) - sum(l-1);
    }
};

void solve() {
    int n,q;
    string s;
    cin >> n >> s >> q;
    int t,l,r;
    char c;
    vector<BIT<>> vb(26, BIT<>(n));
    REP(i,0,n) {
        vb[s[i]-'a'].add(i+1,1);
    }
    REP(i,0,q) {
        cin >> t;
        if (t == 1) {
            cin >> l >> c;
            vb[s[l-1]-'a'].add(l,-1);
            s[l-1] = c;
            vb[s[l-1]-'a'].add(l,1);
        } else {
            cin >> l >> r;
            int ans = 0;
            REP(j,0,26) ans += (vb[j].sum(l,r) > 0);
            cout << ans << endl;
        }
    }
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 53672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int A, B, C, D, E, F;
int main () {
  cin >> A >> B >> C >> D >> E >> F;

  pair<int, int> ans;
  double c = -1;
  for(int x = 0; 100*A*x <= F; ++x) {
    for(int y = 0; 100*A*x + 100*B*y <= F; ++y) {
      int a = 100*A*x + 100*B*y;
      for(int s = 0; C*s*100 <= E*a && a + C*s <= F; ++s) {
        for(int t = 0; a + C*s + D*t <= F && 100*(C*s + D*t) <= E*a; ++t) {
          int b = C*s + D*t;
          double cc = double(100)*b/(a+b);
          if(cc > c) {
            ans = make_pair(a+b, b);
            c = cc;
          }
        }
      }
    }
  }

  cout << ans.first << " " << ans.second << endl;
  return 0;
}


Measured memory_bytes: 256
n=0
l= []
while True:
	X,op,Y= input().split()
	x= int(X)
	y= int(Y)
	if(op== '?'):
		break
	elif(op== '+'):
		l.append(x+y)
	elif(op== '*'):
		l.append(x*y)
	elif(op== '-'):
		l.append(x-y)
	elif(op== '/'):
		l.append(x//y)
	n+=1
for i in range(n):
	print(l[i])

Measured memory_bytes: 7660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
import java.util.Queue;
import java.util.ArrayDeque;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        Main m = new Main();
        m.solve();
    }
    private void solve() throws Exception {
        FastScan scan = new FastScan(System.in);
        int N = scan.scanInt();
        List<List<Path>> graph = new ArrayList(N);
        for (int i = 0; i < N; i++) {
            graph.add(new ArrayList<>());
        }
        for (int i = 0; i < N - 1; i++) {
            int a = scan.scanInt()-1;
            int b = scan.scanInt()-1;
            int c = scan.scanInt();
            graph.get(a).add(new Path(b, c));
            graph.get(b).add(new Path(a, c));
        }
        int Q = scan.scanInt();
        int K = scan.scanInt()-1;
        Queue<Integer> queue = new ArrayDeque<>();
        long[] distances = new long[N];
        boolean[] visited = new boolean[N];
        queue.add(K);
        while(!queue.isEmpty()) {
            int current = queue.poll();
            visited[current] = true;
            for (Path p : graph.get(current)) {
                if (visited[p.to]) {
                    continue;
                }
                distances[p.to] = distances[current] + p.cost;
                queue.add(p.to);
            }
        }
        for (int i = 0; i < Q; i++) {
            int from = scan.scanInt() - 1;
            int to = scan.scanInt() - 1;
            System.out.println(distances[from] + distances[to]);
        }
    }

    class Path {
        int to;
        int cost;
        Path(int to, int cost) {
            this.to = to;
            this.cost = cost;
        }
    }
    class FastScan {
        BufferedReader br;
        StringTokenizer st;
        FastScan(InputStream is) {
            InputStreamReader isr = new InputStreamReader(is);
            this.br = new BufferedReader(isr);
        }
        String next() throws IOException {
            while (this.st == null || !this.st.hasMoreTokens()) {
                this.st = new StringTokenizer(br.readLine().trim());
            }
            return st.nextToken();
        }
        long scanLong() throws IOException {
            return Long.parseLong(this.next());
        }
        int scanInt() throws IOException {
            return Integer.parseInt(this.next());
        }
        double scanDouble() throws IOException {
            return Double.parseDouble(this.next());
        }
        char scanCharacter() throws IOException {
            return this.next().charAt(0);
        }
        String nextLine() throws IOException {
            return br.readLine().trim();
        }
    }
}


Measured memory_bytes: 76796
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;
	int tn = N;
	int f = 0;
	rep(i, 0, 8)
	{
		f += tn % 10;
		tn /= 10;
	}

	if (N%f == 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

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

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


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

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

#define fill(a,x) memset(a,x,sizeof(a)) 
#define pb push_back
#define sz(x) (int)x.size() 
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const int N = 2e5+10; 

int nxt[N][26];
int dp[N];
int main(){
  fast;
  string s;
  cin>>s;

  FOR(i,0,25)
  nxt[sz(s)][i]=sz(s);

  NFOR(i,sz(s)-1,0)
  {
  	FOR(j,0,25)
  	{
  		if(s[i]-'a'==j)
  			nxt[i][j]=i;
  		else
  			nxt[i][j]=nxt[i+1][j];
  	}
  }

  dp[sz(s)]=1;
  dp[sz(s)+1]=0;
  NFOR(i,sz(s)-1,0)
  {
  	dp[i]=sz(s)-i;
  	FOR(j,0,25)
  	{
  		dp[i]=min(dp[i],dp[nxt[i][j]+1]+1);
  	}
  	//cout<<i<<" "<<dp[i]<<endl;
  }


  int cur=0;
  string ans="";
  while(cur<sz(s))
  {
  	FOR(j,0,25)
  	{
  		if(dp[cur]==dp[nxt[cur][j]+1]+1)
  		{
  			//cout<<j<<" "<<nxt[cur][j]<<endl;
  			ans+='a'+j;
  			cur=nxt[cur][j]+1;
  			break;
  		}
  	}
  }

  cout<<ans;
  return 0;
}

Measured memory_bytes: 21652
N=int(input())
A=list(map(int,input().split()))
cnt=0
X=set()
for i in range(N):
  if(A[i]>=3200):
    cnt+=1
  else:
    X.add(A[i]//400)
if(len(X)):
  print(len(X),len(X)+cnt)
else:
  print(1,cnt)

Measured memory_bytes: 3060
n,m = map(int,input().split())
s_list = [list(map(int,input().split())) for _ in range(n)]
c_list = [list(map(int,input().split())) for _ in range(m)]

def distance(list1,list2):
    return abs(list1[0]-list2[0]) + abs(list1[1]-list2[1])

for i in range(n):
    student = s_list[i]
    distance_list = []
    for j,c in enumerate(c_list):
        dist = distance(student,c)
        distance_list.append(dist)
    print(distance_list.index(min(distance_list))+1)

Measured memory_bytes: 3188
# AGC 004 B
N, x = map(int,input().split())
A = list(map(int,input().split()))

M = [[float("inf")]*N for k in range(N)]
for k in range(N):
    M[0][k] = A[k]

for k in range(N):
    for l in range(N):
        M[k][l] = min(M[k-1][l],A[k-l])

ans = sum(A)
for k in range(1,N):
    ans = min(ans,sum(M[k])+x*k)

print(ans)


Measured memory_bytes: 140252
<?php


[$N,$T] = fscanf(STDIN, "%d%d");
$town = fscanf(STDIN, str_repeat("%d", $N));
$tele = array_fill(1,$N,0);
$tele[1] = 1;
$i = 0;
$now = 1;
while($T--){
    $now = $town[$now-1];

    if($tele[$now] === 1){
        $start = $now;
        $now = $town[$now-1];
        $count = 1;
        while($now != $start){
            $now = $town[$now-1];
            $count++;
        }
        $T %= $count;
        while($T--){
            $now = $town[$now-1];

        }
        break;
    }else{
        $tele[$now] = 1;
    }


}

echo $now;

Measured memory_bytes: 31124
#include <iostream>
using namespace std;
int main(){
  int A,B,C,X,Y,fee=1<<30;
  cin >> A >> B >> C >> X >> Y;
  //ABピザ2i枚買う場合
  for(int i=0;i<=max(X,Y);i++){
      fee = min(fee,A*max(0,X-i)+B*max(0,Y-i)+C*2*i);
  }
  cout << fee << endl;
  return 0;
}

Measured memory_bytes: 256
def cnt_car(w, p):
    car = 1
    wi = 0
    for i in w:
        if (wi + i) <= p:
            wi += i
        else:
            car += 1
            wi = i
    return car

n, k = map(int, input().split())
w = [int(input()) for i in range(n)]
p = max(max(w), sum(w) // k)
while True:
    if cnt_car(w, p) <= k:
        print(p)
        break
    else:
        #print("failed: ", p, cnt_car(w, p))
        if cnt_car(w, p + 100) > k:
            p += 100
        else:
            p += 1


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

int main(int argc, char const* argv[])
{
  int a, b, c;
  cin >> a >> b >> c;
  if (c >= a and c <= b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

int main() {
  int a, b, c, r = 0, l = 0;
  while (~scanf("%d,%d,%d", &a, &b, &c)) {
    if (a * a + b * b == c * c) r++;
    else if (a == b) l++;
  }
  printf("%d\n%d\n", r, l);
}


Measured memory_bytes: 2580
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >>n>>k;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  int ans;
  ans=(n-2)/(k-1)+1;
  cout << ans <<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e19;
#define MAX_N 200010
class UnionFind {
public:
	//UnionFind
	int par[MAX_N];
	int ufrank[MAX_N];
	int ufsize[MAX_N];
	UnionFind(int ufsize_of_tree) {
		for (int i = 0; i < ufsize_of_tree; i++)
		{
			par[i] = i;
			ufrank[i] = 0;
			ufsize[i] = 1;
		}
	}
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (ufrank[x] < ufrank[y]) {
			par[x] = y;
			int sx = ufsize[x], sy = ufsize[y];
			ufsize[x] = ufsize[y] = sx + sy;
		}
		else {
			par[y] = x;
			if (ufrank[x] == ufrank[y]) ufrank[x]++;
			int sx = ufsize[x], sy = ufsize[y];
			ufsize[x] = ufsize[y] = sx + sy;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};
//////////////////////////////////////////////////////////////////////
ll n, m;
ll x[100010], y[100010];
int main() {
	cin >> n >> m;
	rep(n)cin >> x[i];
	rep(m)cin >> y[i];
	
	ll X=0, Y=0;
	rep(n-1) {
		ll sx;
		sx = (x[i + 1] - x[i])*(i+1) %mod;
		sx *= (n - i - 1); sx %= mod;
		X += sx; X %= mod;
	}
	rep(m - 1) {
	    ll sy;
		sy = (y[i + 1] - y[i])*(i+1) %mod;
		sy *= (m - i - 1); sy %= mod;
		Y += sy; Y %= mod;
	}
	cout << X * Y % mod << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
vector<int> graph[110];
int visited[110][110];
int edgecnt;
int main()
{
    int n;cin >> n;
    if(n%2){
        
        for(int i = 1;i < n-i;i++){
            graph[i].push_back(n-i);
            graph[n-i].push_back(i);
            visited[i][n-i] = 1;
            visited[n-i][i] = 1;
            edgecnt++;

        }
        cout << n*(n-1)/2 - edgecnt << endl;
        for(int i = 1;i <=n ;i++){
            for(int j = i+1;j <= n ;j++){
                
                if(!visited[i][j])printf("%d %d\n",i,j);
            }
        }

    }
    else{
        for(int i = 1;i < n-i+1;i++){
            graph[i].push_back(n-i+1);
            graph[i].push_back(n-i+1);
            visited[i][n-i+1] = 1;
            visited[n-i+1][i] = 1;
            edgecnt++;
        }
        cout << n*(n-1)/2 - edgecnt << endl;
        for(int i = 1;i <=n ; i++){
            for(int j = i+1;j <= n;j++){
                if(!visited[i][j])printf("%d %d\n",i,j);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  int x,a,b; cin >>x>>a>>b;
  if(x + a > 9){
    cout << "error";
  }
  else{
    cout << x+a;
  }
}

Measured memory_bytes: 3580
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)


n, m, k = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))

rA = list(itertools.accumulate(A))
rB = list(itertools.accumulate(B))
# print(rA, rB)

ia = bisect.bisect(rA, k)-1
ib = 0
while ib+1 < len(B) and rA[ia]+rB[ib+1] <= k:
    ib += 1
# print(ia, ib)
vmax = ia+ib

for i in reversed(range(ia)):
    while ib+1 < len(B) and rA[i] + rB[ib+1] <= k:
        ib += 1

    # print(i, ib)
    vmax = max(vmax, i+ib)

print(vmax)


Measured memory_bytes: 127948
#include<iostream>
using namespace std;
int main(){
int N,cnt=0,max=0,i;
cin>>N;
char S[N+1];
for(i=0;i<N;i++){
cin>>S[i];
if(S[i]=='I')cnt++;else cnt--;
if(max<cnt) max=cnt;
}
cout<<max<<endl;
return 0;
}

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

typedef long long ll;
typedef vector <bool> v_bool;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

ll A,B;
int main(){
  cin >> A >> B;
  v_ll x;
  x.push_back(A+B);
  x.push_back(A-B);
  x.push_back(A*B);
  sort(x.begin(),x.begin()+3);
  cout << x[2] << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int main(){
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int a[N];
    for(int i = 0;i < N;i++){
        cin >> a[i];
    }

    stable_sort(a, a + N);
    cout << a[N - 1] - a[0] << endl;

}

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

map<int,int> ma;
int N, a, ans;

int main() {
	cin >> N;
  	for (int i = 0; i < N; ++i) {
    	cin >> a;
        if (ma[a]) {
        	ans--;
          	ma[a] = 0;
        } else {
        	ans++;
          	ma[a] = 1;
        }
    }
    cout << ans;
}


Measured memory_bytes: 4864
def main():

  a = list(map(int,input().split()))
  
  sum = a[0]*a[2]
  for i in range(0,2):
    for j in range(2,4):
      if sum < a[i]*a[j]:
        sum = a[i]*a[j]
        
  print(sum)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
N,X,Y = gets.split.map { |s| s.to_i }
h = {}
for i in 1..N-1
  h[i] = 0
end
for i in 1..N-1
  for j in i+1..N
    d = [(j-i).abs, 
                 (X-i).abs+1+(j-Y).abs,
                 (Y-i).abs+1+(j-X).abs
    ].min
    h[d] += 1

  end
end
puts h.values

Measured memory_bytes: 1916
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}
    public static void Ans() {

			var inputArray = retreiveLongArray().OrderByDescending(x => x).ToArray();
			var inputCount = 3;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long A = inputArray[0];
			long B = inputArray[1];
			long C = inputArray[2];



			//答えの出力
			var ans = A*10 + B +C ;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


Measured memory_bytes: 28020
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
void read()
{
	int sum=0;
	char ch=getchar();
	while(ch<'0'||ch>'9')  ch=getchar();
	while(ch>='0'&&ch<='9')
	  {
	  	if(ch=='2')  sum++;
	  	ch=getchar();
	  }
	printf("%d",sum);
}
int main()
{
	read();
	return 0;
}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


using Weight = int;
using Capacity = int;
struct Edge {
    int src, co;
    Weight weight;
    Edge(int src, int co, Weight w) : src(src), co(co), weight(w) {}
};
using Graph = vector<vector<Edge>>;

// 根からの距離を
class depthTree {
public:
    vector<int> cost;
    depthTree(const Graph &g,int root): cost(g.size()) {
        dfs(g,root,-1,0);
    }

    void dfs(const Graph &g,int v,int p,int nc) {
        cost[v] = nc;
        for(auto &c : g[v]) {
            if (c.co != p) dfs(g,c.co,v,nc+c.weight);
        }
    }
};

void solve() {
    int N;
    cin >> N;
    Graph g(N);
    REP(_,N-1) {
        int v,w,wh;
        cin >> v >> w >> wh;
        v--;w--;
        g[v].emplace_back(v,w,wh);
        g[w].emplace_back(w,v,wh);
    }

    depthTree l(g,0);
    REP(i,N) {
        cerr << l.cost[i] << endl;
        if(l.cost[i]%2 == 0) cout << 0 << endl;
        else cout << 1 << endl;
    }
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 7296
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>

#define MAX 100005
using namespace std;
int n;
int num[MAX];

int main( )
{
	cin >> n;
	for(int j = 0; j < n; j++)
		scanf("%d",&num[j]);
	sort(num,num + n);
	long long a = 0,b = 0;
	for(int j = n - 1; j > 0; j--){
		if(num[j] == num[j - 1])
			if(a == 0)
				a = num[j],num[j] = num[j - 1] = -1;
			else if(b == 0)
				b = num[j],num[j] = num[j - 1] = -1;
	}
	cout << a*b << endl;
}



Measured memory_bytes: 640
// E - Two Currencies

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

const int MAX_N = 50;
const int MAX_COIN = 2500;
const ll INF = 9223372036854775807;
const int UNCONF = 0;
const int CONF = 1;

struct Edge {
	pair<int, int> to;
	ll cost;
};

struct Node {
	vector<Edge> edges;
	int status;
	ll min_cost;
};

// ダイクストラ法（優先度付きキューを使用）
// n: ノード数, start_idx: 開始ノードのインデックス
void Dijkstra(Node nodes[MAX_N][MAX_COIN + 1], int n, pair<int, int> start_idx) {
	for (int i=0; i<n; i++) {
		for (int j=0; j<=MAX_COIN; j++) {
			nodes[i][j].status = UNCONF;
			nodes[i][j].min_cost = INF;
		}
	}

	nodes[start_idx.first][start_idx.second].min_cost = 0;

	// PQ: <コスト, ノード番号>のpairを格納する優先度付きキュー（コストが大きいもの優先）
	priority_queue<pair<ll, pair<int, int>>, vector<pair<ll, pair<int, int>>>, greater<pair<ll, pair<int, int>>>> PQ;
	PQ.push(make_pair(0, start_idx));

	while (!PQ.empty()) {
		pair<ll, pair<int, int>> p = PQ.top();
		PQ.pop();
		ll cost = p.first;
		Node& node = nodes[p.second.first][p.second.second];

		if (cost > node.min_cost) continue; // 他にコストの低いルートが見つかったので使わない

		node.status = CONF;

		for (Edge edge : node.edges) {
			Node& next_node = nodes[edge.to.first][edge.to.second];
			ll next_cost = (edge.cost == INF) ? INF : node.min_cost + edge.cost;
			if (next_node.status != CONF) {
				if (next_cost < next_node.min_cost) {
					next_node.min_cost = next_cost;
					PQ.push(make_pair(next_cost, edge.to));
				}
			}
		}
	}
}

Node nodes[MAX_N][MAX_COIN + 1];
int U[100], V[100], A[100], B[100];
int C[50], D[50];

int main() {
	int N, M, S;
	cin >> N >> M >> S;

	for (int i=0; i<M; i++) {
		cin >> U[i] >> V[i] >> A[i] >> B[i];
		U[i]--;
		V[i]--;
		//nodes[U].edges.push_back(Edge{V, A, B});
		//nodes[V].edges.push_back(Edge{U, A, B});
	}

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

	// 都市間の移動
	for (int i=0; i<M; i++) {
		for (int j=A[i]; j<=MAX_COIN; j++) {
			nodes[U[i]][j].edges.push_back(Edge{make_pair(V[i], j-A[i]), B[i]});
			nodes[V[i]][j].edges.push_back(Edge{make_pair(U[i], j-A[i]), B[i]});
		}
	}

	// 銀貨の補充
	for (int i=0; i<N; i++) {
		for (int j=0; j<=MAX_COIN; j++) {
			nodes[i][j].edges.push_back(Edge{make_pair(i, min(MAX_COIN, j+C[i])), D[i]});
		}
	}

	Dijkstra(nodes, N, make_pair(0, min(MAX_COIN, S)));

	for (int i=1; i<N; i++) {
		ll ans = INF;
		for (int j=0; j<=MAX_COIN; j++) {
			ans = min(ans, nodes[i][j].min_cost);
		}
		cout << ans << endl;
	}

	return 0;
}

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

int dat[200010];
int count[200010];

void init(int N){ 
    for(int i=0; i<N; i++){
        dat[i] = i;
    }   
}

int find(int v)
{
    int x = v, z;
    while(x != dat[x])  x = dat[x];
    while(v != dat[v]){
        z = dat[v];
        dat[v] = x;
        v = z;    
    }   
    return x;
}

void unio(int v,int u)
{
    int t1 = find(v);
    int t2 = find(u);
    dat[t2] = t1; 
}

int main(){
    int N, M;
    scanf("%d %d", &N, &M);
    init(N);
    for(int i=0; i<M; ++i){
        int a, b;
        scanf("%d %d", &a, &b);
        unio(a-1, b-1);
    }   
    memset(count, 0, N*sizeof(int));
    for(int i=0; i<N; ++i){
        int r = find(i);
        count[r]++;
    }   

    int max = 0;
    for(int i=0; i<N; ++i){
        if(max < count[i])
            max = count[i];
    }   
    printf("%d\n", max);
    return 0;
}


Measured memory_bytes: 5364
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    OPT[i][j] - number of solutions for s[:i] and ends in j uses only 1..i

    OPT[i+1][j] = sum(OPT[i][k]) k > j               if s[i+1] = '>'
    OPT[i+1][j] = sum(OPT[i][k]) k < j
    """
    N = read_int()
    s = input().strip()
    dp = [0]*N
    dp[0] = 1
    new_dp = [0]*N
    modulo = 10**9+7
    for i in range(1, N):
        T = 0
        if s[i-1] == '<':
            for j in range(1, i+1):
                T = (T+dp[j-1])%modulo
                dp[j-1] = 0
                new_dp[j] = T
        else: #s[i-1] == '>'
            for j in range(i, -1, -1):
                T = (T+dp[j])%modulo
                dp[j] = 0
                new_dp[j] = T
        dp, new_dp = new_dp, dp
    return sum(dp)%modulo


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


Measured memory_bytes: 40048
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long x[5];
    ll ans;
    for(size_t i=0;i<5; i++)
    {
        cin >> x[i];
        if(x[i] == 0) ans = i+1;
    }
    cout << ans << endl;

#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long LL;
LL my_max(LL a,LL b)
{
    return a>b ?a:b;
}
int main()
{
    LL N,M;
    scanf("%lld %lld",&N,&M);
    if(M==1 && N==1)
        printf("1");
    else
    if(M==1 || N==1)
        printf("%lld\n",my_max(0,my_max(N, M)-2));
    else
        printf("%lld\n",(N-2)*(M-2));
    return 0;
}


Measured memory_bytes: 128
K = int(input())

def nextInts(n):
    if n == 0:
        return (0, 1)
    elif n == 9:
        return (8, 9)
    else:
        return (n-1, n, n+1)

class C:
    cnt = 0
    
    def f(self, t, d, a, s, K): # t: 前の桁の値, d: 残り桁数(この桁を含む), a: 今の値
        if self.cnt == K:
            return
        if d == 0:
            #print(a)
            self.cnt += 1
            if self.cnt == K:
                print(a)
                
            return
        
        l = range(1, 10) if s else nextInts(t)
        for x in l:
            self.f(x, d-1, a * 10 + x, False, K)


c = C()
q = 1
while c.cnt != K:
    c.f(0, q, 0, True, K)
    q += 1




Measured memory_bytes: 3064