akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define MAX 100000


int A[MAX],n;

int partition(int p,int r){
    int x,i,j,t;
    x=A[r];
    i=p-1;
    for(j=p;j<r;j++){
        if(A[j]<=x){  //xより小さいとき
            i++;
            t=A[i];
            A[i]=A[j];
            A[j]=t;
        }
    }
    t=A[i+1];
    A[i+1]=A[r];
    A[r]=t;
    return i+1;
}

int main(void){
    int i,q;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    q=partition(0,n-1);
    for(i=0;i<n;i++){
        if(i!=0){
            printf(" ");
        }
        if(i==q){
            printf("[");
        }
        printf("%d",A[i]);
        if(i==q){
            printf("]");
        }
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 2132
#include <algorithm>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>


using namespace std;

typedef long long ll;


class Solution {
 public:
  void solve(std::istream& in, std::ostream& out) {
    int n;
    string s;
    in >> n >> s;
    int q;
    in >> q;
    while (q--) {
      int k;
      in >> k;
      ll rez = 0;
      ll dp[2] = {0}, occ_b = 0;
      for (int ctr1 = 0; ctr1 < n; ++ctr1) {
        if (ctr1 >= k) {
          if (s[ctr1 - k] == 'D')
            --dp[0], dp[1] -= occ_b;
          if (s[ctr1 - k] == 'M')
            --occ_b;
        }
        if (s[ctr1] == 'D')
          ++dp[0];
        if (s[ctr1] == 'M')
          dp[1] += dp[0], ++occ_b;
        if (s[ctr1] == 'C')
          rez += dp[1];
      }
      out << rez << "\n";
    }
  }
};

void solve(std::istream& in, std::ostream& out)
{
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}
// Powered by caide (code generator, tester, and library code inliner)


#include <fstream>
#include <iostream>


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


  istream& in = cin;


  ostream& out = cout;

  solve(in, out);
  return 0;
}



Measured memory_bytes: 1948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("hitachi2020/hitachi2020_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int A, B, M;
  cin >> A >> B >> M;

  vector<ll> a(A);
  vector<ll> b(B);

  rep(i, A) { cin >> a[i]; }
  rep(i, B) { cin >> b[i]; }

  ll ans = LINF;
  rep(i, M) {
    ll x, y, c;
    cin >> x >> y >> c;
    x--;
    y--;
    ans = min(ans, a[x] + b[y] - c);
  }

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());

  ans = min(ans, a[0] + b[0]);

  cout << ans << endl;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String line;
        List<String> inputs = new ArrayList<>();
        while ((line = br.readLine()) != null && !line.isEmpty()) {
            int len = line.split(" ").length;
            if(len == 1) {
                if(!inputs.isEmpty()) {
                    output(inputs);
                    inputs.clear();
                }
                if("0".equals(line)) break;
            }
            if(len == 2) {
                inputs.add(line);
            }
        }
    }

    public static void output(List<String> inputs) {
        Integer scoreA = 0;
        Integer scoreB = 0;
        for(String line : inputs) {
            List<Integer> input = Arrays.stream(line.split(" ")).map(Integer::valueOf).collect(Collectors.toList());
            int a = input.get(0);
            int b = input.get(1);
            if(a > b) {
                scoreA += ( a + b );
            } else if(a < b) {
                scoreB += ( a + b );
            } else {
                scoreA += a;
                scoreB += b;
            }
        }
        System.out.println(scoreA + " " + scoreB);
    }
}

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

int ilog2(long long n) {
    int ret = 0;
    while (n > 0) {
        n /= 2;
        ret++;
    }
    return ret - 1;
}

int main() {
    long long x, y;
    cin >> x >> y;

    int ans = ilog2(y / x) + 1;
    cout << ans << endl; 
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
        Scanner scan  = new Scanner(System.in);
		 int x,y;
		 
		 while(true) {
		      x =scan.nextInt();
		      y =scan.nextInt();
		      if (x== 0 && y == 0) break;
		      
		      if (x <= y) {
		      System.out.println(x + " " + y);
		      }
		      else {
		      System.out.println(y + " " + x); 
		      }
		 }	
	}

}



Measured memory_bytes: 36684
#include<iostream>
#include<cctype>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;

int main(){
    int n;
    int x[100];
    int y[100];
    double p1 = 0;
    double p2 = 0;
    double p3 = 0;
    double pInf = 0;
    int absDiff = 0;
    
    cin >> n;
    for (int i = 0; i < n; i++) cin >> x[i];
    for (int i = 0; i < n; i++) cin >> y[i];
    
    for (int i = 0; i < n; i++) {
        absDiff = abs(x[i]-y[i]);
        p1 += absDiff;
        p2 += absDiff * absDiff;
        p3 += absDiff * absDiff * absDiff;
        if(pInf < absDiff) pInf = absDiff; 
    }
        
     printf("%lf\n",p1);
     printf("%lf\n",sqrt(p2));
     printf("%lf\n",cbrt(p3));
     printf("%lf\n",pInf);
        
       
            
    
    
   
    return 0;
}

Measured memory_bytes: 1208
from collections import deque
if __name__ == '__main__':
    n, q = input().split()
    n, q= int(n), int(q)
    lists = [deque([]) for i in range(n)]

    for i in range(q):
        p = input().split()
        if p[0] == '0':
            lists[int(p[1])].append(p[2])
        elif p[0] == '1':
            frag = False
            for i in lists[int(p[1])]:
                print(' ' + i if frag else i, end = '')
                frag = True
            print()
        else:
            lists[int(p[1])].clear()


Measured memory_bytes: 42100
#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
#include<vector>
#include<string>
#include<cstring>
#include<ctype.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	new_data_set;
//   <<implemented_sorted_vector>>  new_data_set p;
//   <<insert_like_set>>           insert(key):log(n)
//<<accessing_iterator_by_index>> find_by_order(idx):log(n)
//	    <<accessing_by_value>>   order_of_key(key):log(n)
// << replace less<int> by greater<int> for descending order>>
// find(key), erase(find(key)) works the same!
typedef long long ll;
typedef long l;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ERR(x) cout<<"#x:"<<x<<endl
#define ERR2(x,y) cout<<"#x:"<<x<<" "<<"#y:"<<y<<endl;
#define ERR3(x,y,z) cout<<"#x:"<<x<<" "<<"#y:"<<y<<" "<<"#z:"<<z<<endl;
#define show(v) for(auto e: v) cout<<e<<" ";
#define showArr(A,n) for(int i=0;i<n;i++) cout<<A[i]<<" ";
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define mp make_pair
#define ff first
#define ss second
#define umpit unordered_map<ll,ll>::iterator
#define mpit map<ll,ll>::iterator
#define setit set<ll>::iterator
#define all(v) v.begin(),v.end()

const int N = 1e5+5;

int main()
{
	int n;
	cin>>n;
	int A[N][3];
	FOR(i,0,n)
		FOR(j,0,3)
			cin>>A[i][j];
	
	ll dp[N][3];
	memset(dp, 0 ,sizeof(dp));
	dp[0][0] = A[0][0];
	dp[0][1] = A[0][1];
	dp[0][2] = A[0][2];

	FOR(i,1,n)
	{
		dp[i][0] = A[i][0]+
				max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = A[i][1]+
				max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] = A[i][2]+
				max(dp[i-1][1], dp[i-1][0]);
	}
	cout<<max(dp[n-1][0], 
		max(dp[n-1][1], dp[n-1][2]));	
	return 0;
}


Measured memory_bytes: 7064
# PDF解説を参考に
N = int(input())
S = input()

ans = S[1:N].count("E")
mn_ans = ans
for i in range(1, N):
    if S[i-1] == "E" and S[i] == "E":
        ans -= 1
    elif S[i-1] == "W" and S[i] == "W":
        ans += 1
    if mn_ans > ans:
        mn_ans = ans

print(mn_ans)

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int main()
{
    
    
    int n; cin>>n;
    int a[n][3];
    int dp[n][3];
   
    for(int i=0;i<n;i++){ cin>>a[i][0]>>a[i][1]>>a[i][2];}
    
    
    dp[0][0]=a[0][0];dp[0][1]=a[0][1];dp[0][2]=a[0][2];
    
   for(int i=1;i<n;i++)
   {
       
       dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
       dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
       dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0]);
       
   }
   
   cout<<max(dp[n-1][0],    max(dp[n-1][1],dp[n-1][2])  );
    
}

Measured memory_bytes: 2560
#include<stdio.h>

int main(void){
    int x, y;
    char op;
    
    while(1){
    scanf("%d %c %d", &x, &op, &y);
    if(op == '+')
        printf("%d\n", x + y);
    else if(op == '-')
        printf("%d\n", x - y);
    else if(op == '*')
        printf("%d\n", x * y);
    else if(op == '/')
        printf("%d\n", x / y);
    else if(op == '?')
        break;
    }
    return 0;
}


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

using namespace std;

int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);

	string s;
	cin >> s;
	
	if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
		cout << "3\n";
	}else if(s[0] == 'R' && s[1] == 'R' || s[1] == 'R' && s[2] == 'R') {
		cout << "2\n";
	}else if(s[0] == 'S' && s[1] == 'S' && s[2] == 'S') {
		cout << "0\n";
	}else{
		cout << "1\n";
	}

	return 0;
}

Measured memory_bytes: 3604
S = input()
S = '.'.join([S[i] for i in range(len(S) - 2)]).replace('.', '')
while True:
    former = '.'.join([S[i] for i in range(int(len(S) / 2))]).replace('.', '')
    latter = '.'.join([S[i] for i in range(int(len(S) / 2), len(S))]).replace('.', '')
    if former ==latter:
        print(len(former)*2)
        exit(0)
    else:
        S = '.'.join([S[i] for i in range(len(S) - 2)]).replace('.', '')



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0; i<N; i++)
#define lint long long
#define square_vector(name,N,M) vector<vector<lint>>name(N,vector<lint>(M,0))
#define sort(V) sort(V.begin(),V.end())

int mindis(vector<vector<lint>>dis,lint E,queue<lint> Q,vector<lint> point,lint N) {
  lint now;
  while (!Q.empty()) {
    now = Q.front();
    rep(i,N) {
      if (dis[now][i] != 0) {
        if (point[now] + dis[now][i] < point[i]) {
          Q.push(i);
          point[i] = point[now] + dis[now][i];
        }
      }
    }
    Q.pop();
  }
  return point[E];
}

int main() {
  lint N,M;
  cin >> N >> M;
  square_vector(abc,M,3);
  square_vector(dis,N,N);
  rep(i,M) {
    cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
    abc[i][0]--;
    abc[i][1]--;
    dis[abc[i][0]][abc[i][1]] = abc[i][2];
    dis[abc[i][1]][abc[i][0]] = abc[i][2];
  }
  
  lint ans = 0;
  
  rep(i,M) {
    queue<lint> Q;
    Q.push(abc[i][0]);
    vector<lint> point(N,2000000);
    point[abc[i][0]] = 0;
    if(abc[i][2] > mindis(dis,abc[i][1],Q,point,N)) {
      ans++;
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 512
//
//  main.cpp

#include <iostream>
using namespace std;


int main(){	
	int L,A,B,C,D;
	cin >> L >> A >> B >> C >> D;

	int L1 = A / C;
	if(A%C != 0)L1++;
	int L2 = B / D;
	if(B%D != 0)L2++;
	
	cout << L - max(L1,L2) << endl;
	return 0;
}

Measured memory_bytes: 3068
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int M = Integer.parseInt(strArr[1]);
		if (N == 1) {
			System.out.println(M);
			return;
		}

		HashSet<Integer> primes = new HashSet<Integer>();
		for (int n = 2; n <= M && n < 100000; n++) {
			boolean isP = true;
			for (int p : primes) {
				if (n % p == 0) {
					isP = false;
					break;
				}
			}
			if (isP)
				primes.add(n);
		}

		boolean isP = true;
		for (int p : primes) {
			// System.out.println(p);
			if (M % p == 0) {
				isP = false;
				break;
			}
		}
		if (isP) {
			System.out.println(1);
			return;
		}
		for (; M % N != 0; N++) {
		}
		System.out.println(M / N);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
	}

	public void solve() {

	}
}


Measured memory_bytes: 28816
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define mkp make_pair
#define pii pair<int,int>
typedef long long ll;
const int inf=0x3f3f3f3f;
const int maxn=2e5+5;
const int mod=1e9+7;
int fac[maxn],inv[maxn],dp[maxn],sz[maxn];
int n;
vector<int>v[maxn];
ll mul(ll a,ll b){
	return (a*b)%mod;
}
void init(int n){
	fac[1]=1;
	fac[0]=1;
	for(int i=2;i<=n;i++){
		fac[i]=mul(fac[i-1],i);
	}
	inv[1] = 1;
	for(int i = 2; i <=n; ++ i)
    inv[i] = mul((mod - mod / i) , inv[mod % i] );
}
void dfs(int x,int fa){
	sz[x]=1;
	for(auto y:v[x]){
		if(y==fa)continue;
		dfs(y,x);
		sz[x]+=sz[y];
	}
}
void reroot(int x,int fa){
	dp[x]=mul(mul(dp[fa],sz[x]),inv[(n-sz[x])]);
	for(auto p:v[x]){
		if(p==fa)continue;
		reroot(p,x);
	}
}
int main(){
	
	scanf("%d",&n);
	init(n);
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		v[x].pb(y);
		v[y].pb(x);
	}
	dfs(1,-1);
	dp[1]=fac[n];
	for(int i=1;i<=n;i++){
		dp[1]=mul(dp[1],inv[sz[i]]);
	}

	for(auto p:v[1]){
		reroot(p,1);
	}
	for(int i=1;i<=n;i++)printf("%d\n",dp[i]);
	return 0;
}


Measured memory_bytes: 17012
<?php
$N=(int)fgets(STDIN);
$Ab=$As=explode(' ',trim(fgets(STDIN)));
 
for($i=0;$i<$N;$i++)
  for($j=$N-1;$i<$j;$j--)
    if($Ab[$j][1]<$Ab[$j-1][1])
      list($Ab[$j],$Ab[$j-1])=[$Ab[$j-1],$Ab[$j]];
 
for($i=0;$i<$N;$i++){
  $mini=$i;
  for($j=$i;$j<$N;$j++)
    if($As[$j][1]<$As[$mini][1]) $mini=$j;
  if($i==$mini) continue;
  list($As[$i],$As[$mini])=[$As[$mini],$As[$i]];
}
 
$diff=0;
for($i=0;$i<$N;$i++){
  if($Ab[$i]!=$As[$i]){$diff=1;break;}
}
 
$sAb=implode(' ',$Ab);
echo $sAb,PHP_EOL,'Stable',PHP_EOL;
if($diff) echo implode(' ',$As),PHP_EOL,'Not stable',PHP_EOL;
else echo $sAb,PHP_EOL,'Stable',PHP_EOL;

Measured memory_bytes: 15444
import sys

def solve():
    N, M = map(int, input().split())

    ncnt = [0]*N

    for i in range(M):
        a, b = map(int, sys.stdin.readline().split())
        a -= 1
        b -= 1

        ncnt[a] += 1
        ncnt[b] += 1

    if all(ni & 1 == 0 for ni in ncnt):
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    solve()

Measured memory_bytes: 3828
sx, sy, tx, ty = map(int,input().split())

dx = (tx - sx)
dy = (ty - sy)

s = 'U' * dy + 'R' * dx

s += 'D' * dy + 'L' * dx

s += 'L' + 'U' * (dy+1) + 'R' * (dx+1) + 'D'

s += 'R' + 'D' * (dy+1) + 'L' * (dx+1) + 'U'

print(s)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

int main(){
  ll n; cin >> n;
  ll ans = 0;
  for(ll i = 2; i*i <= n; i++){
    if(n % i == 0){
      int cnt = 0;
      while(n % i == 0){
        cnt++;
        n /= i;
      }
      for(int j = 1; j <= cnt; j++){
        ans++;
        cnt -= j;
      }
    }
  }
  if(n != 1) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
import math

line = input()
x1, y1, x2, y2 = list(map(int, line.split()))
line = input()
q = int(line)
pts = []
for _ in range(0, q):
    line = input()
    x, y = list(map(int, line.split()))
    pts += [[x, y]]

def solve():
    l1 = math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
    for x, y in pts:
        l2 = math.sqrt((x - x1)**2 + (y - y1)**2)
        dx = (x2 - x1) / l1
        dy = (y2 - y1) / l1
        ip = (x - x1) * (x2 - x1) + (y - y1) * (y2 - y1)
        xx = x1 + dx * ip / l1
        yy = y1 + dy * ip / l1
        print(xx, yy)

solve()


Measured memory_bytes: 5920
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ROCK ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f first
#define sec second
using namespace std;
using namespace __gnu_pbds;
const long long int linf =(long long)9223372036854775807;
const int dx[8] =  {0,0,1,-1,1,-1,1,-1},dy[9] = {1,-1,0,0,1,-1,-1,1};
typedef long long int ll;

const int N=1e3+5,MOD=(int)1e9+7;
char grid[N][N];
ll dp[N][N],n,m;

bool valid(int x,int y){
    return x>=0 && x<n && y>=0 && y<m && grid[x][y]!='#';
}


ll solve(int x,int y){
    if(!valid(x,y))return 0;
    if(dp[x][y]!=-1)return dp[x][y]%MOD;
    if(x==n-1 && y==m-1)return 1;
    return dp[x][y]=(solve(x,y+1)%MOD+solve(x+1,y)%MOD)%MOD;
}

int main()
{
    ROCK;
    memset(dp,-1,sizeof dp);
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>grid[i][j];
        }
    }cout<<solve(0,0)<<endl;
    return 0;
}






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

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int x, sum;
main() {
  file("threesum");
  ios;
  int n, m;
  cin >> n >> m;
  fo(i, 1, m, 1) cin >> x, sum += x;
  if (n < sum) return !(cout << -1);
  cout << n - sum;
  return 0;
}
/**

*/


Measured memory_bytes: 3644
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	path := make([]string, 9)

	for i := 0; i < 9; i++ {
		path[i] = getNextString(scanner)
	}

	q := make([]Pair, 0)

	q = append(q, Pair{
		path: strings.Join(path, ""),
		c:    0,
	})

	visited := make(map[string]int, 0)
	ans := 0
	visited[q[0].path] = 1
	for len(q) > 0 {
		p := q[0]
		q = q[1:]
		if p.path == "123456780" {
			ans = p.c
			break
		}
		for i := 0; i < 9; i++ {
			if p.path[i] == '0' {
				if i-3 >= 0 {
					ap := swap(p.path, i, i-3)
					if _, ok := visited[ap]; ok == false {
						q = append(q, Pair{
							path: ap,
							c:    p.c + 1,
						})
						visited[ap] = 1
					}
				}
				if i+3 < 9 {
					ap := swap(p.path, i, i+3)
					if _, ok := visited[ap]; ok == false {
						q = append(q, Pair{
							path: ap,
							c:    p.c + 1,
						})
						visited[ap] = 1
					}
				}
				if i%3 != 0 {
					ap := swap(p.path, i, i-1)
					if _, ok := visited[ap]; ok == false {
						q = append(q, Pair{
							path: ap,
							c:    p.c + 1,
						})
						visited[ap] = 1
					}
				}
				if i%3 != 2 {
					ap := swap(p.path, i, i+1)
					if _, ok := visited[ap]; ok == false {
						q = append(q, Pair{
							path: ap,
							c:    p.c + 1,
						})
						visited[ap] = 1
					}
				}
				break
			}
		}
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}

type Pair struct {
	path string
	c    int
}

func swap(s string, i, j int) string {
	sp := strings.Split(s, "")
	sp[i], sp[j] = sp[j], sp[i]
	return strings.Join(sp, "")
}



Measured memory_bytes: 29704
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
 
public class Main {
	private static FastScanner sc = new FastScanner();
	
	public static void main(String[] args) {
		char[] S = sc.next().toCharArray();
		int min1 = S.length;
		for(int i=0; i<S.length; i++) {
			if(S[i] == '1') {
				if(S.length%2 == 1 && i == S.length/2) {
					if(S.length/2 + 1 < min1) min1 = S.length/2 + 1;
				} else if(i < S.length/2) {
					if(S.length - i - 1 < min1) min1 = S.length - i - 1;
				} else {
					if(i < min1) min1 = i;
				}
			}
		}
		
		for(int i=0; i<S.length; i++) {
			if(S[i] == '0') {
				S[i] = '1';
			} else {
				S[i] = '0';
			}
		}
		
		int min2 = S.length;
		for(int i=0; i<S.length; i++) {
			if(S[i] == '1') {
				if(S.length%2 == 1 && i == S.length/2) {
					if(S.length/2 + 1 < min2) min2 = S.length/2 + 1;
				} else if(i < S.length/2) {
					if(S.length - i - 1 < min2) min2 = S.length - i - 1;
				} else {
					if(i < min2) min2 = i;
				}
			}
		}
		
		System.out.println(Math.max(min1, min2));
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 23508
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main() {
  
  ll n,k;
  cin >> n >> k;

  vll  a(n,0);

  rep(i,k)
  {
    ll d;
    cin >> d;
    rep(j,d)
    {
      ll e;
      cin >> e;
      a[e-1]++;
    }
  }

  ll ans = 0;

  rep(i,n)
  {
    if(a[i] == 0)
      ans++;
  }

  cout << ans << endl;
  

  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main(){
  int n,m,x,y;
  scanf("%d %d %d %d",&n,&m,&x,&y);
  int xn[101];
  int xm[101];
  for(int i=0;i<n;i++){
    scanf("%d",&xn[i]);
    if(x < xn[i]){
      x = xn[i];
    }
  }
  for(int i=0;i<m;i++){
    scanf("%d",&xm[i]);
    if(y > xm[i]){
      y = xm[i];
    }
  }
  if(x >= y){
    printf("War");
  }else{
    printf("No War");
  }
}

Measured memory_bytes: 1736
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

int A[330][330], N, M;
int chk[330][330];
int cnt[330];

void solve(){
	scanf("%d%d", &N, &M);
	for(int i=1;i<=N;i++) for(int j=1;j<=M;j++) scanf("%d", A[i]+j);
	int ans = N;
	for(int i=1;i<=N;i++) for(int j=1;j<=M+1;j++) chk[i][j] = 1;
	int p[330] = {};
	for(int i=1;i<=N;i++) p[i] = 1;
	rep(a, M) {
		for(int i=1;i<=M;i++) cnt[i] = 0;
		int mx = 0, mxi = -1;
		for(int i=1;i<=N;i++) if(mx < ++cnt[A[i][p[i]]]) {
			mx = cnt[A[i][p[i]]];
			mxi = A[i][p[i]];
		}
		ans = min(ans, mx);
		
		for(int i=1;i<=N;i++) for(int j=1;j<=M;j++) if(A[i][j] == mxi) chk[i][j] = 0;
		for(int i=1;i<=N;i++) while(chk[i][p[i]] == 0) ++p[i];
		
	}
	printf("%d\n", ans);
}

int main(){
	int T = 1; // scanf("%d", &T);
	while(T--) {
		solve();
	}
	
	return 0;
}


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

int main() {
  string s; ll k; cin >> s >> k;
  ll sn = s.size();
  ll sum = 0, ans = 0;
  int l = 0, r = sn - 1, lc = 0, rc = 0, mc = 0;
  if (s[l] == s[r]) {
    while(s[l] == s[0] && l < sn) {lc++; l++;}
    while(s[r] == s[sn-1] && r >= 0) {rc++; r--;}
    if (l == sn) {
      ans = sn * k / 2;
      cout << ans << endl;
      return 0;
    }
    if (lc+rc == 2) mc = 1;
    else mc = (lc+rc)/2;
    ans += lc / 2;
    ans += rc / 2;
    ans += mc * (k-1);
  }
  for (int i = l; i<=r; i++) {
    int cnt = 1;
    while(i+1<=r && s[i] == s[i+1]) {
      i++;
      cnt++;
    }
    sum += cnt / 2;
  }
  ans += sum * k;
  cout << ans << endl;
  return 0;
}

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

using namespace std;

long long n;
char tt[15];
long long ss[10];
map<long long,long long>m;

long long ha(char s[])
{
    long long ans = 0;
    for(long long i = 0;i < 10;i++)
        ans = ans * 131 + s[i] - 'a' + 1;
    return ans;
}

int main()
{
    scanf("%lld",&n);
    for(long long i = 1;i <= n;i++)
    {
        memset(ss,0,sizeof ss);
        scanf("%s",tt);
        for(long long j = 0;j < 10;j++)
        {
            ss[j] = tt[j] - 'a';
        }
        sort(ss,ss + 10);
        char s[15];
        for(long long j = 0;j < 10;j++)
            s[j] = ss[j] + 'a';
        m[ha(s)]++;

    }
    map<long long,long long>::iterator it = m.begin();
    long long ans = 0;
    for(;it != m.end();it++)
    {
        long long t = it->second;
        if(t >= 2)
            ans += (t * (t - 1)) / 2;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
using namespace std;

int main(){
    long long a,b,x;
    cin>>a>>b>>x;
    long long ans = b/x-a/x;
    if(a%x==0) ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N=int(input())
c=[]
for i in range(N):
    city,point=input().split()
    c.append([city,int(point),i+1])
    c.sort(key=lambda c:c[1],reverse=True)
    c.sort(key=lambda c:c[0])
for i in range(N):
    c[i].append(i)
c.sort(key=lambda c:c[3])
for i in range(N):
    print(c[i][2])

Measured memory_bytes: 3060
#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(){
  vector<char> alphabet(26) ;
  alphabet = {'a','b','c','d','e','f',
       'g','h','i','j','k','l','m','n',
       'o','p','q','r','s','t','u','v','w','x','y','z'};
  char ans;
  cin >> ans;
  rep(i,26)
    if(ans == alphabet[i]){
      ans = alphabet[i+1];
      break;
    }
  cout << ans << endl;
}

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

using namespace std;

const long long MOD = 1e9 + 7;
typedef long long llint;

// dp[決めた桁数][N未満]
llint dp[101010][2];

int main() {
  string s;
  cin >> s;
  int n = s.size();
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    int d = s[i] - '0';
    // a + b = 0
    if (d == 0) {
      dp[i + 1][0] += dp[i][0];
      dp[i + 1][1] += dp[i][1];
    } else {
      dp[i + 1][1] += dp[i][0] + dp[i][1];
    }
    dp[i + 1][0] %= MOD;
    dp[i + 1][1] %= MOD;
    // a + b = 1
    if (d == 0) {
      dp[i + 1][1] += dp[i][1] * 2;
    } else {
      dp[i + 1][0] += dp[i][0] * 2;
      dp[i + 1][1] += dp[i][1] * 2;
    }
    dp[i + 1][0] %= MOD;
    dp[i + 1][1] %= MOD;
  }
  cout << (dp[n][0] + dp[n][1]) % MOD << endl;

  return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int n;
  cin >> n;

  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());

  double ans = (v[0] + v[1]) / 2.0;
  for (int i = 2; i < n; ++i) {
    ans = (ans + v[i]) / 2.0;
  }

  cout << ans << '\n';

  return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    string s; cin >> s;
    i32 p = stoi(s.substr(0,2)), b = stoi(s.substr(2, 2));

//    debug(p);debug(b);

    bool can1 = (0 < p && p <= 12), can2 = (0 < b && b <= 12);
    if(can1 && can2) cout << "AMBIGUOUS" << '\n';
    else if(can1) cout << "MMYY" << '\n';
    else if(can2) cout << "YYMM" << '\n';
    else cout << "NA" << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 256
n, m, q = map(int, input().split())
cond = []

for qq in range(q):
    a,b,c,d = map(int, input().split())
    cond.append([a,b,c,d])

cond.sort()
#print(cond)
finalres = 0
dat = [1] * n
while True:
    for i in range(n - 1, -1, -1):
        if dat[i] > m:
            dat[i] = dat[i - 1]
            dat[i - 1] += 1
        else:
            break
    ispass = False
    for i in range(n - 1, 0, -1):
        if dat[i] < dat[i - 1]:
            ispass = True
            break
    if ispass:
        dat[n - 1] += 1
        if dat[0] >= m:
            break
        continue

    #print("Try:", dat)

    can = True
    res = 0
    for i in range(q):
        a, b, c, d = cond[i]
        a, b = a-1, b-1
        if dat[b] - dat[a] == c:
            #print(" > match i{0} -i{1} == c gain {2}".format(b, a, d))
            res += d
    finalres = max(finalres, res)

    dat[n - 1] += 1
    if dat[0] >= m:
        break
print(finalres)


Measured memory_bytes: 74040
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_sum_of_three_integers(void) {
	int k, s;
	int cnt = 0;
	cin >> k >> s;
	for (int h = 0; h <= k; h++) {
		for (int i = 0; i <= k; i++) {
			int z = s - h - i;
			if ((z >= 0) && (z <= k))cnt++;
		}
	}
	cout << cnt << endl;
}

int main()
{
	b_sum_of_three_integers();
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {

	int n, cnt = 0;
	cin >> n;
	vector<ll> a(n);
	vector<ll> b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n-1; i++) {
		if (a.at(i) == a.at(i + 1)) {
			b.at(i)=a.at(i);
		}
	}
	sort(b.begin(), b.end(), greater<int>());
	for (int i = 0; i < b.size()-1; i++) {
		if (b.at(i) == b.at(i + 1)) {
			b.erase(b.begin() + i);
		}
	}
	cout<<b[0]*b[1]<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

	ll dp[114][4][4][4];

int main() {
	
	int N;
	cin>>N;
	dp[0][3][3][3]=1;
	fw(N){
		fx(4){
			fy(4){
				fz(4){
					if(dp[w][x][y][z]==0){continue;}
					for(int v=0;v<4;v++){
						if(y==0&&z==1&&v==2){continue;}
						if(y==0&&z==2&&v==1){continue;}
						if(y==1&&z==0&&v==2){continue;}
						if(x==0&&z==1&&v==2){continue;}
						if(x==0&&y==1&&v==2){continue;}
						
						dp[w+1][y][z][v]+=dp[w][x][y][z];
						dp[w+1][y][z][v]%=MOD;
						
					}
				}
			}
		}
	}
	
	ll ans=0;
	fx(4){
			fy(4){
				fz(4){
					ans+=dp[N][x][y][z];
					ans%=MOD;	
					}
				}
			}
	ce(ans)
}

Measured memory_bytes: 256
package main

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

func main() {
	fsc := NewFastScanner()
	N := fsc.Next()
	fmt.Println("ABC" + N)

}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640
from collections import Counter

H,W = map(int, input().split())
S = [input() for _ in range(H)]


 
class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count += 1

uf = UnionFind(H*W)

for i in range(H):
    for j in range(W):
        
        # 横
        if j != W-1 and S[i][j] != S[i][j+1]:
            uf.unite(i*W+j, i*W+j+1)
        
        # 縦
        if i != H-1 and S[i][j] != S[i+1][j]:
            uf.unite(i*W+j, (i+1)*W+j)

for i in range(H*W):
    uf.root(i)

black = Counter()
white = Counter()

#あるユニオンに所属（#.#.の移動できる塊）の#と.の数を数える
for i in range(H):
    for j in range(W):
        k = i*W+j
        if S[i][j] == "#":
            black[uf.root(k)] += 1
        else:
            white[uf.root(k)] += 1

#ユニオンごとに足し合わせ
ans = 0
for k in black.keys():
    ans += black[k] * white[k]

print(ans)

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while( x->left != NIL ) x = x->left;
  return x;
}
Node treeMaximum(Node x){
  while( x->right != NIL ) x = x->right;
  return x;
}

Node find(Node u, int k){
  while( u != NIL && k != u->key ){
    if ( k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  if ( x->right != NIL ) return treeMinimum(x->right);
  Node y = x->parent;
  while( y != NIL && x == y->right ){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if ( z->left == NIL || z->right == NIL ) y = z;
  else y = treeSuccessor(z);
  if ( y->left != NIL ) x = y->left;
  else x = y->right;

  if ( x != NIL ) x->parent = y->parent;

  if ( y->parent == NIL ){
    root = x;
  } else {
    if (y == y->parent->left) y->parent->left = x;
    else y->parent->right = x;
  }

  if ( y != z ){
    z->key = y->key;
  }

  free(y);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ){
    y = x;
    if ( z->key < x->key ){
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if ( y == NIL ){
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node u){
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node u){
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( strcmp(com, "find") == 0 ){
      scanf("%d", &x);
      Node t = find(root, x);
      if ( strcmp(com, "findMin") == 0 ){
	Node minn = treeMinimum(t);
	printf("%d\n", minn->key);
      } else if ( strcmp(com, "findMax") == 0 ){
	Node maxn = treeMaximum(t);
	printf("%d\n", maxn->key);
      } else {
	if ( t != NIL ) printf("yes\n");
	else printf("no\n");
      }
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( strcmp(com, "print") == 0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( strcmp(com, "delete") == 0 ){
      scanf("%d", &x);
      treeDelete(find(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20468
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define LL long long
using namespace std;
LL read() {
    LL k = 0; char c = getchar();
    while(c < '0' || c > '9') c = getchar();
    while(c >= '0' && c <= '9')
        k = k * 10 + c - 48, c = getchar();
    return k;
}
int main() {
    LL n = read(), tot = 1, ans = 0;
    while(n > 0) {
        ans += tot;
        n >>= 1ll; tot <<= 1ll;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdio>
#include<cstring>
#include<set>
#include<queue>
#include<algorithm>
#define N 1005
#define INF 0x3f3f3f3f
using namespace std;
long long int a,b,x,y;
long long int exgcd(long long int a,long long int b,long long int &x,long long int &y){
if(b==0){
x=1;
y=0;
return a;
}
long long int ans=exgcd(b,a%b,y,x);
y-=a/b*x;
return ans;
}

int main(){
long long int s;
scanf("%lld",&s);
//s=(long long int )1e18-2;
a=1000000000;
b=1;
x=s%a?s/a+1:s/a;
y=a*x-s;
printf("0 0 %lld %lld %lld %lld",a,b,y,x);
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define INF 1e9;
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n; cin >> n;
    ll sum = 0;
    vector<int> ans(32, 0);

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

    int i = 0;
    while (n != 0) {
        if (n % 2 != 0) {
            ans[i]++;
            n -= 1;
        }
        n /= -2;
        i++;
    }

    bool a = false;
    rep(i, 32) {
        if (ans[31-i] != 0) {
            cout << ans[31-i];
            a = true;
        } else {
            if (a) cout << ans[31-i];
        }
        
    }
    cout << endl;

}

Measured memory_bytes: 256