akhauriyash/Code-Regression huggingface dataset:
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define eps 0.00000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int n;
	cin >> n;
	vector<long long> hoge;
	REP(i, n) {
		long long a;
		cin >> a;
		hoge.push_back(a);
	}
	sort(hoge.begin(), hoge.end());
	long long ans = 0;
	for (int i = n - 2;i >= 0;--i) {
		if (hoge[i] == hoge[i + 1]) {
			if (ans == 0) {
				ans = hoge[i];
				i--;
			}else{
				ans *= hoge[i];
				cout << ans << endl;
				return 0;
			}
		}
	}
	cout << 0 << endl;
}

Measured memory_bytes: 2032
L =[]
for i in range(3):
    a,b,c = map(int,input().split())
    L.append([a,b,c])

#print(L)
n = int(input())
li = []
for i in range(n):
    li.append(int(input()))
    
for i in range(3):
    if (L[i][0] in li) and (L[i][1] in li) and (L[i][2] in li ):
        print("Yes")
        exit()
if (L[0][0] in li) and (L[1][1] in li) and (L[2][2] in li ):
    print("Yes")
    exit()
if (L[0][2] in li) and (L[1][1] in li) and (L[2][0] in li ):
    print("Yes")
    exit()
for i in range(3):
    if (L[0][i] in li) and (L[1][i] in li) and (L[2][i] in li ):
        print("Yes")
        exit()

print("No")

Measured memory_bytes: 3064
#include<stdio.h>
 
int main()
{
int ans = 0,K = 0,M=0;
scanf("%d",&K);
M = K / 2;
 
if(K % 2 == 0)
{
printf("%d",M*M);
}else{
printf("%d",M * (M + 1));
}
return 0;
}

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

int main()
{
    int n;
    scanf("%d", &n);
    if(n>=0 && n<=9) printf("%d", n);
    else if(n>=10 && n<=99) printf("9");
    else if(n>=100 && n<=999) printf("%d", 9+n-99);
    else if(n>=1000 && n<=9999) printf("909");
    else if(n>=10000 && n<=99999) printf("%d", 909+n-9999);
    else if(n==100000) printf("90909");


    return 0;
}


Measured memory_bytes: 128
function main(lines) {
  const N = +lines[0];
  const ls = splitN(lines[1]);
  
  let ans = 0;
  for (let i = 0; i < N; i++) {
    for (let j = i+1; j < N; j++) {
      for (let k = j+1; k < N; k++) {
        const a = ls[i], b = ls[j], c = ls[k];
        if (a != b && b != c && c != a
          && a+b > c && b+c > a && c+a > b)
          ans++;
      }
    }
  }
  
  return ans;
}


const ans = main( require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n") );
console.log( ans );

function splitN(s) {
  return s.split(' ').map(Number);
}


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

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

    vector<int>right(n,0);
    vector<vector<int>>exist(n,vector<int>(10,0));
    right[n-1] = 1;
    exist[n-1][s[n-1]-'0'] = true;


    for(int i=n-2;0<=i;i--){
        if(exist[i+1][s[i]-'0']==true){
            right[i] = right[i+1];
            copy(exist[i+1].begin(),exist[i+1].end(),exist[i].begin());
        }else{
            right[i] = right[i+1] + 1;
            copy(exist[i+1].begin(),exist[i+1].end(),exist[i].begin());
            exist[i][s[i]-'0'] = 1;
        }
    }

    vector<vector<int>>flag(10,vector<int>(10,0));
    vector<int>complete(10,0);

    int ans = 0;
    for(int i=0;i<n-2;i++){
        if(complete[s[i]-'0']==1) continue;
        for(int j=i+1;j<n-1;j++){
            if(flag[s[i]-'0'][s[j]-'0']==0){
                flag[s[i]-'0'][s[j]-'0'] = 1;
                ans += accumulate(exist[j+1].begin(),exist[j+1].end(),(int)0);
                if(accumulate(flag[s[i]-'0'].begin(),flag[s[i]-'0'].end(),(int)0)==10) complete[s[i]-'0']=1;
                // cout << i << ' ' << j << ' ' << ans << ' ' << endl;
            }
        }
    }
    cout << ans << endl;

    // for(int i=0;i<n;i++){
    //     for(int j=0;j<10;j++){
    //         cout << exist[i][j] << ' ';
    //     }cout << endl;
    // }

    // for(int i=0;i<s.length();i++){
    //     for(int j=i+1;j<s.length();j++){
    //         if 
    //     }
    // }
    return 0;
}

Measured memory_bytes: 3968
s = list(input())
n = len(s)
i, ans = 1, 1
lm = False

while i < n:
    if (s[i] == s[i-1]) and not lm:
        if i == n-1: break
        i += 2
        lm = True
    else:
        i += 1
        lm = False
    ans += 1

print(ans)

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

using namespace std;

int main(){

	int b,r,g,c,s,t;
	while(cin>>b>>r>>g>>c>>s>>t&&!(b==0&&r==0&&g==0&&c==0&&s==0&&t==0)){
		int left=t-b-r-g-c-s-b*5-r*3;
		int medal=100-left*3;
		medal+=b*12;
		medal+=(5*b)*13;
		medal+=r*12;
		medal+=(3*r)*13;

		medal+=g*4;
		medal+=c*(-1);

		cout<<medal<<endl;
	}


	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 2e7 + 9, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
    long long n;
    cin >> n;
    if(n >777777753)n=777777753;
    long long c=0;
    for(long long  i=357;i<=n;i+=2){
        long long a=i;
        bool is3=false,is5=false,is7=false;
        while(a){
            int b=a%10;
            if(b==3)is3=true;
            else if(b==5)is5=true;
            else if(b==7)is7=true;
            else {is3=false;break;}
            a/=10;
        }
        if(is3&&is5&&is7)c++;
    }



    cout << c << endl;


    return 0;

}


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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 60;

const int mod = 1e9 + 7;

template< class T >
struct ConvexHullTrickAddQueryMonotone {
  deque< pair< T, T > > L;
  int isdec;

  ConvexHullTrickAddQueryMonotone() : isdec(-1) {}

  inline T getX(const pair< T, T > &a, const T &x) {
    return (a.first * x + a.second);
  }

  inline bool check(const pair< T, T > &a, const pair< T, T > &b, const pair< T, T > &c) {
    return ((b.first - a.first) * (c.second - b.second) >= (b.second - a.second) * (c.first - b.first));
  }

  inline bool empty() { return (L.empty()); }

  void add(T a, T b) {
    pair< T, T > line(a, b);

    if(isdec == -1 && !L.empty()) {
      if(a < L[0].first) isdec = 1;
      else if(a > L[0].first) isdec = 0;
    }

    if(isdec == 1) {
      if(!L.empty() && L.back().first == a) {
        line.second = min(line.second, L.back().second);
        L.pop_back();
      }
      while(L.size() >= 2 && check(L[L.size() - 2], L.back(), line)) L.pop_back();
      L.emplace_back(line);
    } else {
      if(!L.empty() && L.front().first == a) {
        line.second = min(line.second, L.front().second);
        L.pop_front();
      }
      while(L.size() >= 2 && check(line, L[0], L[1])) L.pop_front();
      L.emplace_front(line);
    }
  }

  T getMinimumQuery(T x) {
    int low = -1, high = (int) L.size() - 1;
    while(high - low > 1) {
      int mid = (low + high) >> 1;
      if((getX(L[mid], x) >= getX(L[mid + 1], x))) low = mid;
      else high = mid;
    }
    return (getX(L[high], x));
  }

  T getMinimumQueryMonotone(T x) {
    while(L.size() >= 2 && getX(L[0], x) >= getX(L[1], x)) {
      L.pop_front();
    }
    return (getX(L[0], x));
  }
};


int main() {
  int N;
  int64 C;
  int64 H[200000];

  cin >> N >> C;
  for(int i = 0; i < N; i++) cin >> H[i];
  ConvexHullTrickAddQueryMonotone< int64 > conv;
  conv.add(2 * H[0], H[0] * H[0]);
  for(int i = 1; i < N; i++) {
    int64 uku = conv.getMinimumQuery(-H[i]) + H[i] * H[i] + C;
    if(i + 1 == N) {
      cout << uku << endl;
    }
    conv.add(2 * H[i], uku + H[i] * H[i]);
  }
}

Measured memory_bytes: 5120
n, a, b, c, d = map(int, input().split())
a, b, c, d = a-1, b-1, c-1, d-1
s = input()

if c < d:
    for i in range(b, d):
        if s[i] == "#" and s[i+1] == "#":
            print("No")
            exit()

    for i in range(a, c):
        if s[i] == "#" and s[i+1] == "#":
            print("No")
            exit()
    print("Yes")

else:
    for i in range(b, d+1):
        if s[i] != "#" and s[i-1] == "." and s[i+1] == ".":
            print("Yes")
            exit()

    print("No")

Measured memory_bytes: 3572
#include <stdio.h>
#define N 100005
#define s 100

typedef struct{
  char name[s];
  int time;
}Q;

Q A[N+1];
int h, t;

void ENQ(Q J){
  if( N==t ) t = 0;
  A[t] = J;
  t++;
}
Q DEQ(void){
  if( h==N ) h = 0;
  return A[h++];
}

int main(){
  int n, q, i, T=0;
  Q u;
  scanf("%d %d", &n, &q);

  for(i=0;i<n;i++){
    scanf("%s %d", u.name, &u.time);
    ENQ(u);
  }
  while(n!=0){
    u = DEQ();
    if(u.time>q){
      u.time = u.time - q;
      T += q;
      ENQ(u);
    }
    else{
      T += u.time;
      printf("%s %d\n", u.name, T);
      n--;
    }
  }
  return 0;
}

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

int main() {
    
    int n;
    cin >> n;
    int t[n];
    int sum =0;
    for(int i=0; i<n; i++) {
        int s;
        cin >> s;
        t[i]=s;
        sum+=s;
    }
    int m;
    cin >>m;
    for (int i=0; i<m; i++) {
        int p,x;
        cin >> p >> x;
        cout << sum-t[p-1]+x << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : August 30, 2020 12:34 PM
 *    Problem Name  : C - Next Prime
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc149/tasks/abc149_c
 *    @genarated by : ai-virtual-assistant
**/

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

vector<ll>v;
bool arr[10000000+10];
void sieve()
{
  v.push_back(2);
  for(ll i=4; i<=sz; i+=2 )
    arr[i]=1;
  for(ll i=3; i<=sz; i+=2){
      if(!arr[i]){
        v.push_back(i);
        if(i*i<=sz){
          for(ll j=i*i; j<=sz; j+=i+i){
            arr[j]=1;
          }
        }
      }
      
    }
}

int main(){
    ios_base::sync_with_stdio(false);

    sieve();
    ll x;
    cin >> x;

    for(ll i=0; i<v.size(); i++){
        if(v[i] >= x){
            cout << v[i] << endl;
            break;
        }
    }

    return 0 ;
}


Measured memory_bytes: 3884
n=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
sum=0
for i in range(n):
  if a[i]>=b[i]:
    sum+=b[i]
  else:
    if a[i]+a[i+1]>=b[i]:
      sum+=b[i]
      a[i+1]-=b[i]-a[i]
    else:
      sum+=a[i]+a[i+1]
      a[i+1]=0
print(sum)
    

Measured memory_bytes: 19116
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <bitset>
#include <functional>
#include <set>
#include <map>
#include <array>

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
//#define int long long int
const int MOD = 1000000007;
const int INF = 1001001000;
const double EPS = 0.000000001;

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

bool pairCompare(const P& pair1, const P& pair2) {
    return pair1.second > pair2.second;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  string s;
  int k;
  cin >> n >> k;
  cin >> s;
  if(s[k-1] == 'A') s[k-1] = 'a';
  else if(s[k-1] == 'B') s[k-1] = 'b';
  else s[k-1] = 'c';
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
constexpr ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a, b; cin >> a >> b;
    cout << lcm(a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
# 最大公約数
def gcd(a,b):
    while b != 0:
        a,b = b, a%b
    return a

# 最小公倍数

def lcm(a,b):
    return a*b // gcd(a,b)


a,b,c,d = map(int,input().split())

def mod(x,y):
    return x // y if x % y == 0 else x //y + 1

cc = b // c - mod(a,c)+1
dd = b // d - mod(a,d)+1
cd = b // lcm(c,d) - mod(a,lcm(c,d))+1
print(b-a+1-cc-dd+cd)

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
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 (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n; cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    vector<ll> r(n, 0);
    DSRNG(i, n, 1) {
        ll s = 0;
        for (ll j = i; j <= n; j += i) {
            s ^= r[j-1];
        }
        r[i-1] = s ^ a[i-1];
    }
    vector<ll> ans; ans.reserve(n);
    REP(i, n) if (r[i]) ans.push_back(i+1);

    cout << ans.size() << endl;
    REP(i, ans.size()) cout << ans[i] << " \n"[i == i_len-1];
    
}

Measured memory_bytes: 4864
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String key = sc.next();
    int count = 0;
    String ans = "NO";
    
    if(key.equals("keyence")){
      ans = "YES";
    }else
    if('k'!=key.charAt(0)){
      count = 7;
    }else
    if('k'==key.charAt(0)&&'e'!=key.charAt(1)){
      count = 6;
    }else
    if('k'==key.charAt(0)&&'e'==key.charAt(1)&&'y'!=key.charAt(2)){
      count = 5;
    }else
    if('k'==key.charAt(0)&&'e'==key.charAt(1)&&'y'==key.charAt(2)
       &&'e'!=key.charAt(3)){
      count = 4;
    }else
    if('k'==key.charAt(0)&&'e'==key.charAt(1)&&'y'==key.charAt(2)
       &&'e'==key.charAt(3)&&'n'!=key.charAt(4)){
      count = 3;
    }else
    if('k'==key.charAt(0)&&'e'==key.charAt(1)&&'y'==key.charAt(2)
       &&'e'==key.charAt(3)&&'n'==key.charAt(4)&&'c'!=key.charAt(5)){
      count = 2;
    }else
    if('k'==key.charAt(0)&&'e'==key.charAt(1)&&'y'==key.charAt(2)
       &&'e'==key.charAt(3)&&'n'==key.charAt(4)&&'c'==key.charAt(5)
      &&'e'!=key.charAt(6)){
      count = 1;
    }else
    if('k'==key.charAt(0)&&'e'==key.charAt(1)&&'y'==key.charAt(2)
       &&'e'==key.charAt(3)&&'n'==key.charAt(4)&&'c'==key.charAt(5)
      &&'e'==key.charAt(6)){
      ans = "YES";
    }
    
    int last = key.length();
    
    if(count==1 && 'e'==key.charAt(last-1)){
      ans = "YES";
    }else
    if(count==2 && 'e'==key.charAt(last-1) && 'c'==key.charAt(last-2)){
      ans = "YES";
    }else
    if(count==3 && 'e'==key.charAt(last-1) && 'c'==key.charAt(last-2)
      && 'n'==key.charAt(last-3)){
      ans = "YES";
    }else
    if(count==4 && 'e'==key.charAt(last-1) && 'c'==key.charAt(last-2)
      && 'n'==key.charAt(last-3) && 'e'==key.charAt(last-4)){
      ans = "YES";
    }else
    if(count==5 && 'e'==key.charAt(last-1) && 'c'==key.charAt(last-2)
      && 'n'==key.charAt(last-3) && 'e'==key.charAt(last-4)
      && 'y'==key.charAt(last-5)){
      ans = "YES";
    }else
    if(count==6 && 'e'==key.charAt(last-1) && 'c'==key.charAt(last-2)
      && 'n'==key.charAt(last-3) && 'e'==key.charAt(last-4)
      && 'y'==key.charAt(last-5) && 'e'==key.charAt(last-6)){
      ans = "YES";
    }else
    if(count==6 && 'e'==key.charAt(last-1) && 'c'==key.charAt(last-2)
      && 'n'==key.charAt(last-3) && 'e'==key.charAt(last-4)
      && 'y'==key.charAt(last-5) && 'e'==key.charAt(last-6)
      && 'k'==key.charAt(last-7)){
      ans = "YES";
    }

    System.out.println(ans);
    
  }
}

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

#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcd(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

template <class Abel> class WeightedUnionFind {
  private:
    std::vector<int> par;
    std::vector<int> rank;
    std::vector<Abel> diff_weight;

  public:
    WeightedUnionFind(int n, Abel SUM_UNITY = 0) : par(n), rank(n, 0), diff_weight(n, SUM_UNITY) {
      for(int i = 0; i < n; ++i) par[i] = i;
    }

    Abel weight(int x) {
      find(x);
      return diff_weight[x];
    }

    int find(int x) {
      if(x == par[x]) return x;

      int r = find(par[x]);
      diff_weight[x] += diff_weight[par[x]];
      return par[x] = r;
    }

    void unite(int x, int y, Abel w) {
      w += weight(x);
      w -= weight(y);
      x = find(x);
      y = find(y);

      if(x == y) return;
      if(rank[x] < rank[y]) {
        std::swap(x, y);
        w = -w;
      }
      par[y] = x;
      diff_weight[y] = w;
      if(rank[x] == rank[y]) rank[x]++;
    }

    bool same(int x, int y) {
      return find(x) == find(y);
    }

    Abel diff(int x, int y) {
      return weight(y) - weight(x);
    }
};


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

  int n, q;
  cin >> n >> q;
  WeightedUnionFind<int> uf(n);
  rep(i, 0, q) {
    int c, x, y;
    cin >> c >> x >> y;
    if(c == 0) {
      int z;
      cin >> z;
      uf.unite(x, y, z);
    }
    else {
      if(uf.same(x, y)) cout << uf.diff(x, y) << endl;
      else cout << '?' << endl;
    }
  }
}


Measured memory_bytes: 4148
#include<stdio.h>
#include<string.h>
int main(){
  int n;
  char S[10001];
  char test = 'z';//122
  scanf("%d",&n);
  scanf("%s",S);

  for(int i=0;i<strlen(S);i++){

    for(int k=0;k<n;k++)
      {
	if(S[i]=='Z'){
	  S[i]='A';
	}else {
	  S[i]++;
	}
      }
  }
  printf("%s\n",S);
  

  return 0;

  
  
}


Measured memory_bytes: 128
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
prime = [True] * (10 ** 6 + 10)
 
b = sorted(set(a))
 
for i in b:
    num = i * 2
    while True:
        if num >= 10 ** 6 + 10:
            break
        prime[num] = False
        num += i
 
ans = 0
for s in a:
    if prime[s] == True and c[s] == 1:
        ans += 1
 
print(ans)

Measured memory_bytes: 166220
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int n;
	int suretu[100];
	int counter = 0;
	int mini;
	
	cin >> n;
	
	for (int i = 0; i < n; ++i) {
		cin >> suretu[i];
	}

	for (int i = 0; i < n; ++i) {
		mini = i; 
		for (int j = i; j < n; j++) {
			if (suretu[j] < suretu[mini]) {
				mini = j;
			}
		}
		if (i != mini) {
			swap(suretu[i], suretu[mini]);
			counter++;
		}
	}

	cout << suretu[0] << flush;

	for (int i = 1; i < n; i++) {
		cout << ' ' << suretu[i];
	}

	cout << endl << counter << endl; 

	return 0;
}

Measured memory_bytes: 1160
def main():
    # 町の数N, 町iの転送先はindexがAi-1の町
    N,K = map(int, input().split())
    A = list(map(int, input().split()))

    # K回移動した時の町番号を出力
    # もし一度出てきた番号が出てきたら記憶している道順リストを使う
    # 最初は道を覚えさせる作業が必要
    now = 0
    history = [0]
    isVisited = [False for i in range(N)]
    i = 0
    while i<K:
        # まず進む
        now = A[now]-1
        # 道順登録
        #if now not in history:
        if isVisited[now] == False:
            history.append(now)
            isVisited[now] = True
            i+=1
        # 以前出てきてる町ならそこから末尾までを自動で進めてiのカウントも進める
        else:
            start = history.index(now)
            r = start + (K-1-i)%(len(history)-start)
            now = history[r]
            break

    print(now+1)

main()


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

vector<bitset<5001>> dp(5050);

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  a.resize(lower_bound(a.begin(), a.end(), k) - a.begin());

  n = a.size();
  if (n == 0) {
    cout << 0 << endl;
    return 0;
  }

  auto f = [&](int i) {
    dp[0][0] = true;
    for (int j = 0; j < n; j++) {
      if (i == j) {
        dp[j + 1] = dp[j];
      } else {
        dp[j + 1] = dp[j] | (dp[j] << a[j]);
      }
    }

    bool ok = false;
    for (int j = k - a[i]; j < k; j++) if (dp[n][j]) ok = true;
    return ok;
  };
  ll l = 0, r = n;
  if (f(l)) {
    cout << 0 << endl;
    return 0;
  }
  while (r - l > 1) {
    ll m = (r + l) / 2;
    if (f(m)) {
      r = m;
    } else {
      l = m;
    }
  }
  cout << r << endl;

  return 0;
}


Measured memory_bytes: 3456
# ライブラリのインポート
#import re #正規表現
#import sys
import heapq
#import collections


def main():
    tempheap = []
    while(1):
        instr = input()
        if instr[2] == 'd': break
        if instr[0] == 'i': heapq.heappush(tempheap, -int(instr[7:]))
        else: 
            print(-heapq.heappop(tempheap))

    


    
if __name__ == '__main__':
    main()



Measured memory_bytes: 45308
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define de cout<<"debuglandınız\n";
ll int n,c,i,j,ans;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >> n >> c;
	long long int kutle[n+1],deger[n+1];
	for(i=1;i<=n;i++)cin>>kutle[i]>>deger[i];
	long long int dp[n+1][c+1];
	for(i=0;i<=n;i++)for(j=0;j<=c;j++)dp[i][j]=0;
	for(i=1;i<n+1;i++){
		for(j=1;j<=c;j++){
			if(dp[i-1][j]){
				dp[i][j]=max(dp[i-1][j],dp[i][j]);
				if(kutle[i]+j<=c)dp[i][j+kutle[i]]=max(dp[i][j+kutle[i]],dp[i-1][j]+deger[i]);
			}
		}
		if(kutle[i]<=c)dp[i][kutle[i]]=max(dp[i][kutle[i]],deger[i]);
	}
	for(i=1;i<=c;i++){
		ans=max(ans,dp[n][i]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 79104
def main() :
    N,M = [int(i) for i in input().split()]

    if (N > 2) :
        rows = N-2
    elif (N == 1) :
        rows = 1
    else :
        print("0")
        return
    
    if (M > 2) :
        cols = M-2
    elif (M == 1):
        cols = 1
    else :
        print("0")
        return

    print(rows * cols)

main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
#define int long long int
#define ff first
#define ss second
#define pb push_back
 
int bexp(int a, int b, int mod)
{
    int res = 1;
    if (mod <= 0)
        return 0;
 
    while (b)
    {
        if (b & 1) res = (res * a) % mod;
 
        a = (a * a) % mod; 
        b >>= 1;
    }
    return res;
}
 
#define N 300010
#define MOD 1000000007
 
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

struct comp {
    bool operator() (const pair<int, int> a, const pair<int, int> b) const
    {
        return a.ss * (a.ff - a.ff / 2) > b.ss * (b.ff - b.ff / 2);
    }
};

vector<vector<pair<int, int>>> g;
int up[N][30];
int mi[N][30];
int in[N], out[N];
int tim = 0;
int dep[N];

void dfs(int v, int p, int de, int wei)
{
    up[v][0] = p;
    mi[v][0] = wei;
    in[v] = tim++;
    dep[v] = de;

    for (int i = 1; i < 30; ++i)
    {
        up[v][i] = up[up[v][i - 1]][i - 1];
        mi[v][i] = min(mi[up[v][i - 1]][i - 1], mi[v][i - 1]);
        // cout << mi[v][i] << ":: ";
    }

    for (auto k : g[v])
    {
        if (k.ff != p)
        {
            dfs(k.ff, v, de + 1, k.ss);
        }
    }

    out[v] = tim++;
}

int is_ances(int u, int v)
{
    return in[u] <= in[v] && out[u] >= out[v];
}

int lca(int u, int v)
{
    if (is_ances(u, v))
        return u;
    if (is_ances(v, u))
        return v;

    for(int i = 29; i >= 0; --i)
        if(!is_ances(up[u][i], v))
            u = up[u][i];
    
    return up[u][0];
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

    int d, s, t;
    cin >> d >> s >> t;

    if (d <= s * t)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
int v;
vector<int> G[205];
int match[205];
bool used[205];

void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
}

bool dfs(int v){
    used[v]=true;
    for(int i=0; i<G[v].size();i++){
        int u=G[v][i],w=match[u];
        if(w<0||(!used[w]&&dfs(w))){
            match[v]=u;
            match[u]=v;
            return true;
        }
    }
    return false;
}
int bipartite_matching(){
    int res=0;
    memset(match,-1,sizeof(match));
    rep(i,0,v){
        if(match[i]<0){
            memset(used,0,sizeof(used));
            if(dfs(i))res++;
        }
    }
    return res;
}
signed main(){
    cin>>v;
    P s[105],t[105];
    rep(i,0,v){
        cin>>s[i].first>>s[i].second;
    }
    rep(i,0,v){
        cin>>t[i].first>>t[i].second;
    }
    rep(i,0,v){
        rep(j,0,v){
            if(t[i].first>s[j].first&&t[i].second>s[j].second)add_edge(j,i+v);
        }
    }v*=2;
    cout<<bipartite_matching()<<endl;return 0;
}


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

int a, b, m = -1;

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

	for (int i = 1009; i >= 10; i--) {
		if (i * 2 / 25 == a && i / 10 == b)
			m = i;
	}

	cout << m << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n,k;
	cin>>n>>k;
	if(k==1)cout<<"0\n";
	else cout<<n-k<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

/*******************************************************/

int main() {
  string s; cin >> s;
  ll n = s.length();
  ll ans = n * (n - 1) / 2 + 1;
  map<char, ll> mp;
  Loop(i, n) mp[s[i]]++;
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    ll k = itr->second;
    ans -= itr->second * (itr->second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int x;
    cin >> x;
    if (x == 3 || x == 5 || x == 7) {
        YES;
    }else{
        NO;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

int main(){

    ll a, b, c;
    cin >> a >> c >> b;
    if(a < b && b < c)cout << "Yes" << endl;
    else if(a > b && b > c)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  vector<int> v(N);
  
  for(int i=0;i<N;i++){
    cin >> v.at(i);
  }
  
  int ans = 0;
  for(int j=0;j<N-1;j++){
    for(int k=j+1;k<N;k++){
    ans += v.at(j) * v.at(k);
    }
  }
  
  cout<< ans<< endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  ll N, K; cin >> N >> K;
  if (K == 0){
    cout << N * N << endl;
    return 0;
  }
  ll ans = 0;
  for (ll i = K + 1; i <= N; i++){
    ll now = (i - K) * (N / i);
    if (N % i >= K){
      now += (N % i) - K + 1;
    }
    ans += now;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int a=scanner.nextInt();
        int b=scanner.nextInt();
        LinkedList<Integer>[] linkedLists=new LinkedList[n+1];
        for(int j=1;j<=n;j++){
            linkedLists[j]=new LinkedList<>();
        }
        for(int i=1;i<n;i++){
            linkedLists[i].add(i+1);
            linkedLists[i+1].add(i);
        }
        if(!linkedLists[a].contains(b)){
            linkedLists[a].add(b);
            linkedLists[b].add(a);
        }
        boolean[] org=new boolean[n+1];
        int ans[]=new int[n];
        for(int j=1;j<=n;j++){
            org[j]=true;
            Queue<Integer> queue=new LinkedList<>();
            queue.add(j);
            queue.add(-1);
            boolean[] vis=new boolean[n+1];
            int dis=1;
            vis[j]=true;

            while (!queue.isEmpty()){
                int temp=queue.poll();

                if(temp==-1){
                    if(queue.isEmpty()){
                        break;
                    }
                    dis++;
                    queue.add(-1);
                    continue;
                }

                for(Integer i:linkedLists[temp]){
                    if(!vis[i]){
                        vis[i]=true;
                        queue.add(i);
                        if(i>j){
                            ans[dis]++;
                        }
                    }
                }
            }
        }
        for(int j=1;j<n;j++){
            System.out.println(ans[j]);
        }
    }
}


Measured memory_bytes: 105692
#@author: Behradm

def main():
    n = int(input())
    a = list(map(int, input().split()))

    a.sort()
    res = 1
    for i in range(n):
        res *= a[i]
        if (res > 1000000000000000000):
            print(-1)
            return 0
    print(res)

if (__name__ == "__main__"):
    main()


Measured memory_bytes: 21604
#include <stdio.h>
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;

#define INF 1 << 15

typedef pair<int, int> P;

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

int X,Y;
int d[12][12],dd[12][12];
int IceNum, Ice[144];
P S,G;

queue<P> que;

bool check(int NX, int NY)
{
	if(NX >= X || NY >= Y || NX < 0 || NY < 0)
		return false;
	return true;
}

void dfs(P pos, int now)
{
	if(pos == G){
		dd[pos.second][pos.first] = min(dd[pos.second][pos.first], now);
		return;
	}
	if(now > dd[pos.second][pos.first])
		return;

	dd[pos.second][pos.first] = now;

	int nx,ny;
	for(int i = 0; i < 4; i++){
		nx = pos.first + dx[i], ny = pos.second + dy[i];
		if(check(nx,ny) && d[ny][nx] != -1){
			if(d[ny][nx] > 0){
				if(Ice[ d[ny][nx] ] > 0){
					Ice[ d[ny][nx] ]--;
					dfs(P(nx,ny), now+1);
					Ice[ d[ny][nx] ]++;
				}
			}
			else
				dfs(P(nx,ny), now+1);
		}
	}


		
}
int main(void)
{
	while(cin >> X >> Y, X > 0 && Y > 0){
		fill(&dd[0][0],&dd[0][0]+144, INF);
		fill(&Ice[0],&Ice[0]+144, 0);
		IceNum = 0;
		char s[13];

		for(int i = 0; i < Y; i++){
			scanf("%s", s);
			for(int j = 0; s[j] != '\0'; j++){
				if(s[j] == '.')
					d[i][j] = 0;
				else if(s[j] == '#')
					d[i][j] = -1;
				else if(s[j] == 'X')
					d[i][j] = -2;
				else if(s[j] == 'S')
					S = P(j,i),d[i][j] = 0;
				else if(s[j] == 'G')
					G = P(j,i),d[i][j] = 0;
			}
		}
		for(int i = 0; i < Y; i++){
			for(int j = 0; j < X; j++){
				if(d[i][j] == -2){
					IceNum++;
					
					que.push(P(j,i));

					while(que.size()){

						P p = que.front();
						que.pop();
						d[p.second][p.first] = IceNum;
						Ice[IceNum]++;
						int nx,ny;
						for(int i = 0; i < 4; i++){
							nx = p.first + dx[i], ny = p.second + dy[i];
							if(check(nx,ny) && d[ny][nx] == -2){
								que.push(P(nx,ny));
							}
						}
					}


				}

			}
		}

		for(int i = 0; i < 144; i++)
			Ice[i] /= 2;

		dfs(S,0);
		printf("%d\n", dd[G.second][G.first]);

	}

	return 0;
}

Measured memory_bytes: 3908
fn main() {
    let stdin = std::io::stdin();
    let mut rd = ProconReader::new(stdin.lock());

    let n: u64 = rd.get();
    let x: usize = rd.get();
    let m: usize = rd.get();

    let b = 34;
    let mut nxt = vec![vec![0; m]; b];
    // dp[i][j]: x = j から始めたときの a[1] + a[2] + ... + a[2^i]
    let mut dp = vec![vec![0; m]; b];
    for y in 0..m {
        nxt[0][y] = (y * y) % m;
        dp[0][y] = y;
    }
    for i in 1..b {
        for j in 0..m {
            nxt[i][j] = nxt[i - 1][nxt[i - 1][j]];
            dp[i][j] = dp[i - 1][j] + dp[i - 1][nxt[i - 1][j]];
        }
    }
    let mut y = x;
    let mut ans = 0;
    for i in (0..b).rev() {
        if (n >> i & 1) == 1 {
            ans += dp[i][y];
            y = nxt[i][y];
        }
    }
    println!("{}", ans);
}

pub struct ProconReader<R: std::io::Read> {
    reader: R,
}

impl<R: std::io::Read> ProconReader<R> {
    pub fn new(reader: R) -> Self {
        Self { reader }
    }
    pub fn get<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&byte| byte == b' ' || byte == b'\n' || byte == b'\r')
            .take_while(|&byte| byte != b' ' && byte != b'\n' && byte != b'\r')
            .collect::<Vec<_>>();
        std::str::from_utf8(&buf)
            .unwrap()
            .parse()
            .ok()
            .expect("Parse Error.")
    }
}

Measured memory_bytes: 55348
#include<stdio.h>
  int f[13];
int main()
{
  int i,j,k,l,m,n,num,p;
  f[1]=0;f[3];f[5]=0;f[7]=0;f[8]=0;f[10]=0;f[12]=0;f[4]=1;f[6]=1;f[9]=1;f[11]=1;f[2]=2;

  scanf("%d%d",&j,&k);
if (f[j]==f[k])printf("Yes");else printf("No");

  return 0;
}


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

using namespace std;

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

	int n;
	cin >> n;

	vector<int> l;
	l.resize(n);

	vector<int> sum;
	sum.resize(1001);

	for(int i = 0; i < n; ++i) {
		cin >> l[i];
		++sum[l[i]];
	}
	
	for(int i = 0; i < 1000; ++i) {
		sum[i + 1] += sum[i];
	}

	long long ans = 0;

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

	/*
	 x + i > j;
	 x + j > i;
	 i + j > x

	 x > j - i
	 x > i - j
	 x < i + j
	 */ 

	for(int i = 0; i < n; ++i) {
		for(int j = i + 1; j < n; ++j) {
			ans += sum[min(1000, l[i] + l[j] - 1)] - sum[l[j] - l[i]];
			
			if(l[j] - l[i] < l[i] && l[i] < l[i] + l[j]) {
				--ans;
			}

			if(l[j] - l[i] < l[j] && l[j] < l[i] + l[j]) {
				--ans;
			}
		}
	}

	cout << ans / 3 << '\n';

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
)

func main() {
	var M [2]int
	var tmp int
	for i := 0; i < 2; i++ {
		if _, err := fmt.Scan(&M[i], &tmp); err != nil {
			os.Exit(-1)
		}
	}
	if M[0] != M[1] {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 512
from collections import Counter
N = input()
S=0
mod_count=[0]
ans=0
i=0
for X in N[::-1]:
  S = int(X)*pow(10,i,2019) % 2019
  S=mod_count[i]+S
  mod_count.append(S%2019)
  i+=1

c = Counter(mod_count)
ans = sum(Y * (Y-1)/2 for Y in c.values())
print(int(ans))

Measured memory_bytes: 16920
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

int N = 100001;

vector<bool> prime(N, true);

void fillPrime(){
    prime[0] = false;   
    prime[1] = false;
    ll N = prime.size();
    for(ll i=2; i<N; i++){
        if(!prime[i]) continue;
        if(prime[i]){
            ll num = i << 1;
            while(num < N){
                prime[num] = false;
                num += i;
            }
        }
    }
}

int main(){
    int Q; cin >> Q;
    fillPrime();
    vi like2017(N, 0);
    rep(i, 1, N){
        if(i % 2 == 0) continue;
        if(prime[i] && prime[(i+1)/2]) like2017[i]++;
    }
    vi cumsum(N+1, 0);
    rep(i, 0, N){
        cumsum[i+1] = cumsum[i] + like2017[i];
    }
    
    vi L;
    vi R;
    rep(i, 0, Q){
        int l, r;
        cin >> l >> r;
        L.push_back(l);
        R.push_back(r);
    }
    rep(i, 0, Q){
        ll l = L[i];
        ll r = R[i];
        cout << cumsum[r+1] - cumsum[l] << endl;
    }

    return 0;
}




Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define eb emplace_back
#define MP make_pair
#define pb push_back
#define pf push_front
#define ins insert
#define all(v) (v).begin(), (v).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define tr(c,it) for(auto it=c.begin();it!=c.end();it++)
#define fr(i,n) for(lli i=0;i<(n);i++)
#define inc(i,a,b) for(lli i=a;i<=b;i++)
#define dec(i,a,b) for(lli i=a;i>=b;i--)
#define fr2(i,n) for(int i=0;i<(n);i++)
#define inc2(i,a,b) for(int i=a;i<=b;i++)
#define dec2(i,a,b) for(int i=a;i>=b;i--)
#define ymin(a,b)  (a=min((a),(b)))
#define ymax(a,b)  (a=max((a),(b)))
#define sz(x) (lli)(x).size()
typedef long long int lli;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<lli,lli> plli;
typedef vector<lli> vlli;
typedef vector<int> vi;
//typedef  vector<vector<lli> >ncr(1001,vector<lli>(1001,0))
typedef vector<plli> vplli;
long long MOD=1000000009;
double startTime;
double getCurrentTime()
{
	return ((double)clock()-startTime)/CLOCKS_PER_SEC;
}

lli pwr(lli x,lli n)
{
	lli res=1;
	for(; n!=0;n>>=1)
	{
		if(n&1)
			res=(res*x)%MOD;
		x=(x*x)%MOD;
	}
	return res;
}
lli inver(lli num)
{
	return pwr(num,MOD-2);
}
lli findncr(lli n,lli r)
{
	r=min(r,n-r);
	if(n==0||n==1||r==0)
		return 1;
	lli numer=1;
	for(lli i=n;i>=n-r+1;i--)
		numer=(numer*i)%MOD;
	lli den=1;
	for(lli i=2;i<=r;i++)
		den=(den*i)%MOD;
	den=inver(den);
	lli res=(numer*den)%MOD;
	return res;
}
lli gcd(lli a,lli b)
{
	if(b==0)
		return a;
	else
		return gcd(b,a%b);
}
int main()
{
	// 	#ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS
	int n;
	
	cin>>n;
	int h[n+1]={0};
	fr2(i,n)
	cin>>h[i+1];
	int cost[n+1]={0};
	cost[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++)
	{
		cost[i]=min((cost[i-1]+abs(h[i]-h[i-1])),(cost[i-2]+abs(h[i]-h[i-2])));
	}
	cout<<cost[n]<<endl;
	
	// startTime=(double)clock();
	// cout<<startTime<<" ";   clock_t end = clock();
	// double elapsed_secs = double(end - startTime) / CLOCKS_PER_SEC;
	// cerr << elapsed_secs;
	
}



Measured memory_bytes: 1024
n = int(input())
a = [int(i) for i in input().split()]
m = max(a)
ans = 0

l = [0 for y in range(m+3)]
for j in range(n):
    l[a[j]] += 1
    l[a[j]+1] += 1
    l[a[j]+2] += 1
print(max(l))



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

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');

            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);

            if (a < b)
            {
                Console.WriteLine("a < b");
            }else if (a > b)
            {
                Console.WriteLine("a > b");
            }
            else
            {
                Console.WriteLine("a == b");
            }

        }
    }
}



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

typedef pair<int, int> P;
struct wksg {
  bool operator() (const P &l, const P &r) const {
    if (l.second > r.second) {
      return true;
    } else if (l.second < r.second) {
      return false;
    } else if (l.first < r.first) {
      return true;
    } else {
      return false;
    }
  }
};

typedef set<P, wksg> M;

int vv[1000001];
M m;

int main() {
  int n, q, a, v, b;
  M::iterator it;

  cin >> n >> q;
  for (int i=0; i<n; i++) vv[i] = 0;
  for (int i=0; i<q; i++) {
    cin >> a >> v;
    it = m.find(P(a,vv[a]));
    if (it != m.end()) {
      m.erase(it);
    }
    vv[a] += v;
    m.insert(P(a,vv[a]));
    it = m.begin();
    cout << it->first << " " << it->second << endl;
  }

  return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,t;
    cin >> n >> t;
    vector<pair<ll,ll>> ab(n);
    for(i = 0;i < n;++i){
        cin >> ab.at(i).first >> ab.at(i).second;
    }
    sort(all(ab));
    vector<vector<ll>> dp(n+1,vector<ll>(t,0));
    for(i = 1;i <= n;++i){
        rep(j,t){
            if(j < ab.at(i-1).first) dp.at(i).at(j) = dp.at(i-1).at(j);
            else dp.at(i).at(j) = max(dp.at(i-1).at(j), dp.at(i-1).at(j - ab.at(i-1).first) + ab.at(i-1).second);
        }
    }
    ll ans = 0;
    for(i = n-1;i >= 0;--i){
        ll tmp = dp.at(i).at(t-1) + ab.at(i).second;
        ans = max(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 70784
N, M = map(int,input().split())
L = [0] * M
R = [0] * M
for i in range(M):
    L[i], R[i] = map(int, input().split())

if min(R) >= max(L):
    print(min(R) - max(L) + 1)
else:
    print(0)

Measured memory_bytes: 10868
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char *argv[]) {
  string s;
  cin >> s;

  int m=0;
  if (s[5]=='1') m=10;
  m += s[6]-'0';

  if (m>4) cout << "TBD"<< endl;
  else     cout << "Heisei"<< endl;

  return 0;
}


Measured memory_bytes: 256