akhauriyash/Code-Regression huggingface dataset:
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;

// a と b の最大公約数を求める
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}

// a と ｂ の最小公倍数を求める
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a / g * b;
}


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


  ll A,B; cin>>A>>B;

  ll ans = lcm(A,B);
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,x;
  cin >> N >> x;
  vector<int> A(N);
  for(int i=0; i<N ; i++)
  {
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  int B=0;
  while(1)
  {
    if(B==N)break;
    if(x-A.at(B)<0)break;
    if((B+1==N) && (x>A.at(B)))break;
    x=x-A.at(B);

    B++;
  }

  cout << B << endl;
}

Measured memory_bytes: 3572
#include<stdio.h>
#include<string.h>
#define inf 1072114514
 
int dx4[4]={1,-1,0,0};
int dy4[4]={0,0,1,-1};
 
#define size 16777216
 
int deque[size],fpt=size/2,bpt=(size/2)+1;
 
void push(int v,int isbk){
  if(isbk){deque[bpt]=v;bpt++;}
  else{deque[fpt]=v;fpt--;}
}
 
int pop(int isbk){
  int r;
  if(isbk){bpt--;r=deque[bpt];deque[bpt]=inf;}
  else{fpt++;r=deque[fpt];deque[fpt]=-inf;}
  return r;
}
 
int main(){
  int h,w;
  int sh,sw;
  int th,tw;
  char s[1024][1024];
  int dl[1024][1024];
  scanf("%d%d%d%d%d%d",&h,&w,&sh,&sw,&th,&tw);
  for(int i=0;i<=w+1;i++){s[0][i]='.';s[h+1][i]='.';}
  for(int i=1;i<=h;i++){
    s[i][0]='.';
    scanf("%s",&s[i][1]);
    s[i][w+1]='.';
    for(int j=1;j<=w;j++){dl[i][j]=inf;}
  }
  push(1024*sh+sw,0);
  dl[sh][sw]=0;
  while(fpt+1!=bpt){
    int v,ci,cj,ni,nj;
    v=pop(0);
    ci=(v/1024);cj=(v%1024);
    //printf("%d %d : %d\n",ci,cj,dl[ci][cj]);
    if(ci==th&&cj==tw){printf("%d\n",dl[th][tw]);return 0;}
    for(int k=0;k<4;k++){
      ni=ci+dx4[k];nj=cj+dy4[k];
      if(s[ni][nj]=='#'){continue;}
      if(dl[ci][cj]<dl[ni][nj]){
        dl[ni][nj]=dl[ci][cj];
        push(1024*ni+nj,0);
      }
    }
    for(int i=-2;i<=2;i++){
      for(int j=-2;j<=2;j++){
        ni=ci+i;nj=cj+j;
        if(s[ni][nj]=='#'){continue;}
        if(dl[ci][cj]+1<dl[ni][nj]){
          dl[ni][nj]=dl[ci][cj]+1;
          push(1024*ni+nj,1);
        }
      }
    }
  }
  puts("-1");
  return 0;
}

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

const int dy[4] = {1, 0, -1, 0};
const int dx[4] = {0, 1, 0, -1};
const string ENWS = "ENWS";

int main() {
    int W, H;
    while (cin >> W >> H, W) {
        vector<string> S(H);
        for (int i = 0; i < H; ++i) cin >> S[i];

        int ans = -1;
        for (int t = 0; t <= 180; ++t) {
            vector<pair<int, int>> pos;
            for (int i = 0; i < H; ++i) {
                for (int j = 0; j < W; ++j) {
                    if (ENWS.find(S[i][j]) != string::npos) {
                        pos.emplace_back(i, j);
                    }
                }
            }
            if (pos.empty()) {
                ans = t;
                break;
            }

            map<pair<int, int>, vector<pair<int, int>>> mp;
            for (int i = 0; i < pos.size(); ++i) {
                int y, x;
                tie(y, x) = pos[i];
                int dir = ENWS.find(S[y][x]);
                for (int j = 0; j < 4; ++j) {
                    int ny = y + dy[(dir + j) % 4];
                    int nx = x + dx[(dir + j) % 4];
                    if (ny >= 0 && ny < H && nx >= 0 && nx < W && (S[ny][nx] == '.' || S[ny][nx] == 'X')) {
                        mp[make_pair(ny, nx)].emplace_back((dir + j + 1) % 4, i);
                        S[y][x] = ENWS[(dir + j + 3) % 4];
                        break;
                    }
                }
            }
            for (auto &p : mp) {
                sort(p.second.begin(), p.second.end());
                int sy, sx, ty, tx;
                tie(sy, sx) = pos[p.second[0].second];
                tie(ty, tx) = p.first;
                if (S[ty][tx] == '.') {
                    S[ty][tx] = S[sy][sx];
                }
                S[sy][sx] = '.';
            }
        }
        if (ans < 0) cout << "NA" << endl;
        else cout << ans << endl;
    }
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int a,b;
    cin >> a >> b;
    if(a>b) cout << a-1 << endl;
    else cout << a << endl;



}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back

using namespace std;
typedef long long ll;

int main()
{
  int N; cin >> N;
  vector<int> A(N), B(N), C(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> B[i];
  for (int i = 0; i < N; i++) cin >> C[i];
  sort(A.begin(), A.end());
  sort(C.begin(), C.end());

  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ll lb = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
    ll ub = upper_bound(C.begin(), C.end(), B[i]) - C.begin();
    ans += lb * (N - ub);
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

ll calc_count_choose_2(int n) {
    return (n >= 2) ? ((ll)n * ((ll)n - 1) / 2) : 0;
}

int main() {
    // get values from input
    ll pattern_count_before_ban = 0;

    map<int, int> ball_count_by_number_map;
    map<int, ll> pattern_count_by_number_map;

    int N;
    READ(N);

    vector<int> A(N);
    REP(i, N)
    {
        READ(A[i]);
        ball_count_by_number_map[A[i]] += 1;
    }

    // main procedure
    for (auto p : ball_count_by_number_map) {
        ll c = calc_count_choose_2(p.second);
        pattern_count_by_number_map[p.first] = c;
        pattern_count_before_ban += c;
    }

    REP(i, N)
    {
        ll pattern_count;
        int ball_count = ball_count_by_number_map[A[i]];
        pattern_count = pattern_count_before_ban
                - calc_count_choose_2(ball_count)
                + calc_count_choose_2(ball_count - 1);
        // output
        WRITE_N(pattern_count);
    }
    return 0;
}


Measured memory_bytes: 16256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
	int a;
	int b;

	while (cin >> a >> b) {
		//scanf("%d%d", &a, &b);
		if (a + b == 0) printf("%d\n", 1);
		else printf("%d\n", (int)log10(a + b) + 1);
	}

		return (0);
	
}

Measured memory_bytes: 1188
N,X,Y = map(int,input().split())

bucket = [0]*2001

for i in range(1,N):
    for j in range(i+1,N+1):
        bucket[min(abs(j-i),abs(X-i)+ 1 + abs(Y-j))] += 1
for i in range(1,N):
    print(bucket[i])

Measured memory_bytes: 3444
N = int(input())
D,X = map(int,input().split())
# A = []
sumsum = 0
for i in range(N):
    tmp = int(input())
    if D % tmp == 0:
        plus = D // tmp
    else:
        plus = (D // tmp) + 1

    sumsum += plus

print(sumsum+X)

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

int n;
vector<int> t,u;


int solve(){
  int ans=0;
  for(int i=0;i<n;i++){
    if(i==0)continue;
    if(i==n-1)continue;
    
    if( t[i-1] < t[i] && t[i] < t[i+1] ){

      if(i+2<n && t[i] > t[i+2] ){
        swap(t[i+1],t[i+2]);
      }else{
        swap(t[i],t[i+1]);
      }
      ans++;
      

      
    }else if( t[i-1] > t[i] && t[i] > t[i+1] ){
      
      if(i+2<n && t[i] < t[i+2] ){
        swap(t[i+1],t[i+2]);
      }else{
        swap(t[i],t[i+1]);
      }
      ans++;

    }

  }
  return ans;
}

int solve2(){
    int ans=0;
  for(int i=0;i<n;i++){
    if(i==0)continue;
    if(i==n-1)continue;
    if( t[i-1] < t[i] && t[i] < t[i+1] ){
      swap(t[i],t[i+1]);
      ans++;
    }else if( t[i-1] > t[i] && t[i] > t[i+1] ){
      swap(t[i],t[i+1]);
      ans++;
    }
  }
  return ans;
}

int main(){
  cin>>n;
  t.resize(n);
  for(int i=0;i<n;i++){
    cin>>t[i];
  }
  u=t;
  
  int ans = solve();

  t=u;
  swap(t[0],t[1]);
  ans  = min( solve() + 1 , ans);

  t=u;
  ans = min( solve2(), ans );
  
  t=u;
  swap(t[0],t[1]);
  ans = min( solve2()+1 , ans);
  
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
int dp[1001][1001];

signed main(){
    int h,w;
    string a[1000];
    cin>>h>>w;
    for(int i=0;i<h;i++)
        cin>>a[i];
    a[0][0]='#';
    dp[1][1]=1;
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
            if(a[i-1][j-1]=='.')
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
    cout<<dp[h][w]<<endl;
}

Measured memory_bytes: 9088
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		int[] A = nextIntArray(N+1);//monster num
		int[] B = nextIntArray(N);//hunt max

		long sum = 0;
		for(int i=0;i<N;i++) {
			if(B[i]<=A[i]) {
				sum+=B[i];
				continue;
			}
			sum+=A[i];
			B[i]-=A[i];
			if(B[i]<=A[i+1]) {
				sum+=B[i];
				A[i+1]-=B[i];
			}else if(B[i]>A[i+1]){
				sum+=A[i+1];
				A[i+1]=0;
			}

		}
		out.println(sum);
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}


}

Measured memory_bytes: 50888
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef vector<int> vi;
const int mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    S s;
    cin >> s;
    if((s[5]-'0')*10+s[6]-'0'<=4){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
/*input
8
1 2 1 4 2 1 4 1



*/

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	int n;
	cin >> n;
	vector<long long> a(n+1), v(n+1);
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		a[x]++;
		v[i+1] = x; 
	}
	long long tot = 0;
	for(int i = 1; i <= n; i++) {
		tot += (a[i] * (a[i]-1))/2;
	}

	for(int i = 1; i <= n; i++) {
		long long cur = tot;
		long long prev = (a[v[i]] * (a[v[i]]-1))/2;
		long long ne = ((a[v[i]]-1) * (a[v[i]]-2))/2;
		cout << cur - prev + ne << '\n'; 
	}

	return 0;
}


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

int main()
{
  string str1,str2;
  cin >> str1 >> str2;
  int cnt = 0;
  for(int i=0; str1[i]; i++)
  {
    if(str1[i] != str2[i])
      cnt += 1;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3912
def run_magic_tiles(magic_tiles, past_matrix):
    i, j = 0, 0
    while True:
        move = {
            '^': (-1, 0),
            'v': (1, 0),
            '<': (0, -1),
            '>': (0, 1),
            '.': (-1, -1)
        }.get(magic_tiles[i][j])
        if move[0] == -1 and move[1] == -1:
            return j, i
        else:
            i += move[0]
            j += move[1]
            if past_matrix[i][j]:
                return 'LOOP'
            past_matrix[i][j] = 1


def main():
    while True:
        c, r = map(int, input().split(' '))
        if c == 0 and r == 0:
            break

        past_matrix = [[0 for _ in range(r)] for _ in range(c)]
        tiles = []
        for _ in range(c):
            tiles.append(list(input()))

        res = run_magic_tiles(tiles, past_matrix)
        print('LOOP' if res == 'LOOP' else '%d %d' % (res[0], res[1]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 7956
#include<iostream>
using namespace std;
int main(){
  int i,j,k;
  int r,c;
  int b;
  cin >> r >> c;
  int rsum[100]={};
  int csum[100]={};
  int sum=0;
  for(i=0;i<r;i++){
    cin >> b;
    cout << b;
    rsum[i]+=b;
    csum[0]+=b; 
    for(j=1;j<c;j++){
      cin >> b;
      cout <<" " << b;
      rsum[i]+=b;
      csum[j]+=b; 
    }
    cout << " " << rsum[i] << endl;
    sum+=rsum[i];
  }
  cout << csum[0];
  for(j=1;j<c;j++){
    cout << " " << csum[j];    
  }
  cout << " " << sum <<  endl;
  return 0;
}


Measured memory_bytes: 3076
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();        
        String S = r.s();
        char[] T = S.toCharArray();
        T[3] = '8';
        S = String.valueOf(T);
        println(S);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 23124
from collections import Counter
n,*a = map(int,open(0).read().split())
s = set(a)
c = Counter(a)
m = max(s)
l = [True]*(m+1)
ans = 0
for i in range(1,m+1):
  if i in s and l[i]:
    if c[i] == 1:
      ans += 1
    for j in range(1,m//i+1):
      l[i*j] = False
print(ans)

Measured memory_bytes: 49796
#include <iostream>
#include <map>
#include <algorithm>
#include <cstdio>
#include <string>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

int no;
char k;
string chi;
	
map<string,int> ket;
	
	ket["A"]=0;   ket["B"]=0;
	ket["O"]=0;   ket["AB"]=0;
	
	while(cin >>no >>k >>chi){
		
		ket[chi]++;
	}	
	
	cout << ket["A"]  << endl <<  ket["B"] << endl;
	cout << ket["AB"] << endl <<  ket["O"] << endl;

	return 0;
	
	
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int x,y,a,b,c; cin>>x>>y>>a>>b>>c;
	vector<int>A(a),B(b),C(c);
	for(auto&&i:A)cin>>i; for(auto&&i:B)cin>>i; for(auto&&i:C)cin>>i;
	sort(A.begin(),A.end()); sort(B.begin(),B.end());
	for(int i=a-1;i>=a-x;--i)C.emplace_back(A.at(i));
	for(int i=b-1;i>=b-y;--i)C.emplace_back(B.at(i));
	sort(C.begin(),C.end());
	int64_t ans=0;
	for(int i=C.size()-1;i>=C.size()-x-y;--i)ans+=C.at(i);
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 2552
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

# 最小公倍数
def lcm(a, b):
  y = a*b / gcd(a, b)
  return int(y)

s = input()
l = [chr(i) for i in range(97, 97+26)]

for i in range(len(l)):
  if l[i] == s:
    print(l[i+1])


Measured memory_bytes: 5160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
int n;
ll k;
ll ans, sum;
ll a[maxx];

int main() {
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int bit = 60; bit >= 0; bit--) {
		ll tmp = 1ll << bit;
		int c1 = 0, c0 = 0;
		for(int i = 1; i <= n; i++) {
			if(a[i] & tmp) c1++;
			else c0++;
		}
		if(c0 >= c1) {
			if(ans + tmp <= k) ans += tmp;
			else ans += 0 << bit;
		}
		else ans += 0 << bit;
	}
	//cout << ans << endl;
	for(int i = 1; i <= n; i++) sum += ans ^ a[i];
	cout << sum << endl;
}

Measured memory_bytes: 1024
input_line = input()
x, y, z = map(str, input_line.split())

resultNum = 0

for i in range(int(x)+1):
  loopCnt = len(str(i))
  addNum = 0
  for j in range(loopCnt):
    addNum += int(str(i)[j])
  if int(y) <= addNum <= int(z):
    resultNum += i

print(resultNum)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int s[100002];

int main()
{
   int n,x;
   cin>>n;
   for(int i=1;i<=n;i++)
   {
       cin>>x;
       s[x]=i;
   }
   cout<<s[1];
   for(int i=2;i<=n;i++)cout<<" "<<s[i];
   cout<<endl;
    return 0;

}


Measured memory_bytes: 1152
#include<stdio.h>
int main()
{
	int n,m,a,b,l,r;
	while(~scanf("%d %d", &n, &m))
	{
		a=0;b=200000;
		while(m--)
		{
			scanf("%d %d", &l, &r);
			if(l>a)
				a=l;
			if(r<b)
				b=r;
		}
		if(b-a<0) printf("0\n");
		else printf("%d\n", b-a+1);
	}
	return 0;
}

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

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;//998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template<class _T> static void getint(_T& a) {
	if (sizeof(_T) > sizeof(int)) {
		scanf("%lld", &a);
	}
	else {
		scanf("%d", &a);
	}
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	int N, M;
	get(N, M);

	std::vector<int> graph(N, 0);
	for (int i = 0; i < M; i++) {
		int a, b;
		get(a, b); a--; b--;
		graph[a]++;
		graph[b]++;
	}

	const char* ans = "YES\n";
	for (int i = 0; i < N; i++) {
		if (graph[i] % 2) {
			ans = "NO\n";
			break;
		}
	}
	printf(ans);
}


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

typedef long long ll;
int main()
{
    ll a,b;
    cin>>a>>b;
    if(a>(b*2))
    {
        cout<<a-(b*2)<<endl;
    }
    else
    {
        cout<<0<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define pb push_back 
#define ll long long
using namespace std;
int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
	ll n,a,b;
  	cin>>n>>a>>b;
  	if(a*n < b) cout<<n*a;
  	else cout<<b;
  	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define LEFT 0
#define RIGHT 1
#define UP 2
#define DOWN 3

int main(void){
	int wall_s[5][4];
	int wall_l[4][5];
	int x, y;
	int dir;
	int i, j;

	//üÍ
	for(j=0; j<4; j++){
		for(i=0; i<4; i++){
			scanf("%1d", &wall_s[j][i]);
		}
		for(i=0; i<5; i++){
			scanf("%1d", &wall_l[j][i]);
		}
	}
	for(i=0; i<4; i++){
		scanf("%1d", &wall_s[4][i]);
	}

	x = 0;
	y = 0;	
	dir = RIGHT;
	while(1){
		if(dir == RIGHT){
			if(y-1 >= 0 && wall_l[y-1][x] == 1){
				y--;
			   	printf("U");
				dir = UP;
			}else if(x+1 <= 4 && wall_s[y][x] == 1){
				x++;
				printf("R");
				dir = RIGHT;
			}else if(y+1 <= 4 && wall_l[y][x] == 1){
				y++;
				printf("D");
				dir = DOWN;
			}else if(x-1 >= 0 && wall_s[y][x-1] == 1){
				x--;
				printf("L");
				dir = LEFT;
			}
		}else if(dir == LEFT){
			if(y+1 <= 4 && wall_l[y][x] == 1){
				y++;
			   	printf("D");
				dir = DOWN;
			}else if(x-1 >= 0 && wall_s[y][x-1] == 1){
				x--;
				printf("L");
				dir = LEFT;
			}else if(y-1 >= 0 && wall_l[y-1][x] == 1){
				y--;
				printf("U");
				dir = UP;
			}else if(x+1 <= 4 && wall_s[y][x] == 1){
				x++;
				printf("R");
				dir = RIGHT;
			}
		}else if(dir == UP){
			if(x-1 >= 0 && wall_s[y][x-1] == 1){
				x--;
				printf("L");
				dir = LEFT;
			}else if(y-1 >= 0 && wall_l[y-1][x] == 1){
				y--;
				printf("U");
				dir = UP;
			}else if(x+1 <= 4 && wall_s[y][x] == 1){
				x++;
				printf("R");
				dir = RIGHT;
			}else if(y+1 <= 4 && wall_l[y][x] == 1){
				y++;
			   	printf("D");
				dir = DOWN;
			}
		}else if(dir == DOWN){
			if(x+1 <= 4 && wall_s[y][x] == 1){
				x++;
				printf("R");
				dir = RIGHT;
			}else if(y+1 <= 4 && wall_l[y][x] == 1){
				y++;
			   	printf("D");
				dir = DOWN;
			}else if(x-1 >= 0 && wall_s[y][x-1] == 1){
				x--;
				printf("L");
				dir = LEFT;
			}else if(y-1 >= 0 && wall_l[y][y-1] == 1){
				y--;
				printf("U");
				dir = UP;
			}
		}
		if(x == 0 && y == 0) break;
		//printf("%d %d\n", x, y); fflush(stdout);
	}
	puts("");

	return 0;
}

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

int main(){
 vector<int> a(3,0);
 cin >> a[0] >> a[1] >> a[2];
 sort(a.begin(),a.end());
 cout << a[0] << " " << a[1] << " " << a[2] << endl;
 return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


struct Point {
  int y;
  int x;
  Point(int a, int b) : y(a), x(b) { }
};

int h,w;
vector<string> field;
vector<vector<int>> dist;

int main() {
  cin >>h >>w;
  field.assign(h, "");
  rep(i, h) cin >>field.at(i);
  int white = 0;
  for (int i=0; i<h; i++) for (int j=0; j<w; j++) if (field.at(i).at(j) == '.') white++;

  queue<Point> que;
  que.push(Point(0, 0));
  dist.assign(h, vector<int>(w, -1));
  for (int i=0; i<h; i++) for (int j=0; j<w; j++) if (field.at(i).at(j) == '#') dist.at(i).at(j) = -10;
  dist.at(0).at(0) = 1;

  vector<int> dy = {0, 1, 0, -1};
  vector<int> dx = {1, 0, -1, 0};

  while (!que.empty()){
    auto v = que.front(); que.pop();
    for (int i=0; i<4; i++){
      int ni = v.y + dy.at(i), nj = v.x + dx.at(i);
      if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
      if (dist.at(ni).at(nj) != -1) continue;
      dist.at(ni).at(nj) = dist.at(v.y).at(v.x) + 1;
      que.push(Point(ni, nj));
    }
  }

  if (dist.at(h-1).at(w-1) == -1) cout <<-1 <<endl;
  else cout <<white - dist.at(h-1).at(w-1) <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

//約数列挙
template <class T>
vector<T> divisor(T x){
	vector<T> res;
	for(T i=1;i*i<=x;i++){
		if(x%i==0){
			res.push_back(i);
			if(i!=x/i){
				res.push_back(x/i);
			}
		}
	}
	return res;
}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	ll ans=0;
	vector<ll> ret=divisor(n);
	for(auto k:ret){
		if(k==1) continue;
		ll now=n;
		while(now%k==0){
			now/=k;
		}
		if(now%k==1) ans++;
	}
	ret=divisor(n-1);
	ans+=ret.size()-1;
	cout<<ans<<endl;
}

Measured memory_bytes: 384
n = int(input())
div_table = [1]*(n+1)
div_table[0] = 0
for i in range(2, n+1):
    j = i
    while j < n+1:
        div_table[j] += 1
        j += i

ans = 0
for i in range(n+1):
    ans += i*div_table[i]
#print(div_table)
print(ans)

Measured memory_bytes: 145628
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;
 
ll vis[N], a[N];
 
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++) cin >> a[i];
    int city = 1;
    int len;
    for(int i = 1; i <= n + 5; i++){
        if(i == k + 1) return cout << city, 0;
        if(vis[city]){
            k -= (vis[city] - 1);
            len = i - vis[city];
            break;
        }
        vis[city] = i;
        city = a[city];
    }
    k = k % len;
    while(k--){
        city = a[city];
    }
    cout << city;
 
 
 
    return 0;
}

Measured memory_bytes: 6720
// ABC157B - Bingo

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

int main() {
	int A[3][3];

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

	int N;
	cin >> N;

	vector<int> b(N);
	for (int i = 0; i < N; i++) {
		cin >> b.at(i);
	}

	bool isHit[3][3];
	sort(b.begin(), b.end());
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			isHit[i][j] = binary_search(b.begin(), b.end(), A[i][j]);
		}
	}

	bool answer = false;

	for (int i = 0; i < 3; i++) {
		if (isHit[i][0] && isHit[i][1] && isHit[i][2]) {
			answer = true;
		}
	}
	for (int i = 0; i < 3; i++) {
		if (isHit[0][i] && isHit[1][i] && isHit[2][i]) {
			answer = true;
		}
	}
	if (isHit[0][0] && isHit[1][1] && isHit[2][2]) {
		answer = true;
	}
	if (isHit[0][2] && isHit[1][1] && isHit[2][0]) {
		answer = true;
	}

	if (answer) {
		cout << "Yes";
	} else {
		cout << "No";
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'

//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#define SZ(x) ((int)x.size())
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back

using namespace std;
template<class T, class T2> inline int chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline int chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const int MAXN = (1 << 21);
const int mod = 1000003;

int pw(int x, int p)
{
	int r = 1;
	while(p)
	{
		if(p & 1) r = r * 1ll * x % mod;
		x = x * 1ll * x % mod;
		p >>= 1;
	}

	return r;
}

int inv(int x) { return pw(x, mod - 2); }

struct node
{
	int p;

	node() {p = 1;}
	node(int val)
	{
		p = val;
	}
};

node temp, broken;

node merge(node l, node r)
{
	temp.p = l.p * 1ll * r.p % mod;
	return temp;
}

struct segment_tree
{
	node tr[4 * MAXN];

	void init(int l, int r, int idx)
	{
		if(l == r)
		{
			tr[idx] = node(l % mod);
			return;
		}

		int mid = (l + r) >> 1;
		init(l, mid, 2 * idx + 1);
		init(mid + 1, r, 2 * idx + 2);

		tr[idx] = merge(tr[2 * idx + 1], tr[2 * idx + 2]);
	}

	node query(int qL, int qR, int l, int r, int idx)
	{
		if(l > qR || r < qL)
			return broken;

		if(qL <= l && r <= qR)
			return tr[idx];

		int mid = (l + r) >> 1;
		return merge(query(qL, qR, l, mid, 2 * idx + 1), query(qL, qR, mid + 1, r, 2 * idx + 2));
	}
};

segment_tree t;

void prepare()
{
	t.init(0, 2 * mod + 42, 0);
}

int x, d, n; 

void read()
{
	cin >> x >> d >> n;
}

void solve()
{
	if(d == 0)
	{
		cout << pw(x, n) << endl;
		return;
	}

	if(n >= mod)
	{
		cout << 0 << endl;
		return;
	}

	int ans = pw(d, n), dd = inv(d);
	int st = x * 1ll * dd % mod;
	ans = ans * 1ll * t.query(st, st + n - 1, 0, 2 * mod + 42, 0).p % mod;
	cout << ans << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	prepare();

	int T;
	cin >> T;
	while(T--)
	{
		read();
		solve();
	}

	return 0;
}



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

char v[200005];
int n;
int check2Rock(int l,int r){
    char lst='.';
    for(int i=l;i<r&&i<=n;i++){
        if(v[i]=='#'&&lst=='#')return 0;
        lst=v[i];
    }
    return 1;
}

int check3Squ(int l,int r){
    char lst='#',llst='#';
    for(int i=l;i<r&&i<=n;i++){
        if(v[i]=='.'&&lst=='.'&&llst=='.')return 1;
        llst=lst;
        lst=v[i];
    }
	return 0;
}

int main(){
    int a,b,c,d;
    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
    scanf("%s",v+1);
    if(c>d){
        if(check3Squ(b-1,d+2)&&check2Rock(b,d)&&check2Rock(a,c))
            printf("Yes\n");
        else printf("No\n");
    }
    else{
        if(check2Rock(a,c)&&check2Rock(b,d))
            printf("Yes\n");
        else printf("No\n");
    }
}

Measured memory_bytes: 384
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    S = in_s()
    date = int(S[0:4] + S[5:7] + S[8:])
    if date <= 20190430:
        ans = 'Heisei'
    else:
        ans = 'TBD'

    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
	
	string s;
	string t;
	int counter = 0;
	
	cin>>s>>t;
	
	for(int i = 0; i < s.length(); i++){
		if(s[i] != t[i]){
			counter++;
		}
	}
	
	cout<<counter;
	
	
}

Measured memory_bytes: 3916
#include <stdio.h>
#include <limits.h>
int main(){
  char line[100];
  int num;
  fgets(line, sizeof(line), stdin);
  sscanf(line, "%d", &num);
  int N[200000];
  int i, j;
  for(i=0; i<num; ++i){
	fgets(line, sizeof(line), stdin);
	sscanf(line, "%d", &N[i]);
  }
  int max=INT_MIN;
  int tmp;
  int min=N[0];
  for(i=1; i<num; ++i){
	tmp=N[i]-min;
	if(tmp>max)
	  max=tmp;
	if(N[i]<min)
	  min=N[i];
}
  printf("%d\n", max);
  return 0;
}



Measured memory_bytes: 2624
#include <iostream>
#include <bits/c++io.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
 int x,t=0,maxs=0;

 cin>>x;
  char s[x];
  for(int i=0;i<x;i++)
 {
     cin>>s[i];
 }
 for(int i=0;i<x;i++)
 {
     if(s[i]=='I')
        t++;
     else if(s[i]=='D')
        t--;
     if(t>maxs)
        maxs=t;
 }
 cout<<maxs<<endl;
}


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

int main(){
  string S;
  cin >>S;
  if (S=="Sunny"){
    cout << "Cloudy";
  }
  if (S=="Cloudy"){
    cout << "Rainy";
  }
  if (S=="Rainy"){
    cout << "Sunny";
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

typedef int value_type; /* ソートするキーの型 */

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[], int left, int right,value_type index[])
/* クイックソート
 * a     : ソートする配列 
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 * index: index配列
 */
{
    if (left < right) {
        int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
        while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
            while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
            while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
            tmp = index[i]; index[i] = index[j]; index[j] = tmp;
            i++; j--;
        }
        quicksort(a, left, i - 1,index);  /* 分割した左を再帰的にソート */
        quicksort(a, j + 1, right,index); /* 分割した右を再帰的にソート */
    }
}


int dfs(int n,int N){
    if (n>N){
        return 0;
    }
    

    int ret;
    
    return ret;
}

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

    int C[N],V[N];

    FOR(i,N){
        cin >> V[i];
    }
    FOR(i,N){
        cin>>C[i];
    }

    int ans=0;
    FOR(i,N){
        ans+=max(0,V[i]-C[i]);
    }

    cout <<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
using namespace std;

void dfs(int root, int father, std::vector<int>& state,
         std::vector<int>& depth, std::vector<std::vector<int>>& edge) {
  for (int i = 0; i < edge[root].size(); i++) {
    if (depth[edge[root][i]] != -1) {
      if (depth[edge[root][i]] < depth[root] - 1) {
        printf("%d %d\n", root, edge[root][i]);
        state[root] ^= 1;
      }
      continue;
    }
    depth[edge[root][i]] = depth[root] + 1;
    dfs(edge[root][i], root, state, depth, edge);
    if (state[edge[root][i]] == 1) {
        printf("%d %d\n", edge[root][i], root);
        state[edge[root][i]] ^= 1;
    } else {
        printf("%d %d\n", root, edge[root][i]);
        state[root] ^= 1;
    }
  }
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  if (m & 1) {
    printf("-1\n");
    return 0;
  }
  std::vector<int> state(n + 1, 0), depth(n + 1, -1);
  depth[1] = 0;
  std::vector<std::vector<int>> edge(n + 1);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  dfs(1, 0, state, depth, edge);
  return 0;
}


Measured memory_bytes: 15488
n, m = map(int, input().split())
a = [-1] + [int(input()) for i in range(m)] + [n+1]

res = 1
for i in range(1, len(a)):
    steps = a[i] - a[i-1] - 2
    if steps < 0:
        patern_nmu = 0
    elif steps <= 1:
        patern_nmu = 1
    elif steps <= 2:
        patern_nmu = 2
    else:
        p, q = 2, 1
        for j in range(1, steps-1):
            p, q = p+q, p
        patern_nmu = p
    res *= patern_nmu
    res %= 1000000007

print(res)


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

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

	string ans = "No";
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			if (n == i*j) {
				ans = "Yes";
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def gcd(m, n):
    while n:
        m, n = n, m % n
    return m


N, K = map(int, input().split())
A = list(map(int, input().split()))

gcd_value = A[0]
for i in range(1, N):
    gcd_value = gcd(gcd_value, A[i])

# print(gcd_value)
if K in A:
    print("POSSIBLE")
elif K > max(A):
    print("IMPOSSIBLE")
elif K % gcd_value == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 14252
import sys
input = sys.stdin.readline

x, y = map(int, input().split())
MOD = 10**9+7

def nck_tables(mod, n):
    fac = [1, 1] # 階乗テーブル
    ifac = [1, 1] #階乗の逆元テーブル
    inverse = [0, 1] #逆元テーブル

    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac

def nck(n, k, mod, fac, ifac):
    """
    nCkを計算する
    """
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod

if (x+y) % 3 != 0 or x > 2*y or y > 2*x:
    print(0)
    sys.exit()

times = (x+y)//3
k = max(x, y) - times
fac, ifac = nck_tables(MOD, times)
ans = nck(times, k, MOD, fac, ifac)
print(ans)

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

int main() {
  int n;
  cin >> n;
  bool a = 0;
  rep(i,10) {
    rep(j,10) {
      if(i*j == n){
         a = 1;
      }
    }
  }
  if(a) {
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 256
def solve(N, M):
    d = 10 ** 9 + 7
    N, M = min(N, M), max(N, M)
    if abs(N - M) >= 2:
        return 0
    elif abs(N - M) == 1:
        ans = M
    else:
        ans = 2
    for i in range(1, N + 1):
        ans *= pow(i, 2, d)
        ans %= d
    return ans


if __name__ == "__main__":
    N, M = tuple(map(int, input().split(" ")))
    print(solve(N, M))



Measured memory_bytes: 3060
import std.stdio, std.string, std.algorithm, std.range, std.conv;
void main()
{
    auto ip = readln.split.to!(int[]), A = ip[0], B = ip[1];
    if(A > 8 || B > 8) {
        writeln(":(");
    } else {
        writeln("Yay!");
    }
}

Measured memory_bytes: 256
import bisect

N = int(input())
A = sorted(list(map(int, input().split()))) 
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

#print(A)
#print(B)
#print(C)

a = [0]
b = [0]
for i in range(N):
    ai = bisect.bisect_right(B, A[i])
    a.append(N-ai+a[i])

    bi = bisect.bisect_right(C, B[i])
    b.append(N-bi+b[i])

#print(a)
#print(b)

ans = 0
for i in range(1, N+1):
    #print(b[-1] - b[-(a[i]-a[i-1])])
    ans += b[-1] - b[-(a[i]-a[i-1])-1]

print(ans)


Measured memory_bytes: 115812
#include <bits/stdc++.h>
using namespace std;typedef vector<int> vi;int main(){int n,k;cin>>n>>k;vi h(n);for(int i=0;i<n;i++)cin>>h[i];vi x(n,1e9);x[0]=0;for(int i=1;i<n;i++){for(int j=1;(i<k?j<=i:j<=k);j++){x[i]=min(x[i],x[i-j]+abs(h[i]-h[i-j]));}}cout<<x[n-1]<<'\n';}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <queue>
using namespace std;

int numbering(map<string,int>& m, const string& s)
{
  const map<string,int>::const_iterator it = m.find(s);
  if (it == m.end()) {
    const int n = m.size();
    m.insert(make_pair(s, n));
    return n;
  } else {
    return it->second;
  }
}

int dijkstra(const vector<vector<pair<int,int> > >& g, int start, int goal)
{
  priority_queue<pair<int,int> > q;
  vector<int> dist(g.size(), 10000000);
  q.push(make_pair(0, start));
  dist[start] = 0;
  while (!q.empty()) {
    const int c = -q.top().first;
    const int n = q.top().second;
    q.pop();
    if (n == goal) {
      return c;
    }
    if (dist[n] < c) {
      continue;
    }
    for (vector<pair<int,int> >::const_iterator it = g[n].begin(); it != g[n].end(); ++it) {
      const int cc = c + it->second;
      if (cc < dist[it->first]) {
        dist[it->first] = cc;
        q.push(make_pair(-cc, it->first));
      }
    }
  }
  throw "fail";
}

int main()
{
  int N, M;
  while (cin >> N >> M && N != 0) {
    map<string,int> m;
    string s, p, q;
    cin >> s >> p >> q;
    const int ss = numbering(m, s);
    const int pp = numbering(m, p);
    const int qq = numbering(m, q);
    vector<vector<pair<int,int> > > g(N);
    for (int i = 0; i < M; i++) {
      string u, v;
      int d, t;
      cin >> u >> v >> d >> t;
      const int c = d/40+t;
      const int uu = numbering(m, u);
      const int vv = numbering(m, v);
      g[uu].push_back(make_pair(vv, c));
      g[vv].push_back(make_pair(uu, c));
    }
    cout << dijkstra(g, ss, pp) + dijkstra(g, pp, qq) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

template<typename T>
struct SegmentTree {
	
	SegmentTree(int _n) : n(_n) { 
		t.resize(n * 4);
		lazy.resize(n * 4);
		len.resize(n * 4);
		lengths(1, 1, n);
	}
	
	SegmentTree(vector<T>& a) {
		n = (int)a.size();
		t.resize(4 * n);
		lazy.resize(4 * n);
		len.resize(4 * n);
		build(a, 1, 1, n);
		lengths(1, 1, n);
	}
	
	int n;
	vector<T> t, lazy, len;
	
	void build(vector<T>& a, int v, int tl, int tr) {
	    if (tl == tr) {
	        t[v] = a[tl - 1];
	    } else {
	        int tm = (tl + tr) / 2;
	        build(a, v*2, tl, tm);
	        build(a, v*2+1, tm+1, tr);
	        t[v] = t[v*2] + t[v*2+1];
	    }
	}
	
	void lengths(int v, int tl, int tr) {
	    if (tl == tr) {
	        len[v] = 1;
	    } else {
	        int tm = (tl + tr) / 2;
	        lengths(v*2, tl, tm);
	        lengths(v*2+1, tm+1, tr);
	        len[v] = len[v*2] + len[v*2+1];
	    }
	}
	
	void _push(int v) {
	    t[v*2] += (len[v * 2] * lazy[v]);
	    lazy[v*2] += lazy[v];
	    t[v*2+1] += (len[v * 2 + 1] * lazy[v]);
	    lazy[v*2+1] += lazy[v];
	    lazy[v] = 0;
	}
	
	void update(int l, int r, T addend) {
		_update(1, 1, n, l, r, addend);
	}
	
	void _update(int v, int tl, int tr, int l, int r, T addend) {
	    if (l > r) 
	        return;
	    if (l == tl && tr == r) {
	        t[v] += (r - l + 1) * addend;
	        lazy[v] += addend;
	    } else {
	        _push(v);
	        int tm = (tl + tr) / 2;
	        _update(v*2, tl, tm, l, min(r, tm), addend);
	        _update(v*2+1, tm+1, tr, max(l, tm+1), r, addend);
	        t[v] = t[v*2] + t[v*2+1];
	    }
	}
	
	T query(int l, int r) {
		return _query(1, 1, n, l, r);
	}
	
	T _query(int v, int tl, int tr, int l, int r) {
	    if (l > r)
	        return 0;
	    if (l <= tl && tr <= r)
	        return t[v];
	    _push(v);
	    int tm = (tl + tr) / 2;
	    return _query(v*2, tl, tm, l, min(r, tm)) +
	           _query(v*2+1, tm+1, tr, max(l, tm+1), r);
	}
};
int main() {
	ios_base::sync_with_stdio(0);
	int n, q;
	cin >> n >> q;
	SegmentTree<ll> tree(n);
	REP(i, q) {
		int type, s, t, x;
		cin >> type;
		if (type == 0) {
			cin >> s >> t >> x;
			tree.update(s, t, x);
		} else {
			cin >> s >> t;
			cout << tree.query(s, t) << "\n";
		}
	}
	return 0;
}
 



Measured memory_bytes: 12340
import java.util.Scanner;

public class Main {
    private static Scanner sc=new Scanner(System.in);
    private static int n=sc.nextInt();
    private static int[] a=new int[n];
    private static int cnt=0;
    public static void main(String[] args){
        for(int i=0;i<n;i++) a[i]=sc.nextInt();
        int[] gd=new int[100];
        gd[0]=1;
        int j=0;
        do{
            gd[j+1]=3*gd[j]+1;
            j++;
        }while(gd[j]<n);
        int m=j;
        int[] g=new int[j];
        for(int i=0;i<=m-1;i++) g[m-1-i]=gd[i];
        for(int i=0;i<=m-1;i++) insertionSort(g[i]);
        System.out.println(m);
        for(int i=0;i<m-1;i++) System.out.print(g[i]+" ");
        System.out.println(g[m-1]);
        System.out.println(cnt);
        for(int i=0;i<n;i++) System.out.println(a[i]);
    }
private static void insertionSort(int g){
        for(int i=g;i<=n-1;i++){
            int v=a[i];
            int j=i-g;
            while(j>=0&&a[j]>v){
                a[j+g]=a[j];
                j=j-g;
                cnt++;
            }
            a[j+g]=v;
        }
    }
}

Measured memory_bytes: 326100
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t X;
    std::cin >> X;

    int64_t dist = 0;
    int64_t time = 0;
    while (dist < X)
    {
        time++;
        dist += time;
    }
    
    std::cout << time << std::endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int main() {
	int r;

	std::cin >> r;

	if (r < 1200) {
		std::cout << "ABC" << std::endl;
	}
	else if (r < 2800) {
		std::cout << "ARC" << std::endl;
	}
	else {
		std::cout << "AGC" << std::endl;
	}
}

Measured memory_bytes: 256
from collections import defaultdict 
import sys
import heapq

sys.setrecursionlimit(10**8)

#N:頂点数   M:辺数
N,M,s,t = map(int,input().split())


#root[n] -> nからいけるlist
roots = defaultdict(set)

#weight[a] = start -> a のコスト 未探索->-1
weight_yen = [-1 for i in range(N+1)]
weight_snu = [-1 for i in range(N+1)]
weight_yen[s] = 0
weight_snu[t] = 0


for i in range(M):
	u,v,a,b = list(map(int,input().split())) #

	roots[u].add((v,a,b))
	roots[v].add((u,a,b))
		
	
def search_yen (n,w_0): #nから更新 w_0:確定コスト
	global weight_yen
		
	for root in list(roots[n]):
		i = root[0]
		w = w_0 + root[1]
		if weight_yen[i] == -1 or weight_yen[i] > w: #未探索orより小さい
			heapq.heappush(q, [w,i])
			weight_yen[i] = w
			
def search_snu (n,w_0): #nから更新 w_0:確定コスト
	global weight_snu
		
	for root in list(roots[n]):
		i = root[0]
		w = w_0 + root[2]
		if weight_snu[i] == -1 or weight_snu[i] > w: #未探索orより小さい
			heapq.heappush(q, [w,i])
			weight_snu[i] = w

#q = 次に探索する(確定する)もの q[0]=[w,n]
q = [[0,s]]
heapq.heapify(q)
			
while q:
	w,n = heapq.heappop(q)
	search_yen(n,w)
	
heapq.heappush(q, [0,t])
	
while q:
	w,n = heapq.heappop(q)
	search_snu(n,w)
	

finalans = float('inf')
ans_li = []

for i in range(0,N):
	ans = weight_yen[N-i] + weight_snu[N-i]
	finalans = min(finalans, ans)
	ans_li.append(finalans)
	
for i in range(N):
	print(10**15 - ans_li[N-i-1])

Measured memory_bytes: 74616
use std::io::*;
use std::cmp;

fn read() -> i64 {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char) 
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
    
  token.parse().ok().expect("failed to parse token")
}

fn main() {
  let (a, b, k) = (read(), read(), read());
  println!("{}",
    if k <= a { format!("{} {}", a - k, b) }
    else { format!("0 {}", cmp::max(b - (k - a), 0)) }
  );
}

Measured memory_bytes: 4352