akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

std::string solve(std::vector<int>& xs, int k)
{
  std::sort(xs.begin(), xs.end());
  return xs.back() - xs.front() <= k ? "Yay!" : ":(";
}

int main()
{
  std::vector<int> xs(5);
  int k;
  for (auto& x : xs) {
    std::cin >> x;
  }
  std::cin >> k;

  std::cout << solve(xs, k) << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
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 long long INF=1LL<<60;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int m,n;
	string s;
	cin>>m>>n;
	for(int i=0;i<m;i++){
		cin>>s;
		if(i==0){
			for(int j=0;j<s.length()+2;j++)cout<<'#';
			cout<<endl;
		}
		cout<<'#'<<s<<'#'<<endl;
		if(i==m-1){
			for(int j=0;j<s.length()+2;j++)cout<<'#';
			cout<<endl;
		}
	}
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int a,b,c,x,cnt=0;
  std::cin >>  a >> b >> c >> x;
  for(int i=0; i<=a; i++){
    for(int j=0; j<=b; j++){
      for(int k=0; k<=c; k++){
        if(500*i+100*j+50*k==x) cnt++;
      }
    }
  }

  std::cout << cnt << '\n';

  return 0;

}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)
const LL mod = LL(1e9) + 7;

void solve()
{
    int N;
    cin >> N;
    int n1 = 0, n2 = 0, n3 = 0;  // n1 <= n2 <=n3

    LL ans = 1;
    REP0 (i, N)
    {
        int A;
        cin >> A;
        int f = (A == n3) + (A == n2) + (A == n1);
        ans *= f;
        ans %= mod;
        if (A == n3)
        {
            n3++;
        }
        else if (A == n2)
        {
            n2++;
        }
        else if (A == n1)
        {
            n1++;
        }
        else
        {
            std::cout << 0 << endl;
            return;
        }
    }
    std::cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var n, m int

	fmt.Fscan(r, &n, &m)
	curR := 0
	a := make([]int, n, n)
	rs := make(map[int]int)
	rs[0] = 1
	ans := int64(0)
	for i := 0; i < n; i++ {
		var ai int
		fmt.Fscan(r, &ai)
		a[i] = ai % m
		curR += ai % m
		curR %= m
		ans += int64(rs[curR])
		rs[curR]++
	}
	fmt.Fprintln(w, ans)
}

Measured memory_bytes: 8872
"""
ビット全探索
"""
n, m = map(int, input().split())
lamps = [list(map(lambda x:int(x)-1, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))
ans = 0
#ビット全探索
for i in range(2**n) :
    for r in range(m) :
        on = 0
        for j in range(n) :
            #j桁目が1であるかどうかを調べる
            #jがsに含まれているかどうか調べる
            if (i>>j) & 1 == 1 and j in lamps[r] :
                on += 1
        if on % 2 != p[r] :
            break
    else :
        ans += 1
print(ans)


Measured memory_bytes: 9120
import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True



MOD = 10**9 + 7
class ModInt:

    def __init__(self, x):
        self.x = x.x if isinstance(x, ModInt) else x % MOD

    __str__ = lambda self:str(self.x)
    __repr__ = __str__
    __int__ = lambda self: self.x
    __index__ = __int__

    __add__ = lambda self, other: ModInt(self.x + ModInt(other).x)
    __sub__ = lambda self, other: ModInt(self.x - ModInt(other).x)
    __mul__ = lambda self, other: ModInt(self.x * ModInt(other).x)
    __pow__ = lambda self, other: ModInt(pow(self.x, ModInt(other).x, MOD))
    __mod__ = lambda self, other: ModInt(self.x % ModInt(other).x)
    __truediv__ = lambda self, other: ModInt(self.x * pow(ModInt(other).x, MOD - 2, MOD))
    __floordiv__ = lambda self, other: ModInt(self.x // ModInt(other).x)
    __radd__ = lambda self, other: ModInt(other + self.x)
    __rsub__ = lambda self, other: ModInt(other - self.x)
    __rpow__ = lambda self, other: ModInt(pow(other, self.x, MOD))
    __rmod__ = lambda self, other: ModInt(other % self.x)
    __rmul__ = lambda self, other: ModInt(other * self.x)
    __rtruediv__ = lambda self, other: ModInt(other * pow(self.x, MOD - 2, MOD))
    __rfloordiv__ = lambda self, other: ModInt(other // self.x)

    __lt__ = lambda self, other: self.x < ModInt(other).x
    __gt__ = lambda self, other: self.x > ModInt(other).x
    __le__ = lambda self, other: self.x <= ModInt(other).x
    __ge__ = lambda self, other: self.x >= ModInt(other).x
    __eq__ = lambda self, other: self.x == ModInt(other).x
    __ne__ = lambda self, other: self.x != ModInt(other).x


def main():
    S = list(input())
    N = len(S)-1
    dp = [[0] * 13  for _   in range(N)]
    dp[0] = [ModInt(0) for _ in range(13)]
    
    if S[0] == '?':
        for i in range(10):
            dp[0][i] = ModInt(1)
    else:
        dp[0][int(S[0])] = ModInt(1)

    for i in range(1,N):
        if S[i] == '?':
            for j in range(13):
                for k in range(10):
                    dp[i][(j * 10 + k) % 13 ] += dp[i-1][j]
        else:
            for j in range(13):
                dp[i][ (j* 10 + int(S[i])) % 13 ] += dp[i-1][j]
        

    print(dp[len(S)-2][5])









    pass
if __name__ == '__main__':
    main()

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

#define int long long
#define inf 1000000007LL

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)

int func(int w, int h) {
  int mi = (w + 2) / 3 * h - w / 3 * h;
  trep(i, h) {
    mi = min(mi, max(i * w, max(w / 2 * (h - i), (w - w / 2) * (h - i))) - min(i * w, min(w / 2 * (h - i), (w - w / 2) * (h - i))));
  }
  return mi;
}

signed main() {
  int h, w;
  cin >> h >> w;
  cout << min(func(h, w), func(w, h)) << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=n-1;i>=0;i--){
        cout<<a[i];
        if(i)cout<<" ";
        }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <cmath>
using namespace std;
int main() {
long long n,d,a,b,c,e,f,k=0;
cin>>n>>d;
while(n--){
  cin>>a>>b;
  c=a*a;
  e=b*b;
  f=e+c;
if(sqrt(f)<=d){
  k+=1;
}

}
cout<<k;
}

Measured memory_bytes: 3676
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pbi pair<bool,int>
#define pob pop_back
#define all(a) a.begin(),a.end()
#define fio ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define i64 long long int
#define mem(x,y) memset(x,y,sizeof(x))
#define fill(arr,b) fill(arr, arr+sizeof(arr)/sizeof(arr[0]), b)
#define maxarr(n,arr,m) m =-1e9;for(int i=0;i<n;i++)if(arr[i]>m) m=arr[i];
#define read freopen("input.txt","r",stdin);

const double pi = acos(-1.0);
const int maxn = (i64)2e9+5;

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


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

// using namespace std;



// const int N = 100000, MAXI = 10000;

// int getRandom(int l, int r) {
//     return l + rand() % (r - l + 1);
// }



// // Driver code to test above functions
// int main() 
// {
//     freopen("output.txt", "r", stdin);
//     freopen("input.txt", "w", stdout);
   
//     srand(time(nullptr));
   
//     int tc = 30;
//     cout << tc << "\n";
//     //int n = 2;
//     while (tc--)
//     {
//         int n = getRandom(99900, 100000);
//         cout << n << "\n";
//         int a[n+1];
//         for(int i=1;i<=n;i++)
//         {
//             if(i==1)
//                 a[1] = getRandom(2, n);
//             else if(i==n)
//                 a[n] = getRandom(1, n-1);
//             else
//             {
//                 int x = getRandom(1, i-1);
//                 int y = getRandom(i+1, n);

//                 int flag = rand()%2;

//                 if(flag==0)
//                     x = y;

//                 a[i] = x;
//             }
//             cout << a[i] << " ";
//         }
//         cout << "\n~\n";
//     }

//     return 0;
// }








// -----------------------------------------------------//


 

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



// int main()
// {
//     freopen("input.txt","r", stdin);
//     freopen("output.txt","w", stdout);

//     ios_base::sync_with_stdio(0);
//     cin.tie(NULL);
//     cout.tie(NULL);

//     int t;
//     cin >> t;
//     while(t--)
//     {
        
//     }
   
//     return 0;
// }














//  /* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005
 

// Driver code to test above functions
int32_t main()
{
   
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int n;
    cin >> n;

    int a[n];
    for(int i=0;i<n;i++)
        cin >> a[i];

    int pre[n], suf[n];

    pre[0] = a[0];
    suf[n-1] = a[n-1];

    for(int i=1;i<n;i++)
        pre[i] = (pre[i-1]^a[i]);

    for(int i=n-2;i>=0;i--)
        suf[i] = (suf[i+1]^a[i]);

    for(int i=0;i<n;i++)
    {
        if(i==0)
            cout << suf[i+1] << " ";
        else if(i==n-1)
            cout << pre[n-2] << " ";
        else
            cout << (pre[i-1] ^ suf[i+1]) << " ";
    }
    
    return 0; 
}



Measured memory_bytes: 8212
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;

int main(){
    int PQR[3];
    scanf("%d %d %d",&PQR[0],&PQR[1],&PQR[2]);

    int minRootCost = 200;
    int cost;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(i==j) continue;
            cost = PQR[i] + PQR[j];
            if(minRootCost > cost) minRootCost = cost;
        }
    }
    printf("%d\n",minRootCost);
    return 0;
}

Measured memory_bytes: 256
import itertools
n,m = map(int,input().split())
s = set()
for i in range(m):
    a,b = map(int,input().split())
    s.add((a,b))
    s.add((b,a))
ans = 0
#print(s)
for i in itertools.permutations(range(2,n+1)):
    genzai = 1
    #print(i)
    for j in range(len(i)):
        if (genzai,i[j]) not in s:
            break
        genzai = i[j]
    else:
        ans += 1
print(ans)

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

const int MAX_P=350,MAX_N=8;
const int dx[13]={1,0,0,1,-1,1,1,1,1,0,0,1,-1}
        ,dy[13]={0,1,0,1,1,-1,1,1,-1,1,1,0,0}
        ,dz[13]={0,0,1,1,1,1,-1,0,0,1,-1,1,1};

int n,m,p,cnt,nx,ny,nz;
int x[MAX_P],y[MAX_P];
int now[MAX_N][MAX_N];
int col[MAX_N][MAX_N][MAX_N];

void solve(){
    for (int i=0;i<n;++i)
        for (int j=0;j<n;++j)
            now[i][j]=0;
    for (int i=0;i<n;++i)
        for (int j=0;j<n;++j)
            for (int k=0;k<n;++k)
                col[i][j][k]=-1;
    for (int i=0;i<p;++i){
        col[x[i]][y[i]][now[x[i]][y[i]]++]=(i&1);
        for (int j=0;j<13;++j){
            cnt=-1;
            for (int k=0;k<2;++k){
                for (int l=0;l<=m;++l){
                    nx=x[i]+dx[j]*(k?l:-l);
                    ny=y[i]+dy[j]*(k?l:-l);
                    nz=now[x[i]][y[i]]-1+dz[j]*(k?l:-l);
                    if (nx<0||n<=nx||ny<0||n<=ny||nz<0||n<=nz) break;
                    if (col[nx][ny][nz]!=(i&1)) break;
                    ++cnt;
                }
            }
            if (m<=cnt){
                cout << (i&1?"White":"Black") << ' ' << i+1 << '\n';
                return;
            }
        }
    }
    cout << "Draw" << '\n';
    return;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n >> m >> p,n){
        for (int i=0;i<p;++i){
            cin >> x[i] >> y[i];
            --x[i],--y[i];
        }
        solve();
    }
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define int long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define w(x) int x;cin>>x;while(t--)
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

 

#define TRACE
#ifdef TRACE
#define see(...) __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...);
}
#else
#endif

const int POSITIVE_INFINITY = 9223372036854775807;
const int NEGATIVE_INFINITY = -9223372036854775807;
const int MOD = 1000000007;
const ld PI = acos(-1.0);
const int INF = 1e18;
const int MX = 1000001;

int pow(int a, int n , int m){
    int res = 1;
    while(n){
        if(n%2){
            res=(res*a)%m;
            n--;
        }
        a=(a*a)%m;
        n/=2;
    }
    return res;
}

int32_t main() {
    io;
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    int total = pow(10,n,MOD);
    int wo9 = (2*pow(9,n,MOD))%MOD;
    wo9=(wo9+MOD)%MOD;
    int wob = pow(8,n,MOD);
    int res =( total -wo9+wob)%MOD;
    res= (res+MOD)%MOD;
    cout<<res<<endl;
 
    
 
    return 0;
}


Measured memory_bytes: 3600
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
import queue
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A, B, X):
    ans = 0
    c = X[0]
    for x in X[1:]:
        ac = A*(x - c)
        if ac > B:
            ans += B
        else:
            ans += ac
        c = x

    return ans


def main():
    N, A, B = read_int_n()
    X = read_int_n()

    print(slv(N, A, B, X))


if __name__ == '__main__':
    main()


Measured memory_bytes: 16652
#include <bits/stdc++.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007

int main (){
    string w;
    bool flag=true;
    cin >> w;
    int x=w.length();
    map<char,int> mp;
    rep(i,x){
        mp[w[i]]++;
    }
    for(auto &p:mp){
        if(p.second%2==1) flag=false;
    }
    if(flag) cout << "Yes" << endl;
    else cout<< "No" << endl;
    return 0; 
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
   int a, b, c, d, s, o;

   scanf("%d%d%d%d",&a,&b,&c,&d);
   if(a<c)
      s=c;
   else
      s=a;
   if(b<d)
      o=b;
   else
      o=d;
   if(s<o)
      printf("%d\n",o-s);
   else
      printf("0\n");
   return 0;
}

Measured memory_bytes: 1716
S = input()
if((int(S[:2])>0 and int(S[:2])<=12) and (int(S[2:4])>12 or int(S[2:4])==0)):
    print('MMYY')
elif(int(S[2:4])>0 and int(S[2:4])<=12 and (int(S[:2])>12 or int(S[:2])==0)):
    print('YYMM')
elif((int(S[:2])>0 and int(S[:2])<=12) and (int(S[2:4])>0 and int(S[2:4])<=12)):
    print('AMBIGUOUS')
else:
    print('NA')

Measured memory_bytes: 3064
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()

vector <int> conn[100050];
vector <int> son[100050];
int gr[100050];
bool dchk[100050];
void DFS(int n) {
	dchk[n] = true;
	for (auto it : conn[n]) {
		if (dchk[it]) continue;
		son[n].push_back(it);
		DFS(it);
	}

	for (auto it : son[n]) gr[n] ^= gr[it] + 1;
}
int main() {
	int N, i;
	scanf("%d", &N);
	for (i = 1; i < N; i++) {
		int t1, t2;
		scanf("%d %d", &t1, &t2);
		conn[t1].push_back(t2);
		conn[t2].push_back(t1);
	}
	DFS(1);
	if (gr[1]) printf("Alice\n");
	else printf("Bob\n");
	return 0;
}

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

using namespace std;

int l[10],N,A,B,C;

int dfs(int n,int a,int b,int c){
    if(n==N){
        if(0<min({a,b,c})){
            return abs(A-a)+abs(B-b)+abs(C-c)-30;
        }else{
            return 1e8;
        }
    }else{
        int ret0 = dfs(n+1,a,b,c);
        int ret1 = dfs(n+1,a+l[n],b,c)+10;
        int ret2 = dfs(n+1,a,b+l[n],c)+10;
        int ret3 = dfs(n+1,a,b,c+l[n])+10;
        return min({ret0,ret1,ret2,ret3});
    }
}

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

    cout << dfs(0,0,0,0) << endl;
}

Measured memory_bytes: 256
n,y = map(int,input().split())

ok = 0
for i in range(n+1):
  for j in range(n+1-i):
    x1 = i
    x2 = j
    x3 = n-i-j
    if (10000*x1 + 5000*x2 + 1000*x3) == y:
      ok = 1
      break
  if ok:
    break
  
print("%d %d %d"%(x1, x2, x3)) if ok else print("-1 -1 -1")

Measured memory_bytes: 3064
n = int(input())
s = input()
ss = input()

i = 0
state = 0
ans = 1
while i<n:
    if n-i>1:
        if s[i+1]==s[i]:
            if state == 0:
                ans *= 6
            elif state == 1:
                ans *= 2
            else:
                ans *= 3
            state = 2
            i+=2
        else:
            if state == 0:
                ans *= 3
            elif state == 1:
                ans *= 2
            else:
                ans *= 1
            state = 1
            i+=1
    else:
        if state == 0:
            ans *= 3
        elif state == 1:
            ans *= 2
        else:
            ans *= 1
        state = 1
        i += 1
    ans %= 10**9+7

print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  ll n,k;
  cin>>n>>k;
  vecll h(n+2);
  for(ll i:irange(0l,n)) {
    int a;
    cin>>a;
    h[i+1] = a;
  }
  ll sum = 0;
  vecll cnt(n+1);
  for(ll i:irange(0l,n+1)) {
    cnt[i] = max(0l, h[i] - h[i+1]);
    sum += cnt[i];
  }
  vecll cnts(n+1);
  boost::partial_sum(cnt, begin(cnts));
  constexpr ll INF = 1e15;
  vector<vecll> dp(n+2, vecll(k+1, INF));
  dp[0][0] = 0;
  for (ll i:irange(1l,n+2)) {
    for (ll j:irange(0l,k+1)) {
      if (i-j-1 < 0) continue;
      ll d = max(0l, h[i-j-1] - h[i]);
      for (ll p:irange(0l,k+1)) {
        if (j+p > k) break;
        dp[i][j+p] = min(dp[i][j+p], dp[i-j-1][p] + d);
      }
    }
  }
  cout<<*boost::min_element(dp[n+1])<<endl;
  return 0;
}


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

#define f first
#define s second
#define pb push_back
#define all(c) c.begin(),c.end()

#define gi(x) scanf("%d", &x)
#define pi(x) printf("%d", x)
#define gl(x) scanf("%lld", &x)
#define pl(x) printf("%lld", x)
#define sp printf(" ")
#define nl printf("\n")

typedef long long int lld;
typedef long double ldb;

lld dp[55];
const lld mod = 1e9+7;
main(){
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    // dp[0] = 3;
    int pdiff = (s1[0] != s2[0]), cdiff, sdiff;
    if(pdiff) dp[0] = 6, dp[1] = 6;
    else dp[0] = 3;
    sdiff = pdiff;
    for(int i = (pdiff == 0 ? 1: 2); i < n;){
        cdiff = (s1[i] != s2[i]);
        if(sdiff){
            if(cdiff){
                dp[i] = (3*dp[i-1])%mod;
                dp[i+1] = dp[i];
                i+=2;
            }
            else{
                dp[i] = dp[i-1];
                i+=1;
            }
        }
        else{
            if(cdiff){
                dp[i] = (dp[i-1]*2)%mod;
                dp[i+1] = dp[i];
                i+=2;
            }
            else{
                dp[i] = (dp[i-1]*2)%mod;
                i+=1;
            }
        }
        sdiff = cdiff;
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const int MAX = 200000;

int main(){
    int R[MAX], n;

    cin >> n;
    for (int i=0; i<n; i++) cin >> R[i];

    int maxDiff = -2000000000;
    int minVal = R[0];

    for (int i=1; i<n; i++){
        maxDiff = max(maxDiff, R[i]-minVal);
        minVal = min(minVal, R[i]);
    }

    cout << maxDiff << endl;

    return 0;
}


Measured memory_bytes: 3880
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    string s;
    cin>>s;
    int ans = 700;
    rep(i, s.size()){
        if(s[i] == 'o') ans += 100;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
static const int MOD = 1000000007;
static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define ALL(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll
//struct edge {int to,cost;};

bool rullonz = false;

void dfs2(int n,int a,int b,int c){
    if(rullonz) return;
    if(a+b+c==n){
        printf("%d %d %d\n",c,b,a);
        rullonz = true;
        return;
    }
    if(a+b+c>n) return;
    if(c>=1) dfs2(n,a+10,b,c-1);
    if(c>=1) dfs2(n,a,b+2,c-1);
    if(b>=1) dfs2(n,a+5,b-1,c);
}

void dfs(int n,int a,int b,int c){
    if(rullonz) return;
    if(a+b+c==n){
        printf("%d %d %d\n",c,b,a);
        rullonz = true;
        return;
    }
    if(a+b+c<n) return;
    if(a>=5) dfs(n,a-5,b+1,c);
    if(a>=10) dfs(n,a-10,b,c+1);
    if(b>=2) dfs(n,a,b-2,c+1);
}

signed main(){
    int n,y;
    cin >> n >> y;
    if(5000*n>y) dfs(n,y/1000,0,0);
    else{
        int c = y/10000;
        y -= c*10000;
        int b = y/5000;
        y -= b*5000;
        int a = y/1000;
        dfs2(n,a,b,c);
    }
    if(!rullonz) puts("-1 -1 -1");
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)

int main()
{
  int n;
  string s;
  cin >> n >> s;
  ll r = 0, g = 0, b = 0;
  for (auto c: s)
  {
    if (c == 'R')
      r++;
    else if (c == 'G')
      g++;
    else
      b++;
  }
  ll all = r * g * b;
  ll sub = 0;
  for (int i = 0; i < n; i++)
  {
    for (int j = i + 1; j < n; j++)
    {
      if (s[i] == s[j])
        continue;
      int k = j * 2 - i;
      if (k >= n || s[k] == s[i] || s[k] == s[j])
        continue;
      sub++;
    }
  }
  cout << all - sub << endl;
}



Measured memory_bytes: 3636
n = int(input())
s = []
for i in range(n):
    si = input()
    s.append(si)
m = int(input())
t = []
for i in range(m):
    ti = input()
    t.append(ti)
ans = 0
for i in s:
    ans = max(ans,s.count(i)-t.count(i))
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
using namespace std;
bool isp[100100],is2017[100100];
int Prefix[100100];
int main()
{
	int N;
	cin>>N;
	for(int i=0;i<100100;i++)
		isp[i]=true;
	isp[0]=isp[1]=false;
	for(int i=2;i<=sqrt(100100);i++)
		if(isp[i])
			for(int j=i*i;j<100100;j+=i)
				isp[j]=false;
	for(int i=1;i<100100;i+=2)
		is2017[i]=(isp[i]&&isp[(i+1)/2]);
	for(int i=1;i<100100;i++)
		Prefix[i]=Prefix[i-1]+is2017[i];
	while(N--)
	{
		int L,R;
		cin>>L>>R;
		cout<<Prefix[R]-Prefix[L-1]<<endl;
	}
	return 0;
}


Measured memory_bytes: 4144
#include "bits/stdc++.h"

using namespace std;

int g(int x, int y, int z) {
    return x * x + y * y + z * z + x * y + y * z + z * x;
}

void Main() {
    int N;
    cin >> N;

    map<int, int> f;
    for (int i = 1; i <= N; ++i) {
        f.insert(make_pair(i, 0));
    }

    for (int i = 1; i < 100; ++i) {
        for (int j = 1; j < 100; ++j) {
            for (int k = 1; k < 100; ++k) {
                int a = g(i, j, k);
                if (a <= N) {
                    f[a] += 1;
                }
            }
        }
    }

    for (int i = 1; i <= N; ++i) {
        cout << f[i] << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 4044
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
	V,E = map(int,input().split())
	dist = [[INF]*V for _ in range(V)]
	for _ in range(E):
		s,t,d = map(int,input().split())
		dist[s][t] = d
	
	for k in range(V):
		for i in range(V):
			for j in range(V):
				if dist[i][k] != INF and dist[k][j] != INF and dist[i][j] > dist[i][k] + dist[k][j]:
					dist[i][j] = dist[i][k] + dist[k][j]
	
	for i in range(V):
		if dist[i][i] < 0:
			print('NEGATIVE CYCLE')
			return
		dist[i][i] = 0
	
	for i in range(V):
		print(' '.join(map(lambda x:'INF' if x == INF else str(x),dist[i])))
if __name__ == '__main__':
	main()


Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100;

vector<int> G[MAX_N];
int d[MAX_N];

int main()
{
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		int id;
		cin >> id;
		int k;
		cin >> k;
		for(int j=0;j<k;j++){
			int to;
			cin >> to;
			G[id-1].push_back(to-1);
		}
	}
	fill(d,d+n,INF);
	deque<int> bfs;
	bfs.push_back(0);
	d[0] = 0;
	while(!bfs.empty()){
		int v = bfs.front();
		bfs.pop_front();
		for(int i=0;i<G[v].size();i++){
			int to = G[v][i];
			if(d[to] > d[v]+1){
				d[to] = d[v]+1;
				bfs.push_back(to);
			}
		}	
	}
	for(int i=0;i<n;i++){
		if(d[i] == INF){
			d[i] = -1;
		}
		cout << i+1 << " " << d[i] << "\n";
	}
}

Measured memory_bytes: 3104
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int A,B;
    string op;
    R(A,op,B);
    if(op=="+")W(A+B);
    else W(A-B);
    return 0;
}


Measured memory_bytes: 256
n = input()
l = len(n)-1

for i in range(2**l):
    op=["-"]*l
    for j in range(l):
        if (i>>j)&1:
            op[l - j - 1] = "+" #なぜ i - j - 1 ではなく、l - j - 1なのか、決まっている数から引いたものが知りたい
    formula = ""
    for op_1,op_2 in zip(n,op+[""]): #式の文字列を作るループ
        formula += op_1 + op_2
    if eval(formula)==7:
        print(formula + "=7")
        break

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

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

    vector<int> cnt(m, 0);
    rep (i, n)
    {
        int k;
        cin >> k;

        rep (i, k)
        {
            int a;
            cin >> a;
            cnt[a - 1]++;
        }
    }

    int ans = 0;
    for (auto v : cnt)
        if (v == n)
            ans++;

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

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 7;
char s[MAXN];
int main()
{
    int ans = 0;
    scanf(" %s", s + 1); int len = strlen(s + 1);
    for (int i = 1; i <= len; i++) s[i] -= '0'; 
    s[0] = 0;
    for (int i = len; i >= 0; --i)
    {
        assert(s[i] <= 10);
        if (s[i] > 5 || (s[i] == 5 && (s[i - 1] + 1 > 5)))
        {
            ans += 10 - s[i];
            s[i - 1]++;
        }
        else ans += s[i];
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int n, i, x, k, d, maxim;
int cmmdc(int a, int b){
    int r;
    while(b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}
int main(){
    cin>> n >> k;
    for(i = 1; i <= n; i++){
        cin>> x;
        d = cmmdc(x, d);
        maxim = max(maxim, x);
    }
    if(k % d == 0 && k <= maxim){
        cout<<"POSSIBLE";
    }
    else{
        cout<<"IMPOSSIBLE";
    }
}


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

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int N;
    static int[] H;
    static void input()
    {
        cin = new Scanner();
        N = cin.nextInt();
        H = cin.ArrayInt(N);
    }
    static void solve()
    {
        input();
        int height = 0;
        for(int i = 0; i < N; i++)
        {
            if(H[i] < height)
            {
                WriteLine("No");
                return;
            }

            if (height < H[i])
                height = H[i] - 1;
            else
                height = H[i];
        }
        WriteLine("Yes");
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 28768
a = input()
b = input()
c = input()
x,num = [a,b,c],a[0]
for i in range(len(a)+len(b)+len(c)):
	if num=="a":
		if x[0]=="":
			break
		else:
			num = x[0][0]
			x[0] = x[0][1:]
	elif num=="b":
		if x[1]=="":
			break
		else:
			num = x[1][0]
			x[1] = x[1][1:]
	elif num=="c":
		if x[2]=="":
			break
		else:
			num = x[2][0]
			x[2] = x[2][1:]
print(num.upper())

Measured memory_bytes: 3064
#coding:utf-8
from collections import defaultdict


def get_primes(n):
    primfac = []
    d = 2
    while d * d <= n:
        while (n % d) == 0:
            primfac.append(d)  # supposing you want multiple factors repeated
            n //= d
        d += 1
    if n > 1:
        primfac.append(n)
    return primfac


N, P = list(map(int, input().split()))

primes = get_primes(P)

primes_dict = defaultdict(int)

for i in primes:
    primes_dict[i] += 1

for k, v in primes_dict.items():
    primes_dict[k] = int(v / N)

result = 1
for k, v in primes_dict.items():
    result = result * k ** v

print(result)


Measured memory_bytes: 3316
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int h,w,i,j;
    cin>>h>>w;
    int flag=1;
    char a[55][55];
    for(i=0;i<h;i++)
        for(j=0;j<w;j++)
           cin>>a[i][j];
     for(i=0;i<h;i++)
        for(j=0;j<w;j++)
        {
            if(a[i][j]=='#')
            {
                if(((i-1)>=0)&&(a[i-1][j]!='#'))
                    if(((i+1)<h)&&(a[i+1][j]!='#'))
                        if(((j-1)>=0)&&(a[i][j-1]!='#'))
                            if(((j+1)<w)&&(a[i][j+1]!='#'))
                                 flag=0;
            }
        }
        if(flag==0)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    ll n;
    string s;
    cin >> n >> s;
    ll count = 0;
    for (ll i = 0 ;  i < (n - 2); ++i) {
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
            ++count;
        }
    }
    cout << count << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> xs(N);
  rep(i, N) cin >> xs[i];
  sort(xs.begin(), xs.end());

  int ans = INT_MAX;
  for(int p = 1; p <= 100; p++) {
    int sum = 0;
  rep(i, N) {
    int x = xs[i];
    int dif = abs(x-p);
    int num = dif*dif;
    sum += num;
  }
    ans = min(ans, sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())
v1 = [x2 - x1, y2 - y1]
v = [-v1[1], v1[0]]

x3, y3 = x2 + v[0], y2 + v[1]
x4, y4 = x1 + v[0], y1 + v[1]

print(x3, y3, x4, y4)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int A[]=new int [N];
		int a=0;
		int b=0;
		for(int i=0;i<N;i++) {
			A[i]=sc.nextInt();
		}
		while(b==0) {
			for(int k=0;k<N;k++) {
				if(A[k]%2==0) {
					A[k]=A[k]/2;
				}else {
					b=1;
					a=a-1;
					break;
				}
			}
			a=a+1;
		}
		System.out.println(a);
	}
}

Measured memory_bytes: 22868
def main():
    s = str(input())
    t = str(input())
    for index, v in enumerate(s):
        if v != t[index]:
            print('No')
            exit()
    if len(s) + 1 != len(t):
        print('No')
        exit()
    print('Yes')


def input_list():
    return list(map(int, input().split()))


if __name__ == '__main__':
    main()


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

int main() {
  int N; cin >> N;
  vector<int> b(N+1);
  for(int i = 1; i <= N; ++i) cin >> b[i];
  vector<int> a;
  for(int i = N; i >= 1; --i) {
    int r = -1;
    for(int j = 1; j <= i; ++j) if(b[j] == j) r = j;
    if(r == -1) {
      cout << -1 << endl;
      return 0;
    }
    a.push_back(r);
    for(int j = r; j < i; ++j) b[j] = b[j+1];

  }
  for(int i = N-1; i >= 0; --i) {
    std::cout << a[i] << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; i++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	int N, K; cin >> N >> K;
	ll n = 1;
	for (int i = 0; i < N; i++) {
		if (n * 2 < n + K)n *= 2;
		else n += K;
	}

	cout << n << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cctype>
#include <complex>

using namespace std;

struct query {
    int l,r;
};

template<size_t N>
bitset<N> get_prime_table()
{
    bitset<N> table;
    table.set();
    table.reset(0);
    table.reset(1);
    const int max = (int)sqrt(N) + 1;
    for(size_t i = 2; i < max; ++i)
    {
        if(!table[i]) continue;
        for(size_t k = 2; i*k < N; ++k)
        {
            table.reset(i*k);
        }
    }
    return table;
};

const bitset<100001> prime_table = get_prime_table<100001>();

int main()
{
    size_t n;
    cin >> n;
    
    vector<int> counts;
    counts.reserve(100001);
    
    int count = 0;
    for(int i = 0; i < 100001; ++i)
    {
        if(prime_table[i] && prime_table[(i+1)/2])
            count++;
        counts[i] = count;
    }
   

    for(size_t i = 0; i < n; ++i){
        int l, r;
        cin >> l >> r;
        if(l == r)
        {
            if(prime_table[l] && prime_table[(l+1)/2])
            {
                cout << 1 << '\n';
            }
            else
            {
                cout << 0 << '\n';
            }
        }
        else{
            cout << (counts[r] - counts[l-1]) << '\n';
        }
    }
    
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, k; cin >> n >> k;
	int p[n];
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}
	sort(p, p + n);
	int res = 0;
	for (int i = 0; i < k; i++)
	{
		res += p[i];
	}
	cout << res << endl;
	return 0;
}


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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A=LI()
    S=sum(A)
    S2=0
    for i in range(1,N,2):
        S2+=A[i]
    
    B=[0]*N
    B[0]=S-S2*2
    for i in range(1,N):
        B[i]=A[i-1]*2-B[i-1]
        
    print(' '.join(map(str, B)))

main()


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

int main() {
  int H, W;
  cin >> H >> W;
  
  char board[50][50];
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++)
      cin >> board[i][j];
  }
  
  const int dx[4] = {0, 1, 0, -1};
  const int dy[4] = {1, 0, -1, 0};
  
  bool can = true;
  
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      int num = 0;
     
      if(board[i][j] == '.')
        continue;
      else{
        for(int k = 0; k < 4; k++){
          int ni = i + dx[k];
          int nj = j + dy[k];
      
          if(ni < 0 || ni >= H) continue;
          if(nj < 0 || nj >= W) continue;
          if(board[ni][nj] == '#') num += 1;
        }
        if(num == 0){
          can = false;
          break;
        }
      }
    }
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
N,D=map(int,input().split())
X=[list(map(int,input().split())) for i in range(N)]
l=len(X)
cnt=0
for i in range(l):
 for j in range(i+1,l):
  t=sum((X[i][d]-X[j][d])**2for d in range(D))**0.5
  cnt+=t==int(t)
print(cnt)

Measured memory_bytes: 9460
#include<stdio.h>

int main(){
  
  int N;
  scanf("%d",&N);

  int A[N];
  int joshi[N];

  for(int i=0; i<=N; i++){
    joshi[i] = 0;
  }

  for(int i=2; i<=N; i++){
    scanf("%d",&A[i]);
    joshi[A[i]]++;
  }

  for(int i=1; i<=N; i++){
    printf("%d\n",joshi[i]);
  }

  return 0;

}

Measured memory_bytes: 3288
/* Elementary data structures - Queue */

#include <stdio.h>
#define N 200000

typedef struct {
  int time;
  char name[20];
} node;

node queue[N];
int start = 0;
int end = 0;

void enqueue( node x )
{
  queue[end++] = x;
  if ( end == N )
    end = 0;
}

node dequeue()
{
  int tmp = start++;
  if ( start == N )
    start = 0;
  return queue[tmp];
}

int emptyp()
{
  return start == end;
}

int main( void )
{
  int n, q, i;
  scanf( "%d", &n );
  scanf( "%d", &q );

  node a;
  for ( i = 0; i < n; i++ ) {
    scanf( "%s", a.name );
    scanf( "%d", &a.time );
    enqueue( a );
  }

  int time = 0;

  while( !emptyp() ) {
    a = dequeue();
    if ( a.time > q ) {
      a.time -= q;
      time += q;
      enqueue( a );
    } else {
      time += a.time;
      printf( "%s %d\n", a.name, time );
    }
  }

  return 0;
}

Measured memory_bytes: 5036