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

int main()
{
    int a[2];

    for(int i = 0; i < 3; i++){
        cin >> a[i];
    }
    sort(a, a+3);

    int s = a[2] * 10 + a[1];

    cout <<  s + a[0];
    return 0;
}




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

using namespace std;

void Main() {
    int N, X;
    cin >> N >> X;
    vector<int> m(N, 0);
    int sum_m = 0;
    for (int i = 0; i < N; ++i) {
        cin >> m[i];
        sum_m += m[i];
    }

    int ans = N;
    ans += (X - sum_m) / (*min_element(m.begin(), m.end()));
    cout << ans << endl;
}

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


Measured memory_bytes: 3640
D = int(input())
C = [int(T) for T in input().split()]
S = [[] for TD in range(0,D)]
for TD in range(0,D):
    S[TD] = [int(T) for T in input().split()]
Type = 26
Last = [0]*Type
SatS = 0
Test = [0]*D
for TD in range(0,D):
    SatC = [0]*Type
    for Select in range(0,Type):
        SatC[Select] = S[TD][Select]
        for TC in range(0,Type):
            SatC[Select] -= [C[TC]*(TD+1-Last[TC]),0][TC==Select]
    TesM = SatC.index(max(SatC))
    Last[TesM] = TD+1
    Test[TD] = TesM+1
    SatS += max(SatC)
print('\n'.join(str(TD) for TD in Test))

Measured memory_bytes: 69048
#include<bits/stdc++.h>
using namespace std;
main()
{int a, n;
cin>>n;
	vector <int> m;
	for(int i=1;i<n;i++)
	{
		cin>>a;
		m.push_back(a);
	}
	unordered_map<int,int> mp;
	for(int i=0;i<m.size();i++)
	{
		mp[m[i]]=mp[m[i]]+1;
	}
	for(int i=1;i<=n;i++)
	{
		if(mp[i]>0)
		{
			cout<<mp[i]<<endl;
		}
		else{
			cout<<0<<endl;
		}
	}
		
}

Measured memory_bytes: 12196
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
C = gets.split.map(&:to_i)

ret = B.inject(&:+)
last = A.first

A.each_with_index do |a, index|
  next if index == 0
  ret += C[last - 1] if a == last + 1 
  last = a
end
puts ret

Measured memory_bytes: 1788
#!/usr/bin/env python3
import sys

sys.setrecursionlimit(10 ** 8)
ni = lambda: int(sys.stdin.readline())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
ns = lambda: sys.stdin.readline().rstrip()

N, K, C = nm()
S = ns()
assert len(S) == N

INF = 1 << 60


def solve():
    lfilled = [0] * N  # max left count where i-th position is filled
    lempty = [0] * N  # max left count where i-th position is empty
    for i in range(0, N):
        if i > 0:
            lempty[i] = max(lempty[i - 1], lfilled[i - 1])
        if S[i] == "x":
            lfilled[i] = -INF
        elif i - C >= 0:
            lfilled[i] = lempty[i - C] + 1
        else:
            lfilled[i] = 1

    rfilled = [0] * N
    rempty = [0] * N
    for i in range(N - 1, -1, -1):
        if i < N - 1:
            rempty[i] = max(rempty[i + 1], rfilled[i + 1])
        if S[i] == "x":
            rfilled[i] = -INF
        elif i + C < N:
            rfilled[i] = rempty[i + C] + 1
        else:
            rfilled[i] = 1

    def must_work(s, t):
        l = max(lfilled[s - 1], lempty[s - 1]) if s - 1 >= 0 else 0
        r = max(rfilled[t], rempty[t]) if t < N else 0
        # print(f"day {s}-{t}: l+r={l+r} l={l} r={r}", file=sys.stderr)
        return l + r < K

    # imos
    no_need_to_work = [0] * (N + C)
    for t in range(1, N + C):
        s = max(t - C, 0)
        if not must_work(s, t):
            no_need_to_work[s] += 1
            no_need_to_work[t] -= 1
    acc = [0] * (N + C + 1)
    ans = []
    for i in range(1, N + 1):
        acc[i] += acc[i - 1] + no_need_to_work[i - 1]
        if acc[i] == 0:
            ans.append(i)
    return ans


def solve0():
    workable = [i + 1 for i, x in enumerate(S) if x == "o"]
    if len(workable) == K:
        return workable
    assert len(workable) > K
    return []


if C == 0:
    print(*solve0(), sep="\n")
else:
    print(*solve(), sep="\n")


Measured memory_bytes: 89000
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
typedef long long ll;

int main(void) {
	int N, count = 0, num=0;
	cin >> N;
	for (int i = 1;i <= N;i++) {
		if(i%2==1) {
			num = 0;
			for (int j = 1;j <= (N + 1) / 2;j++) {
				if (i % (2 * j - 1) == 0)num++;
			}
			if (num == 8)count++;
		}
	}
	cout << count << endl;
	return 0;
}

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

#define fori(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string a,b;
    cin >> a >> b;
    int count = 0;;
    fori(i, (int)a.size()) {
        if (a[i] != b[i]) count++;
    }
    cout << count << "\n";
    return 0;
}


Measured memory_bytes: 3796
/*
 *  author : Atul Anand   
 *  created on : Wed Apr 01 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        int A = in.nextInt();
        int B = in.nextInt();
        println(Math.max(0, A - 2 * B));
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 21332
#include<stdio.h>
int main(){
int s,n,m;
scanf("%d",&n);
m=n;
while(m>9){
s+=m%10;
m=(m-(m%10))/10;
}
s+=m;
if(n%s==0){printf("Yes");}
else{printf("No");}
return 0;
}

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

int main(void){
    double a, b, C;
    double radC, PI=acos(-1);
    double S, L, h;
    
    scanf("%lf %lf %lf", &a, &b, &C);
    radC = C * PI / 180;
    
    S = 1.0/2.0 * a * b * sin(radC);
    L = a + b + sqrt( pow(a,2) + pow(b,2) - 2.0*a*b*cos(radC) );
    h = b * sin(radC);
   
    printf("%.8f\n%.8f\n%.8f\n", S, L, h);    
    
    return 0;
}



Measured memory_bytes: 2104
/*
Roses are red
Memes are neat
All my test cases time out
Lmao yeet
**************************
Time to solve: 
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int W = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         int[] arr2 = new int[N];
         for(int i=0; i < N; i++)
         {
            st = new StringTokenizer(infile.readLine());
            arr[i] = Integer.parseInt(st.nextToken());
            arr2[i] = Integer.parseInt(st.nextToken());
         }
         long res = knapSack(W, arr, arr2, N);
         System.out.println(res);
      }
      public static long knapSack(int W, int wt[], int val[], int n) 
       { 
            int i, w; 
           long K[][] = new long[n+1][W+1]; 
           // Build table K[][] in bottom up manner 
           for (i = 0; i <= n; i++) 
           { 
               for (w = 0; w <= W; w++) 
               { 
                   if (i==0 || w==0) 
                        K[i][w] = 0; 
                   else if (wt[i-1] <= w) 
                         K[i][w] = Math.max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
                   else
                         K[i][w] = K[i-1][w]; 
               } 
            } 
            return K[n][W]; 
       } 
   }
   

Measured memory_bytes: 125524
#include<iostream>
#include<cstdio>
using namespace std;
int a,b,c,i;
int main(){
    scanf("%d%d%d",&a,&b,&c);
    for(i=1;i<=b;i++)
    {
        if((a*i)%b==c){cout<<"YES"<<endl;return 0;}
    }
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    int i,temp,w1=0,w2=0,w3=0,k1=0,k2=0,k3=0;
    for (i=0; i<10; i++) {
        scanf("%d",&temp);
        if (temp>w1) {
            w3=w2;
            w2=w1;
            w1=temp;
        } else if (temp>w2) {
            w3=w2;
            w2=temp;
        } else if (temp>w3) {
            w3=temp;
        }
    }
    printf("%d ",w1+w2+w3);
    for (i=0; i<10; i++) {
        scanf("%d",&temp);
        if (temp>k1) {
            k3=k2;
            k2=k1;
            k1=temp;
        } else if (temp>k2) {
            k3=k2;
            k2=temp;
        } else if (temp>k3) {
            k3=temp;
        }
    }
    printf("%d\n",k1+k2+k3);
    return 0;
}

Measured memory_bytes: 596
n,m=[int(s)for s in input().split(" ")]
bibs=[int(input())for i in range(n)]
for k in range(1,m+1):
    for i in range(n-1):
        if bibs[i]%k>bibs[i+1]%k:(bibs[i],bibs[i+1])=(bibs[i+1],bibs[i])
for bib in bibs:print(bib)

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

using namespace std;
#define ll  long long
#define ld  long double

#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int MAXN=1e5 + 5;
string h;
int a,b,k;
ll fastPow(ll x,ll b)
{
    if(b==0)
        return 1;
    else if(!(b & 1))
    {
        return fastPow(x*x,b/2);
    } else
        return x*fastPow(x*x,(b-1)/2);
}
//__builtin_popcount ();
int main() {
    FAST
   int h,n;
    cin>>h>>n;
    int arr[n];
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    if(sum>=h)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 640
x, y = input().split()
x = int(x)
y = int(y)
for k in range(min(x, (y + 1) // 4),-1,-1):
    r = 4 * k
    t = (y - r) // 2
    r += t * 2
    if k + t == x and r == y:
        print('Yes')
        break
else:
    print('No')

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

#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define ll long long int
#define pb(a) push_back(a)
#define vi vector<int>
#define ii pair<int,int>
#define mp(a,b) make_pair(a,b)

using namespace std;

int main()
{
  //cin.tie(NULL);
  unsigned ll x,y;
  cin >> x >> y;
    int ctr = 0;
    //unsigned ll m = 1;
    while(true){
        if(x<=y)ctr++;else break;
        x*=2;
    }
    cout<<ctr<<endl;
  
  return 0;
}


Measured memory_bytes: 256
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
char in[210000];
int x[210000];
long long y[210000];
int main(){
	int a;scanf("%d",&a);
	scanf("%s",in);
	long long ret=a*2;
	for(int i=0;i<a;i++){
		if(in[a-1-i]=='1')ret=(ret+pw(2,i)*2*a)%mod;
	}
	int sz=0;
	for(int i=1;i<a;i++){
		if(a%i)continue;
		if(a/i%2==0)continue;
		
		long long ks=0;
		for(int j=0;j<i;j++){
			ks*=2;
			ks+=in[j]-'0';
			ks%=mod;
		}
		bool ok=true;
		for(int j=0;j<a;j++){
			if(in[j]<(in[j%i]^(j/i%2)))ok=false;
			if(in[j]>(in[j%i]^(j/i%2)))break;
		}
		if(ok)ks++;
		for(int j=0;j<sz;j++)if(i%x[j]==0)ks=(ks+mod-y[j])%mod;
		ks%=mod;
		x[sz]=i;
		y[sz]=ks;
		sz++;
		// printf("%d: %lld\n",i,ks);
		ret=(ret+mod-ks*2*a%mod)%mod;
		ret=(ret+i*2*ks)%mod;
	}
	printf("%lld\n",ret);
}


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

int main() {
  int A, B ,C;
  cin >> A >> B >> C;
  
  int x = C - (A - B);
  
  if(x > 0){
    cout << x << endl;
  }
  
  else{
    cout << 0 << endl;
  }
  
}


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

using namespace std;

int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);
    
    int N;
    cin >> N;
    vector<double> p(N);
    for (int i = 0; i < N; ++i) {
        cin >> p[i];
    }
    vector<double> dp(N + 1, 0.);
    dp[0] = 1.;
    for (int i = 0; i < N; ++i) {
        vector<double> nxt(N + 1, 0.);
        for (int num_head = 0; num_head <= i; ++num_head) {
            nxt[num_head + 1] += dp[num_head] * p[i];
            nxt[num_head] += dp[num_head] * (1 - p[i]);
        }
        dp = nxt;
    }
    cout.precision(17);
    cout << fixed << accumulate(begin(dp) + (N + 1) / 2, end(dp), 0.) << "\n";
    return 0;
}

Measured memory_bytes: 384
#include<algorithm>
#include<cstring>
#include <iostream>
#include <cstdio>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef unsigned long long ull;
typedef set<int>::iterator sit;
#define st first
#define sd second
#define mkp make_pair
#define pb push_back
void tempwj(){freopen("hash.in","r",stdin);freopen("hash.out","w",stdout);}
ll gcd(ll a,ll b){return b == 0 ? a : gcd(b,a % b);}
ll qpow(ll a,ll b,ll mod){a %= mod;ll ans = 1;while(b){if(b & 1)ans = ans * a % mod;a = a * a % mod;b >>= 1;}return ans;}
struct cmp{bool operator()(const pii & a, const pii & b){return a.second < b.second;}};
int lb(int x){return  x & -x;}
//friend bool operator < (Node a,Node b)   重载
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const int maxn = 2e6+10;
char a[maxn];

int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s",a + 1);
	int l = -1,r = -1;
	for (int i = 1; i <= n; i ++ )
	{
		if(a[i] == 'W')
		{
			l = i;
			break;
		}
	}
	for (int i = n; i>= 1; i -- )
	{
		if(a[i] == 'R')
		{
			r = i;
			break;
		}
	}
	if(l == -1 || r == -1 || l > r)
	{
		printf("0\n");
		return 0;
	}
	int k = 0, s = 0;
	for (int i = l; i <= r; i ++ )
	{
		if(a[i] == 'R')
			k ++ ;
	}
	for(int i = l; i <= l + k - 1; i ++ )
	{
		if(a[i] == 'W')
			s ++ ;
	}
	printf("%d\n",s);
}



Measured memory_bytes: 3444
using System;
using System.Collections.Generic;

namespace Project
{
	class Point
	{
		public double x;
		public double y;
		public Point(double x, double y)
		{
			this.x = x;
			this.y = y;
		}
	}

	class MainClass
	{
		public static Queue<Point>[] s = new Queue<Point>[2];

		public static void Main(string[] args)
		{
			s[0] = new Queue<Point>();
			s[1] = new Queue<Point>();
			int n = int.Parse(Console.ReadLine());
			Koch(n);
			foreach (Point a in s[(n + 1) % 2])
			{
				Console.WriteLine(a.x + " " + a.y);
			}
		}

		public static void Koch(int i)
		{
			if (i == 0)
			{
				s[1].Enqueue(new Point(0, 0));
				s[1].Enqueue(new Point(100, 0));
				return;
			}
			Koch(i - 1);
			Point p1, p2, p3, p4, p5;
			p1 = s[i % 2].Dequeue();
			while (s[i % 2].Count != 0)
			{
				p5 = s[i % 2].Dequeue();
				p2 = new Point((2 * p1.x + p5.x) / 3, (2 * p1.y + p5.y) / 3);
				p4 = new Point((p1.x + 2 * p5.x) / 3, (p1.y + 2 * p5.y) / 3);
				p3 = new Point(((p2.x + p4.x) - (-p2.y + p4.y) * Math.Sqrt(3)) / 2, ((-p2.x + p4.x) * Math.Sqrt(3) + (p2.y + p4.y)) / 2);
				s[(i + 1) % 2].Enqueue(p1);
				s[(i + 1) % 2].Enqueue(p2);
				s[(i + 1) % 2].Enqueue(p3);
				s[(i + 1) % 2].Enqueue(p4);
				p1 = p5;
			}
			s[(i + 1) % 2].Enqueue(p1);
			return;
		}
	}
}

Measured memory_bytes: 10736
/*

साहिल पे पहुंचने से इनकार किसे है लेकिन,
तूफ़ानो से लड़ने का मज़ा ही कुछ और है,
कहते है, कि किस्मत खुदा लिखता है लेकिन,
उसे मिटा के खुद गढ़ने का मजा ही कुछ और है।

*/


#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
using namespace std;
 
#define int                 long long int
#define ull					unsigned int
#define ld                  long double
#define pb                  push_back
#define ff                  first
#define ss                  second
#define S(arr)              sort(arr.begin(),arr.end());
#define RS(arr)              sort(arr.rbegin(),arr.rend());
#define R(arr)              reverse(arr.begin(),arr.end());
#define si                  set <int>
#define vi                  vector <int>
#define vvi                 vector <vector <int>>
#define vs                  vector <string>
#define pii                 pair <int, int>
#define vpi                 vector <pii>
#define vpp                 vector <pair<int, pii>>
#define mii                 map <int, int>
#define mci                 map<char, int>
#define mpi                 map <pii, int>
#define spi                 set <pii>
#define speed               ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl                "\n"
#define all(p)              p.begin(), p.end()
#define T                   int tcf;cin>>tcf;while(tcf--)
#define que_max(t)             priority_queue <t>
#define que_min(t)             priority_queue <t, vector<t>, greater<t>>
#define debuga(a, l, r)     for(auto x:a)cout<<x<<" ";cout<<endl;
#define debug1(x)           cout << #x " = " << x << endl;
#define debug2(x,y)         cout << #x " = " << x << " " << #y " = " << y << endl;
#define debug3(x,y,z)       cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define debug4(x,y,z,w)     cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << " " << #w " = " << w << endl;
#define debug5(x,y,z,w,v)   cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << " " << #w " = " << w << " " << #v " = " << v << endl;
#define debug6(x,y,z,w,v,a) debug3(a, y, x)debug3(w, v, a)
#define p2d(v)     	    for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)      	    for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppi(v)	for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;

 
void read(int n=10){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<setprecision(n)<<fixed;
    #ifndef ONLINE_JUDGE
         freopen("input.txt",  "r",  stdin);
         freopen("output.txt", "w", stdout);
    #endif
}

int M = 1e9 + 7;
int M1 = 998244353;
#define qqq 4000005



int32_t main(){
	//read();
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
	int a,b;
	cin>>a>>b;
	cout<<6-a-b;
} 

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var N = ReadInt();
        var JPY = 0d;
        var BTC = 0d;

        for (var i = 0; i < N; i++)
        {
            var inputs = Reads();
            if (inputs[1] == "JPY")
            {
                JPY += double.Parse(inputs[0]);
            }
            else if (inputs[1] == "BTC")
            {
                BTC += double.Parse(inputs[0]);
            }
        }

        Console.WriteLine(JPY + BTC * 380000);
    }


    public static string Read() { return Console.ReadLine(); }
    public static int ReadInt() { return int.Parse(Read()); }
    public static long ReadLong() { return long.Parse(Read()); }
    public static double ReadDouble() { return double.Parse(Read()); }

    public static string[] Reads() { return Console.ReadLine().Split(' '); }
    public static int[] ReadInts() { return Reads().Select(_ => int.Parse(_)).ToArray(); }
    public static long[] ReadLongs() { return Reads().Select(_ => long.Parse(_)).ToArray(); }
    public static double[] ReadDoubles() { return Reads().Select(_ => double.Parse(_)).ToArray(); }
}




Measured memory_bytes: 11092
/**
 *  winners never quit
**/

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
typedef long long Long;
void FastIO(){
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
}

const int N = 1e6;

int main()
{
  FastIO();
  int tc, ca = 0;
  string s;
  cin >> s;
  if (s[5]!=s[4] || s[3]!=s[2])cout << "No" << '\n';
  else cout << "Yes" << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[102],h,minn;
int deal(int x)
{
	int ans=0;
	for(int i=1;i<=n;i++)
		ans+=(a[i]-x)*(a[i]-x);
	return ans;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	int l=a[1],r=a[n],last=1000000000;
	for(int i=l;i<=r;i++)
	{
		int k=deal(i);
		if(k<=last)
			last=k;
		else
			break;
	}
	printf("%d",last);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,k,n) for (ll i = k; i < n; ++i)
#define inputar(a,n) ll a[n];rep(i,0,n)cin>>a[i]
#define PI 3.14159265
const int MOD=1e9+7;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a)  (a).begin(),(a).end()

#define test4(x,y,z,a) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cerr<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cerr<<"x is "<<x<<endl;


int main()
{
    IOS;
    ll n;
    cin>>n;
    ll x[n+1],y[n+1];
    for(int i=0;i<n;i++)
    {
        cin>>x[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>y[i];
    }
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        if(x[i]-y[i]>0)
        {
            sum+=x[i]-y[i];
        }
    }
    cout<<sum<<endl;
}

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

def main():
    b = input()

    maxcnt = 0
    scnt = 0
    for c in b:
        if(c=='A' or c=='C' or c=='G' or c=='T'):
            scnt += 1
        else:
            if(maxcnt<scnt):
                maxcnt=scnt
            scnt = 0

    print(max(scnt,maxcnt))

main()

Measured memory_bytes: 2940
using System;
using System.Linq;
class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
		string input = Console.ReadLine();
		
		char c1 = input[0];
		char c2 = new char();
		
		foreach(var c in input){
			if(c1 != c){
				c2 = c;
			}
		}
		var result = input.Count(c=>c==c1)==2 && input.Count(c=>c==c2)==2 ? "Yes" : "No";
		
		// 出力
		Console.WriteLine(result);
	}
}

Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>

#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;

using namespace std;

void solve(){
    int n;
    cin >> n;
    int a[100500];
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = n - 1; i > 0; i--){
        if(a[i] < a[i - 1]){
            if(a[i - 1] - a[i] > 1){
                cout << "No";
                return;
            }
            a[i - 1] -= 1;
        }
    }
    cout << "Yes";
}

int main(){
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}



Measured memory_bytes: 640
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")



n,d,a = map(int, input().split())
xh = [None]*n
# h = [None]*n
for i in range(n):
    xh[i] = tuple(map(int, input().split()))
xh.sort()

r = 0
val = 0
from queue import deque
q = deque([])
s = 0
for l,(x,h) in enumerate(xh):
    bound = x+2*d
    while q and l>=q[0][1]:
        s -= q[0][0]
        q.popleft()
    while r<n and xh[r][0]<=bound:
        r += 1
    nokori = h - s
    if nokori>0:
        num = nokori//a + int(nokori%a!=0)
        val += num
        q.append((num*a, r))
        s += num*a
        
print(val)

Measured memory_bytes: 97032
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    AC=set()
    WA=defaultdict(int)
    ans = 0
    for _ in range(M):
        p,s = ST().split()
        if s=="AC":
            if p in AC:
                continue
            ans += WA[p]
            AC.add(p)
        else:
            WA[p]+=1
    print(len(AC),ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 61788
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
    n:usize,
    a:[i64;n],
     }
    let mut ai = vec![(0, 0); n];
    for (i, &x) in a.iter().enumerate() {
        ai[i] = (x, i);
    }
    ai.sort_by_key(|x| -x.0);
    let mut dp = vec![vec![-INF; n + 1]; n + 1];
    dp[0][0] = 0;
    for i in 0..n {
        let k = ai[i].0;
        let r = ai[i].1;
        for x in 0..=i {
            let y = i - x;
            dp[x + 1][y] = max(dp[x + 1][y], dp[x][y] + k * (x as i64 - r as i64).abs());
            dp[x][y + 1] = max(
                dp[x][y + 1],
                dp[x][y] + k * ((n - 1 - y) as i64 - r as i64).abs(),
            );
        }
    }
    // dbg!(&dp);
    let mut ans = 0;
    for i in 0..=n {
        ans = max(ans, dp[i][n - i]);
    }
    println!("{}", ans);
}
const INF: i64 = 1 << 60;


Measured memory_bytes: 33436
#include<bits/stdc++.h>
#define speed_input ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
{
  	speed_input;
	char temp;
	int r,c;
	cin>>r>>c;
	long long int grid[r][c]={},dp[r][c]={};
	dp[0][0]=1;
	
	for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
		{
			cin>>temp;
			grid[i][j]=((temp=='.')?1:0);
			if(!i&&j)dp[0][j]=grid[0][j]&dp[0][j-1];
			else if(i&&!j)dp[i][0]=grid[i][0]&dp[i-1][0];	
		}
	}
	
	for(int i=1;i<r;i++)
		for(int j=1;j<c;j++)
			dp[i][j]=((grid[i][j])?dp[i-1][j]+dp[i][j-1]:0)%1000000007;	

	cout<<dp[r-1][c-1]<<"\n";
	return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;

const ll mod=998244353;

int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  vector<vector<ll>> dp(c-a+1,vector<ll>(d-b+1));
  dp[0][0]=1;
  for(ll i=1;i<=c-a;i++){
    dp[i][0]=dp[i-1][0]*b%mod;
  }
  for(ll i=1;i<=d-b;i++){
    dp[0][i]=dp[0][i-1]*a%mod;
  }

  for(ll i=1;i<=c-a;i++){
    for(ll j=1;j<=d-b;j++){
      dp[i][j]+=dp[i-1][j]*(j+b)%mod;
      dp[i][j]%=mod;
      dp[i][j]+=dp[i][j-1]*(i+a)%mod;
      dp[i][j]%=mod;
      dp[i][j]-=dp[i-1][j-1]*(i+a-1)*(j+b-1)%mod;
      dp[i][j]%=mod;
    }
  }


  cout << (dp[c-a][d-b]+mod)%mod << endl;


  return 0;
}


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

int main() {
    ll n;
    cin>>n;
    ll h[n];
    for (int i = 0; i < n; ++i) {
        cin>>h[i];
    }
    vector<ll> sa;
    for (ll j = 0; j < n; ++j) {
        sa.push_back(j-h[j]);
    }
    ll ans=0;
    sort(sa.begin(),sa.end());
    for (ll k = 0; k < n; ++k) {
        ans+=upper_bound(sa.begin(),sa.end(),k+h[k])-lower_bound(sa.begin(),sa.end(),k+h[k]);
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define X first
#define Y second
#define int long long int 
const int N = (int)1e6 + 10;
const int MOD = (int) 1e9 + 7;
 
int fastpower(int a, int b){
    int res = 1;
    a %= MOD;
    while(b){
        if(b&1) res = (res * a) % MOD;
        a *= a; a %= MOD;
        b >>= 1;
    }
    return res;
}
 
 
void solve(){
    int n, k;
    cin >> n >> k;
    vector<int> dp(k + 1, 0);
    for(int gd = k; gd >= 1; --gd){
        int total_multiples = k/gd;
        int temp = fastpower(total_multiples, n);
        temp %= MOD;
        temp %= MOD;
        int extra = 0;
        for(int j = gd * 2; j <= k; j += gd){
            extra = (extra + dp[j]) % MOD;
        }
        dp[gd] = (temp - extra + MOD) % MOD;
    }
 
    int ans = 0;
    for(int i = 1; i <= k; ++i){
        int add = ( dp[i] % MOD * i % MOD ) % MOD;
        ans += add, ans %= MOD;
    }
 
    cout << ans << '\n';
   
    
}
 
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    //int t; cin >> t;
    //while(t--)
        solve();
    return 0;
}
/*
Sample inp
*/

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

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var K = int.Parse(ReadLine());

            var que = new Queue<long>();
            for (int i = 1; i <= 9; i++)
                que.Enqueue(i);

            var num = 0L;
            for (int i = 1; i <= K ; i++)
            {
                num = que.Dequeue();
                if (num % 10 != 0) que.Enqueue(num * 10 + num % 10 - 1);
                que.Enqueue(num * 10 + num % 10);
                if (num % 10 != 9) que.Enqueue(num * 10 + num % 10 + 1);
            }
            WriteLine(num);
        }
    }
}


Measured memory_bytes: 15072
#include <iostream>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

int main() {
    int S, W;

    cin >> S >> W;

    if (W >= S) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
}


Measured memory_bytes: 3592
package main

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

func main() {
	N := getStdinInt()
	fmt.Printf("%d\n", N*N*N)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinIntU64() uint64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return uint64(rtn)
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func getStdinIntArrU64() []uint64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]uint64, len(list))
	for idx, val := range list {
		r, _ := strconv.ParseInt(val, 10, 64)
		rtn[idx] = uint64(r)
	}
	return rtn
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}
func abs64(n int64) int64 {
	if n < 0 {
		return -n
	}
	return n
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2172
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)

	s := oneStr()

	flg := false
	l := len(s)
	t := []string{"dream", "dreamer", "erase", "eraser"}
	for i := len(s) - 1; i >= 0; i-- {
		for j := 0; j < len(t); j++ {
			if s[i:l] == t[j] {
				l = i
				flg = true
				break
			} else {
				flg = false
			}
		}
	}
	if flg == true {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func oneInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func oneStr() string {
	sc.Scan()
	return sc.Text()
}

func scanNums(len int) (nums []int) {
	for i := 0; i < len; i++ {
		nums = append(nums, oneInt())
	}
	return nums
}

func scanStrings(len int) (strs []string) {
	for i := 0; i < len; i++ {
		strs = append(strs, oneStr())
	}
	return strs
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums []int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums []int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func sum(nums []int) int {
	sum := 0
	for i := 0; i < len(nums); i++ {
		sum += nums[i]
	}
	return sum
}

func cumSum(nums []int) []int {
	sums := []int{0}

	for i := 0; i < len(nums); i++ {
		sums = append(sums, sums[i]+nums[i])
	}
	return sums
}

func sumOfEachDigit(num int) int {
	sum := 0
	for num > 0 {
		sum += num % 10
		num /= 10
	}
	return sum
}


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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(ll i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(ll j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


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

    int N, K;
    cin >> N >> K;

    vector<int> p(N);
    REPinit(i, 0, N) cin >> p[i];

    sort(CONTAINER_ALL(p));

    int ans = 0;
    REPinit(i, 0, K) ans += p[i];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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


  return 0;
}


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

using namespace std;

int main(void) {
	string S, T; cin >> S >> T;

	int res = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == T[i]) res++;
	}

	cout << res << endl;

	return 0;
}

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

ll solve() {
    ll N, K;
    cin >> N >> K;
    vector<ll> P(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> P[i];
    }
    sort(P.begin(), P.end());
    ll ans = 0;
    for ( int i = 0; i < K; i++ ) {
        ans += P[i];
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, m;

signed main() {
	cin >> n >> m;
	if (n == 1 && m == 1)cout << 1 << endl;
	else if (n == 1 || m == 1)cout << n * m - 2 << endl;
	else cout << (n - 2)*(m - 2) << endl;
	getchar(); getchar();
	return 0;
}

Measured memory_bytes: 256
#coding:utf-8
import sys
N,K,L=map(int,raw_input().split())

# https://www.kumilog.net/entry/union-find#Python%E3%81%A7%E5%AE%9F%E8%A3%85
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]

ufR=UnionFind(N+1)
ufT=UnionFind(N+1)
for i in range(K):
    p,q=map(int,sys.stdin.readline().split())
    ufR.union(p,q)
for i in range(L):
    p,q=map(int,sys.stdin.readline().split())
    ufT.union(p,q)    
from collections import defaultdict
R=defaultdict(set)
T=defaultdict(set)
for i in range(1,N+1):
    R[ufR.find(i)].add(i)
    T[ufT.find(i)].add(i)

ans=[0]*(N+1)
for i in range(1,N+1):
    if ans[i]!=0:continue
    r=R[ufR.find(i)]
    t=T[ufT.find(i)]
    if len(r)==0 or len(t)==0: continue
    s=r&t
    for c in s:
        ans[c]=str(len(s))
    r-=s
    t-=s

print(" ".join(ans[1:]))
    


Measured memory_bytes: 181012
from math import sqrt
x = int(input())
def f(x):
  h = int(sqrt(x))
  for i in range(1,h+1):    
    if x%i == 0:
      
      m = x//i      
      for a in range(0,1000):        
        b = a-i        
        if a**4 + (a**3)*b + (a**2)*(b**2) + a*b**3 + b**4 ==m:
          return a,b
      
print(*f(x))      

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
string s,t;
int m,n,memo[2001][2001][2];

int check(int i,int j,int idx){
  if(memo[i][j][idx]) return memo[i][j][idx];
  int res=0;
  char ima[2]={'I','O'};
  if(s[i]&&s[i]!=ima[idx]) res=1+check(i+1,j,(idx+1)%2);
  if(t[j]&&t[j]!=ima[idx]) res=max(res,1+check(i,j+1,(idx+1)%2));
  return memo[i][j][idx]=res;
}

int main(){
  cin>>m>>n;
  cin>>s>>t;

  int ans=0;
  for(int i=0;i<s.size();i++)
    for(int j=0;j<t.size();j++){
      if(s[i]=='I') ans=max(ans,1+check(i+1,j,0));
      if(t[j]=='I') ans=max(ans,1+check(i,j+1,0));
    }
  if(ans)ans-=!(ans%2);
   
  cout <<ans<<endl;
  return 0;
}

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

if A == 0:
    print(B)
    exit()

"""
A~Bを～～したのを求めよ
→0~Bまで～～したものから、0~A-1まで～～したものを引くのが定石
また、 (2*n) ^ (2n+1) = 1　奇数では成り立たない
"""
def xors(n):
    ret = 0
    d = (n+1) % 4
    # 排他的論理和求めていくと1が偶数個できる
    if d == 0:
        ret = 0
    #
    elif d == 1:
        ret = n
    elif d == 2:
        ret = 1
    else:
        ret = 1 ^ n

    if n == 0: ret = 0

    return ret

ans = xors(A-1) ^ xors(B)
print(ans)





Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
    int N;
    cin>>N;
    int sort[100]={};
    for (int i=0;i<N;i++){
        cin>>sort[i];
    }
    int v,j=0;
    for(int i=0;i<N;i++){
        v = sort[i];
        j = i - 1;
        while(j >= 0 && sort[j] > v){
           sort[j+1] = sort[j];
           j--;
           sort[j+1] = v;
        }
        for(int k=0;k<N-1;k++){
            cout<<sort[k]<<" ";
        }
        cout<<sort[N-1];
        cout<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3100
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

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

Measured memory_bytes: 256
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<utility>
#include<functional>
#include<cassert>
using namespace std;
typedef pair<int, int> P;

int main(void) {
	int h, w,cnt=0;
	cin >> h >> w;
	vector<vector<char>> a(h + 2, vector<char>(w + 2));
	vector<vector<int>> b(h + 2, vector<int>(w + 2));
	P g = P(h, w);
	for (int i = 0; i < h + 2; i++) {
		a[i][0] = a[i][w + 1] = '#';
	}
	for (int i = 0; i < w + 2; i++) {
		a[0][i] = a[h + 1][i] = '#';
	}

	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> a[i][j];
			if (a[i][j] == '#') {
				cnt++;
			}
		}
	}
	P serch[4] = { P(1,0),P(0,1),P(-1,0),P(0,-1) };
	queue<P> q;
	q.push(P(1, 1));
	while (q.size()!=0) {
		P p;
		p = q.front(); q.pop();
		if (g == p)break;
		for (int i = 0; i < 4; i++) {
			if (a[p.first+serch[i].first][p.second+serch[i].second] == '.'&& b[p.first + serch[i].first][p.second + serch[i].second] == 0) {
				q.push(P(p.first + serch[i].first,p.second + serch[i].second));
				b[p.first + serch[i].first][p.second + serch[i].second] = b[p.first][p.second] + 1;
			}
		}
	}
	if (b[h][w] == 0) {
		cout << -1;
		return 0;
	}
	cout << h*w-cnt-b[h][w]-1;
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc105/tasks/abc105_c

#include <algorithm>
#include <cmath>
#include <iostream>
#include <regex>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)

#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {
    long target;
    cin >> target;

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

    for (uint64_t i = abs(target); i < 1UL << 34; i += 2) {
        //奇数
        uint64_t odd1 = i & UINT64_C(0b010101010101010101010101010101010101);
        uint64_t odd2 =
            (i + 1) & UINT64_C(0b010101010101010101010101010101010101);
        //偶数
        uint64_t eve = i & UINT64_C(0b101010101010101010101010101010101010);
        long sum = target + eve;
        if (sum == odd1 || sum == odd2) {
            // 34桁の2進数に変換
            string s = bitset<34>(i).to_string();
            // 先頭の0を除去
            cout << s.substr(s.find("1")) << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import sys

a, b = map(int, input().split())
 
sum = a + b
minus = a - b
sub = a * b
 
if (sum - minus) > 0:
  if (sum - sub) > 0:
    print(sum)
  else:
    print(sub)
else:
  if (minus - sub) > 0:
    print(minus)
  else:
    print(sub)


Measured memory_bytes: 2940
A=[]
B=[]
a=0
i=0
for c in input():
 if"\\"==c:
  A+=[i]
 elif"/"==c and A:
  j=A.pop()
  t=i-j
  a+=t
  while B and B[-1][0]>j:
   t+=B[-1][1];B.pop()
  B+=[(j,t)]
 i+=1
print(a)
if B:
 print(len(B),*list(zip(*B))[1])
else:
 print(0)


Measured memory_bytes: 6496