akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5])yn;
    return 0;
}
 
 


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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a+b == c+d) cout << "Balanced" << endl;
  else if(a+b > c+d) cout << "Left" << endl;
  else cout << "Right" << endl;
  return 0;
}


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

int main(){
    long long H,W;
    cin >> H >> W;
    if(H == 1LL || W == 1LL){
        cout << "1" << endl;
    } else {
        if((H*W) % 2 == 1){
            cout << (H*W)/2 + 1 << endl;
        } else {
            cout << (H*W)/2 << endl;
        }
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static void Main()
    {
        string N = RString();
        long num = 0;
        for (int i = 0; i < N.Length; i++)
        {
            num += N[i] - '0';
        }
        WriteLine(num%9==0?"Yes":"No");
    }
}

class Scanner
{
    public static int RInt() => int.Parse(Console.ReadLine());
    public static long RLong() => long.Parse(Console.ReadLine());
    public static string RString() => Console.ReadLine();
    public static double RDouble() => double.Parse(Console.ReadLine());

    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static string[] RStrings() => Console.ReadLine().Split();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static T1 ReadStream<T1>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadStream<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadStream<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadStream<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[0], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[0], typeof(T4));
        return (r1, r2, r3, r4);
    }
}

Measured memory_bytes: 26476
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<int> A(N),B(N);
    for(int i=0;i<N;i++) cin >> A[i];
    for(int i=0;i<N;i++) cin >> B[i];
    int inf = 1e9;
    vvec<int> dp(1<<N,vec<int>(51,inf));
    dp[0][0] = 0;
    for(int S=0;S<(1<<N);S++){
        for(int j=0;j<N;j++) if(!(S&(1<<j))){
            int n = __builtin_popcount(S);
            int ne = (abs(n-j)%2? B[j]:A[j]);
            int T = S^(1<<j);
            int now = j;
            int cost = 0;
            for(int k=j+1;k<N;k++) if(S&(1<<k)) now++;
            if(now>=n) cost = now-n;
            int c = 0;
            for(int k=N-1;k>=0;k--){
                if(S&(1<<k)) c++;
                else if(k!=j && k+c<n) cost++;
            }
            for(int k=0;k<=50;k++) if(k<=ne && dp[S][k]!=inf){
                dp[T][ne] = min(dp[T][ne],dp[S][k]+cost);
            }
        }
    }
    int ans = inf;
    for(int k=0;k<=50;k++) ans = min(ans,dp[(1<<N)-1][k]);
    cout << (ans==inf? -1:ans) << endl;
}

Measured memory_bytes: 65792
X, N = map(int,input().split())
if N == 0:
    print(X)
    exit()

p = list(map(int,input().split()))
if p.count(X) == 0:
    print(X)
    exit()


l = list(range(0,102)) #ここの範囲設定が一番難しい部分だと思う
flist = []
for i in range(len(l)):
    if p.count(l[i]) == 0:
        flist.append(l[i])


flist.append(X)
anslist = sorted(flist)
t = anslist.index(X)

dist1 = anslist[t] - anslist[t-1] #Xと1つ前の数字との距離
dist2 = anslist[t+1] - anslist[t] #Xと1つ後ろの数字との距離
if dist1 <= dist2:
    print(anslist[t-1])
else:
    print(anslist[t+1])

Measured memory_bytes: 9064
#include<bits/stdc++.h>
using namespace std;
vector<int> e[200005];
int n,m,ans;bool vis[200005];
void bfs(int x)
{
	queue<int> q;int num=1;
	q.push(x);vis[x]=1;
	while(!q.empty())
	{
		int k=q.front();q.pop();
		for(int i=0;i<e[k].size();++i)
		 if(!vis[e[k][i]])
		 {
		 	vis[e[k][i]]=1;++num;
		 	q.push(e[k][i]);
		 }
	}
	if(num>ans) ans=num;
}
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;++i)
	{
		int x,y;
		cin>>x>>y;
		e[x].push_back(y);
		e[y].push_back(x);
	}
	for(int i=1;i<=n;++i)
	 if(!vis[i]) bfs(i);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 15248
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
		String s = sc.next();
		String t = sc.next();
		int a =sc.nextInt();
		int b =sc.nextInt();
		String u = sc.next();
		if (u.equals(s)) {
			System.out.print(a-1);
			System.out.print(" ");
			System.out.print(b);
		} else {
			System.out.print(a);
			System.out.print(" ");
			System.out.print(b-1);
		} 
		
		//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  string S;cin>>S;
  
  if(S=="Rainy"){
    cout<<"Sunny"<<endl;
  }
  else if(S=="Sunny"){
    cout<<"Cloudy"<<endl;
  }
  else{
    cout<<"Rainy"<<endl;
  }
}

Measured memory_bytes: 3588
#include<iostream>
#include<queue>

#define MAX 20
char map[MAX][MAX];
int mymap[MAX][MAX];
using namespace std;
typedef pair<int,int> p;
int direct_x[4] = {1,0,-1,0};
int direct_y[4] = {0,1,0,-1};
int main(void){
  int H,W;
  cin >> H >> W;
  for(int h=0;h<H;h++){
    for(int w=0;w<W;w++){
      cin >> map[h][w];
    }
  }
  int max = 0;
  for(int h=0;h<H;h++){
    for(int w=0;w<W;w++){
      //cout << h << w << endl;
      // whether (h,w) is '.'
      if(map[h][w] == '.'){
	int num=0;
	//initialize map
	for(int h1=0;h1<H;h1++){
	  for(int w1=0;w1<W;w1++){
	    mymap[h1][w1] = -1;
	  }
	}
	mymap[h][w] = 0;
	// make queue
	queue<p> q;
	p tmp(h,w);
	q.push(tmp);
	while(q.size()){
	  p point = q.front();
	  q.pop();
	  // search 4 points
	  for(int i=0;i<4;i++){
	    // inner points?
	    if(0 <= point.first + direct_x[i] && point.first + direct_x[i] < H
	       && 0 <= point.second + direct_y[i] && point.second + direct_y[i] < W){
	      // visited? on the path?
	      p next(point.first + direct_x[i],point.second + direct_y[i]);
	      if(map[next.first][next.second] == '.' && mymap[next.first][next.second] == -1){
		// marked
		  q.push(next);
		  mymap[next.first][next.second] = mymap[point.first][point.second]+1;
		}
	    }
	  }
	}
	//all distances have been calculated
	for(int h1=0;h1<H;h1++){
	  for(int w1=0;w1<W;w1++){
	    if(mymap[h1][w1] > max){
	      max = mymap[h1][w1];
	    }
	  }
	}
      }      
    }
  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 40) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<string, P>> v;
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        int p;
        cin >> p;
        v.push_back(make_pair(s, P(-p, i)));
    }
    sort(all(v));
    for(int i = 0; i < n; i++) {
        cout << v[i].second.second + 1 << endl;
    }
}

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

int main(){
	int n,m,flag=0,i,j;
	char s[256][16],t[16];
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%s",s[i]);
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%s",t);
		for(j=0;j<n;j++){
			if(!strcmp(t,s[j])){
				if(!flag){
					printf("Opened by %s\n",t);
					flag=1;
					break;
				}else{
					printf("Closed by %s\n",t);
					flag=0;
					break;
				}
			}
		}
		if(j==n)printf("Unknown %s\n",t);
	}
	return 0;
}

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

#define x first
#define y second

using namespace std;

typedef long long ll;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll x;
  cin >> x;
  if (x == 0) cout << 1 << '\n';
  else if (x == 1) cout << 0 << '\n';

  return 0;
}


Measured memory_bytes: 3648
a, b, c = map(int, input().split())
k = int(input())
flag = 0
for trial in range(0, k+1):
    for red in range(0, trial+1):
        for green in range(0, trial+1-red):
            for blue in range(0, trial+1-red-green):
                new_num = [a * 2**red, b * 2**green, c * 2**blue]
                if new_num[1] > new_num[0] and new_num[2] > new_num[1]:
                    flag = 1
if flag == 0:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 9140
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
    while(kbd.hasNext()){
        int n = kbd.nextInt();
        if(n!=0) solve(n);
    }
    }
 
    static void solve(int n){
    int taro = 0;
    int hana = 0;
    String t, h;
 
    while(n>0){
        t = kbd.next();
        h = kbd.next();
        int j = t.compareToIgnoreCase(h);
        if(j < 0){
        hana += 3;
        }
        else if(j > 0){
        taro += 3;
        }
        else{
        hana += 1;
        taro += 1;
        }
        n--;
    }
 
    System.out.println(taro+" "+hana);
    }
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn long long

typedef long long ll;
typedef pair<ll,ll> p;

string rotate(string s)
{
  return s.substr(1, int(s.size())-1) + s[0];
}

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

  for (int i = 0; i < int(s.size()); i++)
  {
    if(s == t){
      cout << "Yes" << endl;
      return 0;
    }
    s = rotate(s);
    // cout << s << endl;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-

S = input()
t = len(S)-1

for i in range(2**t):
    p = bin(i)[2:]
    p = "0"*(t - len(p))+p  # 桁数 t

    x = ""
    for j, k in enumerate(S):
        x += k
        if j != t and p[j] == "1":
            x += "+"
        elif j != t and p[j] == "0":
            x += "-"

    if eval(x) == 7:
        print("{0}=7".format(x))
        exit()


Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {

    int N; cin >> N;
    vector<ll> A(N);
    REP(i,N) cin >> A[i];
    sort(A.begin(), A.end());

    ll sum = 0;
    REP(i,N - 1) sum += A[i];

    for (int i = N - 2; i >= 0; i--) {
        if (sum * 2 < A[i + 1]) {
            cout << N - i - 1 << endl;
            return 0;
        }
        sum -= A[i];
    }

    cout << N << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.math.*

fun main(args: Array<String>) {
    val mod = 1000000007L
    val (n, m) = readInputLine().split(" ").map { it.toInt() }
    
    val factorial = LongArray(100001)
    
    factorial[0] = 1L
    for (i in 1..100000) {
        factorial[i] = factorial[i - 1] * i % mod
    }
    
    // 差が2以上の場合は並べ方なし
    if (Math.abs(n - m) >= 2) {
        println(0)
        return
    }
    
    // 同数の場合は階乗 * 階乗 * 2
    if (n == m) {
        println(factorial[n] * factorial[m] % mod * 2 % mod)
        return
    }
    
    // 差が1の場合は階乗 * 階乗
    println(factorial[n] * factorial[m] % mod)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 37780
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  string s;
  cin >> s;
  s[5] = ' ';
  s[5 + 7 + 1] = ' ';
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<limits.h>
using ll = unsigned long long;
using namespace std;

int main(void) {
    int n, k;
    cin >> n >> k;
    vector<ll> h(n);

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

    std::sort(h.begin(), h.end());
    // for(int i = 0; i < h.size(); ++i) {
        // cout << ":" << h[i] << endl;
    // }

    // n-k+1個チェックする
    ll minv = LLONG_MAX;
    ll cand = 0;
    for(int i = 0; i < n-(k-1); ++i) {

        // i: smallest i+k-1: iのk-1個大きい値
        cand = h.at(i+(k-1)) - h.at(i);
        // cout << "check:"<< i << ";" << h.at(i+(k-1)) << "-" << h.at(i) << endl;
        // cout << "cand:" << cand << endl;
        if ( cand < minv) {
            // cout << "swap" << endl;
            minv = cand;
        }
    }

    cout << minv << endl;

    return 0;
}

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

int main(){

    int A,B,C;
    cin>>A>>B>>C;
    int D=A,E=0,F=0;
    if(B>=D){
        E=D;
        D=B;
    }
    else E=B;
    if(C>=D){
        F=E;
        E=D;
        D=C;
    }
    else if(C>=E){
        F=E;
        E=C;
    }
    else F=C;

    int ans=0;
    if((D-E)%2==1) ans=ans+(D+1-E)/2+1;
    else ans=ans+(D-E)/2;
    if((D-F)%2==1) ans=ans+(D+1-F)/2+1;
    else ans=ans+(D-F)/2;
    if((D-E)%2==1&&(D-F)%2==1) ans-=3;
    cout<<ans<<endl;
}
    


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int a, b, card[15] = { 0,14,2,3,4,5,6,7,8,9,10,11,12,13 };
	scanf("%d %d", &a, &b);
	if (card[a] > card[b]) { printf("Alice\n"); }
	else {
		if (card[a] == card[b]) { printf("Draw\n"); }
		else { printf("Bob\n"); }
	}
	return 0;
}

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

#define y1 hasjdnasd
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define pb push_back
#define fr front()

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

#define ll long long
#define oo 1e18 + 7
#define int long long

const int N = 55;
int n , k , res , mod = 1e9 + 7;
int f[N][N];

struct Matrix
{
    int x[N][N];
    Matrix(){};
    Matrix(int a[N][N])
    {
        FOR(i , 1 , n)
            FOR(j , 1 , n)
                x[i][j] = a[i][j];
    }
    Matrix operator *(Matrix const &b)
    {
        Matrix c;
        FOR(i , 1 , n)
            FOR(j , 1 , n)
            {
                c.x[i][j] = 0;
                FOR(k , 1 , n)
                    c.x[i][j] = (c.x[i][j] + x[i][k] * b.x[k][j]) % mod;
            }
        return c;
    }
    friend Matrix operator ^ (Matrix const &a , int const b)
    {
        if(b == 1)
            return a;
        Matrix c = a ^ (b / 2);
        if(b & 1)
            return c * c * a;
        else
            return c * c;
    }
};

main()
{
    //freopen("R.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    FOR(i , 1 , n)
        FOR(j , 1 , n)
            cin >> f[i][j];
    Matrix I = Matrix(f);
    Matrix A = I ^ k;
    FOR(i , 1 , n)
    {
        FOR(j , 1 , n)
            res = (res + A.x[i][j]) % mod;
    }
    cout << res;
}


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

using namespace std;

int main()
{
	string o, e, r;
	cin >> o >> e;
	for (int i = 0; i < e.size(); i++)
	{
		r += o[i];
		r += e[i];
	}
	if (o.size() > e.size()) r += o.back();
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

int dp[100005][13];

signed main() {
	string s;
	cin >> s;
	dp[0][0] = 1;
	for (int i = 1; i <= s.size(); i++) {
		int now;
		if (s[i - 1] == '?') now = -1;
		else now = s[i - 1] - '0';
		for (int j = 0; j <= 9; j++) {
			if (now != -1 && now != j) {
				continue;
			}
			for (int k = 0; k <= 12; k++) {
				dp[i][(k * 10 + j) % 13] += dp[i - 1][k];
			}
			for (int k = 0; k <= 12; k++) {
				dp[i][k] %= MOD;
			}
		}
	}
	cout << dp[s.size()][5] << endl;

	return 0;
}


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

const ll MOD=1000000007;

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear1(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p){
  ll n=solveLinear1(a,p,1);
  n=n%p;
  if(n<0)return n+p;
  return n;
}

int main(){
  int i,j,k,cnt=0;
  int n;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)cin>>a[i];
  int b[100001];
  for(i=0;i<=100000;i++)b[i]=0;
  for(i=0;i<n;i++)b[a[i]]++;
  for(i=0;i<=100000;i++){
    if(b[i]>1)cnt+=b[i]-1;
  }
  if(cnt%2==0)cout<<n-cnt<<endl;
  else cout<<n-cnt-1<<endl;
}


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

int main() {
  int n, r;
  cin >> n >> r;
  if(n >= 10){
    cout << r << endl;
  }else{
    cout << r + (100 * (10 - n)) << endl;
  }
  return 0;
}

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

using namespace std;

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

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}


ll test(ll a, ll b, ll N){
	if(a%2 == b%2) return (b-a)/2;
	else return min(a-1, N-b) + (b-a+1)/2;
}

int main() {
	ll N, a, b;
	cin >> N >> a >> b;
	cout << test(a, b, N);
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<pair<int, int> > B(N * N);
    pair<int, int> p;
    int a = 0;
    vector<vector<pair<int, int> > > xy(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        for (int j = 0; j < A.at(i); j++) {
            cin >> B.at(a).first >> B.at(a).second;
            xy.at(i).push_back(B.at(a));
            a++; 
        }
    }

    int bit_keep, ans = 0, ans_keep;
    bool can;
    for (int bit = 0; bit < (1 << N); bit++) {
        bit_keep = bit;
        ans_keep = 0;
        can = true;
        for (int i = 0; i < N; i++) {
            if (bit_keep & (1 << i)) {
                for (int j = 0; j < A.at(i); j++) {
                    if (xy.at(i).at(j).second == 1 && !(bit_keep & (1 << (xy.at(i).at(j).first - 1)))) {
                        can = false;
                        break;
                    }
                    if (xy.at(i).at(j).second == 0 && bit_keep & (1 << (xy.at(i).at(j).first - 1))) {
                        can = false;
                        break;
                    }
                    if (xy.at(i).at(j).second == 1) {
                        bit_keep |= (1 << (xy.at(i).at(j).first - 1));
                    }
                    else {
                        bit_keep &= ~(1 << (xy.at(i).at(j).first - 1));
                    }
                }
            }
            if (!can) {
                break;
            }
        }
        for (int i = 0; i < N; i++) {
            if (bit & (1 << i)) {
                ans_keep++;
            }
        }
        if (!can) {
            ans_keep = 0;
        }
        ans = max(ans, ans_keep);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int n, k; cin >> n >> k;
    vector<int> A(n);
    for(int i = 0; i < n; i++)
    {
        cin >> A[i];
    }

    int idx = 0, ans = 0;
    while(idx < n)
    {
        int tmp_k = k - 1;
        while(tmp_k--)
        {
            if(idx >= n) break;
            if(A[idx] == 1)
            {
                tmp_k++;
                idx++;
                continue;
            }
            A[idx] = 1;
            idx++;
        }
        ans++;
    }
    cout << ans << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

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

int main() {
	int n,k; cin>>n>>k;
	int a[n],cnt=0,sum=0;
	for(int i=0;i<n;i++) cin>>a[i];
	int i=0;
	while(sum<=k && i<n) {
		sum+=a[i]; i++; cnt++;
	}
	if(sum<=k) cnt++;
	cout<<cnt; 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	ll a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a+3);
	if(a[0] * a[1] % 2 * a[2] % 2) cout << a[0] * a[1] << endl;
	else cout << 0 << endl;

}





Measured memory_bytes: 3608
"""
頂点1から頂点Nまでのルートの途中でサイクルがあれば、無限にスコアを大きくできる。
サイクルがない場合、V-1回でNまでのスコアが求まる。
サイクルがある場合、もう一周回すと、Nまでのスコアが増えているはず。
Nのスコアが増えたらサイクル有、ということ
"""
N,M = map(int,input().split())
edges = [list(map(int,input().split())) for _ in range(M)]
dp = [-1*float("INF")]*(N+1)
dp[1] = 0

for _ in range(N-1):
    for a,b,c in edges:
        dp[b] = max(dp[b],dp[a]+c)

tmp1 = dp[N]

for _ in range(N-1):
    for a,b,c in edges:
        dp[b] = max(dp[b],dp[a]+c)

tmp2 = dp[N]
if tmp2 > tmp1:
    print("inf")
else:
    print(tmp1)

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


class BIT():
    def __init__(self, n, data=None):
        self.n = n
        self.bit = [0] * (self.n + 1)
        self.data = [0] * (self.n + 1)
        if data:
            self.build(data)

    def build(self, data):
        for i in range(self.n):
            self.bit[i + 1] = self.data[i + 1] = data[i]
        for i in range(1, self.n):
            j = i + (i & (-i))
            if j <= self.n:
                self.bit[j] += self.bit[i]

    def add(self, idx, x):
        self.data[idx] += x
        while idx <= self.n:
            self.bit[idx] += x
            idx += (idx & (-idx))

    def sum(self, idx):
        s = 0
        while idx:
            s += self.bit[idx]
            idx -= (idx & (-idx))
        return s


n,q=map(int,input().split())
a=list(map(int,input().split()))
bit=BIT(n,a)
for i in range(q):
    t,x,y=map(int,input().split())
    if t==0:
        bit.add(x+1,y)
    else:
        print(bit.sum(y)-bit.sum(x))

Measured memory_bytes: 65032
def main():
    n = int(input())
    d = dict()
    for i in range(1, 10001):
        d[i] = 0
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                r = x**2+y**2+z**2+x*y+y*z+z*x
                if r <= 10000:
                    d[r] += 1
    for i in range(1, n+1):
        print(d[i])


main()


Measured memory_bytes: 69660
#include <stdio.h>
#include <math.h>

int isPrime(int x)
{
    if(x == 2) {
        return 1;
    }
    if(x < 2 || x % 2 == 0) {
        return 0;
    }
    int i = 3;
    while(i <= sqrt(x)) {
        if(x % i == 0) {
            return 0;
        }
        i = i + 2;
    }
    return 1;
}

int main(void){
    int i, n, p;
    int count = 0;
    
    scanf("%d\n", &n);
    
    for(i = 0; i < n; i++) {
        scanf("%d\n", &p);
        if(isPrime(p)) {
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 2100
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int max = 0;
		int pmu[] = {a + b, a - b, a * b};
		for(int i = 1; i < pmu.length;i++) {
		    if (pmu[i] > pmu[max]) {
		        max = i;
		    }
		}
		System.out.println(pmu[max]);
		

	}

}



Measured memory_bytes: 22868
X,Y = map(int,input().split())
def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a = 1
  b = 1
  c = 1
  for i in range(1,n+1):
    a = (a*i)%p
  for i in range(1,k+1):
    b = (b*i)%p
  for i in range(1,n-k+1):
    c = (c*i)%p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
if (X+Y)%3 != 0 or X > 2*Y or Y > 2*X:
    print(0)
else:
    ab = (X+Y)//3
    a = X - ab
    b = ab - a
    mod = 10**9+7
    ans = comb(ab,min(a,b),mod)
    print(ans)

Measured memory_bytes: 3192
n, goal = gets.split.map(&:to_i)
balls   = gets.split.map(&:to_i)
count   ={}

balls.each do |b|
  if count[b] == nil
    count[b]  = 1
  else
    count[b] += 1
  end
end

count = count.sort_by{|c| c[1]}
ans   = 0

(count.size - goal).times do |i|
  ans += count[i][1]
end

puts ans


Measured memory_bytes: 40960
#include <bits/stdc++.h>  
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod=1e9+7;
const ll longINF=3e18;
const double eps=1e-8;
const double dinf=190.0;
const double pi=acos(-1);
const int INF=2e9+1;

int n, a[100005],m[3];            
        
int main() 
{        
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);                     
        //freopen("input.txt","r",stdin);
        //freopen("output.txt","w",stdout);
        cin>>n;
        for (int i=0;i<n;i++) {
                cin>>a[i];
                if (a[i]%4==0)
                        a[i]=0;
                if (a[i]%4==2)
                        a[i]=2;
                if (a[i]%4==1 || a[i]%4==3)
                        a[i]=1;
                m[a[i]]++;
        }
        if (m[2]==0 && m[0]==n/2) {
                cout<<"Yes";
                return 0;
        }
        if (m[0]>=m[1])
                cout<<"Yes";
        else
                cout<<"No";
        return 0;

}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		sc.close();
		int[]g = new int[13];
		g[1] = 1;
		g[3] = 1;
		g[5] = 1;
		g[7] = 1;
		g[8] = 1;
		g[10] = 1;
		g[12] = 1;
		g[4] = 2;
		g[6] = 2;
		g[9] = 2;
		g[11] = 2;
		g[2] = 3;
		if(g[x] == g[y]) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def prime_factorize(n): # Nの素因数分解
    A = []
    while n % 2 == 0:
        A.append(2); n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            A.append(f); n //= f
        else:
            f += 2
    if n != 1:
        A.append(n)
    return A

N = ir()
primes = set(prime_factorize(N))
answer = 0
for p in primes:
    d = p
    while N%d == 0:
        answer += 1
        N //= d
        d *= p

print(answer)


Measured memory_bytes: 9212
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
import collections
n=int(input())
p=collections.Counter(prime_factorize(n))
p=p.values()

ans=0
for i in p:
    k=1
    while True:
        if i-k>=0:
            i-=k
            ans+=1
            k+=1
        else:
            break

print(ans)

Measured memory_bytes: 9364
n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))
c1,c2, c3 = 0,0,0
for i in range(n):
    if p[i] <= a:
        c1 +=1
    elif (a+1) <= p[i] <= b:
        c2 += 1
    elif (b+1) <= p[i]:
        c3 += 1
print(min(c1,c2,c3))

Measured memory_bytes: 3064
#!/usr/bin/python3
import sys

MEMO = dict()

def search(n, data):
    global MEMO

    if n in MEMO:
        return MEMO[n]
    else:
        if not n in data:
            MEMO[n] = 0
            return 0

        MEMO[n] = max(search(i, data) for i in data[n]) + 1
        return MEMO[n]


def main():
    # sys.setrecursionlimit(65535)
    sys.setrecursionlimit(10**9)
    N, M = map(int, input().split())
    data = dict()
    for _ in range(M):
        x, y = map(int, input().split())
        if x not in data:
            data[x] = [y]
        else:
            data[x].append(y)

    print(max(search(n, data) for n in range(1, N+1)))



if __name__ == '__main__':
    main()


Measured memory_bytes: 132752
module Weighted01DirectedGraph
  (* 頂点を添字，経路長を要素とした配列の実装 *)
  (Array : sig
    type t
    type key
    type elt = int (* 重みのない（=全ての重さが0か1な）グラフなので経路長は非負整数 *)
    val get : t -> key -> elt
    val set : t -> key -> elt -> unit
  end)
: sig
  type vertex = Array.key

  val shortest_path :
    (* 全ての頂点についての経路長が無限大で初期化された配列 *)
    Array.t ->
    (* 最短経路を求めたいグラフの，ある頂点から伸びる辺に対してのイテレータ
       重みが0の辺に対してはf0を，1の辺に対してはf1を用いる *)
    (vertex -> f0:(vertex -> unit) -> f1:(vertex -> unit) -> unit) ->
    (* 始点 *)
    vertex ->
    (* 終点を受け取って，始点からの最短距離を返す関数
       始点から辿り着けない場合，無限大を返す
       この関数を覚えておけば，呼び出しごとの途中までの計算結果がシェアされる *)
    (vertex -> int)
end =
struct
  type vertex = Array.key

  let shortest_path d es s =
    (* 始点への経路長を0にする *)
    Array.set d s 0;
    let w = ref 1 in
    let q = ref [s] in
    let rec bfs t =
      match !q with
      (* もう既に全ての頂点までの経路が分かっているので返す *)
      | [] -> Array.get d t
      | us ->
          match Array.get d t with
          (* 既に終点までの距離が分かっているので返す *)
          | x when x < !w -> x
          (* 終点までの距離が分かっていないので，BFSを続行 *)
          | _ ->
              q := [];
              List.iter dfs us;
              incr w;
              bfs t
    and dfs u =
      es u
        ~f0:(fun v ->
          if !w <= Array.get d v then
            (Array.set d v (!w - 1); dfs v))
        ~f1:(fun v ->
          if !w < Array.get d v then
            (Array.set d v !w; q := v :: !q)) in
    bfs
end

module G = Weighted01DirectedGraph (struct
  type t = int array
  type elt = int
  type key = int
  let get = Array.get
  let set = Array.set
end)

let () = Scanf.scanf "%d" @@ fun k ->
  Printf.printf "%d\n" @@
  succ @@
  G.shortest_path
    (Array.make k max_int)
    (fun i ~f0 ~f1 -> f0 (i * 10 mod k); f1 ((i + 1) mod k)) 1 0


Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
int a[500005];
long long int ans;
int cmp(int xx,int yy)
{
	return xx>yy;
}
int main()
{
    int n,i;
    cin>>n;
    for(i=1;i<=n;i++)
	cin>>a[i];
	sort(a+1,a+n+1,cmp);
	n--;
	if(n==0)cout<<"0";
	else
	{
	ans+=a[1];
	n--;
    if(n%2==0)
    {
    	for(i=2;i<=(n+2)/2;i++)
    	ans+=a[i]*2;
	}
	else
	{
		for(i=2;i<=(n+2)/2;i++)
		ans+=a[i]*2;
		ans+=a[(n+2)/2+1];
	}
	cout<<ans;
	}
	
} 

Measured memory_bytes: 4308
x, y = map(int, input().split())
if y == 0 and x <= 0:
    print(abs(x-y))
elif x >= 0 and y == 0:
    print(abs(x-y)+1)
elif x >= 0 and y >= 0:
    if x <= y:
        print(abs(x-y))
    else:
        print(abs(x-y)+2)
elif x <= 0 and y >= 0:
    print(abs(y-abs(x))+1)
elif x >= 0 and y <= 0:
    print(abs(x-abs(y))+1)
elif x <= y:
    print(abs(x-y))
else:
    print(abs(x-y)+2)

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include<algorithm>
#include <cstdlib>
#include <cmath>

using namespace std;

int main()
{
	int n,a,b,ans=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		ans += b - a + 1;
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <stack>
#include <vector>
#include <set>
#include <cstring>
#include <algorithm>
#define INT long long
#define oo 987654321
using namespace std;

int n, m, r, w[220][220], ord[10], chk[10], ans = oo;
int main()
{
    ios::sync_with_stdio(false);
    memset(w, 0x3f, sizeof(w));
    cin>>n>>m>>r;
    for(int i = 0 ; i < r ; i++ ) cin>>ord[i];
    for(int i = 0, a, b, c ; i < m ; i++ )
        cin>>a>>b>>c, w[a][b] = w[b][a] = c;
    for(int k = 1 ; k <= n ; k++ )
        for(int i = 1 ; i <= n ; i++ )
            for(int j = 1 ; j <= n ; j++ )
                if( i!=j and w[i][j] > w[i][k] + w[k][j] )
                    w[i][j] = w[i][k] + w[k][j];
                else if( i == j ) w[i][j] = 0;
    sort(ord, ord+r);
    do{
        int now = 0;
        for(int i = 1 ; i < r ; i++ )
            now += w[ord[i-1]][ord[i]];
        ans = min( ans, now );
        
    }while( next_permutation(ord, ord+r) );
    cout<<ans<<endl;
}

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

#define REP(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main(void)
{
    const int N_MAX = 18;
    int N;
    int l[N_MAX];
    int r[N_MAX];
    int count[7];
    while (scanf("%d", &N) != EOF) {
        REP(i, 7) count[i] = 0;
        REP(i, N) {
            char c;
            cin >> c;
            l[i] = c - '0';
            cin >> c;
            r[i] = c - '0';
            ++count[l[i]];
            ++count[r[i]];
        }
        int odd = 0;
        REP(i, 7) {
            if (count[i] % 2 == 1) {
                ++odd;
            }
        }
        if (odd > 2) {
            cout << "No" << endl;
        } else {
            int dbl = 0;
            int N0 = N;
            REP(i, N) {
                if (l[i] == r[i]) {
                    ++dbl;
                    if (count[l[i]] > 2) {
                        --dbl;
                        --N0;
                        count[l[i]] -= 2;
                    }
                }
            }
            if (N0 == 1 || dbl == 0) {
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        }
    }
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<string>s(n);
    for (int i = 0; i < n; i++)
    {
        cin >> s.at(i);
    }
    sort(s.begin(),s.end());
    int countt = 1;
    for (int i = 1; i < s.size(); i++)
    {
        if(s.at(i) != s.at(i-1)){
            countt++;
        }
    }
    
    cout << countt << endl;
    

}

Measured memory_bytes: 9484
#include<stdio.h>
#include<string.h>
int main()
{
	char  a[101];
    int l,i,j=0,f,b,c=0;
    gets(a);
    l=strlen(a);
    for(i=0;i<l;i++)
    {
    	if(a[i]=='C')
		 {    f=i;
		 c=1;}
    		 	if(a[i]=='F'){
    		b=i;j=1;
    		 }
    	
    }
    
     
  if(c&j&f<b)
    printf("Yes\n");
    else
    printf("No\n");
    
   return 0;
	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod= 1e9+7;

int main(){
  int N,l[1000],r[1000];
  cin>>N;
  for (int i(0);i<N;i++) cin>>l[i]>>r[i];
  ll sum(0);
  for (int i(0);i<N;i++) {
    sum+=r[i]-l[i]+1;
  }
  cout << sum << endl;
  return 0;
}


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

int main(){  
 string n;
 int a,b;
 cin >> n;
 a = ((n[0] - '0')*10 + (n[1] - '0') );
 b = ((n[2] - '0')*10 + (n[3] - '0') );
 if ((1 <= a) && (a<= 12)){
    if ((1 <= b) && (b<= 12)){
        cout << "AMBIGUOUS" << endl;
    }
    else{
        cout << "MMYY" << endl;
    }
 }
else
    if ((1 <=b) && (b<= 12)){
        cout << "YYMM" << endl;
    }
    else{
        cout << "NA" << endl;
    }
} 

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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double EPS = 1e-10;
typedef complex<double> P;
namespace std {
	bool operator < (const P& a, const P& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
double cross(const P& a, const P& b) {
	return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
	return real(conj(a)*b);
}

struct L : public vector<P> {
	L(const P &a, const P &b) {
		push_back(a); push_back(b);
	}
};

int main(){
	double xA, yA, xB, yB, xC, yC, xD, yD;
	while(cin >> xA >> yA >> xB >> yB >> xC >> yC >> xD >> yD){
		L a(P(xA, yA), P(xB, yB)), b(P(xC, yC), P(xD, yD));

		if(abs(dot(a[0]-a[1], b[0]-b[1])) < EPS) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

Measured memory_bytes: 1224
class Proc:
    def __init__(self, name, time):
        self.name = name
        self.time = time

n, q = map(int, input().split(' '))
procs = []

for i in range(0, n):
    name, time = input().split(' ')
    time = int(time)
    procs.append(Proc(name, time))

elapsed = 0
while len(procs) > 0:
    proc = procs.pop(0)
    if proc.time > q:
        proc.time -= q
        elapsed += q
        procs.append(proc)
    else:
        elapsed += proc.time
        print(proc.name, elapsed)

Measured memory_bytes: 19324
#include <bits/stdc++.h>
#define  rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;


int main()
{
    int a,b,h;
    cin>>a>>b>>h;
    cout<<(a+b)*h/2<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
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 gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;

void solve()
{
	int n;
	cin>>n;
	vector<ll>a(n),b(n);
	rep(i,n)cin>>a[i]>>b[i];
	sort(all(a));
	sort(all(b));
	int x=n/2;
	if(n%2==1)
	cout<<b[x]-a[x]+1;
	else {
		cout<<(b[x]+b[x-1]-(a[x]+a[x-1]))+1;
	}
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}


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

int main() {
	int a,b,cnta,cntb,maxa,maxb,max1,max2;
	cin >> a >>b;
	cnta=a+(a-1);
	cntb=b+(b-1);
	max1=max(cnta,cntb);
	max2=a+b;
	max1=max(max1,max2);
	cout << max1<< endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
d,x = map(int, input().split())
a = [int(input()) for i in range(n)]
a_eat = []
for i in range(n):
    y = 1
    j = 1
    while j+a[i] <= d:
        y += 1
        j += a[i]
    a_eat.append(y)

print(sum(a_eat)+x)

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

int main() {
  int n;
  cin>>n;
  string S[50];
  for (int i(0);i<n;i++)cin>>S[i];
  int ans[30]={0};
  for (int i(0);i<30;i++)ans[i]=10000;
  for (int i(0);i<n;i++){
    int list[30]={0};
    for (int j(0);j<S[i].size();j++){
      list[S[i][j]-'a']+=1;
    }
    for (int j(0);j<30;j++){
      ans[j]=min(ans[j],list[j]);
    }
  }
  for (int i(0);i<30;i++){
    for (int j(0);j<ans[i];j++){
      cout << (char)('a'+i);
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;

bool solver(double xa1,double ya1,double xa2,double ya2,double xb1,double yb1,double xb2,double yb2){
    if(xa1 > xb2 || xb1 > xa2) return false;
    if(ya1 > yb2 || yb1 > ya2) return false;
    return true;
}

int main(){
    while(cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2){
        cout << (solver(xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2)?"YES":"NO") << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(llint i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
const ll mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const ll INF = 1000000000;



int main() {
	int n, m, k;
	cin >> n >> m >> k;
	whei(int) G(n),B(n);
	rep(i, 0, m) {
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	rep(i, 0, k) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		B[a].push_back(b);
		B[b].push_back(a);
	}
	hei(int) Tag(n, -1), Ts(n+1, 0);
	int T = -1;
	rep(i, 0, n) {
		if (Tag[i] != -1) {
			Ts[Tag[i]]++;
			continue;
		}
		T++;
		Ts[T]++;
		queue<int> que;
		que.push(i);
		while (!que.empty()) {
			int v = que.front();
			que.pop();
			Tag[v] = T;
			for (int x : G[v]) {
				if (Tag[x] == -1)que.push(x);
			}
		}
	}
	rep(i, 0, n) {
		int ans = Ts[Tag[i]] - G[i].size()-1;
		for (int v : B[i])if (Tag[i] == Tag[v])ans--;
		cout << ans;
		if (i == n - 1)cout << endl;
		else cout << " ";
	}
    return 0;
}

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

using int64 = long long;

int64 Solve(const int64 N, const int64 C, const vector<int64>& x, const vector<int64>& v) {
  vector<int64> a(N);
  int64 sa = 0;
  for (int64 i = 0; i < N; ++i) {
    sa += v[i];
    a[i] = sa - x[i];
  }
  vector<int64> b(N);
  int64 sb = 0, mb = 0;
  for (int64 i = N - 1; i >= 0; --i) {
    sb += v[i];
    mb = max(mb, sb - (C - x[i]));
    b[i] = mb;
  }

  int64 ret = 0;
  for (int64 i = 0; i < N; ++i) {
    ret = max(ret, a[i]);  // no return
    if (i < N - 1)
      ret = max(ret, a[i] + b[i + 1] - x[i]);  // no return
  }
  return ret;
}

int main() {
  int64 N, C;
  cin >> N >> C;
  vector<int64> x(N), v(N);
  for (int64 i = 0; i < N; ++i) {
    cin >> x[i] >> v[i];
  }
  int64 a = Solve(N, C, x, v);
  for (int64 i = 0; i < N; ++i)
    x[i] = C - x[i];
  reverse(x.begin(), x.end());
  reverse(v.begin(), v.end());
  int64 b = Solve(N, C, x, v);
  cout << max(a, b) << "\n";
  return 0;
}


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

int N,M;

int main(){
    cin>>N>>M;
    vector<long long> a[3];
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            long long num;cin>>num;
            a[j].push_back(num);
        }
    }

    long long res=0;
    for(int bit=0;bit<(1<<3);bit++){
        vector<long long>b;
        for(int i=0;i<N;i++){
            long long tmp=0;
            for(int j=0;j<3;j++){
                if(bit&(1<<j))tmp+=a[j][i];
                else tmp-=a[j][i];
            }
            b.push_back(tmp);
        }
        sort(b.begin(),b.end(),greater<long long>());
        long long sum=0;
        for(int i=0;i<M;i++){
            sum+=b[i];
        }
        res=max(res,sum);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
S = input()

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

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

Measured memory_bytes: 3064