akhauriyash/Code-Regression huggingface dataset:
S = input()
T = input()
#A=[0]*(len(S))
 
ans = float('inf')
for i in range(len(S)-len(T)+1):
  x = 0
  for j in range(len(T)):
    if S[i+j] != T[j]:
      x += 1
  ans = min(ans, x)

print(ans)

Measured memory_bytes: 9116
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
  cin.tie(0);
  ios::sync_with_stdio(false);
    
  ll n;
  cin >> n;
  
  vector<ll> a(n), b;
  
  for ( ll i = 0; i < n; i++ )
    cin >> a[i];
  
  for ( ll i = 0; i < n - 1; i++ ){
    if (a[i+1] == a[i] ) continue;
    b.push_back( a[i+1] - a[i] );
  }
  
  ll ans = 0;
  ll t = 0;
  ll m = b.size();
  for ( ll i = 0; i < m - 1; i++ ){
    
    if ( t != 0 ){
      t = 0;
      continue;
    }
    if ( b[i+1] * b[i] < 0 ){
      ++t;
      ++ans;
    }
  }
  
  cout << ans + 1 << endl;
    
    return 0;
}


Measured memory_bytes: 2168
def solve(a):
    if 0 in a:
        return 0
    ans = 1
    for i in a:
        ans *= i
        if ans > 10**18:
            return -1
    else:
        return ans

if __name__ == '__main__':
    n = int(input())
    a = list(map(int,input().split()))
    print(solve(a))

Measured memory_bytes: 84668
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define INF (1LL<<57)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	ll n;
	cin>>n;
	ll x = (n/500);
	n -= (x * 500);
	ll y = (n / 5);
	n -= (y * 5);
	cout<<(x*1000 + y*5)<<"\n";
	return;
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

// #ifndef ONLINE_JUDGE
// 	time_t time_t1, time_t2;
// 	time_t1 = clock();
// #endif

	while(T--)
	solve(T);

// #ifndef ONLINE_JUDGE
// 	time_t2 = clock();
// 	SETF();
// 	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
// 	UNSETF();
// #endif

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
  
typedef struct dice{
    int face[6];
}dice;
  
void rotate(dice *d, char dir)
{
    int temp;
    switch(dir) {
    case 'N':
        temp=d->face[0];
        d->face[0]=d->face[1];
        d->face[1]=d->face[5];
        d->face[5]=d->face[4];
        d->face[4]=temp;
        break;
    case 'E':
        temp=d->face[0];
        d->face[0]=d->face[3];
        d->face[3]=d->face[5];
        d->face[5]=d->face[2];
        d->face[2]=temp;
        break;
    case 'W':
        temp=d->face[0];
        d->face[0]=d->face[2];
        d->face[2]=d->face[5];
        d->face[5]=d->face[3];
        d->face[3]=temp;
        break;
    case 'S':
        temp=d->face[0];
        d->face[0]=d->face[4];
        d->face[4]=d->face[5];
        d->face[5]=d->face[1];
        d->face[1]=temp;
        break;
    }
}
  
int isSame(dice d1, dice d2)
{
    static const char dir[]="NNNESSSWNNNESSSWNNNESSSW";
    int i, j;
    for(i=0; i<24; i++) {
        for(j=0; j<6 && d1.face[j]==d2.face[j]; j++);
        if(j==6) return 1;
        rotate(&d2, dir[i]);
    }
    return 0;
}
  
int main()
{
    dice d[100];
    int i, j, n;
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        for(j=0; j<6; j++) {
            scanf("%d", &d[i].face[j]);
        }
        for(j=0; j<i; j++) {
            if(isSame(d[i], d[j])) {
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

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 * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/

int n, k, a[100005], sum;
signed main() {
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	for (int i = 40; i >= 0; i--) {
		int cnt = 0;
		if (sum + ((int)(1) << i) > k)continue;
		rep(j, n) {
			if ((a[j] >> i)&(int)(1))cnt++;
		}
		if (cnt <= n - cnt) {
			sum += ((int)(1) << i);
		}
	}
	int ans = 0;
	rep(i, n) {
		ans += sum ^ a[i];
	}
	cout << ans << endl;
	endre;
}

Measured memory_bytes: 1024
#include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
#define pb push_back

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

    vector<int> v;
    int w;
    int total = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> w;
        total += w;
        v.push_back(total);
    }

    int min = total;

    for(auto vw : v){
        int d = abs(total - 2 * vw);
        if(d < min){
            min = d;
        }
    }
    cout << min << endl;

    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n); ++(i))
using namespace std;

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

    int s_size = s.size() - 1;

    if(s[s_size] == '3') {
        cout << "bon" << endl;
    } else if(s[s_size] == '0' || s[s_size] == '1' ||s[s_size] == '6' ||s[s_size] == '8') {
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }

    return 0;
}

Measured memory_bytes: 3132
#include <iostream>

int main()
{
  int r,g,b;      //カード
  int integer;    //3桁の整数

  std::cin >> r >> g >> b;

  integer = r*100 + g*10 + b*1;

  if(integer%4 == 0){
    std::cout << "YES" << '\n';
  }else{
    std::cout << "NO" << '\n';
  }

  return (0);
}


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

public class Main {

    public static void main(String[] args) {
	Main m = new Main();
	m.answer();
    }

    private Scanner scan = new Scanner(System.in);
    private int N;
    private int H;
    private PriorityQueue<Sword> swordList;

    public Main() {
	N = Integer.parseInt(scan.next());
	H = Integer.parseInt(scan.next());
	swordList = new PriorityQueue<Sword>(N*2);
	for (int i = 0; i < N; i++) {
	    int a = Integer.parseInt(scan.next());
	    int b = Integer.parseInt(scan.next());

	    swordList.add(new Sword(a, 0));
	    swordList.add(new Sword(b, 1));
	}

	scan.close();
    }

    public final void answer() {

	int count = 0;
	
	while(H > 0) {
	    Sword s = swordList.peek();
	    if(s.type == 0) {
		int c = H / s.damage;
		if(H % s.damage > 0) c++;
		H = H - s.damage * c;
		count += c;
	    } else if(s.type == 1) {
		swordList.poll();
		H = H - s.damage;
		count++;
	    }
	}

	System.out.println(count);
	
    }

    private class Sword implements Comparable<Sword> {

	int damage;
	int type;

	Sword(int damage, int type) {
	    this.damage = damage;
	    this.type = type;
	}

	@Override
	public int compareTo(Sword s) {
	    return s.damage - this.damage;
	}
    }
}


Measured memory_bytes: 66796
import java.util.*;
import java.io.*;
public class Main {
    static String s1,s2;
    static int dp[][];
    public static void main(String args[]) {
        Scanner input=new Scanner(System.in);
        s1=input.next();
        s2=input.next();
        lcs();
        System.out.println(find_lcs());
    }
    public static int lcs() {
        dp=new int[s1.length()+1][s2.length()+1];
        for(int i=0;i<=s1.length();i++) {
            for(int j=0;j<=s2.length();j++) {
                if(i==0 || j==0) {
                    dp[i][j]=0;
                }
                else if(s1.charAt(i-1)==s2.charAt(j-1)) {
                    dp[i][j]=1+dp[i-1][j-1];
                }
                else {
                    dp[i][j]=Math.max(dp[i-1][j],dp[i][j-1]);
                }
            }
        }
        return dp[s1.length()][s2.length()];
    }
    
    public static String find_lcs() {
        int i=s1.length(),j=s2.length();
        StringBuilder ans=new StringBuilder("");
        while(i!=0 && j!=0) {
            if(s1.charAt(i-1)==s2.charAt(j-1)) {
                ans.append(s1.charAt(i-1));
                i--;
                j--;
            }
            else {
                if(dp[i-1][j]>dp[i][j-1]) {
                    i--;
                }
                else {
                    j--;
                }
            }
        }
        ans.reverse();
        return ""+ans;
    }
}


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

int main(){
    int n,i;
    int ans=0;
    std::cin >> n;
    int v[n],c[n];
    for (i=0;i<n;i++){
        std::cin >>v[i] ;
    }
    for (i=0;i<n;i++){
        std::cin >>c[i];
        if (v[i]>c[i]) ans+=(v[i]-c[i]);
    } 
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(n):
    ans += b[a[i] - 1]
    if i == n - 1:
        break
    if a[i] + 1 == a[i + 1]:
        ans += c[a[i] - 1]

print(ans)


Measured memory_bytes: 9060
from collections import Counter

def n_combi_2(n):
    if n < 2:
        return 0
    return n * (n - 1) // 2
  
N = int(input())
A = list(map(int, input().split()))
counter = Counter(A)

patterns_by_number = {key: n_combi_2(counter[key]) for key in counter.keys()}
total = sum(patterns_by_number.values())
res_dict = {}
for a in A:
    if a in res_dict.keys():
        print(res_dict[a])
    else:
        res = total - patterns_by_number[a] * (2) // counter[a]
        res_dict[a] = res
        print(res)

Measured memory_bytes: 41072
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D
# CreatedDate:  2020-04-06 00:29:17 +0900
# LastModified: 2020-04-06 00:37:37 +0900
#


import os
import sys
from collections import deque

def main():
    K=int(input())
    Q=deque()
    for i in range(1,10):
        Q.append(i)
#    print(Q)
    count=0
    while Q:
        count+=1
        x = Q.popleft()
        if x%10!=0:
            Q.append(10*x+x%10-1)
        Q.append(10*x+x%10)
        if x%10!=9:
            Q.append(10*x+x%10+1)
        if count==K:
            print(x)
            return


if __name__ == "__main__":
    main()


Measured memory_bytes: 11908
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define double long double

const double PI = acosl(-1.0l);

double a, b, h, m;

int32_t main()
{
	IOS;
	cin >> a >> b >> h >> m;
	double angle1 = (2 * PI) / 12 * h;
	double angle2 = (2 * PI) / 60 * m;
	angle1 += (2 * PI) / (12 * 60) * m;
 	double diff = angle1 - angle2;
	if(diff < 0)
		diff += 2 * PI;
	if(diff == PI)
		cout << a + b;
	else
	{
		double ans = a * a + b * b - (2 * a * b * cos(diff));
		ans = sqrtl(ans);
		cout << fixed << setprecision(12) << ans;
	}
	return 0;
}


Measured memory_bytes: 4180
# python3.4.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')
def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,A=imn()
x = iln()
X = 50

dp = [[[0 for _ in range(N*X+1)] for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 1

for j in range(N):
    for k in range(N):
        for s in range(N*X+1):
            #dp[j+1][k][s] = max(dp[j+1][k][s], dp[j][k][s])
            if s-x[j] < 0:
                dp[j+1][k][s] = dp[j][k][s]
            else:
            #if s-x[j] >= 0:
                dp[j+1][k+1][s] = dp[j][k+1][s] + dp[j][k][s-x[j]]


ans = 0
for i in range(1, N+1):
    ans += dp[N][i][i*A]
    #print(dp[i][1])
    #print(dp[N][i][i*A])
print(ans)

                


Measured memory_bytes: 120152
#ifdef DEBUG
#include <LeetcodeHelper.h>
#include <prettyprint.hpp>
#endif
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int cost(const vector<int>& v) {
  int n = v.size();
  vector<int> dp(n + 1, INT_MAX);
  dp[0] = 0;
  for (int i = 1; i < n; ++i) {
    if(i-1 >= 0) {
      dp[i] = min(dp[i], dp[i-1]+abs(v[i] - v[i-1]));
    }

    if(i-2 >= 0) {
      dp[i] = min(dp[i], dp[i - 2] + abs(v[i] - v[i - 2]));
    }
  }
  return dp[n - 1];
}

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for(auto& e: v) {
    cin >> e;
  }
  cout << cost(v) << '\n';
  return 0;
}


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


using namespace std;





int main(){
	string x;cin>>x;
	int c;
	int n;
	n=x.size()-2;
	vector<int> A(n);
	//1文字目2文字目3文字目～７文字目８文字目９文字目の7つの配列を作って、その中で一番753に近いものをとればいい
	for(int i = 0;i<n;i++){
		string b = "000";
		char d=x.at(i);
		char e=x.at(i+1);
		char f=x.at(i+2);
		b.at(0)	=d;
		b.at(1)=e;
		b.at(2)=f;
		//cout<<b<<endl;
	c = stoi(b);
		c=753-c;
		if(c<0){
			c*=-1;
		  }
		  A.at(i)=c;
	  }
	  sort(A.begin(),A.end());
	  cout<<A.at(0)<<endl;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int A ,B;
   char op;
   cin >> A >> op >> B ;

   if (A >=1 && A <= 10^9 && B >=1 && B <= 10^9 )

    if (op == '+' )

    cout << A+B;

   else if ( op == '-')
    cout << A - B;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
int main(){
	int n=read();
	if(n==3){
		printf("2 5 63\n");
		return 0;
	}
	if(n==4){
		printf("2 5 20 63\n");
		return 0;
	}
	DREP(i,min(n-1,15000),1){
		if((i%3==0 || i%3==2) && (n-i)%2==0){
			REP(j,1,i) printf("%d ",j*2);
			REP(j,1,n-i) printf("%d ",j*6-3);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
   
   int N;
   
   scanf("%d",&N);
   
   int *A = malloc(sizeof(int)*N);
   
   int i,j;
   int *Gcd_1 = malloc(sizeof(int)*N);
   int *Gcd_2 = malloc(sizeof(int)*N);
   int *Gcd_Ans = malloc(sizeof(int)*(N+1));
   
   
   
   for(i = 0;i < N;i++){
      scanf("%d",&A[i]);
   }
   
   Gcd_1[0] = A[0];
   Gcd_2[0] = A[N-1];
   
   for(i = 1;i < N;i++){
      Gcd_1[i] = GCD(Gcd_1[i-1],A[i]);
   }
   
   for (i = N - 2; i >= 0; i--) {
      Gcd_2[N - 2 - i + 1] = GCD(Gcd_2[N - 2 - i],A[i]);
   }
   
   Gcd_Ans[0] = Gcd_2[N-2];
   
   for (i = 1; i < N - 1; i++) {
      Gcd_Ans[i] = GCD(Gcd_1[i - 1],Gcd_2[N - i - 2]);
   }
   
   Gcd_Ans[N-1] = Gcd_1[N-2];
   Gcd_Ans[N]   = Gcd_1[N-1];
   
   
   int ans = 0;
   
   for(i = 0;i <= N;i++){
      if(ans < Gcd_Ans[i]) {
         ans = Gcd_Ans[i];
      }
   }
   
   printf("%d\n",ans);
   
   return 0;
}


int GCD(int a,int b) {
   int r;
   while ((r = a%b) != 0) {
      a = b;
      b = r;
   }
   return b;
}


Measured memory_bytes: 1664
import collections

MOD = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))
ap = [0 for _ in range(N)]

for a in A:
	ap[a] += 1
	
flg = 1
if N % 2 == 0:
	for i in range(1, N, 2):
		if ap[i] != 2:
			flg = 0
			break
			
else:
	if ap[0] != 1:
		flg = 0
	else:
		for i in range(2, N, 2):
			if ap[i] != 2:
				flg = 0
				break
				
# print(*ap)			
	
if not flg:
	print(0)
else:
	if N % 2 == 0:
		ans = pow(2, N // 2, MOD)
	else:
		ans = pow(2, (N - 1) // 2, MOD)
		
	print(ans)

Measured memory_bytes: 56172
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

//解説
//ソートして上から取ることでパターンごとのNlogNにできる．
//当たり前だが重さが全部1であるようなナップサックはソートで解けるので二度手間しないように注意
//ちなみにソートした時に上からM番目をO(N)で探すこともできる
int N,M;
int xyz[3][1005];
int dp[10][1005][1005];
signed main(){
    scanf("%lld %lld",&N,&M);
    rep(i,N){
        scanf("%lld %lld %lld",&xyz[0][i],&xyz[1][i],&xyz[2][i]);
    }
    rep(p,8)rep(i,N+1)rep(j,M+1)dp[p][i][j]=-LLINF;
    rep(p,8)dp[p][0][0]=0;
    rep(p,8){
        rep(i,N){
            int plus=0;
            rep(t,3){
                if((p>>t)%2==1)plus+=xyz[t][i];
                else plus-=xyz[t][i];
            }
            rep(j,M+1){
                //itr=iのケーキを食べる   
                dp[p][i+1][j+1]=max(dp[p][i+1][j+1],dp[p][i][j]+plus);
                //itr=iのケーキを食べない
                dp[p][i+1][j]=max(dp[p][i+1][j],dp[p][i][j]);
            }
        }
    }
    int ans=-LLINF;
    rep(p,8)ans=max(ans,dp[p][N][M]);
    printf("%lld\n",ans);
}


Measured memory_bytes: 64656
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int n;
  cin >> n;
  if (n % 2) {
    cout << n / 2 << endl;
  } else {
    cout << n / 2 - 1 << endl;
  }
  return 0;
}


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

int main() {
  int i, j;
  char str[220];
  char temp[110];
  int len;
  int count;
  int flag = 0;

  scanf("%[^\n]%*c", str);
  len = strlen(str);
  count = (len-1) / 2;
  for (i = count; i > 0; i--) {
    strncpy(temp, str + i, i);
    temp[i] = '\0';
    //printf("%s\n", temp);
    if (strstr(str, temp) == str) {
      flag = 1;
      break;
    }
  }

  printf("%d", 2*i);
  return 0;
}

Measured memory_bytes: 128
use std::cmp;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    	n:isize,
        m:isize
    }
       
    println!("{}", cmp::max(cmp::max(n+m, n-m), n*m));
}

Measured memory_bytes: 4352
n,m,k=map(int,input().split())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]

ans=0

time=0
book=0

for i in range(n):
    if A[i]+time<=k:
        time+=A[i]
        book+=1
    else:
        break

ans=max(ans,book)
abook=book
bnow=0

for i in range(book+1):
    #print(abook,book)
    if abook+1==i:
        break
    if bnow>=m:
        break
    while time+B[bnow]<=k:
        time+=B[bnow]
        bnow+=1
        book+=1
        if bnow>=m:
            break
    ans=max(ans,book)
    time-=A[abook-i-1]
    book-=1

print(ans)

Measured memory_bytes: 40716
//====== begin of bisma c++ template===========
#include<bits/stdc++.h>
#include <assert.h>
using namespace std;
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define repn(a,b,c) for(int a=b;a>=c;a--)
#define ll long long 
#define sum(a,b) a=a+b
#define mem(a, b) memset(a, (b), sizeof(a))


//=======binarysearch===========
int bs(vector<long long>&a,int que){
 auto it=lower_bound(a.begin(),a.end(),que);
 if(*it==que){
    return it-a.begin();
 }
 return -1;
}
//========binarysearch=========



//=======SUBSET WITH BRUTEFORCE=============
void subsets(string S, int n) {
     int nSub = 1<<n; 
     for(int i=0; i<nSub; i++){
     	  cout<<"{ ";//optional
          for(int k=0; k<n; k++){
               //if the k-th bit is set
               if( (1<<k) & i){
                    cout<<S[k]<<" ";
               } 
          }
          cout<<"}\n"; //optional
     }
}
//======SUBSET WITH BRUTE FORCE================


//======permuatate all ==================
void permutate(){
int n,x;
cin>>n;

vector<int> permutation;
for (int i = 0; i < n; i++) {
	cin>>x;
permutation.push_back(x);
}
do {
 rep(i,0,n-1) cout<<permutation[i];
 cout<<endl;
} while (next_permutation(permutation.begin(),permutation.end()));

}
//====permuatate all======================


//====check prime =========================

bool prime(ll x){
	ll ans=0;

	if(x==1){
		return false;
	}

	for(ll i=2;i<=sqrt(x);i++){
		if(x % i == 0){
			return false;
		}
	}

	return true;
}
//===check prime ========================


//======= the end of bisma c++ template ============


int main(){

string s;
cin>>s;
int cnt=0;
rep(i,0,s.size()-1){
 if(s[i]=='+') cnt++;
 if(s[i]=='-')cnt--;
}

cout<<cnt;


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;
    int AT;
    if(A%D==0){AT=A/D;}
    else{AT=A/D+1;}
    int CT;
       if(C%B==0){CT=C/B;}
       else{CT=C/B+1;}
    if(AT>=CT){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    if (n%x == 0) cout << n/x*t << endl;
    else cout << (n/x+1)*t << endl;
}


Measured memory_bytes: 3596
#include<iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i += 2) {
    int count = 0;
    for(int a = 1; a <= i; a++) {
      if(i % a == 0) {
        count += 1;
      }
    }
    
    if(count == 8) ans += 1;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
A, B = map(int, input().split())


def solve_odd(x):
    if (x + 1) % 4 == 0:
        return 1
    else:
        return 0


def solve(x):
    if x % 2 == 1:
        return solve_odd(x)
    else:
        xor_sum = solve_odd(x + 1)
        return xor_sum ^ (x + 1)


print(solve(B) ^ solve(A - 1))


Measured memory_bytes: 2940
'use strict';

function Main(input) {
    const tmp = input.split('\n')[0];
    const a = parseInt(tmp.split(' ')[0], 10);
    const b = parseInt(tmp.split(' ')[1], 10);
    const c = parseInt(tmp.split(' ')[2], 10);

    if (a + b == c || a + c == b || b + c == a) {
        console.log("Yes");
    } else {
        console.log("No");
    }
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }
template<class T>
inline T upper(T a, T b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	ll H, W;
	cin >> H >> W;

	ll ans = H * W;
	ll s[3];

	for (int i = 0; i < 2; ++i) {
		for (int h = 1; h < H; ++h) {
			s[0] = h * W;
			s[1] = (H - h) * (W / 2);
			s[2] = H * W - (s[0] + s[1]);
			sort(s, s + 3);
			ans = min(ans, s[2] - s[0]);

			s[0] = h * W;
			s[1] = ((H - h) / 2) * W;
			s[2] = H * W - (s[0] + s[1]);
			sort(s, s + 3);
			ans = min(ans, s[2] - s[0]);
		}
		swap(H, W);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
N=1e7,a[1<<26];main(i,j){for(i=j=2;i*i<N;a[i]||j>N?j=++i:a[j+=i]++);for(;i=~scanf("%d",&j);j&&printf("%d\n",j))for(;a[j]|a[j-2]|a[j-6]|a[j-8];j--);}

Measured memory_bytes: 0
#include<cstdio>
using namespace std;
typedef long long ll;
const int N=400400;
int i,j,k,n,m,ch,ff,l,r,x;
int a[N];
void R(int &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void R(ll &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void W(int x) {
	if (x>=10) W(x/10);
	putchar(x%10+'0');
}
void W(ll x) {
	if (x>=10) W(x/10);
	putchar(x%10+'0');
}
int main() {
	R(n);
	R(a[n]);
	l=n;r=n;
	for (i=2;i<=n;i++) {
		R(x);
		if (l<=r) a[++r]=x;
		else a[--r]=x;
		int t=l;l=r;r=t;
	}
	if (l<=r) {
		for (i=l;i<=r;i++) W(a[i]),putchar(' ');
	}
	else {
		for (i=l;i>=r;i--) W(a[i]),putchar(' ');
	}
	puts("");
}

Measured memory_bytes: 2944
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

ll modpow(ll a, ll b)
{
	if (b == 0)
	{
		return 1;
	}

	if (b % 2)
	{
		return a * modpow(a, b-1) % MOD;
	}
	else
	{
		ll halfB = b / 2;
		ll half = modpow(a, halfB);
		return half * half % MOD;
	}
}

ll calcComb(ll n, ll m)
{
	if (m > n-m)
	{
		return calcComb(n, n-m);
	}

	ll ansMul = 1;
	ll ansDiv = 1;

	rep(i, m)
	{
		ansMul *= (n-i);
		ansDiv *= (i+1);
		ansMul %= MOD;
		ansDiv %= MOD;
	}

	/*
	ll ans = ansMul * modpow(ansDiv, MOD - 2) % MOD;
	return ans;
	*/
	return ansMul * modpow(ansDiv, MOD - 2) % MOD;
}

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

	ll N;
	ll M;
	
	cin >> N >> M;

	ll remain = M;

	ll ans = 1;

	for(int i = 2; i * i <= remain; i++)
	{
		if (remain % i == 0)
		{
			int cnt = 0;
			while(remain % i == 0)
			{
				cnt++;
				remain /= i;
			}
			ans = ans * calcComb(cnt + N - 1, cnt) % MOD;
		}
		
	}

	if (remain != 1)
	{
		ans = ans * calcComb(1 + N - 1, 1) % MOD;
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#import
#import math
#import numpy as np
N = int(input())
#= input()
#= map(int, input().split())
p = list(map(float, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}

dp = [[0.0] * (N + 1) for _ in range(N + 1)]

dp[0][0] = 1

for i, p in enumerate(p, 1):
    pp = 1 - p
    for j in range(i + 1):
        if j == 0:
            dp[i][j] = dp[i - 1][j] * pp
        elif j == i:
            dp[i][j] = dp[i - 1][j - 1] * p
        else:
            dp[i][j] = dp[i - 1][j - 1] * p + dp[i - 1][j] * pp

res = 0.0
n = N // 2 + 1

for cnt in dp[-1][n:]:
    res += cnt

print(res)

Measured memory_bytes: 222612
N,K = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(N)]
from collections import Counter
ctr = Counter()
for a,b in AB:
    ctr[a] += b

for k,v in sorted(ctr.items()):
    if K <= v:
        print(k)
        exit()
    K -= v

Measured memory_bytes: 26360
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define deb(x) cout<<#x<<" = "<<x<<"\n";
#define F first
#define S second
#define mod 1000000007

signed main()
{
	
	int n; cin>>n;
	vector<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 idx = -1;
	
	for(int i=0; i<n; i++)
	{
		if(a[i] != b[i])
		{
			idx = i;
			break;
		}
	}
	if(idx == -1)
	{
		cout<<"0\n";
		return 0;
	}
	
	if(a[idx] > b[idx])
	{
		vector<int> temp = a;
		a = b;
		b = temp;
	}
	int ans = 0;
	do{
		if(a == b)
			break;
		ans++;
	}while(next_permutation(a.begin() + idx, a.end()));
	cout<<ans<<"\n";
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

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;
}

int main() {
  int n, x, t;
  cin >> n >> x >> t;
  int time = 0;
  if (n % x == 0)
    time = n / x;
  else
    time = n / x + 1;

  cout << time * t << endl;
  return 0;
}

Measured memory_bytes: 3588
n,m,q = gets.split.map(&:to_i)
ary = Array.new(n+1){Array.new(n+1,0) }

m.times do
  l,r = gets.split.map(&:to_i)
  ary[l][r] += 1
end

1.upto(n) do |i|
    i.upto(n-1) do |j|
    ary[i][j+1] += ary[i][j]
  end
end

n.downto(1) do |i|
    i.downto(2) do |j|
    ary[j-1][i] += ary[j][i]
  end
end

q.times do
  l,r = gets.split.map(&:to_i)
  puts ary[l][r]
end


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

ll f(vector<int> a, int op) {
  ll res = 0;

  ll sum = 0;
  rep(i, a.size()) {
    sum += a[i];

    if (op > 0 && sum <= 0) {
      res += (1 - sum);
      sum = 1;
    }
    if (op < 0 && sum >= 0) {
      res += abs(-1 - sum);
      sum = -1;
    }

    op *= -1;
  }

  return res;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  cout << min(f(a, -1), f(a, 1)) << endl;
}


Measured memory_bytes: 1408
program ec12;
var 
	j:int64;
	s:array[0..200001] of int64;
	n,m,i,x:longint;
begin 
	readln(n);
	s[0]:=0;
	for i:=1 to n do 
	begin 
		read(x);
		s[i]:=s[i-1]+x;
	end;
	j:=maxlongint-1;
	for i:=1 to n-1 do 
	begin
		if abs(s[n]-s[i]-s[i])<j then 
		j:=abs(s[n]-s[i]-s[i]);
	end;
	writeln(j);
end. 

Measured memory_bytes: 1664
#include<stdio.h>
int main(void)
{
	int n,m,flg=1,i;
	char s[11];
	scanf("%d %d",&n,&m);
	scanf("%s",s);
	for(i=0;i<n;i++){
		if(s[i]=='-') flg=0;
	}
	for(i=n+1;i<n+m+1;i++){
		if(s[i]=='-') flg=0;
	}
	if(s[n]!='-') flg=0;
	if(flg==1) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

void solve() {

}

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i,n) cin >> vec[i];
  vector<int> tmp = vec;
  sort(ALL(tmp));
  tmp.erase(unique(ALL(tmp)),tmp.end());
  if( tmp.size() == vec.size() ) cout << "YES" << endl;
  else puts("NO");
  return 0;
}


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


long seq_sum(long a1, long n, long d) {
    return n * (2 * a1 + (n - 1) * d) / 2;
}

int main() {
    long n;
    cin >> n;
    cout << (seq_sum(1, n, 1) - seq_sum(3, n / 3, 3) - seq_sum(5, n / 5, 5) + seq_sum(15, n / 15, 15));
    return 0;
}

Measured memory_bytes: 3164
s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
ans = "No"
cnt = 0
for i in range(min(len(s), len(t))):
    if ord(s[i]) < ord(t[i]):
        ans = "Yes"
        break
    elif ord(s[i]) == ord(t[i]):
        cnt += 1
if cnt == min(len(s), len(t)) and len(s) < len(t):
    ans = "Yes"
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>

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

using namespace std;

int n, x;
int ms[100];

void input() {
  cin >> n >> x;
  REP(i, n) cin >> ms[i]; 
}

void solve() {
  sort(ms,ms+n);
  long xsum = accumulate(ms,ms+n,0);
  long ans = n + ((x-xsum) / ms[0]);
  cout << ans << endl;
}

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


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


int e(char a){
    return (a - 'a');
}

    int a[26], a2[26];
int main(){
    string s, t;

    cin >> s >> t;


    for(int i=0; i < t.size(); ++i){
        ++a[e(t[i])];
    }

    for(int i=0; i < s.size(); ++i){
        ++a2[e(s[i])];
    }

    for(int i=0; i<26; ++i){
        if(a[i] != 0){
            for(int k=0; k<26; ++k){
                if(a[i] == a2[k]){
                    a2[k] = 0;
                    break;
                }

                if(k == 25) { cout << "No" << endl; return 0; }
            }
        }
    }

    for(int i=0; i<26; ++i){
        if(a2[i] != 0){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 776
#include <iostream>

using namespace std;
using ll = long long;

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

    if(a + b == 15){
        cout << "+" << endl;
    }
    else if(a * b == 15){
        cout << "*" << endl;
    } else{
        cout << "x" << endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll long long
#define Add_Speed ios_base::sync_with_stdio(0);cin.tie(0);
#define ins insert
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define sz size()
#define s second
#define all(s) s.begin(), s.end()
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define inf (int)1e9
#define gcd(a, b) __gcd(a, b)
//#define int ll
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

const int maxn = (int)1e5 + 17;
const int maxm = (int)15e2 + 7;
const int minn = (int)1e3 + 7;
const int mod = (int)1e9 + 7;
const long double PI = acos(-1);
const int P = (int)1e5 + 7;

int n, dp[maxn], a[maxn];

int main () {
 
    Add_Speed

    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    dp[1] = 0;
    dp[2] = abs(a[1] - a[2]);
    for(int i = 3; i <= n; i++){
        dp[i] = min(dp[i - 1] + abs(a[i - 1] - a[i]), dp[i - 2] + abs(a[i - 2] - a[i]));
    }
    cout << dp[n];
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
const lli INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1e9 + 7;
const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871; 
const int N = 1e5 + 10;
int dp[N][3];
int nums[N];
lli bpow(lli baseee, lli exponenttt) {
	if(exponenttt < 0) return 0;
	lli res = 1;
	baseee %= MOD;
	while (exponenttt > 0) {
		if ((exponenttt & 1) == 1) res = (res*baseee) % MOD;
		baseee = (baseee*baseee) % MOD;
		exponenttt >>= 1;
	}
	return res;
}
lli multInverse(lli a) {//if_mod_is_prime
	return bpow(a, MOD - 2);
}
lli divm(lli a, lli b) {//if_mod_is_prime
	return (a * multInverse(b)) % MOD;
}
lli multm(lli a, lli b) {
	return (a * b) % MOD;
}
lli subm(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli addm(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	
	int a, b, c;
	for(int i = 1; i <= n; i++) {
		cin >> a >> b >> c;
		dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a;
		dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b;
		dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c;
	}
	cout << max({dp[n][0], dp[n][1], dp[n][2]}) << "\n";
	
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
using namespace std;
int map[5][5]={0},vis[5][5]={0};
void DFS(int x,int cnt) {
	// cout<<x<<' '<<cnt<<endl;
	// for(int i=1;i<=4;i++) {
	// 	for(int j=1;j<=4;j++) cout<<vis[i][j]<<' ';
	// 	cout<<endl;
	// }
	// cout<<"*****\n";
	if(cnt==4) {cout<<"YES";exit(0);}
	for(int i=1;i<=4;i++) {
		if(i!=x&&vis[x][i]==0&&vis[i][x]==0&&map[x][i]) {
			vis[x][i]=vis[i][x]=1;
			DFS(i,cnt+1);
			vis[x][i]=vis[i][x]=0;
		}
	}
}
int main() {
	for(int i=1;i<=3;i++) {
		int x,y;
		cin>>x>>y;
		map[x][y]=1;
		map[y][x]=1;
	}
	for(int i=1;i<=4;i++) {
		DFS(i,1);
	}
	cout<<"NO";
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
int i;
int h,m,s;
scanf("%d",&i);
 
h=i/3600;
m=(i%3600)/60;
s=(i%3600)%60;
 
 
printf("%d:%d:%d\n",h,m,s);
 
return 0;
}


Measured memory_bytes: 1848
using System;

namespace Math_Functions
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Console.ReadLine().Split(' ');
            var a = double.Parse(x[0]);
            var b = double.Parse(x[1]);
            var c = double.Parse(x[2]);

            var t = c * Math.PI / 180;

            Console.Write("{0:F4}\n{1:F4}\n{2:F4}\n",
                          0.5 * a * b * Math.Sin(t),
                          a + b + Math.Sqrt(a * a + b * b - 2 * a * b * Math.Cos(t)),
                          b * Math.Sin(t));
        }
    }
}

Measured memory_bytes: 9160
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main()
{
    long long int c=0,i,n,d;
    cin>>n>>d;
    vector<long long int> y(n),x(n);
    for(i=0;i<n;i++) cin>>x[i]>>y[i];
    for(i=0;i<n;i++)
    {
        if(sqrt(x[i]*x[i]+y[i]*y[i])<=d) c++;
    }
    cout<<c;
}

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

using namespace std;

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

class U {
public:
  int n;
  vector<int> p, s;

  U(int _) {
    n = _;
    p.resize(n);
    s.resize(n);
    for (int i = 0; i < n; i++) {
      p[i] = i;
      s[i] = 1;
    }
  }

  bool connect(int a, int b) {
    int ap, bp;
    for (ap = p[a]; ap != p[ap]; ap = p[ap]);
    for (bp = p[b]; bp != p[bp]; bp = p[bp]);
    if (ap == bp)
      return true;
    int mi = min(ap, bp), ma = max(ap, bp);
    p[ma] = mi;
    s[mi] += s[ma];
    s[ma] = 0;
    for (int pp = a; pp != mi;) {
      int next = p[pp];
      p[pp] = mi;
      pp = next;
    }
    for (int pp = b; pp != mi;) {
      int next = p[pp];
      p[pp] = mi;
      pp = next;
    }
    return false;
  }

  int q(int a) {
    int ap;
    for (ap = a; ap != p[ap]; ap = p[ap]);
    return s[ap];
  }

  int parent(int a) {
    int ap;
    for (ap = a; ap != p[ap]; ap = p[ap]);
    return p[ap];
  }

  bool query(int a, int b) { return parent(a) == parent(b); }
};

vector<vector<pair<int, ll>>> ps;

void dfs(vector<vector<ll>> &dist, int i, int from, int base, ll maxp) {
  dist[base][i] = maxp;
  for (auto &v : ps[i]) {
    if (v.first == from) continue;
    dfs(dist, v.first, i, base, max(v.second, maxp));
  }
}

struct N {
  int a, b;
  ll c;
};

bool operator<(const N &l, const N &r) {
  return l.c < r.c;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  ps.resize(n);
  U u(n);
  ll sum = 0;
  vector<N> ns(m);
  for (int i = 0; i < m; i++) {
    cin >> ns[i].a >> ns[i].b >> ns[i].c;
    ns[i].a--;
    ns[i].b--;
  }
  sort(ns.begin(), ns.end());
  for (int i = 0; i < m; i++) {
    if (!u.connect(ns[i].a, ns[i].b)) {
      ps[ns[i].a].emplace_back(ns[i].b, ns[i].c);
      ps[ns[i].b].emplace_back(ns[i].a, ns[i].c);
      sum += ns[i].c;
    }
  }
  vector<vector<ll>> dist(n, vector<ll>(n, -1));

  for (int i = 0; i < n; i++) {
    dfs(dist, i, -1, i, 0);
  }

  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    cout << sum - dist[s][t] << endl;
  }

  return 0;
}


Measured memory_bytes: 134400
N,M,X=map(int,input().split())
ans=-1
C=[]; A=[]
flag=[[]]*(1<<N)

#bitマスク生成
for i in range(1<<N):
    d=[0]*N
    for j in range(N):
        if (i>>j)&1==1: d[j]=1
    flag[i]=d
#入力
for i in range(N):
    inp=list(map(int,input().split()))
    C.append(inp[0]); A.append(inp[1:])
#処理
for i in range(1<<N):
    f=flag[i]
    exp=[0]*M; yen=0
    for j in range(N):
        a=A[j]
        if f[j]==1:
            for k in range(M): exp[k]+=a[k]
            yen+=C[j]
    ok=True
    for j in range(M):
        if exp[j] < X: ok=False
    if ok: ans=min(ans,yen) if ans!=-1 else yen
print(ans)

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

int cmp(const int *a,const int *b){

return *a > *b ? -1 : *a < *b ? 1 : 0 ;
}
//qsort(pa,n,sizeof(int),(int(*)(const void* ,const void*))cmp);

int main(void){

  int x,a;
  scanf("%d%d",&x,&a);
  if(a>x){
    printf("%d",0);
    return 0;
  }
  else{
    printf("%d",10);
  }


  return 0;
}


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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

int main(){
     int A, B;
     cin >> A >> B;
     if(B < A) swap(A, B);
     int d = abs(A - B);
     if(d % 2 == 0) print(A + (d / 2));
     else print("IMPOSSIBLE");
}

Measured memory_bytes: 256