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

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

// N%10 N%100/10 N%1000/100 N/1000
  if (N%10 == (N%100)/10 && (N%100)/10 == (N%1000)/100 && (N%1000)/100 == N/1000) {
  cout << "Yes" << endl;
  }
  else if (N%10 == (N%100)/10 && (N%100)/10 == (N%1000)/100) {
  cout << "Yes" << endl;
  }
  else if ((N%100)/10 == (N%1000)/100 && (N%1000)/100 == N/1000) {
  cout << "Yes" << endl;
  }
  else {
  cout << "No" << endl;
  }
}

Measured memory_bytes: 3600
fun main(args: Array<String>) {
    val (n,m) = readLine()!!.split(" ").map(String::toInt)
    val ans = IntArray(n)
    repeat(m) {
        val (a, b) = readLine()!!.split(" ").map(String::toInt).map(Int::dec)
        ans[a]++
        ans[b]++
    }
    ans.forEach(::println)
}


Measured memory_bytes: 37908
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  private static final long MOD = 1000000007L;


  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    long a = sc.nextLong();
    long b = sc.nextLong();

    long c = sc.nextLong();
    long d = sc.nextLong();

    a--;

    long cumA = a - (a / c + a / d - a / lcm(c, d));
    long cumB = b - (b / c + b / d - b / lcm(c, d));

    os.println(cumB - cumA);
  }

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

  static long gcd(long a, long b) {
    long r;
    while( (r = a % b) != 0 ) {
      a = b;
      b = r;
    }
    return b;
  }
}

Measured memory_bytes: 23636
#include<iostream>
#define mod 1000000007
#define ll long long
#define inf 1e9
using namespace std;
int h,w;
ll dp[1005][1005];
char s[1005][1005];
int main()
{
	cin>>h>>w;
	for(int i=1;i<=h;i++){
	for(int j=1;j<=w;j++)cin>>s[i][j];
	}
	dp[1][1]=1;
	for(int i=0;i<=h;i++){
		for(int j=0;j<=w;j++){
			if(!i||!j)dp[i][j]=0;
			else if(i!=1||j!=1){
				dp[i][j]=(((s[i-1][j]=='.')?dp[i-1][j]:0)+((s[i][j-1]=='.')?dp[i][j-1]:0))%mod;
			}
		}
	}
	cout<<dp[h][w];
}

Measured memory_bytes: 9088
using System;

namespace ConsoleApplication18
{
    class Program
    {
        static void Main(string[] args)
        {
            int H = 1;
            int W = 1;
            for ( int a = 0 ; a < 5; )
            {
            string[] str = Console.ReadLine().Split(' ');
            H = int.Parse(str[0]);
            W = int.Parse(str[1]);
                if (H == 0 && W == 0)
                {
                    break;
                }
                else
                {
                    for (int I = 0; I < H; I++)
                    {
                        for (int i = 0; i < W; i++)
                        {
                            Console.Write("#");
                        }
                        Console.WriteLine("");
                    }
                    Console.WriteLine("");
                } 
             }
        }
    }
}

Measured memory_bytes: 8764
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

void dfs(int v, int p, vector<vector<int>> &G, vector<int> &score) {
    if(p >= 0)
        score[v] += score[p];
    for(int nv : G[v]) {
        if(nv == p)
            continue;
        dfs(nv, v, G, score);
    }
}

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<vector<int>> G(N, vector<int>());
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    vector<int> score(N);
    rep(i, Q) {
        int p, x;
        cin >> p >> x;
        p--;
        score[p] += x;
    }
    dfs(0, -1, G, score);
    rep(i, N) { cout << score[i] << ((i == N - 1) ? "\n" : " "); }
    return 0;
}

Measured memory_bytes: 26624
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		int min = Integer.MAX_VALUE;
		for (long i = 1; i * i <= n; i++) {
			if (n % i == 0) {
				long x = n / i;
				int f = Math.max(String.valueOf(i).length(), String.valueOf(x).length());
				if (min > f) {
					min = f;
				}
			}
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 22736
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		String s = sc.next();
		char[] a = s.toCharArray();
		char[] b = sc.next().toCharArray();
		sc.close();
		boolean you = false;
		for(int i = 0 ; i < s.length() ; i++){
			boolean che = true;
			for(int j = 0 ; j < s.length() ; j++){
				if(a[j] != b[(j + i) % s.length()]) che = false;
			}
			if(che) you = true;
		}
		if(you) ou.println("Yes");
		else ou.println("No");
		ou.flush();
	}
}

Measured memory_bytes: 27048
x, n = list(map(int, input().split()))


if n == 0:
    print(x)
else:
    pn = list(map(int, input().split()))
    for i in range(x + 1):
        if x - i not in pn:
            print(x - i)
            break
        elif x + i not in pn:
            print(x + i)
            break
    else:
        print(-1)


Measured memory_bytes: 9160
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = getInt(sc);
		int b = getInt(sc);
		int m = getInt(sc);

		int[] freezer = new int[a];
		int[] microwave = new int[b];

		int minFreezer = Integer.MAX_VALUE;
		int minMicrowave = Integer.MAX_VALUE;

		for (int i = 0; i < a; i++) {
			int price = getInt(sc);
			freezer[i] = price;
			if (price < minFreezer) {
				minFreezer = price;
			}
		}

		for (int i = 0; i < b; i++) {
			int price = getInt(sc);
			microwave[i] = price;
			if (price < minMicrowave) {
				minMicrowave = price;
			}
		}

		// 割引券不使用
		int min = minFreezer + minMicrowave;

		// 割引券使用
		for (int i = 0; i < m; i++) {
			int couponF = getInt(sc);
			int couponM = getInt(sc);
			int discount = getInt(sc);
			int price = freezer[couponF - 1] + microwave[couponM - 1] - discount;
			if (price < min) {
				min = price;
			}
		}
		System.out.println(min);

	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}


Measured memory_bytes: 65008
n,a,b = map(int,input().split())
s = list(input())
finalists = a + b
rank_b = 0

for i in range(n):
	if s[i] == "a":
		if finalists > 0:
			print("Yes") 
			finalists -= 1
		else:
			print("No")
	elif s[i] == "b":
		rank_b += 1
		if finalists > 0 and rank_b <= b:
			print("Yes") 
			finalists -= 1
		else:
			print("No")
	else:
		print("No")

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

typedef long long LL;

const int N=10;

int n,m;

void into(){
  scanf("%d%d",&n,&m);
}

int ans[(1<<N)+9][(1<<N)+9];

void Dfs_ans(int x,int y,int n){
  if (!n) return;
  int t=1<<n-1;
  ans[x+t][y+t]=1;
  Dfs_ans(x,y,n-1);
  Dfs_ans(x,y+t,n-1);
  Dfs_ans(x+t,y,n-1);
  Dfs_ans(x+t,y+t,n-1);
}

void work(){
  Dfs_ans(0,0,max(n,m));
}

void outo(){
  for (int i=1;i<1<<n;++i){
	for (int j=1;j<1<<m;++j)
      putchar(ans[i][j]+'0');
    puts("");
  }
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 7788
def test():

	inputs = list(map(int,input().split()))

	n = inputs[0]
	m = inputs[1]

	A = [[0 for i in range(m)] for j in range(n)]
	b = [0 for i in range(m)]
	Answer = [0 for i in range(n)]
	

	# Read A
	for i in range(n):
		inputs = list(map(int,input().split()))
		for j in range(m):
			A[i][j] = inputs[j]
	# Read b
	for i in range(m):
		b[i] = int(input())

	for i in range(n):
		for j in range(m):
			Answer[i] += A[i][j] * b[j]

		print(f"{Answer[i]}")


if __name__ == "__main__":
	test()


Measured memory_bytes: 5956
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <set>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cstring>
#include <map>
#include <queue>
using namespace std;

vector<vector<int>> vc(100001);


int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		vc[a].push_back(b);
	}
	long long ans = 0;
	priority_queue<int> pq;
	for (int i = m - 1; i >= 0; i--) {
		for (auto x : vc[m-i]) {
			pq.push(x);
		}
		if(pq.size()) {
			ans += pq.top();
			pq.pop();
		}
			
	}
	cout << ans;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int M;
  cin >> N >> M ;
  vector<int> A(M);
  
  for (int i = 0; i < M ; i++) {
    cin >> A.at(i);
  }
  
  int S = 0;
  
  for (int i = 0 ; i < M ; i++) {
    S = S + A[i];
  }
    
  int R;
  
  R = N - S;

  if(R >= 0){
    cout << R <<endl;
  }else{
    cout << -1 <<endl;
  }  
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    ll n;
    cin >> n;
    vector <ll> h(n);
    rep(i,0,n){
        cin >> h[i];
    }
    ll x =0;
    rep(i,0,n){
        if (h[i] > x) h[i]--;
        if (h[i] <x) {
            no
            return 0;
        }
        x = h[i];
    }
    yes

}

Measured memory_bytes: 1152
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
int dp[100000][3];
int main(){
  int N;
  int K;
  int R;
  int S;
  int P;
  string T;
  cin >> N >> K;
  cin >> R >> S >> P;
  cin >> T;

  int ans = 0;
  for(int i = 0; i < K; i++){
    for(int j = 0; j < 3; j++){
      dp[0][j] = 0;
    }
    if(T[i] == 's'){
      dp[0][0] = R;
    } else if(T[i] == 'p'){
      dp[0][1] = S;
    } else {
      dp[0][2] = P;
    }
    int j_count = 0;
    for(int j = 1; i + K * j < N; j ++){
      j_count = j;
      if(T[i + K * j] == 's'){
        dp[j][0] = R + max(dp[j - 1][1], dp[j - 1][2]);
        dp[j][1] = max(dp[j - 1][0], dp[j - 1][2]);
        dp[j][2] = max(dp[j - 1][0], dp[j - 1][1]);
      } else if(T[i + K * j] == 'p'){
        dp[j][0] = max(dp[j - 1][1], dp[j - 1][2]);
        dp[j][1] = S + max(dp[j - 1][0], dp[j - 1][2]);
        dp[j][2] = max(dp[j - 1][0], dp[j - 1][1]);
      } else {
        dp[j][0] = max(dp[j - 1][1], dp[j - 1][2]);
        dp[j][1] = max(dp[j - 1][0], dp[j - 1][2]);
        dp[j][2] = P + max(dp[j - 1][0], dp[j - 1][1]);
      }
    }
    ans += max(dp[j_count][0], max(dp[j_count][1], dp[j_count][2]));
    /*
    for(int j = 0; j <= j_count; j++){
      for(int k = 0; k < 3; k++){
        cout << dp[j][k] << " ";
      }
      cout << endl;
    }*/
    //cout << ans << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1664
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




ll dp[3005][3005];

int main() {
    string s, t;
    cin >> s >> t;
    ll n = s.size(), m = t.size();
    for(ll i = 1; i <= n; i++){
        for(ll j = 1; j <= m; j++){
            if(s[i - 1] == t[j - 1]){
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else{
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    
    ll x = n, y = m;
    string ans(dp[n][m], ' ');
    while(x > 0 && y > 0 && dp[x][y] > 0){
        while(dp[x - 1][y] == dp[x][y]) x--;
        while(dp[x][y - 1] == dp[x][y]) y--;
        ans[dp[x][y] - 1] = s[x - 1];
        x--; y--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 70656
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    sx,sy,tx,ty = map(int,ipt().split())
    dx = tx-sx
    dy = ty-sy
    print("U"*dy+"R"*dx+"D"*dy+"L"*dx+"L"+"U"*(dy+1)+"R"*(dx+1)+"D"+"R"+"D"*(dy+1)+"L"*(dx+1)+"U")
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 38636
#include<bits/stdc++.h>
using namespace std;tuple<int,int,int>x[1<<17];int n,m,a,b,c,s,h,i,j,k;int dx[2][3]={{1,1,0},{0,-1,-1}},dy[2][3]={{0,1,1},{1,1,0}};main(){cin>>n;for(i=0;i<n;i++){cin>>a>>b>>c;x[i]=make_tuple(a,b,c);}sort(x,x+n);for(i=0;i<n;i++){for(h=0;h<2;h++){for(j=0;j<8;j++){s=0;for(k=0;k<3;k++){if((j/(1<<k))%2==0){c=lower_bound(x,x+n,make_tuple(get<0>(x[i])+dx[h][k],get<1>(x[i])+dy[h][k],0))-x;if(get<0>(x[c])==get<0>(x[i])+dx[h][k]&&get<1>(x[c])==get<1>(x[i])+dy[h][k]){s+=get<2>(x[c]);}}}m=max(m,s+get<2>(x[i]));}}}cout<<m<<" / 1"<<endl;}

Measured memory_bytes: 4256
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    string a,b,c;
    cin>>a>>b>>c;
    
    if(a.at(a.size()-1)==b.at(0) && b.at(b.size()-1)==c.at(0)) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
    return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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 U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}


int main(void) {
    int64 N;
    cin >> N;
    vector<int64> A(N), ml(N+1, 0), mr(N+1, 0);
    REP(i, N) cin >> A[i];
    REP(i, N) {
        ml[i+1] = max(ml[i], A[i]);
        mr[N-i-1] = max(mr[N-i], A[N-i-1]);
    }
    REP(i, N) {
        cout << max(ml[i], mr[i+1]) << endl;
    }
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
int main() {
  ll N,K,h[100000],dp[100000];
	for(int i = 0; i < 100000; i++)dp[i] = 1145141919810893;
  cin>>N>>K;//足場の個数N//何個先まで飛べるかK
  for(ll i=0;i<N;i++){//各足場の高さ
    cin>>h[i];
  }
  dp[0]=0;
  for(ll i=1;i<N;i++){
	  ll ans = 1145141919810893;
    for(ll j=1;j<=min(K,i);j++){
      ans=min(dp[i-j]+nature(h[i]-h[i-j]),ans);//各足場までの最小コスト
    }
    dp[i]=ans;
  }
  cout<<dp[N-1]<<endl;
}

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

using namespace std;

const int N = 100000 + 77 , L = 30;
int n , P[N] , Tx , Ty , a , b , c;
int main(){
   ios::sync_with_stdio(0);cin.tie(0);
   cin >> n >> Tx >> Ty;
   for(int x ,  i = 1;i <= n;++ i){
      cin >> x;
      a += x <= Tx;
      b += x > Tx && x <= Ty;
      c += x > Ty;
   }
   cout << min(a , min(b , c));
   return 0;
}



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

using namespace std;

int main(void) {
	long long X, Y, n;

	cin >> X >> Y;

	if (X + Y < 2) {
		cout << "Brown" << endl;
	}
	else if (abs(X - Y) >= 2) {
		cout << "Alice" << endl;
	}
	else if (abs(X - Y) < 2) {
		cout << "Brown" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long gcd(long long  a, long long b)
{
	long long g = 1;
	const int odd = 1;

	while (a > 0)
	{
		if ((a & odd) == 0 && (b & odd) == 0)
		{
			a = a >> 1;
			b = b >> 1;
			g = 2 * g;
		}
		else if ((a & odd) == 0)
		{
			a = a >> 1;
		}
		else if ((b & odd) == 0)
		{
			b = b >> 1;
		}
		else
		{
			long long t = abs(a - b) >> 1;
			if (a >= b) a = t;
			else b = t;
		}
	}
	return g * b;
}

int main() {
	long long n, m, l;
	char s[100000], t[100000];

	cin >> n >> m >> s >> t;

	if (s[0] != t[0]) {
		cout << -1;
		return 0;
	}

	l = (n * m) / gcd(n, m);

	long long c, d;

	c = l / n;
	d = l / m;

	for (int i = 1; i * d < n || i * c < m; i++) {
		if (s[i * d] != t[i * c]) {
			cout << -1;
			return 0;
		}
	}

	cout << l;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<pair<int,int>>p(n);
  for(int i=0;i<n;i++){
    int num;
    cin >> num;
    p.at(i)=make_pair(num,i+1);
  }
  sort(p.begin(),p.end());
  for(int i=0;i<n;i++){
    cout << p.at(i).second << " ";
  }
  return 0;
}
  

Measured memory_bytes: 1536
// 091-A
// hapdap
#include<stdio.h>

int main(void){
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);

  if(A+B<C){
	  printf("No\n");
  }else{
    printf("Yes\n");
  }

	return 0;
}

Measured memory_bytes: 128
open Batteries

let () =
  let n, m, x = Scanf.scanf "%d %d %d\n" (fun a b c -> a, b, c) in

  let arr = Array.make m 0 in
  for i = 0 to m-1-1 do
    let c = Scanf.scanf "%d " (fun c -> c) in
    Array.set arr i c
  done;
  let c = Scanf.scanf "%d\n" (fun c -> c) in
  Array.set arr (m-1) c;

  let l = ref 0 in
  let r = ref 0 in
  for i = 0 to m-1 do
    let v = Array.get arr i in
    if v < x then
      (l := !l + 1)
    else 
      (r := !r + 1)
  done;

  print_endline (string_of_int (
      if (!l > !r) then !r else !l
    ))


Measured memory_bytes: 1152
N,M,C=[int(x) for x in input().split()]
BM=[int(x) for x in input().split()]
ans=0
for i in range(N):
  AiM=[int(x) for x in input().split()]
  sum=0
  for i in range(M):
    sum+=AiM[i]*BM[i]
  if sum+C>0:
    ans+=1

print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
int main(void){
    int n,i,j,ii,tmp;
    int sum2=0;
    int undiv[100]={0};
    scanf("%d",&n);
    //int *point;
    //point = (int*)malloc(n*sizeof(int));
    for(i=0,j=0;i<n;i++){
        scanf("%d",&tmp);
        if(tmp%10){
            undiv[j]=tmp;
            j++;
        }else{
            sum2+=tmp;
        }
    }
    if(j==0){
        printf("0");
        return 0;
    }
    for(i=0;i<j;i++){
        for(ii=j-1;ii>=i;ii--){
            if(undiv[ii]<undiv[ii-1]){
                tmp=undiv[ii];
                undiv[ii]=undiv[ii-1];
                undiv[ii-1]=tmp;
            }
        }
    }
    int sum=0;
    for(i=0;i<j;i++){
        sum+=undiv[i];
    }
    if(sum%10){
        printf("%d",sum+sum2);
    }else{
        sum-=undiv[0];
        printf("%d",sum+sum2);
    }
    return 0;
}


Measured memory_bytes: 128
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
total=0
ans=0
for i in range(n):
    total+=a[i]
a.reverse()
for i in range(m):
    if a[i]>=total/(4*m):
        ans+=1
if ans==m:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
map <int,int> mp;
bool check(int a)
{
  string s=to_string (a);
  for (int i=0;i<s.size();i++)
  {
    int y=s[i]-'0';
    if (mp[y])
      return false;
  }
  return true;
}
int main()
{
  int n,l;
  cin>>n>>l;
  for (int i=0;i<l;i++)
  {
    int u;
    cin>>u;
    mp[u]++;
  }
  for (int i=n;i<=10*n;i++)
  {
    if (check(i))
    {
      cout<<i;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

// 分数の Ceil を求める関数
UInt Ceil(const UInt a, const UInt b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return a / b + 1;
    }
}

int main(void) {
    Int n;
    cin >> n;
    cout << Ceil(n, 2) << endl;
    return 0;
}


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

int main(){
  int time[5];
  for(int i = 0;i < 5;i++)cin >> time[i];

  int mint;

  vector<int> mintime;


  for(int i = 0;i < 5;i++){
    mint = 0;
    for(int j = 0;j < 5;j++)
      for(int k = 0;k < 5;k++)
        for(int l = 0;l < 5;l++)
          for(int m = 0;m < 5;m++)
            if(i != j and i != k and i != l and i != m and j != k and j != l and j != m and k != l and k != m and l != m)
            {
              mint = time[i];
              if(time[i]%10 != 0)mint += (10 - time[i]%10);
              mint += time[j];
              if(time[j]%10 != 0)mint += (10 - time[j]%10);
              mint += time[k];
              if(time[k]%10 != 0)mint += (10 - time[k]%10);
              mint += time[l];
              if(time[l]%10 != 0)mint += (10 - time[l]%10);
              mint += time[m];
              mintime.push_back(mint);

            }
    }

    cout << *min_element(mintime.begin(),mintime.end()) << endl;



}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

  vector<int> ans;
  for(int i=0;i<N;i++){
    if(i%2==0){
      ans.insert(ans.begin(),a[i]);
    }
    else {
      ans.push_back(a[i]);
    }
  }

  if(N%2==0) reverse(ans.begin(),ans.end());

  for(int i=0;i<N;i++){
    cout << ans[i] << " " ;
  }

  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

const ll MOD = 1e9+7;
const ll MAX = 3e6+10;

ll fac[MAX<<2];  // fac[n] = n!
ll finv[MAX<<2]; // (fac[n] * finv[n]) % MOD = 1
ll inv[MAX<<2];  // (n * inv[n]) % MOD = 1

void init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    FOR (i, 2, MAX<<2) {
        fac[i] = fac[i-1]*i % MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i) % MOD;
        finv[i] = finv[i-1]*inv[i] % MOD;
    }
}

ll nCk (int n, int k) {
    if (n < k || k < 0 || n < 0) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

ll count(int x, int y) {
    ll res = (MOD + nCk(x + y + 2, x + 1) - 1) % MOD;
    return res;
}

int solve(int a, int b, int x, int y) {
    return (4ll * MOD + count(x, y) - count(a-1, y) - count(x, b-1) + count(a-1, b-1)) % MOD;
}

int main() {
    init();
    int a, b, x, y;
    cin >> a >> b >> x >> y;
    cout << solve(a, b, x, y) << endl;
}

Measured memory_bytes: 281472
n = int(input())
v = list(map(int,input().split()))

v = sorted(v)

ans = 0

for i in range(n):
    if i == 0 or i == 1:
        mo = 2**(n-1)
    else:
        mo = 2**(n-i)
    ans += v[i]/mo

print(ans)

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

int main(){
    int A, B, K;
    cin >> A >> B >> K;

    if (A+K <= B-K) {
        int i = A;
        while (i < A + K){
            cout << i << endl;
            i++;
        }

        int j = B - (K - 1);
        while (j < B + 1){
            cout << j << endl;
            j++;
        }
    }

    int l = A;
    if (A+K > B-K) {
        while (l < B + 1){
            cout << l << endl;
            l++;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int a,b;
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0)cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
}








Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int n; cin>>n;
  cout<<"ABC"<<n<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  string s; cin >> s;
  int x,y; cin >> x >> y;

  vector<int> X,Y;
  int pre = -1;
  for(int i = 0; i < s.size(); i++){
    int d = 0;
    while(i < s.size() && s[i] == 'F') d++,i++;
    pre *= -1;
    if(d == 0) continue;
    if(pre == 1) X.push_back(d);
    else Y.push_back(d);
  }
  if(x != 0 && X.empty() || y != 0 && Y.empty()){
    cout << "No" << endl;
    return 0;
  }

  set<int> st;
  int cnt = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'F') break;
    cnt++;
  }
  if(X.size()){
    st.insert(X[0]);
    if(cnt >= 1) st.insert(-X[0]);
  }
  for(int i = 1; i < X.size(); i++){
    set<int> st2;
    for(int p : st){
      st2.insert(p + X[i]);
      st2.insert(p - X[i]);
    }
    st.swap(st2);
   }
  if(*st.lower_bound(x) != x){
    cout << "No" << endl;
    return 0;
  }

  st.clear();
  if(Y.size()) st.insert(Y[0]),st.insert(-Y[0]);
  for(int i = 1; i < Y.size(); i++){
    set<int> st2;
    for(int p : st){
      st2.insert(p + Y[i]);
      st2.insert(p - Y[i]);
    }
    st.swap(st2);
  }
  if(*st.lower_bound(y) != y){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 640
import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int arare[] = new int[N];

		for(int n=0;n<N;n++){
			String st = sc.next();
			switch(st){
				case "P":
				 arare[n] = 0;
				break;
				case "W":
				 arare[n] = 1;
				break;
				case "G":
				 arare[n] = 2;
				break;
				case "Y":
				 arare[n] = 3;
				break;

			}
		}

		int alist[]={0,0,0,0};
		for(int n=0;n<N;n++){
			alist[ arare[n] ]++;
		}

		int count=0;
		for(int n=0;n<4;n++){
			if(alist[n] != 0) count++;
		}

		if(count==3) System.out.println("Three");
		if(count==4) System.out.println("Four");

	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

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

  REP(i,9){
    REP2(j,i,9){
      if((i+1)*(j+1)==n){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
  
  return 0;
}

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

using namespace std;

vector<int64_t> a;

void solve(){
    int64_t del_num = 0;
    int64_t find_num = 1;

    for(auto i = 0; i < a.size(); i++)
    {
        if(a.at(i) == find_num){
            find_num++;
        }
        else{
            del_num++;
        }
    }
    if(del_num == a.size()) del_num = -1;
    cout << del_num << endl;

}

int main(void){
    int64_t n, buf;
    cin >> n;
    for (size_t i = 0; i < n; i++)
    {
        cin >> buf;
        a.push_back(buf);
    }
    solve();
}

Measured memory_bytes: 2420
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL A[100];

LL ans = 0;

void solve(){
	for(int i=0;i<N;i++){
		if(A[i]%2==1 && (i+1)%2==1) ans++;
	}
}

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];

    solve();

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

Measured memory_bytes: 3148
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int K;

int main()
{
    cin >> K;
    int cnt = 0;
    string S = ", 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
    string ans = "";
    for (int i = 0; i < S.size(); i++)
    {
        if (cnt == K && S[i] != ',')
        {
            ans += S[i];
        }
        if (S[i] == ',')
        {
            cnt++;
        }
    }
    for (int i = 1; i < ans.size(); i++)
    {
        cout << ans[i];
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL               long long int
#define PB               push_back
using namespace std;
LL M= 1000000000+7;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;cin>>n;
    LL a[n];
    LL dp[n];
    for (int i=0;i<n;i++){
        cin>>a[i];
        if (i==0) dp[i]=a[i];
        else {
            dp[i]=dp[i-1]+a[i];
            dp[i]%=M;
        }
    }
    LL ans=0;
    for (int i=1;i<n;i++){
        ans+=dp[i-1]*a[i];
        ans%=M;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 6768
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>

int main(int argc, char *argv[])
{
    int n, a, b;
    int max, min;

    scanf("%d %d %d", &n, &a, &b);

    max = (a>b)?b:a;
    min = (a + b > n) ? a + b - n : 0;

    printf("%d %d\n", max, min);

    return 0;
}


Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))

ans = 1
for i in range(N):
    if A[i] == 0:
        print(0)
        exit()

for i in range(N):
    ans *= A[i]
    if ans > pow(10, 18):
        print(-1)
        exit()

print(ans)


Measured memory_bytes: 21480
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
INF = 1 << 60
sys.setrecursionlimit(10 ** 6)

#ここから書き始める
n, k = map(int, input().split())
ans = min(n % k, abs(n % k - k))
print(ans)

Measured memory_bytes: 5032
#include <stdio.h>

int main(void){
  //int型の配列seq
  int seq[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  //int型変数 K
  int K;
  char num[1000];

  //Kに値を格納する
  fgets(num, sizeof(num), stdin);
  sscanf(num, "%d", &K);
  
  printf("%d\n", seq[K - 1]);  
  return 0;
}


Measured memory_bytes: 2152
// Tapan Sahni
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <iomanip>
#include <map>
#include <complex>
#include <set>

using namespace std;
typedef long long LL;
typedef pair <int, int> pii;
typedef pair <LL, LL> pll;

const int N = 1e5 + 10;
const LL mod = 1000000007;

int pres[11];

bool chk(int x) {
  while(x != 0) {
    if(pres[x % 10] > 0)
      return false;
    x /= 10;
  }
  return true;
}

void solve() {  
  int n, k, x;
  cin >> n >> k;
  for(int i = 0; i < k; i++) {
    cin >> x;
    pres[x]++;
  }
  for(int i = n;; i++) {
    if(chk(i)) {
      cout << i << endl;
      break;
    }
  }

  return; 
}
int main() {
  //freopen ("love.in","r",stdin);
  //freopen ("love.out","w",stdout);
  ios::sync_with_stdio(false) ; cin.tie(nullptr);
  solve();
  return  0;
}
// Never Quit

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] str_as = br.readLine().split(" ");
        int[] as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = Integer.parseInt(str_as[i]);
        }
        
        int[] nums = new int[100001];
        
        for (int a : as) {
            nums[a]++;
        }
        
        int count;
        int max_count = 1;
        for (int i = 0; i < 100001; i++) {
            if (i == 0) {
                count = nums[i] + nums[i+1];
            }
            else if (i == 100000) {
                count = nums[i] + nums[i-1];
            }
            else {
                count = nums[i-1] + nums[i] + nums[i+1];
            }
            if (count > max_count) max_count = count;
        }
        System.out.println(max_count);
    }
}


Measured memory_bytes: 35548
n=int(input())
s=input()
now=0
rec=0
for i in s:
    now+=(-1)**(i==")")
    rec=min(now,rec)
f,t="",""
if rec<0:
    f="("*-rec
    now-=rec
if now>0:
    t=")"*now
print(f+s+t)

Measured memory_bytes: 3060
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s;
        s = sc.next();
        char str[] = s.toCharArray();
        str[3] = '8';
        System.out.println(str);
        sc.close();
    }
}


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

long long a[100001];
auto maxn = 1000000000000000000LL;

int main()
{
	int n;
	scanf("%d", &n);
	auto zero=false;
	for(int i=0; i<n; ++i) {
		scanf("%lld", &a[i]);
		if(!a[i]) zero=true;
	}
	if(zero) {
		puts("0");
		return 0;
	}
	auto ans=1LL;
	for(int i=0; i<n; ++i) {
		if(a[i]<=maxn/ans) ans*=a[i];
		else {
			puts("-1");
			return 0;
		}
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 4524
// 5/10 リアルタイム参加
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
// #include <math.h>

static const double pi = 3.141592653589793;

// using ll = long long;
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

    vector<ll> A(N), B(N);
    rep(i, N) {
        cin >> A[i] >> B[i];
    }

    map<P, int> mp;

    rep(i, N) {
        ll a = A[i];
        ll b = B[i];

        if (a == 0 && b != 0) {
            mp[{0, 1}]++;
        }
        else if (a != 0 && b == 0) {
            mp[{1, 0}]++;
        }
        else if (a == 0 && b == 0) {
            mp[{0, 0}]++;
        }
        else {
            // bool minus;
            if (a < 0) {
                a *= -1;
                b *= -1;
            }

            if (b > 0) {
                ll d = gcd(a, b);
                mp[{a/d, b/d}]++;
            } else {
                ll d = gcd(a, -b);
                mp[{a/d, b/d}]++;
            }
        }
    }

    mint ans = 1;

    for (auto p : mp) {
        // P pair1 = p.first;
        ll a = p.first.first;
        ll b = p.first.second;
        ll num1 = p.second;

        // if (pair1.first == 0 && pair1.second == 0) {
        // }

        if (a == 0 && b == 0) continue;

        ll a2, b2;
        if (b >= 0) {
            a2 = b;
            b2 = -a;
        } else {
            a2 = -b;
            b2 = a;
        }
        ll num2 = mp[{a2, b2}];
        // if (b >= 0) {
        //     num2 = mp[{b, -a}];
        // } else {
        //     num2 = mp[{-b, a}];
        // }

        // printf("a, b, num1, num2 = %d, %d, %d, %d\n", a, b, num1, num2);

        mint mul = 1;  // どちらも使わない場合
        mul += mint(2).pow(num1) - 1;  // {a, b}から１つ以上選ぶ場合
        mul += mint(2).pow(num2) - 1;  // {b, a}から１つ以上選ぶ場合

        ans *= mul;

        mp[{a, b}] = 0;
        mp[{a2, b2}] = 0;        
    }

    // ans.x *= mp[{0, 0}] + 1;
    ans.x += mp[{0, 0}];

    // ans.x -= 1;
    ans -= 1;

    cout << ans.x << endl;
}


Measured memory_bytes: 31424
chomp($n=<>);
$flg=0;
while($flg==0){
    @a=split//,$n;
    if($a[0] == $a[1] && $a[1] == $a[2]){
        $flg=1;
        print $n;
        exit;
    }
    $n++;
}
print $n;

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define for(i,a,b) for(int i=a;i<=b;i++)
#define _inline __inline__ __attribute__((always_inline))
#define ll long long
using namespace std;
_inline void read(ll &x){
	ll res=0,f=1;
	char c=getchar();
	if(c=='-') f=-1;
	while(c>'9'||c<'0') c=getchar();
	while(c>='0'&&c<='9'){
		res=res*10+c-'0';
		c=getchar();
	}
	x=res*f;
}
inline void print(ll x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
int main(){
    ll x,y,ans,sum=0;
    read(x),read(y);
    ans=((ll)(y/x));
    while(ans>=1) ans/=2,sum++;
    print(sum),puts("");
    return 0;
}

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

using namespace std;

typedef long long ll;

bool reversecompare(int a, int b)
{
    return a > b;
}

struct katana
{
    ll nom;
    ll wi;
    ll th;
};

bool bandingwi(katana a, katana b)
{
    return a.wi > b.wi;
}

bool bandingth(katana a, katana b)
{
    return a.th > b.th;
}

bool bandingthbalik(katana a, katana b)
{
    return a.th < b.th;
}


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

    katana pedang [100010];
    ll N, H, counta, counter;
    katana dummy;

    cin >> N >>H;

    for(int i = 0; i < N; i++)
    {
        pedang[i].nom = i;
        cin >> pedang[i].wi >> pedang[i].th;
    }

    stable_sort(pedang, pedang+N, bandingthbalik);
    stable_sort(pedang, pedang+N, bandingwi);

    dummy = pedang[0];
    counta = 0;
    counter = 0;

    stable_sort(pedang, pedang+N, bandingth);

    while(H > 0)
    {
        if (dummy.th >= H)
        {
            counta++;
            H -= dummy.th;
        }
        else
        {
            if (counter >= N)
            {
                H -= dummy.wi;
                counta++;
            }
            else if (pedang[counter].nom == dummy.nom)
            {
                counter++;
            }
            else if (dummy.wi >= pedang[counter].th)
            {
                H -= dummy.wi;
                counta++;
            }
            else
            {
                H -= pedang[counter].th;
                counter++;
                counta++;
            }
        }
    }

    cout << counta << endl;


    return 0;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h> 
using namespace std; 
long long n, m, w[101], v[101];
long long KnapSack(long long val[], long long wt[], int n, int W) { 
	//dp[j] cho cac vat co tong trong luong dung bang j
	vector<long long> dp(W+1,-1);
	dp[0] = 0;
	for(int i=0; i < n; i++) 
		for(int j=W; j>=wt[i]; j--) 
			if(dp[j-wt[i]] >= 0) dp[j] = max(dp[j] , val[i] + dp[j-wt[i]]); 
	
	//for(int i=0; i<dp.size(); i++) cout <<dp[i] <<" ";
	return *max_element(dp.begin(), dp.end());
} 

int main() { 
	//freopen("a.in","r",stdin);
	cin >>n >>m;
	for(int i=0; i<n; i++) cin >>w[i] >>v[i];

	cout << KnapSack(v, w, n, m) << endl; 
	return 0; 
} 


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>

using namespace std;
#define vsort(v) sort(v.begin(), v.end()); // 昇順
#define vsort_reverse(v) sort(v.begin(), v.end(), greater<int>()); // 降順
#define bsearch(v, n) binary_search(v.begin(), v.end(), n) 
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string O, E;
	cin >> O >> E;
	for(int i = 0; i < E.length(); i++)	{
		cout << O[i] << E[i];
	}
	if(O.length() > E.length()) cout << O[O.length() - 1];
	cout << endl;
}


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

int main(){
    std::string s;
    std::string t;
    int ans = 0;

    std::cin >> s;
    std::cin >> t;

    for(int a = 0; a < 3; a++){
        if(s[a] == t[a]){
            ans++;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

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

const int S = 1e5 + 10;
int n1, n2, m, a[S], b[S], x, y, p;
int ans = 1e9, mina = 1e9, minb = 1e9;

int main() {
	cin >> n1 >> n2 >> m;
	for (int i = 1; i <= n1; i++) {
		cin >> a[i];
		mina = min(mina, a[i]);
	}
	for (int j = 1; j <= n2; j++) {
		cin >> b[j];
		minb = min(minb, b[j]);
	}
	while (m--) {
		cin >> x >> y >> p;
		ans = min(a[x] + b[y] - p, ans);
	}
	cout << min(ans, mina + minb) << endl;
	return 0;
}



Measured memory_bytes: 1024
n,k,*a=map(int,open(0).read().split())
s=r=0
for x in sorted(a)[::-1]:
	if s+x<k:
		s+=x
		r+=1
	else:
		r=0
print(r)

"""
Σ_[i=m,n]>kのときa(m)以降は凡て必要
(∵ a(i)が必要->a(i+1)が必要)
k-=Σ_[i=m+1,n]として操作を続ける
Σ_[i=1,r]<kとなったときa(r)までが不必要
"""

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define ll long long

int main(void)
{
    ll x, k, d, amari, syou;
    cin >> x >> k >> d;
    amari = abs(x) % d;
    syou = (abs(x) - amari) / d;

    if(syou >= k) {
        cout << abs(x) - k*d;
    } else if((k - syou) % 2) {
        cout << abs(amari - d);
    } else {
        cout << amari;
    }
}

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

using Pi = pair<int, int>;

int main() {
    int N;
    int A[22];
    vector < Pi > say[22];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        for (int j = 0; j < A[i]; j++) {
            int x, y;
            cin >> x >> y; --x;
            say[i].emplace_back(x, y);
        }
    }

    int maxv = 0;
    for (int bit = 0; bit < (1 << N); bit++) {
        bool flag = true;
        int cnt = 0;
        for (int i = 0; i < N; i++) {
            if (!((bit >> i) & 1)) continue;
            cnt++;
            for (auto &s : say[i]) {
                //cout << bit << " " << i << " " << s.first << " " << s.second << " ";
                //cout << ((bit >> s.first) & 1) << endl;
                flag &= (((bit >> s.first) & 1) == s.second);
            }
        }
        if (flag) maxv = max(maxv, cnt);
        //cout << maxv << endl;
    }
    cout << maxv << endl;
    return (0);
}


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

signed main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    //cout<<"I must do it...Yeahhh";
    
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int ans=0;
        ans+=(n/500)*1000;
        ans+=((n%500)/5)*5;
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 256