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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

vector<vector<pii>> r;

vector<ll> dijkstra(int s, int l){
	
	const ll INF = 1e18;
	priority_queue< VI, vector<VI>, greater<VI> > que;
	vector<ll> d(sz(r), INF);
	vector<ll> d2(sz(r), 0);
	d[s] = 0; d2[s] =l;
	que.push({0, -l, s});
	while(!que.empty()){
		auto cr = que.top(); que.pop();
		cr[1] *=-1;
		//if(d[v] < cost) continue;
		for(const auto& rp : r[cr[2]]){ 
			int rto = rp.first;
			if(l < rp.second) continue;
			int nxt = cr[0];
			int nxl = cr[1];
			if(cr[1] < rp.second ){ nxt++; nxl = l;} 
			nxl -= rp.second;
			if(d[rto] > nxt ||(d[rto]==nxt && d2[rto] < nxl)){
				d[rto] = nxt; d2[rto] = nxl;
				que.push({nxt, -nxl, rto});
			}
		}
	}
	return d;
}

int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,m,q; ll l;
	const ll INF =(ll)1e18;
	cin >>n >>m >>l;
	r.resize(n);
	rep(i, m){
		int a,b, c;
		cin >>a >>b >>c;
		r[a-1].push_back(pii(b-1, c));
		r[b-1].push_back(pii(a-1, c));
	}
	
	vector<VL> res(n, VL(n, 0));
	rep(i, n){
		res[i] = dijkstra(i, l);
	}
	
	cin >>q;
	rep(i ,q){
		int s, t;
		cin >>s >>t;
		
		cout << (res[s-1][t-1]==INF? -1: res[s-1][t-1])<<"\n";
	
	}

	return 0;
	
}


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

using namespace std;

// Debug Code
#define deb1(x) cout<<#x<<'='<<x<<"\n"
#define deb2(x,y) cout<<#x<<'='<< x <<"|"<<#y<<'='<<y<< "\n"
#define deb3(x,y,z) cout<<#x<<"="<<a<<"|"<<#y<<"="<<b<<"|"<<#z<<"="<<c<<"\n"
#define deb1d(a,n) {for(int deb1d=0;deb1d<n;++deb1d){cout<<a[deb1d]<<" ";} cout<<"\n";}
#define deb2d(a,n,m) { for(int vari1=0;vari1<n;++vari1){for(int vari2=0;vari2<m;++vari2){cout<<#a<<"["<<vari1<<"]["<<vari2<<"]"<<"="<<a[vari1][vari2]<<' ';} cout<<"\n";} cout<<"\n";}
#define deb2dO(a,n,m) { for(int vari1=0;vari1<n;++vari1){for(int vari2=0;vari2<m;++vari2){cout<<a[vari1][vari2]<<' ';} cout<<"\n";} cout<<"\n";}
#define debCustom(s1,s2,len1,len2,a){cout<<"    ";deb1d(s2,len2); for(int debVari=0;debVari<len1;++debVari){cout<<s1[debVari]<<" ";deb1d(a[debVari],len2);}}

int main (){
	string s,t;
	cin>>s>>t;
	int l1=s.length()+1,l2=t.length()+1;
	vector<vector<int>>dp(l1+1, vector<int>(l2+1));
	vector<vector<pair<int,int>>>last(l1+1,vector<pair<int,int>>(l2+1));
	for(int i=1; i<=l1; ++i){
		for(int j=1; j<=l2; ++j){
			dp[i][j]=dp[i-1][j-1]+((s[i-1]==t[j-1])?1:0);
			last[i][j]={i-1,j-1};
			if(dp[i][j]<dp[i-1][j]){
				dp[i][j]=dp[i-1][j];
				last[i][j]={i-1,j};
			}
			if(dp[i][j]<dp[i][j-1]){
				dp[i][j]=dp[i][j-1];
				last[i][j]={i,j-1};
			}
		}
	}
	vector<char>cbuffer;
	int x=l1-1,y=l2-1;
	while(x!=0&&y!=0){
		if(s[x-1]==t[y-1]) cbuffer.push_back(s[x-1]);
		tie(x,y)=last[x][y];
	}
	reverse(cbuffer.begin(),cbuffer.end());
	for(char c : cbuffer) cout<<c;
	return 0;
}



Measured memory_bytes: 109016
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
template<class T> void chmin(T&x,T y){if(x>y)x=y;}
template<class T> void chmax(T&x,T y){if(x<y)x=y;}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    string s;
    in>>s;
    int n=s.length();
    vector<int> d(n+1);
    fr(i,n) d[i+1]=d[i]^(1<<(s[i]-'a'));
    unordered_map<int,int> dp;
    dp[d[n]]=0;
    ifr(i,n){
        int D=INT_MAX;
        fr(j,26) if(dp.count(d[i]^(1<<j))) D=min(D,dp[d[i]^(1<<j)]+1);
        if(dp.count(d[i])) chmin(dp[d[i]],D);
        else dp[d[i]]=D;
    }
    cout<<max(dp[0],1)<<'\n';
}

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

using namespace std;
#define int long long
#define inf 9999999999
#define N 666666
int arr[N];int f[N];
map<int,int> mp;
int check(string s){
	string t=s;
	reverse(t.begin(),t.end());
	return (s==t);
}
signed main(){
	string s;
	cin>>s;
	if(check(s)){
		cout<<"Second";
		return 0;
	} 
	if(s[0]!=s[s.size()-1]){
		if((s.size()-2)%2) cout<<"First";
		else cout<<"Second";
	}else{
		if((s.size()-2)%2) cout<<"Second";
		else 	cout<<"First";
		
	}

    return 0;
}
/*
xabsb
1
xabab
1
xszs
2
abda
1


*/

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<ll,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;cin>>n;
    pint a[2*n];
    rep(i,n){
        cin>>a[i].first;
        a[i].second=i;
        cin>>a[i+n].first;
        a[i+n].second=i+n;
    }
    sort(a,a+2*n);
    ll ans=0;
    int cnt2=0;
    int cnt=0;
    int used[n];
    rep(i,n)used[i]=false;
    rep(i,n){
        ans+=a[i].first;
        if(!used[a[i].second%n])cnt++;
        used[a[i].second%n]=true;
        if(a[i].second<n)cnt2++;
    }
    if(cnt==n&&cnt2!=n&&cnt2!=0){
        if(a[n-1].second%n!=a[n].second%n){
            ans+=a[n].first-a[n-1].first;
        }
        else ans+=min(a[n].first-a[n-2].first,a[n+1].first-a[n-1].first);
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long int64;
int MOD = 1e9 + 7;
map<string, int> msi;
int main() {
  int N;
  cin >> N;
  string S;
  rep(i, N) {
    cin >> S;
    msi[S]++;
  }

  cout << msi.size() << "\n";
  return 0;
}


Measured memory_bytes: 19260
n = gets.chomp.to_i
max = Math.sqrt(n).to_i
result = Math.log10(n).to_i + 1
max.times do |i|
  i = i+1
  next if n % i > 0
  r = Math.log10(n / i).to_i + 1
  result = r if r < result
end
puts result

Measured memory_bytes: 1788
// 2011/10/11 Tazoe

#include <iostream>
#include <stack>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		stack<int> go;

		int c;
		cin >> c;
		int p = c;
		int m = 1;

		for(int i=1; i<n; i++){
			cin >> c;

			if(i%2==0){
				if(c==p){
					m++;
				}
				else{
					go.push(m);
					m = 1;
					p = c;
				}
			}
			else{
				if(c==p){
					m++;
				}
				else{
					if(!go.empty()){
						m += go.top();
						go.pop();
					}
					m++;
					p = c;
				}
			}
		}

		int cnt = 0;
		if(c==0){
			cnt += m;
			go.pop();
		}

		while(!go.empty()){
			cnt += go.top();
			go.pop();
			if(go.empty())
				break;
			go.pop();
		}

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 0
// Problem : C - 4/N
// Contest : AtCoder - Tenka1 Programmer Contest
// URL : https://atcoder.jp/contests/tenka1-2017/tasks/tenka1_2017_c
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	// int T;cin>>T;
	ll N;
	cin>>N;
	for(ll x=3500;x>=1;x--)
	{
		for(ll y=x;y>=1;y--)
		{
			if(4/(ld)N<=1/(ld)x+1/(ld)y)
				break;
			// bug(y);
			ll v1=N*x/(__gcd(N,x));
			v1=v1*y/__gcd(v1,y);
			ll v2=4*(v1/N)-v1/x-v1/y;
			ld val=1e-20;
			val=v1/(ld)v2;
			// bug(val);
			if(val==(ll)val && val>0 && val<=3500)
			{
				cout<<x<<' '<<y<<' '<<(int)val<<nl;
				return 0;
			}
		}
	}
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
#define ll long long
int main(){
	int A,B;
	cin >> A>>B;
	if((A==2)|(B==2)){
		cout <<"No";
	}else{
    cout << "Yes";
  }
    return 0;
}


Measured memory_bytes: 768
from collections import deque
Sa = deque([s for s in str(input())])
Sb = deque([s for s in str(input())])
Sc = deque([s for s in str(input())])

def solve(turn):
  que = []
  if turn == 'a':
    que = Sa
  elif turn == 'b':
    que = Sb
  elif turn == 'c':
    que = Sc
  if len(que) > 0:
    return que.popleft()
  else:
    return False

this_turn = 'a'
while True:
  next_turn = solve(this_turn)
  if next_turn == False:
    print(this_turn.upper())
    break
  else:
    this_turn = next_turn

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

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

	vector<int> counts( 256 );
	for( auto ch: w ) {
		counts.at( ch ) += 1;
	}

	string result = "Yes";

	for( auto c: counts ) {
		if( c & 1 ) {
			result = "No";
			break;
		}
	}

	cout << result << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<stack>
#include<queue>
#include<cstdlib>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#define fi first
#define se second
#define pb push_back
#define me(a,b) memset(a,b,sizeof(a))
#define INIT() std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
const int MAX_N=200000+5;
const int INF=0x7fffffff;
const int inf=100000;
const double EPS=1e-6;
const ull base=123;
const ll mod=1e9+7;
const double pi=4*atan(1.0);
ll a[MAX_N];
bool cmp(ll a,ll b)
{
    return a>b;
}
int main(void)
{
    int n;
    ll sum=0;
    cin>>n;
    int i;
    for(i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    sort(a+1,a+1+n,cmp);
    sum+=a[1];
    int pos=2;
    for(i=2;i<n;i++)
    {
        if(i%2==0)
            sum+=a[pos];
        else
            sum+=a[pos++];
    }
    cout<<sum<<endl;
}


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

typedef long long int LL;
#define REP(n) for(LL i = 0; i < (n); i++)
#define COUT(val) cout << (val) << endl
#define CIN(val) cin >> (val)
#define SORT(vec) sort(vec.begin(), vec.end())
#define SORT_GRE(vec) sort(vec.begin(), vec.end(), greater<LL>())

int main(){
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    bool v[H][W];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            v[i][j] = true;
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < W; j++){
            v[i][j] = false;
        }
    }
    for(int i = 0; i < w; i++){
        for(int j = 0; j < H; j++){
            v[j][i] = false;
        }
    }
    int ans = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(v[i][j]) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

int main () {
    ios_base::sync_with_stdio(0);
	//freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);

	int n;
	long long L, T;
	cin >> n >> L >> T;

	vector<int> x(n);
	vector<int> dir(n);
	for (int i = 0; i < n; ++i) {
		cin >> x[i] >> dir[i];
		if (dir[i] == 2) {
			dir[i] = -1;
		}
	}

	long long sum_dir = 0;
	for (int i = 0; i < n; ++i) {
		sum_dir += dir[i];
	}

	long long mod = n * L;
	long long shift = ((sum_dir * T) % mod + mod) % mod;

	vector<int> res(n);
	for (int i = 0; i < n; ++i) {
		res[i] = ((x[i] + dir[i] * T) % L + L) % L;	
	}

	sort(res.begin(), res.end());

	long long cur_shift = 0;
	for (int i = 0; i < n; ++i) {
		cur_shift += res[i] - x[i];
   	}

   	cur_shift = (cur_shift % mod + mod) % mod;
   	if (cur_shift > shift) {
   		cur_shift -= mod;
   	}
    int ind = (shift - cur_shift) / L;

   	for (int i = 0; i < n; ++i) {
   		cout << res[(ind + i) % n] << "\n";
   	}
	
	return 0;
}
    

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

namespace _027_Whatdayistoday
{
	class Program
	{
		static void Main ( string[] args )
		{
			while (true)
			{
				int[] inputNum = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();

				if (inputNum[0] == 0)
				{
					break;
				}

				DateTime result = new DateTime (2004, inputNum[0], inputNum[1]);
				Console.WriteLine (result.DayOfWeek);
			}
		}
	}
}

Measured memory_bytes: 9740
import java.util.Scanner

object Main extends App{
  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val s = sc.next

  val alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"

  def rotate(ch: Char, n: Int): Char = {
    alphabets.charAt(alphabets.indexOf(ch) + n)
  }

  val res = s.map(rotate(_,n))

  println(res)
}


Measured memory_bytes: 27328
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;

int r, D;
ll x, tmpX;

int main() {
  cin >> r >> D >> x;
  tmpX = x;
  REP (i, 10) {
    tmpX = r * tmpX - D;
    cout << tmpX << "\n";
  }
}

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

int main(void){
    int i, N, hen[3]={};
    cin >> N;
    for(i=0; i<N; i++){
        cin >> hen[0] >> hen[1] >> hen[2];
        sort(hen, hen+3);
        if(hen[2]*hen[2]==hen[0]*hen[0]+hen[1]*hen[1]) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	a := 0
	fmt.Scanf("%d", &a)
	a %= 10
	switch a {
	case 2, 4, 5, 7, 9:
		fmt.Println("hon")
	case 0, 1, 6, 8:
		fmt.Println("pon")
	default:
		fmt.Println("bon")
	}
}


Measured memory_bytes: 1816
def main():
    a = list(map(int, input().split()))
    A = a[0]
    B = a[1]
    C = a[2]
    D = a[3]
    for i in range(1000):
        C = C - B
        if C <= 0:
            print("Yes")
            break
        A = A - D
        if A <= 0:
            print("No")
            break
if __name__ == '__main__':
    main()


Measured memory_bytes: 9164
import sys

L, R = map(int, input().split())
P = 2019
if R - L >= 2019:
    print(0)
    sys.exit()
elif (R % P) - (L % P) < 0:
    print(0)
    sys.exit()

R %= P
L %= P
ans = 2019
for i in range(L, R):
    for j in range(i + 1, R + 1):
        ans = min(ans, (i * j) % P)
print(ans)


Measured memory_bytes: 64432
n = int(input())
l = []

for i in range(n):
    l.append(input())

L = set(l)

if len(l) == len(L):
    for i in range(n-1):
        if l[i][-1] != l[i+1][0]:
            print('No')
            exit()
    print('Yes')
else:
    print('No')

Measured memory_bytes: 62176
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <queue>
#include <iomanip>
#include <algorithm>
using namespace std;

int n;

string Get(int ind)
{
	printf("%d\n", ind); fflush(stdout);
	string s; cin >> s;
	return s;
}

int main()
{
	scanf("%d", &n);
	string A = Get(0);
	if (A == "Vacant") return 0;
	string B = Get(n - 1);
	if (B == "Vacant") return 0;
	int lef = 1, rig = n - 2;
	while (lef <= rig) {
		int mid = lef + rig >> 1;
		string my = Get(mid);
		if (my == "Vacant") return 0;
		if (mid % 2 == 0)
			if (my == A) lef = mid + 1;
			else rig = mid - 1;
		else if (my == B) lef = mid + 1;
			 else rig = mid - 1;
	} 
	return 0;
}

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

int main()
{
   string s;
   cin>>s;
   int n=s.size();
   if(s[n-1]=='s'){
	   s+="es";
   }
   else{
	   s+='s';
   }
   cout<<s<<endl;
}
		



Measured memory_bytes: 3616
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7



class UnionFind:
    def __init__(self, n):
        # 負  : 根であることを示す。絶対値はランクを示す
        # 非負: 根でないことを示す。値は親を示す
        self.table = [-1] * n
        self.size = n

    def root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.root(self.table[x])
            return self.table[x]


    def is_same(self, x, y):
        return self.root(x) == self.root(y)


    def union(self, x, y):
        r1 = self.root(x)
        r2 = self.root(y)
        if r1 == r2:
            return
        # ランクの取得
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2
        self.size -= 1


n, m = LI()
U = UnionFind(n)
for i in range(m):
    x, y, z = LI()
    U.union(x - 1, y - 1)


print(U.size)







Measured memory_bytes: 68056
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, s, n) for(int i = s; i < n; i++)
using namespace std;
using P = pair<int, int>;

int main(){
  int n;
  cin >> n;
  int d = 1 + 8 * n;
  int ld = (int)sqrt(d);
  if (ld * ld != d) cout << "No" << endl;
  else{
    int k = (1 + ld) / 2;
    vector<vector<int>> s(k, vector<int>(k-1, -1));
    P x = P(0, 0), y = P(0, 0);
    rep2(i, 1, n+1){
      while(1){
        if (x.second == k - 1){
          x.first++;
          x.second = 0;
        }
        if (s[x.first][x.second] == -1){
          s[x.first][x.second] = i;
          x.second++;
          break;
        }
        x.second++;
      }
      while(1){
        if (y.first == k){
          y.second++;
          y.first = 0;
        }
        if (s[y.first][y.second] == -1){
          s[y.first][y.second] = i;
          y.first++;
          break;
        }
        y.first++;
      }
    }
    cout << "Yes" << endl;
    cout << k << endl;
    rep(i, k){
      cout << k-1 << ' ';
      rep(j, k-1){
        cout << s[i][j] << ' ';
      }
      cout << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 2176
a,b = list(map(int,input().split()))
A = []
AAA = 0
list = [["" for i in range(b)] for j in range(a)]
for i in range(a):
    n = input()
    if n.count(".") == b:
       pass 
    else:
        for j in range(b):
            list[i][j] = n[j]
for i in range(b):
    for j in range(a):
        A.append(list[j][i])
    if len(A) == A.count(".")+A.count(""):
        for k in range(a):
            list[k][i] = ""
    A = []
for i in range(a):
    for j in range(b):
        if list[i][j] != "":
            print(list[i][j],end="")
            AAA = 1
    if AAA == 1:
        print()
    AAA = 0

Measured memory_bytes: 4596
x = int(input())
 
 
def Prime(x):
    if x == 2:
        return 2
    if x % 2 == 0:
        return False
    else:
        sqrtx = x**(1/2)
        for i in range(3,int(sqrtx+1),2):
            if x % i == 0:
                return False
        return True
 
while True:
    if Prime(x):
        print(x)
        break
    x+=1

Measured memory_bytes: 2940
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using ull=unsigned long long int;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
   V<int> money={10,50,100,500};
   int t=0;
  while(1){
  ll n;
  cin>>n;
  if(n==0)return 0;
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(t)cout<<"\n";
  t++;
  V<int> ans(4,0);
  ll sum=0;int ma=INT_MAX;
  ll change=0;
  int total=a+b+c+d;
  for(int  i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        for(int r=0;r<=d;r++){
           sum=i*10+j*50+k*100+r*500;
          if(sum<n)continue;
          int cnt=0;
          change=sum-n;
          cnt+=change/500;
          change%=500;
          cnt+=change/100;
          change%=100;
          cnt+=change/50;
          change%=50;
          cnt+=change/10;
          change%=10;
          if(chmin(ma,total-(i+j+k+r)+cnt)){
            ans={i,j,k,r};
          }
        }
      }
    }
  }
  for(int i=0;i<4;i++){
    if(ans[i]){
      cout<<money[i]<<" "<<ans[i]<<"\n";
    }
  }
  }
}


Measured memory_bytes: 3056
#include<bits/stdc++.h>
#define ll  long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pb push_back
#define Max(x,y,z) max(x,max(y,z))
#define f first
#define s second
#define lbd lower_bound
#define sz(x)       (ll)x.size()
#define pi 3.1415926536
#define mod 1000000007
using namespace std;
void solve()
{
    ll n,m,k,x,y,res=0,l,cnt=0,sum=0,z,sum1=0,cnt1=0,h,res1,cnt2=0;
   cin>>n>>m;
   string s1;
   cin>>s1;
   ll dp[n+1]={0};
   rep(i,0,n-1)
   {
       if(s1[i]=='A' && s1[i+1]=='C')
        dp[i+1]=dp[i]+1;
       else
        dp[i+1]=dp[i];
   }
   while(m--)
   {
       cin>>x>>y;
       cout<<dp[y-1]-dp[x-1]<<"\n";
   }




}
int main()
{   speed_up
    ll t;
   // cin>>t;
    t=1;
    while(t--)
        solve();
}


Measured memory_bytes: 1872
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    int n, m;
    cin >> n >> m;
    vector<int> slip(100005);
    rep(i, m) {
        int a;
        cin >> a;
        slip[a] = 1;
    }
    
    vector<int> dp(100005);
    dp[0] = 1;
    rep(i, n) {
        if (dp[i] == 0 || slip[i] == 1) continue;
        (dp[i + 1] += dp[i]) %= inf;
        (dp[i + 2] += dp[i]) %= inf;
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 1024
/*
* ID: juryc
* PROG: Welcome to Atcoder
* LANG: C++
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m; cin>>n>>m; 
vector<int> ac(n,0); 
vector<int> wa(n,0); 
int aw,ca; aw=ca=0;
int p; string s;
for(int i=0;i<m;i++){
cin>>p>>s;
--p;
if(s=="AC") ac[p]=1;
else{ if(ac[p]) continue; else wa[p]++; }
}
for(int i=0;i<n;i++)
if(ac[i]) aw+=wa[i],ca++;
cout<<ca<<" "<<aw<<"\n"; 
return 0;
} 


Measured memory_bytes: 4040
n,x,m=map(int,input().split())
sm=[-1 for i in range(m)]+[0]
w=[-1 for i in range(m)]
d=[m]
a=x
t=0
s=0
while True:
  s+=a
  if w[a]!=-1:
    inter=t-w[a]
    fv=w[a]
    ls=d[(n-fv)%inter+fv]
    lls=d[w[a]]
    print(sm[lls]+(n-fv)//inter*(s-sm[a])+(sm[ls]-sm[lls]))
    break
  w[a]=t
  d.append(a)
  sm[a]=s
  t+=1
  a=(a*a)%m

Measured memory_bytes: 84056
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

int main() {
   Int n;
   std::cin >> n;
   std::vector<Int> ts(n), xs(n), ys(n);
   rep(i,n) std::cin >> ts[i] >> xs[i] >> ys[i];
   bool res = xs[0] + ys[0] <= ts[0] and (xs[0] + ys[0]) % 2 == ts[0] % 2;
   for(Int i = 1; i < n; ++i) {
      Int dt = ts[i]-ts[i-1], dx = std::abs(xs[i]-xs[i-1]), dy = std::abs(ys[i]-ys[i-1]);
      bool f = dx + dy <= dt and (dx + dy) % 2 == dt % 2;
      res = res and f;
   }
   puts(res?"Yes":"No");
}


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

using namespace std;

typedef long long ll;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
  vector<char> ans;
  for(int i=0;i<tx-sx;i++) ans.push_back('R');
  for(int i=0;i<ty-sy;i++) ans.push_back('U');
  for(int i=0;i<tx-sx;i++) ans.push_back('L');
  for(int i=0;i<ty-sy;i++) ans.push_back('D');
  ans.push_back('D');
  for(int i=0;i<tx-sx+1;i++) ans.push_back('R');
  for(int i=0;i<ty-sy+1;i++) ans.push_back('U');
  ans.push_back('L');
  ans.push_back('U');
  for(int i=0;i<tx-sx+1;i++) ans.push_back('L');
  for(int i=0;i<ty-sy+1;i++) ans.push_back('D');
  ans.push_back('R');
  for(char ai: ans) cout << ai;
  cout << endl;
}

Measured memory_bytes: 256
gameCount = gets.chomp!.to_i
gameCount.times do |i|
    score = 0
    hitCnt = 0
    outCnt = 0
    while line = gets .chomp!
        case line
        when "OUT" then
            outCnt += 1
        when "HIT" then
            if hitCnt == 3 
                score += 1
            elsif   
                hitCnt += 1
            end
        when "HOMERUN" then
            score += (hitCnt + 1)
            hitCnt = 0
        end
        if outCnt == 3
            break
        end
    end
    puts score
end

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

if n != 0:
  p = list(map(int, input().split()))
  q = []
  for i in range(102):
    if i in p:
      q.append(150)
    else:
      q.append(abs(i-x))
  list_indexMin = [i for i, v in enumerate(q) if v == min(q)] 
  print(min(list_indexMin))
else:
  print(x)

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

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

  if(A+B>C+D){
    cout << "Left" << endl;
  }

  if(A+B==C+D){
    cout << "Balanced" << endl;
  }

  if(A+B<C+D){
    cout << "Right" << endl;
  }
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		ArrayList<Integer> a = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			a.add(sc.nextInt());
		}
		a.sort(null);

		long alice = 0L;
		long bob = 0L;

		for (int i = 0; i < a.size(); i++) {
			if (i % 2 == 0) {
				// Alice
				alice += a.get(a.size() - i - 1);
			} else {
				// bob
				bob += a.get(a.size() - i - 1);
			}
		}
		System.out.println(alice - bob);

		sc.close();
	}
}


Measured memory_bytes: 23636
import Data.List
import Data.Array.Unboxed

main = do
  [n, k] <- map read . words <$> getLine :: IO [Int]
  [x, y] <- transpose . map (map read . words) . lines <$> getContents :: IO [[Int]]
  let points = zip x y
      index = [(i, j) | i <- [1..n], j <- [1..n], i + k - 1 <= j]
      xArray = listArray (1, n) $ sort x :: UArray Int Int
      yArray = listArray (1, n) $ sort y :: UArray Int Int
  print . minimum . filter (/=(-1)) . concat $ map (loopX points k xArray yArray index) index

loopX :: [(Int, Int)] -> Int -> UArray Int Int -> UArray Int Int -> [(Int, Int)] -> (Int, Int) -> [Integer]
loopX p k x y ys (xi, xj) = let l = x ! xi
                                r = x ! xj
                            in map (loopY p k l r y) ys

loopY :: [(Int, Int)] -> Int -> Int -> Int -> UArray Int Int -> (Int, Int) -> Integer
loopY p k l r y (yi, yj) = let t = y ! yi
                               b = y ! yj
                           in if count l r t b p >= k
                                then (*) (toInteger $ r - l) (toInteger $ b - t)
                                else -1

count :: Int -> Int -> Int -> Int -> [(Int, Int)] -> Int
count _ _ _ _ []     = 0
count l r t b ((x, y):s)
  | l <= x && x <= r && t <= y && y <= b = 1 + count l r t b s
  | otherwise                            = 0 + count l r t b s


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

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

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int i = a; i <= (n); ++i)
#define repD(i, a, n) for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a) memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	int l,r,d; cin >> l >> r >> d;
	cout << r/d - (l-1)/d << '\n';
	return 0;
}



Measured memory_bytes: 3648
//
// Created by sark2 on 22-10-2019.
//

#include "bits/stdc++.h"

using namespace std;
#define PB push_back
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define CASES int t;cin>>t;while(t--)
#define MP make_pair

using ll = long long;
using ld = long double;

ll mod = 1e9 + 7;

const ld PI = (acos(-1));


int main() {
    IOS

    ld a, b, x;
    cin>>a>>b>>x;

   if(a*a*b / 2.0 <= x)
       cout<<fixed<<setprecision(10)<<atan(2*(a*a*b-x)/(a*a*a))*180/PI;
    else
       cout<<fixed<<setprecision(10)<<180/PI * (PI/2-atan(2.0*x/(b*b*a)));

}


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

int main(){
	int k,n;
	cin >> k >> n;
	vector<int> a(n);
	rep(i,n){
		cin >> a[i];
	}
	vector<int> ans(n);
	for(int i=1;i<n;i++){
		ans[i] = a[i] - a[i-1];
	}
	ans[0] = k-a[n-1]+a[0];
	int maxim = 0;
	rep(i,n){
		if(maxim < ans[i]) maxim = ans[i];
	}
  //cout << a[n-1] << endl;
	cout << k-maxim << endl;
}

Measured memory_bytes: 4836
import sys


def input():
    return sys.stdin.readline().rstrip()


def tc():
    N = int(input())



def main():
    N = int(input())

    dp = [0]*(N+1)
    rt = int(N **0.5) +2
    for i in range(1,rt):
        for j in range(1,rt):
            if int( i**2 + j **2 + 1 + i*j + i*1 + j*1 ) >N:
                break
            for k in range(1,rt):
                case =int( i**2 + j **2 + k **2 + i*j + i*k + j*k )
                if case <=N:
                    dp[case] +=1
                else:
                    break

    for l in range(1,N+1):
        print(dp[l])










if __name__ == "__main__":
    main()


Measured memory_bytes: 69088
#include<bits/stdc++.h>
using namespace std;
int d[1111],c[1111];
int n,m;
int memo[1111][1111];
int solve(int day,int tosi){
  if(tosi==n){
    return 0;
  }
  if(day==m){
    return 1000000000;
  }
  if(memo[day][tosi]) return memo[day][tosi];
  int ret=0;
  ret+=min(solve(day+1,tosi+1)+d[tosi]*c[day] , solve(day+1,tosi) );
  return memo[day][tosi]=ret;
}
int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>d[i];
  }
  for(int i=0;i<m;i++){
    cin>>c[i];
  }

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

Measured memory_bytes: 5552
import fractions
n, x = map(int, input().split())
xl = [int(_) for _ in input().split()]
for i in range(n):
    if x > xl[i]:
        xl[i] = x - xl[i]
    else:
        xl[i] = xl[i] - x

x_gcd = xl[0]
if n > 1:
    for i in range(1, n):
        x_gcd = fractions.gcd(x_gcd, xl[i])
print(x_gcd)


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

#define MAX 10000

using namespace std;

#define inf    0x3f3f3f3f
#define ll long long
#define all(a) (a).begin(),(a).end()
#define INF (int)1e15
#define MOD 1000000007
#define access(i) a[i/3][i%3]



 int main(){

 int t; cin>>t;

  int cnt=0,flag= 0;

  while(t--){

      int a,b; cin>>a>>b;

     if(a == b) cnt++;
     else {
      cnt = 0;
     }

     if(cnt == 3){
           cout<<"Yes"<<endl;
           flag = 1;
           break; }
  }

  if(flag == 0)
  cout<<"No"<<endl;

 return 0;
 }


Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#define MOD 1000000007
using namespace std;
int main()
{
	int n, w[100];
	cin >> n;
	int i,wa[100];
	for (i = 0; i < n; i++) {
		cin >> w[i];
	}
	int mm, mw=MOD;
	for (i = 1; i < n ; i++) {
		int r, l, rw = 0, lw = 0;
		for (r = 0; r < i; r++) {
			rw += w[r];
		}
		for (l = n - 1; l >= i; l--) {
			lw += w[l];
		}
		if (abs(rw - lw) < mw) {
			mw = abs(rw - lw);
		}
	}
	cout << mw << endl;
	return 0;
}

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

int main() {
    int A , B, C;
    cin >> A >> B >> C;
    bool kawaisou = false;
    if (A == B && A != C){
        kawaisou = true;
    }else if(A == C && A != B){
        kawaisou = true;
    }else if(B == C && A != B){
        kawaisou = true;
    }
    if(kawaisou == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
    long long h,ans=0,i=0;
    cin>>h;
    while(h>1){
        h=h/2;
        ans+=pow(2,i);
        i++;
    }
    cout<<setprecision(13)<<ans+pow(2,i)<<endl;
}

Measured memory_bytes: 384
#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() {
    char a;
    cin >> a;
    if (a >= 'a' && a <= 'z') {
        cout << "a"<< endl;
        return 0;
    }else if (a >= 'A' && a <= 'Z') {
        cout << "A"<< endl;
         return 0;
    }
    return 0;
}


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

using namespace std;

typedef long long int ll;

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

  ll x;
  cin >> x;
  ll amount = 100;
  for(int i = 1; i <= 100000; i++){
    amount = amount + (amount / 100);
    if(amount >= x){
      cout << i << endl;
      return 0;
    }
  }
}


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

#define ll long long
const ll N = 998244353;
const ll MAX = 100000000000;

int D;
ll G;

vector<pair<int, int>> v;

int main()
{
ios_base::sync_with_stdio(false);
int D;
ll G;
cin>>D>>G;
G/=100;
int x, y;
for (int i = 0; i<D; i++)
{
    cin>>x>>y;
    y/=100;
    v.push_back(make_pair(x, y));
}

int degs[D];
degs[0] = 1;
for (int i = 1; i<D; i++) degs[i] = degs[i-1]*2;

int minn = 1000000000;

for (int i = 0; i<2*degs[D-1]; i++)
{
    int counter = 0;
    int G1 = G;
    for (int j = 0; j<D; j++) if ((i&degs[j])!=0) {counter+=v[j].first; G1-=(v[j].first*(j+1)+v[j].second);}
    if (G1<=0) minn  = min(minn, counter);
    //if (i==1) cout<<G1<<endl;
    else
   {
        for (int j = 0; j<D; j++) if ((i&degs[j])==0) {
            if ((G1+j)/(j+1)<=v[j].first) minn = min(minn, counter+(G1+j)/(j+1));
        }
    }
}

cout<<minn<<endl;


}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	char S[256];
	int len;

	scanf("%s", S);
	len = strlen(S);

	char output[256];
	int i;
	for (i = 0; i < len; i++){
		output[i] = 'x';
	}
	output[i] = '\0';

	printf("%s\n", output);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
struct results{
        int a;
        int b;
        int c;
        int result;
};
int main(){
        while(true){
        int parts[1000]={0};
        int aa,bb,cc,n;
        cin >> aa >> bb >> cc;
        if(aa+bb+cc==0)
                break;
        cin >> n;
        results data[1000];
        for( int i=0 ; i<n ; i++ )
                cin >> data[i].a >> data[i].b >> data[i].c >> data[i].result;
        for( int all_counter=0 ; all_counter<2 ; all_counter++)
        for( int i=0 ; i<n ; i++ ){
                if(data[i].result){
                        parts[data[i].a]=1;
                        parts[data[i].b]=1;
                        parts[data[i].c]=1;
                }
                else{
                        int level=parts[data[i].a]+parts[data[i].b]+parts[data[i].c];
                        if(level>1){
                                parts[data[i].a]==0?parts[data[i].a]=-1:0;
                                parts[data[i].b]==0?parts[data[i].b]=-1:0;
                                parts[data[i].c]==0?parts[data[i].c]=-1:0;
                        }
                }
        }
        for( int i=0+1 ; i<=aa+bb+cc ; i++ )
                if(parts[i]==-1)
                        cout << 0 << endl;
                else if(parts[i]==0)
                        cout << 2 << endl;
                else
                        cout << 1 << endl;
        }
        return 0;
}

Measured memory_bytes: 3012
N = int(input())
for i in range(N):
        a,b,c = map(int,input().split())
        if i == 0:
                preA = a
                preB = b
                preC = c
        else:
                A = max(preB + a, preC + a)
                B = max(preA + b, preC + b)
                C = max(preA + c, preB + c)
                preA = A
                preB = B
                preC = C
print(max(preA, preB, preC))

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

// 小数点以下桁数
// fixed << setprecision(i)

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

int main()
{
  int64_t n, ans = 0, tmp;
  vector<int> a(100001), b(100000);

  cin >> n;
  for (int i = 0; i < n + 1; i++)
    cin >> a[i];
  for (int j = 0; j < n; j++)
    cin >> b[j];
  for (int i = 0; i < n; i++)
  {
    tmp = min(b[i], a[i]);
    b[i] -= tmp;
    ans += tmp;
    tmp = min(b[i], a[i + 1]);
    a[i + 1] -= tmp;
    ans += tmp;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3836
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	string input;
	getline(cin, input);

	string s;
	stringstream ss {input};
	stack<int> x;

	int res = 0;
	while (getline(ss, s, ' '))
	{
		int a;
		int b;

		if (s == "+")
		{
			a = x.top();
			x.pop();

			b = x.top();
			x.pop();

			x.push(b + a);
		}
		else if (s == "-")
		{
			a = x.top();
			x.pop();

			b = x.top();
			x.pop();

			x.push(b - a);
		}
		else if (s == "*")
		{
			a = x.top();
			x.pop();

			b = x.top();
			x.pop();

			x.push(b * a);
		}
		else
		{
			x.push(stoi(s));
		}
	}

	println(x.top());
}



Measured memory_bytes: 3240
#https://atcoder.jp/contests/abc079/tasks/abc079_c

abcd=input()
n=[]
for i in range(4):
    n.append(int(abcd[i]))

for i in range(2**3):
    num=n[0]
    symbol=[]
    for j in range(3):
        if (i>>j)&1:#足し算
            num+=n[j+1]
            symbol.append("+")
        else:
            num-=n[j+1]
            symbol.append("-")
    if num==7:
        print("{0}{1}{2}{3}{4}{5}{6}=7".format(n[0],symbol[0],n[1],symbol[1],n[2],symbol[2],n[3]))
        exit()


Measured memory_bytes: 61988
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
#include <algorithm>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
template<class T>inline T cabs(const T &x){return x>=0?x:-x;}
const int N=210,M=10000010;
int prime[M],ps=0;
bool isp[M];
inline void gmath(int n){
	memset(isp,true,sizeof(isp));
	isp[1]=false;
	for(int i=2;i<=n;i++){
		if(isp[i]){
			prime[ps++]=i;
		}
		for(int j=0,cur=2;j<ps&&i*cur<=n;cur=prime[++j]){
			isp[i*cur]=false;
			if(i%cur==0)break;
		}
	}
}
int pos[N];
int x[N],y[N];
int lcnt=0,rcnt=0;
bool vis[N];
int lnk[N];
bool dfs(int x){
	for(int v=1;v<=rcnt;v++){
		if(!vis[v]&&isp[cabs(::x[x]-y[v])]){
			vis[v]=true;
			if(lnk[v]==-1||dfs(lnk[v])){
				lnk[v]=x;
				return true;
			}
		}
	}
	return false;
}
int main(){
	int n=ni,xs=0,cnt=0;
	for(int i=1;i<=n;i++){
		int cur=ni;
		if(cur==pos[xs]){
			pos[xs]++;
		}else{
			pos[++xs]=cur,pos[++xs]=cur+1;
		}
	}
	gmath(pos[xs]);
	for(int i=1;i<=xs;i++){
		if(pos[i]&1){
			x[++lcnt]=pos[i];
		}else{
			y[++rcnt]=pos[i];
		}
	}
	memset(lnk,-1,sizeof(lnk));
	for(int i=1;i<=lcnt;i++){
		memset(vis+1,0,rcnt);
		cnt+=dfs(i);
	}
	printf("%d\n",xs+((lcnt^cnt)&1)-cnt);
	return 0;
}

Measured memory_bytes: 14592
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second

using namespace std;
int main(){
	std::ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	long double x=1;
	ll a[n];
	bool ok=true;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		if(a[i]==0){
			cout << 0 << endl;
			return 0;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		x*=a[i];
		if(x>1000000000000000000){
			cout << "-1" << endl;
			return 0;
		}
	}
	if(ok){
		cout << (ll)x << endl;
	}

	return 0;
}


Measured memory_bytes: 4428
require 'matrix'
n, m = gets.split.map(&:to_i)
h = {}
(0..n-1).each do |i|
    h[i] = {}
end
loop do
    s, t, e = gets.split.map(&:to_i)
    break if s == 0
    h[s-1][t-1] = e
end
l = gets.to_i
l.times do
    v = gets.split.map(&:to_i)
    puts (0..n-1).map {|i| h[i].map {|k, e| v[k] * e}.inject(:+) || 0} * ' '
end


Measured memory_bytes: 27944
n, k = map(int, input().split())

if k % 2 == 1:
    ans = pow(n // k, 3)
    print(ans)
else:
    ans1 = pow(n // k, 3)
    ans2 = 0
    for i in range(1, n + 1):
        if i % k == k / 2:
            ans2 += 1
    print(ans1 + pow(ans2, 3))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    string s;
    cin>>s;
    int n=s.length();
    vector<int> ans(n,0);
    int a=0,b;
    rep(i,n){
        if(s[i]=='R') a++;
        else{
            if(a%2==1){
                a/=2;
                b=a+1;
            }
            else{
                a/=2;
                b=a;
            }
            ans[i-1]+=b;
            ans[i]+=a;
            a=0;
        }
    }
    //cout<<endl;
    //rep(i,n) cout<<ans[i]<<' ';
    cout<<endl;
    for(int i=n-1; i>=0; --i){
        if(s[i]=='L') a++;
        else{
            if(a%2==1){
                a/=2;
                b=a+1;
            }
            else{
                a/=2;
                b=a;
            }
            ans[i+1]+=b;
            ans[i]+=a;
            a=0;
        }
    }
    rep(i,n){
        cout<<ans[i]<<' ';
    }
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  
  int p[n];
  for(int i = 0; i < n; i++){
    cin >> p[i];
    //cout << p[i];
  }
  sort(p, p+n);
  
  int sum = 0;
  for(int i = 0; i < n-1; i++){
    //cout << p[i] << endl;
    sum += p[i];
  }
  sum += (p[n-1] / 2);
  
  cout << sum << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP2(i,m,n) for (int i=m;i<(n);i++)
typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;

const ll MOD = 1000000007;

int N;
int A[25][25];
ll dp[23][1<<21];
vector<int> masks[25];

void solve() {
    cin >> N;
    REP(i, N) REP(j, N) cin >> A[i][j];
    dp[0][0] = 1;

    REP(mask, 1<<N) masks[__builtin_popcount(mask)].push_back(mask);

    REP(i, N) for (auto mask: masks[i]) {
        REP(j, N) {
            if (!A[i][j] || (mask & (1 << j))) continue;
            (dp[i+1][mask|(1<<j)] += dp[i][mask]) %= MOD;
        }
    }

    cout << dp[N][(1<<N)-1] << "\n";
}

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

    solve();
}


Measured memory_bytes: 320956
#include<iostream>
using namespace std;
int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  if(a){
    if(!b && !c) cout << "Close" << endl;
    else cout << "Open" << endl;
  }
  else if(b) cout << "Close" << endl;
  else{
    if(c) cout << "Open" << endl;
    else cout << "Close" << endl;
  }
}


Measured memory_bytes: 1156
/*  -*- coding: utf-8 -*-
 *
 * 2727.cc: M and A
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

bool check(string &s, string &t, int st) {
  int sn = s.size(), tn = t.size();
  for (int i = st, j = 0; i < sn; i += 2) {
    while (j < tn && s[i] != t[j]) j++;
    if (j >= tn) return false;
    j++;
  }
  return true;
}

/* main */

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

  if (check(s, t, 0) || check(s, t, 1)) puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 3208