akhauriyash/Code-Regression huggingface dataset:
//I am so vegetable
//#define err
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define pb push_back
#define in insert
#define er erase
#define ct count
#define ep empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = acos(-1.0);
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
void exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2,mod); }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }


ll x[1005],y[1005],r[1005];
long double c[1005][1005],lc[1005];
int vis[1005];
int n;
void dij(){
    _for(i,0,n+2){
        lc[i]=c[0][i];
        vis[i]=0;
    }
    vis[0]=1;
    _for(i,1,n+2){
        int k=-1;
        long double mi = 1e18;
        _for(j,1,n+2){
            if(!vis[j]&&lc[j]<mi){
                mi=lc[j];
                k=j;
            }
        }
        vis[k]=1;
        _for(j,1,n+2){
            if(!vis[j]&&lc[k]+c[k][j]<lc[j]){
                lc[j]=lc[k]+c[k][j];
            }
        }
    }
}
signed main() {
    //ifstream cin("E:\\acm dream\\in.in");
	//ofstream cout("E:\\acm dream\\out.out");
	FIO;
    #ifdef err
	double be = clock();
    #endif

    int sx,sy,ex,ey;cin>>sx>>sy>>ex>>ey;
    cin>>n;
    x[0]=sx,y[0]=sy,r[0]=0,x[n+1]=ex,y[n+1]=ey,r[n+1]=0;
    _for(i,0,n+2)
        _for(j,0,n+2)
            c[i][j]=inf;
    _for(i,1,n+1){
        cin>>x[i]>>y[i]>>r[i];
    }
    _for(i,0,n+2){
        _for(j,i+1,n+2){
            c[i][j]=(long double)sqrt((long double)(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
            c[i][j]-=r[i]+r[j];
            if(c[i][j]<0)c[i][j]=0;
            c[j][i]=c[i][j];
        }
    }
    dij();
    cout<<fixed<<setprecision(9)<<lc[n+1];

    #ifdef err
	double en = clock();
    cout<<"time: "<<fixed<<setprecision(8)<<en-be;
    #endif
	return 0;
} // just for test

Measured memory_bytes: 19616
n = int(input())
a = list(map(int, input().split()))
b = sum(a) / 2
p = int((n - 1) / 2)

x = []

t = b
for j in range(p):
    t -= a[2 * j + 1]
x.append(t * 2)

for i in range(n-1):
    t = a[i] - x[i] / 2
    x.append(t * 2)

for i in range(n):
    print(int(x[i]), end=" ")


Measured memory_bytes: 14028
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n, k := iScan(), iScan()
	fmt.Println((n - 1 + k - 1 - 1) / (k - 1))
}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
int i,j,n,a,m,c;
int main(){
  cin>>n;
  vector<int> p(n),q(n);
  for(;i<n;i++)cin>>p[i];
  for(i=0;i<n;i++)cin>>q[i];
  vector<int> x(n);
  for(i=0;i<n;i++)x[i]=i+1;
  map<vector<int>,int> mp;
  do{
    mp[x]=mp.size();
  }while(next_permutation(x.begin(),x.end()));
  a=abs(mp[p]-mp[q]);
  cout<<a;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
int main() {
  int N; cin >> N;
  int chg;
  if (N%1000 == 0) chg =0;
  else chg =1000-N%1000;
  cout << chg << endl;
  return 0;
}


Measured memory_bytes: 3596
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace __gnu_pbds;
using namespace std;

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

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

int n, k, res;

signed main() {
  init_ios();
  cin >> n >> k;
  while (n) {
    ++res;
    n /= k;
  }
  cout<<res<<"\n";
}

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

int main(){
    int a,b,c;
    int k;
    cin>>a>>b>>c>>k;
    for(int i=0;i<k;i++){
        if(b<=a){
        b*=2;
        continue;
        }
        else if(c<=b){
            c*=2;
            continue;
        }
    }
    if(b>a&&c>b)
    cout<<"Yes";
    else
    cout<<"No";
}

Measured memory_bytes: 3632
// AtCoder Beginner Contest 171 D.cpp

#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;

int main()
{
	int n, q, b, c;
	long long s = 0;
	cin >> n;
	unordered_map<int, int>lib;
	vector<int>a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (lib.find(a[i]) != lib.end()) {
			lib[a[i]]++;
		}
		else {
			lib.insert(make_pair(a[i], 1));
		}
		s += a[i];
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> b >> c;
		if (lib.find(b) != lib.end()) {
			s = s + (c - b) * lib[b];
			if (lib.find(c) != lib.end()) {
				lib[c] += lib[b];
			}
			else {
				lib.insert(make_pair(c, lib[b]));
			}
			lib.erase(b);
		}
		cout << s << endl;
	}
}

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

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

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

int main() {
	string s; cin >> s;
	string t;
	rep(i, s.length()) {
		if (i % 2 == 0)t += s[i];
	}

	cout << t << endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
	vector<string> week = { "SUN","MON","TUE","WED","THU","FRI","SAT" };

	map<string, int> ans;

	string today;
	cin >> today;

	for (int i = 0; i < 7; i++) {
		ans[week.at(i)] = 7 - i;
	}
	cout << ans[today];
}

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

int main() {
    char c;
    cin >> c;

    if (c == 'a')
        cout << "vowel" << endl;
    else if (c == 'i')
        cout << "vowel" << endl;
    else if (c == 'u')
        cout << "vowel" << endl;
    else if (c == 'e')
        cout << "vowel" << endl;
    else if (c == 'o')
        cout << "vowel" << endl;
    else
        cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


ll T, n, m;

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin >> n;
	vector<ll> dp(n + 1);
	dp[0] = 1;
	dp[1] = n;
	ll sum = dp[0] * (n - 1);
	for(int i=2;i<=n;i++){
		if(i-3 >= 0) (sum += dp[i-3] - dp[0]) %= MOD;
		dp[i] = (dp[i-1] + (n-1) * (n-1) + sum) % MOD;
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
     int H,W;
      cin>>H>>W;
      vector<vector<char>>s(55,vector<char>(55));
      for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
          cin>>s.at(i).at(j);}}
      string judge="Yes";     
       for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){ 
         if(s.at(i).at(j)=='#'&&s.at(i).at(j-1)!='#'&&s.at(i).at(j+1)!='#'&&s.at(i-1).at(j)!='#'&&s.at(i+1).at(j)!='#'){
           judge="No";break;}
        }}
        cout<<judge<<endl;
      return 0;
    }

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int a,b;
int main(){
	scanf("%d%d",&a,&b);
	if(a+b==15)printf("+\n");
	else if(a*b==15)printf("*\n");
	else printf("x\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(s,x) memset(s,x,sizeof(s))
#define pb push_back
#define mp make_pair
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;

const double PI = acos(-1.0);
const double eps = 1e-8;
const int MAXN = 1e5+5;
const ll MOD = 1e9+7;

queue <pair<string, int>> que;

int main()
{
    int n, q, time, now = 0;
    string name;
    cin >> n >> q;
    while (n--)
    {
        cin >> name >> time;
        que.push(mp(name, time));
    }
    while (!que.empty())
    {
        name = que.front().first;
        time = que.front().second;
        que.pop();
        if (time <= q)
        {
            now += time;
            cout << name << " " << now << endl;
        }
        else
        {
            now += q;
            time -= q;
            que.push(mp(name, time));
        }
    }

    return 0;
}



Measured memory_bytes: 6316
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE TemplateHaskell #-}
--atcoder {-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NoImplicitPrelude #-}

import Prelude
import System.IO
import System.Environment
import System.Exit
import Data.List
import Data.Maybe
import qualified Data.Char as Char
import qualified Data.Text as T
import qualified Data.Text.IO as TIO
import qualified Control.Monad
--atcoder import qualified Data.Semigroup
import qualified Data.Map as Map
import qualified Data.Set as Set

readInt :: IO Int
--readInt = read <$> getLine
readInt = getLine >>= (return . read)

readInts :: IO [Int]
readInts = map (read :: String -> Int) <$> words <$> getLine

bf1 :: Int -> Int -> Int
bf1 l r | l >= r = maxBound :: Int
        | otherwise = min cur (bf1 l (r-1))
        where cur = bf2 l r

bf2 :: Int -> Int -> Int
bf2 l r | l >= r = maxBound :: Int
        | otherwise = min ret (bf2 (l+1) r)
        where ret = mod (l*r) 2019

       

solve :: Int -> Int -> Int
solve l r = if r - l + 1 >= 2019
            then 0
            else bf1 l r

main :: IO ()
main = do
    lr <- getLine >>= (return . words) >>= (return . map (read :: String -> Int))
    let l = lr !! 0
    let r = lr !! 1
    let ret = solve l r
    print ret

Measured memory_bytes: 508
/* -----------------------------------------------------------------------------
	????????????????????? 2012 ?????? ??????5 
	???????????????????????????????????????(?????????) C++?¨????
	g++ pckpre1205.cpp -O2
----------------------------------------------------------------------------- */
#include <iostream>
#include <algorithm>
#include <vector> 

using namespace std;

#define PIPE_MAX 65000

int main() {

	int		n;						// ???????????¬??°
	int 	pipe[PIPE_MAX];			// ??????????????????
	vector<int>	joint;				// ?????§??????????????????
	
	long long		jp;						// ????????¨???????????§??????????????????
	long long		L, L_max;				// ?????????+?????§????????????????????????
	long long		mul;					// ??????
	long long		wage;	// ??????

	// ???????????¬??°???????????????
	cin >> n;

	while(n > 0) {

		// ?????????????????????????????????
		for(int i = 0; i < n; i++)
			cin >> pipe[i];

		// ?????????????????????????????????
		for(int i = 1; i < n; i++) {
			int x;	cin >> x; joint.push_back(x); 
		}

		// ???????????????????????´????????????
		sort(joint.begin(), joint.end());

		// ????????¨???????????§??????????????????
		jp = n-2;
		
		// ????????????????????????
		L = 0;
		for(int i = 0; i < n; i++) L += pipe[i];
		L_max = L; mul = n;

		// ???????????§???????±???????
		for(int i = n - 1; i >= 1; i--) {   //-????????????????????????????????????????????????????±?????????????
			// 
			if(L_max * mul < (L + joint[jp]) * i) {
				// ?????§??????????????????????????????+?????§???????????????????????????????¨???¶
				L_max = L + joint[jp]; mul = i;
			}
			// ??´??°
			L += joint[jp];
			jp--;
		}
				
		// ?????§???????????¨???
		cout << L_max * mul << endl;

		// ???????????¬??°???????????????
		cin >> n;
		joint.clear();
	}

	return 0;
}

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

int n;
long long ans;

int main()
{
	int u,v;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		if(u>v) swap(u,v);
		ans-=(long long)u*(n-v+1);
	}
	for(int i=1;i<=n;i++) ans+=(long long)i*(n-i+1);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3836
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	if a == b && b == c {
		fmt.Println("No")
	} else if a == b || b == c || a == c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 512
#include <iostream>

int main(void) 
{
  while (true) {
    int k;
    std::cin >> k;
    if (k == 0) break;
    int num = k * (k - 1) / 2;
    int sum = 0;
    for (int i=0; i < num; i++) {
      int n;
      std::cin >> n;
      sum += n;
    }
    std::cout << sum / (k - 1) << std::endl;
    //std::cout << "sum = " << sum << std::endl;
  }
  
  
  return 0;
}

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

int main()
{
	string s, t;
	int aim;
	cin >> s >> t;
	string::size_type ls = s.length(), lt = t.length(),i,flag=0;
	for (aim = ls - lt; aim >-1; aim--)
	{
		if (!flag)
		{
			flag = 1;
			for (i = 0; i < lt; i++)
			{
				if (s[aim + i] != '?'&&s[aim + i] != t[i])
				{
					flag = 0;
					break;
				}
			}
		}
		else
			break;
	}
	aim++;
	if (flag)
	{
		for (i = 0; i < aim ; i++)
		{
			if (s[i] == '?')
				cout << "a";
			else
				cout << s[i];
		}
		cout << t;
		for (i = aim + lt; i < ls; i++)
		{
			if (s[i] == '?')
				cout << "a";
			else
				cout << s[i];
		}
		cout << endl;
	}
	else
		cout << "UNRESTORABLE";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n,M[MAX][MAX];
void dijkstra(){
  int v,u,i,minv;
  int d[MAX],color[MAX];
  for(i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }
  d[0]=0;
  color[0]=GRAY;
  while(1){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK&&M[u][v]!=INFTY){
	if(d[v]>d[u]+M[u][v]){
	  d[v]=d[u]+M[u][v];
	  color[v]=GRAY;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d %d\n",i,(d[i]==INFTY ? -1:d[i]));
  }
}
int main(){
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=INFTY;
    }
  }
  int k,c,u,v;
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d %d",&v,&c);
      M[u][v]=c;
    }
  }
  dijkstra();
  return 0;
}



Measured memory_bytes: 2108
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<cmath>
#define eps 1e-9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<ll,ll> LLP;
const int MAXN=2e3+10;
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const int MOD=1e9+7;
const int LOGN=20;
int s[MAXN<<6];
int t[MAXN<<6];
ll dp[MAXN][MAXN];
signed main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;++i)
        scanf("%d",&s[i]);
    for(int i=1;i<=m;++i)
        scanf("%d",&t[i]);
    for(int i=0;i<=m;++i)
        dp[0][i]=1;
    for(int i=0;i<=n;++i)
        dp[i][0]=1;
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=m;++j)
        {
            if(s[i]!=t[j])
                dp[i][j]=(dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]+MOD)%MOD;
            else
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
        }
    }
    printf("%lld\n",dp[n][m]);
    return 0;
}


Measured memory_bytes: 31744
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chkmax(T& a,T b){return a<b?a=b,1:0;}
template<class T> inline bool chkmin(T& a,T b){return a>b?a=b,1:0;}
template<typename T> inline T& read(T& x){
    static char c; bool flag=0;
    while(!isdigit(c=getchar())) if(c=='-') flag=1;
    for(x=c-'0';isdigit(c=getchar());(x*=10)+=c-'0');
    if(flag) x=-x;
    return x;
}
string s;
int main(){
#ifdef xffyjq
    freopen("exec.in","r",stdin);
    freopen("exec.out","w",stdout);
#endif
    cin>>s;
    if(s.substr(0,4)=="YAKI") puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    const int N=1e5+5;
    #define ll long long
    const ll md=1e9+7;
    ll dp[N][15];
     string s;
      	int n;
    ll solve(int idx,int val)
    {	
    	ll &ret=dp[idx][val];
      	if(ret>=0)
          return ret;
      	ret=0;
    	if(idx==n)
        {
          ret=(val==5);	
          return ret;
        }
      	if(s[idx]=='?')
        {
         	int tmp;
          	for(int i=0;i<10;i++)
            {
              tmp=(val*10+i)%13;
              ret+=(solve(idx+1,tmp));
              ret%=md;
            }
        }
      	else{
          int v=s[idx]-'0';
         	val=(val*10+v)%13;
          	ret+=solve(idx+1,val);
          	ret%=md;
        }
      return ret%=md;
     
    }
     
    int main()
    {
    	cin>>s;
      	n=s.size();
      	memset(dp,-1ll,sizeof (dp));
      
      	cout<<solve(0,0)<<endl;
    }

Measured memory_bytes: 19968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}


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

int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long test=1;
// 	cin>>test;	
	while(test--)
	{
	long a,b=0,c=0,k,i,n,j,temp,mini,maxi,ans,q;
	string s;
	cin>>s;
	for(i=0;i<s.length()-1;i++)
	{
	    if(s[i]==s[i+1])
	    {
	        cout<<i+1<<" "<<i+2<<endl;
	        return 0;
	    }
	}
	for(i=0;i<s.length()-2;i++)
	{
	    if(s[i]==s[i+2])
	    {
	        cout<<i+1<<" "<<i+3<<endl;
	        return 0;
	    }
	}
	cout<<-1<<" "<<-1<<endl;
	
    }
    
}


Measured memory_bytes: 512
package main

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

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

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

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

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

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

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

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

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 4
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}

	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	a := getNextInt(scanner)
	b := getNextInt(scanner)
	c := getNextInt(scanner)
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		ss[i] = getNextString(scanner)
	}
	ans := make([]string, n)
	if dfs(0, n, a, b, c, ss, ans) {
		fmt.Fprintln(writer, "Yes")
		for i := 0; i < n; i++ {
			fmt.Fprintln(writer, ans[i])
		}
		return
	}
	fmt.Fprintln(writer, "No")
}

func dfs(i, n, a, b, c int, ss, ans []string) bool {
	if a < 0 {
		return false
	}
	if b < 0 {
		return false
	}
	if c < 0 {
		return false
	}
	if i == n {
		return true
	}
	switch ss[i] {
	case "AB":
		ans[i] = "A"
		if dfs(i+1, n, a+1, b-1, c, ss, ans) {
			return true
		}
		ans[i] = "B"
		if dfs(i+1, n, a-1, b+1, c, ss, ans) {
			return true
		}
	case "AC":
		ans[i] = "A"
		if dfs(i+1, n, a+1, b, c-1, ss, ans) {
			return true
		}
		ans[i] = "C"
		if dfs(i+1, n, a-1, b, c+1, ss, ans) {
			return true
		}
	case "BC":
		ans[i] = "B"
		if dfs(i+1, n, a, b+1, c-1, ss, ans) {
			return true
		}
		ans[i] = "C"
		if dfs(i+1, n, a, b-1, c+1, ss, ans) {
			return true
		}
	}
	return false
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

#define MAX 2000
#define SENTINEL 20000000

int L[MAX/2 + 2], R[MAX/2 + 2];

ll cst = 1000000007;

ll merge(int A[], int n, int left, int mid, int right){
    int i, j, k;
    ll cnt = 0;
    int n1 = mid - left;
    int n2 = right - mid;
    REP(i,n1) L[i] = A[left + i];
    REP(i,n2) R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEL;
    i = j = 0;
    for(k = left; k < right; k++){
        if( L[i] <= R[j]){
            A[k] = L[i++];
        }
        else{
            A[k] = R[j++];
            cnt += n1 - i; //mid + j - k -1
        }
    }
    return cnt;
}

ll mergeSort(int A[], int n, int left, int right){
    int mid;
    ll v1, v2, v3 = 0;
    if(left + 1 < right){
        mid = (left + right)/2;
        v1 = mergeSort(A,n,left,mid);
        v2 = mergeSort(A,n,mid,right);
        v3 = merge(A,n,left,mid,right);
        return v1 + v2 + v3;
    }
    else{return 0;}
}

int main(){
// ここに処理を記述

    int A[MAX], N, i;
    ll K;
    cin >> N >> K;
    REP(i,N) cin >> A[i];

    ll ans1 = mergeSort(A,N,0,N);

    sort(A, A+N);
    int B[MAX];
    REP(i,N) B[i] = 0;
    REP(i,N-1){
        if(A[i+1] > A[i]) B[i+1] = 1;
    }
    FOR(i,1,N){
        if(B[i] == 1) B[i] = i;
        else B[i] = B[i-1];
    }
    
    ll ans2 = accumulate(B, B + N, 0) % cst;

    ll combi = K*(K-1)/2 % cst;

    ll ans = (ans1 * K + ans2 * combi) % cst;

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <iostream>
#include <queue>
#include <set>
#define ll long long
#define sf(a) scanf("%lld",&a)
#define pf(b) printf("%lld",b)
#define sp printf(" ")
#define nw printf("\n")
#define mp make_pair
#define pi pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define fast ios_base::sync_with_stdio(false)
using namespace std;

vector<ll> adj[200009];
ll mark[200009];
ll num;

void dp(ll source)
{
  if(mark[source]) return;
  num++;
  mark[source]=1;
  for(auto e:adj[source])
    dp(e);
}
int main()
{ 
  ll n,m,ans=0;
  sf(n),sf(m);
  for(ll i=0;i<m;i++)
  {
    ll x,y;
    sf(x),sf(y);
    adj[x].pb(y);
    adj[y].pb(x);
  }
  for(ll i=1;i<=n;i++)
  {
    if(!mark[i])
    {
      num=0;
      dp(i);
      ans=max(ans,num);
    }
  }
  pf(ans);
}



Measured memory_bytes: 21816
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

ll H,W;
ll a[1010][1010];
ll dp[1010][1010];
bool used[1010][1010];

ll solve(ll s,ll t){
  if(s==H && t==W) return 1;
  if(s>H || t>W) return 0;
  if(a[s][t]==-1) return dp[s][t]=0;
  if(used[s][t]) return dp[s][t];
  used[s][t]=true;
  dp[s][t]=(solve(s+1,t)%MOD+solve(s,t+1)%MOD)%MOD;
  return dp[s][t];
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> H >> W;
  char c;
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      dp[i][j]=0;
      cin >> c;
      if(c=='.'){
        a[i][j]=1;
      }else{
        a[i][j]=-1;
      }
    }
  }
  dp[1][1]=1;
  ll ans=solve(1,1)%MOD;
  cout << ans%MOD << endl;
  return 0;
}

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

int main(){
    int A[101][101], B[101][101];
    long long C[101][101];
    
    int n, m, l;
    cin >> n >> m >> l;
    
    //matrix A
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> A[i][j];
        }
    }
    
    //matrix B
    for(int j = 0; j < m; j++){
        for(int k = 0; k < l; k++){
            cin >> B[j][k];
        }
    }
    
    //matrix C
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            C[i][j] = 0;
            for(int k = 0; k < m; k++){
                C[i][j] += A[i][k] * B[k][j];
            }
            
            if(j){
                cout <<" ";
            }
            cout << C[i][j];
        }
        cout << endl;
    }
    return 0;
}


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

using namespace std;

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

  int N, A, B;
  cin >> N >> A >> B;
  string S;
  cin >> S;

  int counter = 0;
  int counter_b = 0;
  vector<bool> result(N, false);
  int limit = A + B;
  int i = 0;
  for (auto c : S) {
    if (counter >= limit) {
      break;
    }
    if (c == 'a') {
      result.at(i) = true;
      ++counter;
    } else if (c == 'b' && counter_b < B) {
      result.at(i) = true;
      ++counter;
      ++counter_b;
    } else {
      ++i;
      continue;
    }
    ++i;
  }

  for (auto b : result) {
    if (b) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 3768
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

long long dp[100][2];

int main() {
    int N;
    long long K;
    cin >> N >> K;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    
    for (int i = 0; i < 100; ++i) dp[i][0] = dp[i][1] = -1;
    dp[45][0] = 0;
    for (int d = 44; d >= 0; --d) {
        long long mask = 1LL<<d;
        int num = 0;
        for (int i = 0; i < N; ++i) if (A[i] & mask) ++num;
        
        if (dp[d+1][1] >= 0) chmax(dp[d][1], dp[d+1][1] + mask * max(num, N-num));
        
            if (K & (1LL<<d)) {
                chmax(dp[d][1], dp[d+1][0] + mask * num);
                chmax(dp[d][0], dp[d+1][0] + mask * (N-num));
            }
            else {
                chmax(dp[d][0], dp[d+1][0] + mask * num);
            }
        
    }
    cout << max(dp[0][0], dp[0][1]) << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#define ll long long

using namespace std;

const int mod=1e9+7;
int n,m;
ll dp[52][52][2660]={0};

int main()
{
    int i,j,k;
    cin>>n>>m;
    dp[0][0][0]=1;
    //dp[0][1][1]=1;
    for(i=0;i<n;i++)
    {
        for(j=0;j<i+1;j++)
            for(k=0;k<m+1;k++)
            {
                //if(k+2*j>n*n)
                    //continue;
                ll now=dp[i][j][k];

                (dp[i+1][j+1][k+(j+1)*2%mod]+=now)%=mod;
                (dp[i+1][j][k+j*2%mod]+=now)%=mod;
                if(j>0)
                    (dp[i+1][j-1][k+(j-1)*2%mod]+=now*j*j%mod)%=mod;
                (dp[i+1][j][k+j*2%mod]+=now*j*2%mod)%=mod;
            }
    }
    int ans=0;
    printf("%lld\n",dp[n][0][m]%mod);
    return 0;
}


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

int main()
{
  int n,i=1;

  cin >> n;
  while(++i<=n){
    int x = i;
    if(x%3==0)
      cout << " " << i;
    else if(x%10==3)
      cout << " " << i;
    else{
      while(x/=10){
	if(x%10==3){
	  cout << " " << i;
	  break;
	}
      }
    }
  }

  cout << endl;

  return 0;
}

Measured memory_bytes: 3100
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <iostream>
#include <algorithm>
typedef long long ll;
using namespace std;
const int maxn=100100;
int n,num1[maxn],num2[maxn];
struct node{
    int num,cnt;
};

node sum1[maxn],sum2[maxn];

bool cmp(node n1,node n2){
    return n1.cnt>n2.cnt;
}

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        if(i&1) scanf("%d",&num1[(i+1)/2]);
        else scanf("%d",&num2[i/2]);
    }
    sort(num1+1,num1+(n/2)+1);
    sort(num2+1,num2+(n/2)+1);
    int x1=1,x2=1;
    sum1[x1].cnt=1;sum1[x1].num=num1[1];
    sum2[x2].cnt=1;sum2[x2].num=num2[1];
    for(int i=2;i<=(n/2);i++){
        if(num1[i]==num1[i-1]){
            sum1[x1].cnt++;
        }else sum1[++x1].cnt=1,sum1[x1].num=num1[i];
        if(num2[i]==num2[i-1]){
            sum2[x2].cnt++;
        }else sum2[++x2].cnt=1,sum2[x2].num=num2[i];
    }
    sort(sum1+1,sum1+x1+1,cmp);
    sort(sum2+1,sum2+x2+1,cmp);
    int ans=n;
    if(sum1[1].num!=sum2[1].num){
        ans=((n/2)-sum1[1].cnt)+((n/2)-sum2[1].cnt);
    }else{//相等
        //printf("sbsb  %d  %d\n",x1,x2);
        if(x1>=2){
            if(x2>=2){
                ans=min(((n/2)-sum1[1].cnt)+((n/2)-sum2[2].cnt),((n/2)-sum1[2].cnt)+((n/2)-sum2[1].cnt));
            }else   ans=((n/2)-sum1[2].cnt);
        }else{//x1==1
            if(x2>=2) ans=((n/2)-sum2[2].cnt);
            else ans=(n/2);
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

ll dp[50][2];

int main() {
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> vec(N);
  for (int i = 0; i < N; ++i) {
    cin >> vec[i];
  }
  for (int i = 0; i < 50; ++i) {
    dp[i][0] = dp[i][1] = -1;
  }
  
  dp[45][0] = 0;
  for (int d = 44; d >= 0; --d) {
    ll D = 1LL << d;
    int num1 = 0;
    for (int i = 0; i < N; ++i) {
      if (vec[i] & D) {
        num1++;
      }
    }
    int num0 = N - num1;
    if (dp[d+1][1] >= 0) {
      dp[d][1] = max(dp[d][1], dp[d+1][1] + D * max(num1, num0));
    }
    if (dp[d+1][0] >= 0) {
      if (K & (1LL<<d)) {
        dp[d][1] = max(dp[d][1], dp[d+1][0] + D * num1);
        dp[d][0] = max(dp[d][0], dp[d+1][0] + D * num0);
      }
      else {
        dp[d][0] = max(dp[d][0], dp[d+1][0] + D * num1);
      }
    }
  }
  cout << max(dp[0][0], dp[0][1]) << endl;
  return 0;
}


Measured memory_bytes: 1024
count = 0

def merge(A, left, mid, right):
  global count
  n1 = mid - left
  n2 = right - mid
  L = A[left:left+n1]
  R = A[mid:mid+n2]
  L.append(float("inf"))
  R.append(float("inf"))
  i = 0
  j = 0
  for k in range(left, right):
    count += 1
    if L[i] <= R[j]:
      A[k] = L[i]
      i += 1
    else:
      A[k] = R[j]
      j += 1

def mergeSort(A, left, right):
  if left + 1 < right:
    mid = int((left + right)/2)
    mergeSort(A, left, mid)
    mergeSort(A, mid, right)
    merge(A, left, mid, right)

if __name__ == "__main__":
  n = int(input())
  S = list(map(int, input().split()))
  mergeSort(S, 0, len(S))
  print(" ".join(map(str, S)))
  print(count)

Measured memory_bytes: 68732
N = int(input())
inList = [int(s) for s in input().split(" ")]

sumList = 0
maxList = 0
for i in range(N):
    maxList = max(inList[i], maxList)
    sumList += inList[i]

sumList -= maxList
if maxList < sumList:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define N 200100
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i+=1)
#define rep(i,l,r) for(int i=l;i<=r;i+=1)
#define INF 100000000000000
#define pii pair<int,int>
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int power(int x,int y){
    int res=1LL;
    while(y){
        if(y&1){
            res=(res*x)%MOD;
        }
        x=(x*x)%MOD;
        y=(y>>1);
    }
    return res;
}
vector <int> pr(100000,0);
signed main()
{
    
    speed
    int n,p;cin>>n>>p;
    string s;cin>>s;
    if(p==2){
       int ans=0;
       fn(i,n){
           int xd=s[i]-'0';
           if(xd%2==0){
               ans+=(i+1);
           }
       }
       cout<<ans<<endl;
       exit(0);
    }
    if(p==5){
        int ans=0;
       fn(i,n){
           int xd=s[i]-'0';
           if(xd%5==0){
               ans+=(i+1);
           }
       }
       cout<<ans<<endl;
       exit(0);
    }
    reverse(s.begin(),s.end());
    int res=0;
    int ans=0;
    int t=1;
    pr[0]=1;
    fn(i,n){
        int xd=s[i]-'0';
        res+=(t*xd);
        res%=p;
        t=(t*10)%p;
        ans+=pr[res];
        pr[res]++;
    }
  
    cout<<ans<<endl;

    
    
    
    
    return 0;
}

Measured memory_bytes: 1488
K = gets.chomp.to_i
sum = 0

(1..K).each do |a|
  (1..K).each do |b|
    (1..K).each do |c|
      s = a.gcd(b)
      m = s.gcd(c)
      
      sum = sum + m
    end
  end
end

puts sum

Measured memory_bytes: 14412
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; cin >> n;
  int mx = 0, mn = MOD;

  int ans = 0;
  rep(i, n) {
    int x, y; cin >> x >> y;
    if (mx < x) {
      mx = x;
      ans = x + y;
    }
  }

  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int N, M;
set<int> conn[1010];
int cnt1, cnt2; int col[1010];
void dfs(int x, int c)
{
  if(col[x] == 0)
  {
    col[x] = c; if(c==1) ++cnt1; else ++cnt2;
    for(auto a: conn[x])
      dfs(a, 3-c);
  }
  if(col[x] != c){ puts("-1"); exit(0); }
}
int main()
{
  scanf("%d%d", &N, &M);
  for(int i=1; i<=N; ++i)
    for(int j=1; j<=N; ++j)
      if(i!=j) conn[j].insert(i);
  for(int i=0; i<M; ++i)
  {
    int u, v; scanf("%d%d", &u, &v);
    conn[u].erase(v); conn[v].erase(u);
  }
  int base = 0;
  vector<int> C;
  for(int i=1; i<=N; ++i)
  {
    if(col[i] == 0)
    {
      cnt1 = cnt2 = 0;
      dfs(i, 1);
      base += min(cnt1, cnt2);
      C.push_back(abs(cnt1-cnt2));
    }
  }
  vector<bool> dp(N+1); dp[base] = true;
  for(auto v: C)
  {
    for(int i=N-v; i>=0; --i)
      if(dp[i]) dp[i+v] = true;
  }
  int ans = 0x3f3f3f3f;
  for(int i=0; i<=N; ++i)
    if(dp[i])
    {
      ans = min(ans, i*(i-1)/2 + (N-i)*(N-i-1)/2);
    }
  printf("%d\n", ans);
}

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

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int N; cin>>N;
  vector<int> A(N),B(N);
  REP(i,N) {
    cin>>A[i];
    B[i] = A[i] - i;
  }
  //  pp(A,N);
  //  pp(B,N);
  ll ans = 0;
  map<int, int> cnt;
  for(int i = 1; i < N; i++) {
    cnt[B[i]]++;
  }
  REP(i,N) {
    int idx = -A[i]-i;
    ll tmp = cnt[idx];
    ans += tmp;
    cnt[B[i]]--;
    //    cout << i << " " << idx << " " << tmp << " " << ans << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 21568
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ
int main()
{
    int a, b;
    cin >> a >> b;
    cout << (double)a / b;
}

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

int main(){

	int H, W;

	cin >> H >> W;

	while( H != 0 && W != 0){					//W=0とH=0になるまで繰り返す
		for(int i = 0; i < H; i++){				//縦軸に[＊]を増やして行く
			for(int j = 0; j < W; j++){			//横軸に[＊]を増やして行く
				cout << "#";
			}
			cout << endl ;
		}
		cout << endl;
		cin >> H >> W;
	}

	return 0;
}


Measured memory_bytes: 3120
# Problem https://atcoder.jp/contests/abc095/tasks/abc095_a
# Python 2nd Try


def solver(memo):
    result = 700
    for j in range(len(memo)):
        if memo[j] == 'o':
            result = result + 100
    return result


if __name__ == "__main__":
    result = 0
    result = solver(input())
    print(result)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int h1,m1,h2,m2,k,z=0;
	cin>>h1>>m1>>h2>>m2>>k;
	z=(h2-h1)*60+(m2-m1)-k;
	cout<<z<<endl;
	
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	string s;cin>>s;
	
	//~ cout<<s.size()/3+(s.size()%3>0)<<endl;
	//~ vector<pair<char,int>>v;
	//~ for(char c:s){
		//~ if(v.empty()||v.back().first!=c)v.push_back({c,1});
		//~ else v.back().second++;
	//~ }
	//~ int cnt=0;
	//~ for(auto p:v){
		//~ cnt+=p.second/3+(p.second%3>0);
	//~ }
	//~ cout<<cnt<<endl;
	//~ s.erase(unique(s.begin(),s.end()),s.end());
	//~ cout<<s<<endl;
	//~ cout<<s.size()<<endl;
	string t;t+=s[0];
	vector<string>v{t};
	string cur;
	for(int i=1;i<s.size();i++){
		cur+=s[i];
		if(v.back().size()!=cur.size()||v.back()[cur.size()-1]!=cur.back()){
			v.push_back(cur);
			cur="";
		}
	}
	cout<<v.size()<<endl;
}

Measured memory_bytes: 10996
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    int N,count=0;
    cin >> N;
    int P[N];
    for(int i=0;i<N;i++)cin >> P[i];
    for(int i=0;i<N;i++){
        if(i+1 != P[i])count++;
    }
    if(count<=2)cout << "YES" << endl;
    else cout << "NO" <<endl;
}

Measured memory_bytes: 256
import java.util.stream.*;
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int[] v = IntStream.range(0, n).map(i -> scanner.nextInt()).toArray();
        System.out.println(IntStream.range(0, n).map(i -> v[i] - scanner.nextInt()).filter(i -> i > 0).sum());
    }
}

Measured memory_bytes: 29268
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

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

	cout << r * r << endl;
	return 0;
}


Measured memory_bytes: 256
until(n,m=gets.split.map(&:to_i))==[0,0]do
r,p,a=[],[],[]
n.times{r.unshift(gets.gsub("?",".").split)}
m.times{p<<gets.split}
p.each{|p|r.each{|r|if/#{r[1]}/=~p[0]&&p[1]=~/#{r[2]}/
a<<p*" "if/p/=~r[0]
break
end}}
puts a.size,a
end

Measured memory_bytes: 9448
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<set>
using namespace std;
typedef vector<int> vi;
#define rep(i, n) for(int i = 0; i <(n); ++i)
#define reps(i, m, n) for(int i = m; i < (n); ++i)
#define int long long

signed main(){
    
    
    
    set<char> right;
    right.insert('y');
    right.insert('h');
    right.insert('n');
    right.insert('u');
    right.insert('j');
    right.insert('m');
    right.insert('i');
    right.insert('k');
    right.insert('o');
    right.insert('l');
    right.insert('p');
    

     while (1)
     { int ans=0;
        string s;
        cin >> s; 
        if (s=="#")
        {
            break;
        }
        
    rep(i,s.size())
    {
        if (right.find(s[i])!=right.end())
        {
            s[i]='%';   
        }else
        {
            s[i]='$';
            
        }
        
    }
    
    for(int i=0;i<s.size()-1;i++){
        if(s[i] != s[i+1]){
            ans++;
        }
    }
    
    cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3228
#include <stdio.h>
#include <stdbool.h>

bool is_leap_year(int y);

int get_leap_years(int *leap_years_list, int year_begin, int year_end);

int main(void)
{
    int leap_years_list[1000]; //A.D. 0 - A.D. 3000 の間に閏年は高々1000個しかない

    bool first_set = true; //一つ目のセットの前にだけは改行を入れてはいけないので

    while (true) {
        int year_begin, year_end;

        //読み込み
        scanf("%d %d", &year_begin, &year_end);

        //終了判定
        if (year_begin == 0 && year_end == 0) {
            break;
        }

        //閏年を計算する
        int leap_years_count = get_leap_years(leap_years_list, year_begin, year_end);

        //セットとセットの間には空行を入れる
        if (first_set) {
            first_set = false;
        } else {
            putchar('\n'); //putcharは一文字だけ出力する関数です
        }

        //閏年を出力
        if (leap_years_count == 0) {
            puts("NA"); //putsは与えられた文字列を出力した後改行する関数です
        } else {
            for (int i = 0; i < leap_years_count; i++) {
                printf("%d\n", leap_years_list[i]);
            }
        }
        
    }
}

bool is_leap_year(int y)
{
    if (y % 400 == 0) {
        return true; 
    } else if (y % 100 == 0) {
        return false;
    } else {
        return y % 4 == 0;
    }
}

int get_leap_years(int *leap_years_list, int year_begin, int year_end)
{
    int count = 0;//閏年の個数を数える
    for (int year = year_begin; year <= year_end; year++) {//閏年を配列に代入していく
        if (is_leap_year(year)) {
            leap_years_list[count] = year;
            count++;
        }
    }
    return count;
}

Measured memory_bytes: 1044
#include<iostream>
#include<cmath>
#include<cstdio>
#define PI 3.1415926535897946265338
using namespace std;
struct P{
  double x,y;
};
int n;


int Plot(P p1,P p2,int counter){
  if(counter >= n)return 0; 
  double th = 60.0*(PI/180.0); // degree to rad
  P s,t,u;
  s.x = (2.0 * p1.x + 1.0 * p2.x)/3.0;
  s.y = (2.0 * p1.y + 1.0 * p2.y)/3.0;
  t.x = (1.0 * p1.x + 2.0 * p2.x)/3.0;
  t.y = (1.0 * p1.y + 2.0 * p2.y)/3.0;  
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y ) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y ) * cos(th) + s.y;  

  counter++;
 
  Plot(p1,s,counter);
  printf("%.8lf %.8lf\n",s.x,s.y);
  Plot(s,u,counter);
  printf("%.8lf %.8lf\n",u.x,u.y);
  Plot(u,t,counter);
  printf("%.8lf %.8lf\n",t.x,t.y);
  Plot(t,p2,counter);
   
}


int main(){
  
  const P first = {0.0,0.0},second = {100.0,0.0};

  cin >> n;  
  printf("%.8lf %.8lf\n",first.x,first.y);
  Plot(first,second,0);
  printf("%.8lf %.8lf\n",second.x,second.y);
 

  return 0;
}

Measured memory_bytes: 0