akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException, InterruptedException {
        Scanner sc = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        int[][] gcd = new int[n + 1][n + 1];
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
                gcd[i][j] = gcd(i, j);
        long ans =0;
        for (int a = 1 ; a<=n ; a++)
            for (int b = 1 ; b<=n ; b++)
                for (int c = 1 ; c<=n ; c++)
                    ans+= gcd[gcd[a][b]][c];
                out.println(ans);
        out.flush();
        out.close();
    }

    static int gcd(int n, int m) {
        return m == 0 ? n : gcd(m, n % m);
    }


    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        boolean ready() throws IOException {
            return br.ready();
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        Scanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        int nextChar() throws IOException {
            return next().charAt(0);
        }

        int[] nextIntArray(int n) throws IOException {
            int[] ans = new int[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextInt();
            return ans;
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

    }
}


Measured memory_bytes: 33260
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

string S[3];
int go[3][3000];

bool match(char a, char b) {
	return a == '?' || b == '?' || a == b;
}

int main() {
	REP(i, 3) cin >> S[i];
	
	int ord[3];
	iota(ord, ord + 3, 0);
	
	int ans = 0;
	REP(i, 3) ans += S[i].size();
	do {
		fill(go[0], go[3], 0);
		
		REP(i, S[ord[0]].size() + 1) {
			bool ng = false;
			REP(j, S[ord[1]].size()) {
				if (i + j >= S[ord[0]].size()) break;
				if (!match(S[ord[0]][i + j], S[ord[1]][j])) {
					ng = true;
					break;
				}
			}
			if (!ng) go[0][i] = true;
		}
		
		REP(i, S[ord[1]].size() + 1) {
			bool ng = false;
			REP(j, S[ord[2]].size()) {
				if (i + j >= S[ord[1]].size()) break;
				if (!match(S[ord[1]][i + j], S[ord[2]][j])) {
					ng = true;
					break;
				}
			}
			if (!ng) go[1][i] = true;
		}
		
		REP(i, S[ord[0]].size() + 1) {
			bool ng = false;
			REP(j, S[ord[2]].size()) {
				if (i + j >= S[ord[0]].size()) break;
				if (!match(S[ord[0]][i + j], S[ord[2]][j])) {
					ng = true;
					break;
				}
			}
			if (!ng) go[2][i] = true;
		}
		
		REP(i, S[ord[0]].size() + 1) {
			REP(j, max(S[ord[1]].size(), S[ord[0]].size()) + 1) {
				if (!go[0][i]) continue;
				if (j < S[ord[1]].size() && !go[1][j]) continue;
				if (i + j < S[ord[0]].size() && !go[2][i + j]) continue;
				
				int cur = S[ord[0]].size();
				chmax(cur, i + S[ord[1]].size());
				chmax(cur, i + j + S[ord[2]].size());
				chmin(ans, cur);
			}
		}
	} while (next_permutation(ord, ord + 3));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 2e5+10;
ll n, k;
ll a[maxn], f[maxn];
bool cmp(ll a, ll b){
	return a>b;
}
bool judge(ll x){
	ll ans=0;
	for(int i=0; i<n; i++){
		if(a[i]*f[i] > x){
			ans += a[i]-x/f[i];
		}
	}
	return ans <= k;
}
int main(){
	ios::sync_with_stdio(0);
	cin >> n >> k;
	for(int i=0; i<n; i++)
		cin >> a[i];
	for(int i=0; i<n; i++)
		cin >> f[i];
	sort(a, a+n);
	sort(f, f+n, cmp);
	ll l=-1, r=1e12+10;
	while(abs(r-l) > 1){
		ll mid = (l+r)/2;
		if(judge(mid)){
			r=mid;
		}
		else
			l=mid;
	}
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 3328
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000)
INF = 1<<32


def solve(N: int, A: int, B: int, P: "List[int]"):
    P.sort()
    from bisect import bisect_left, bisect_right
    x = bisect_right(P, A)
    y = bisect_right(P, B)

    print(min(x, y-x, N-y))

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B, P)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
    if(c>=a&&b>=c){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;

int main() {
  int N, L;
  cin >> N >> L;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    A[i] = L + (i + 1) - 1;
  }
  int total = 0;
  for (int i = 0; i < N; ++i) {
    total += A[i];
  }
  int ans = total - A[0];
  for (int i = 0; i < N; ++i) {
    int tmp = total - A[i];
    if (abs(total - tmp) < abs(total - ans)) ans = tmp;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=100000000000000LL;
const ll r197=1000000007;
const ll MAX_N=1<<17;
typedef pair<int,int>P;
typedef pair<int,P>Pa;
typedef pair<int,string> Q;
int kx[4]={0,1,0,-1},ky[4]={1,0,-1,0};
bool Inframe(int a,int b,int h,int w,int k){
	if(a+ky[k]>=0&&a+ky[k]<h&&b+kx[k]>=0&&b+kx[k]<w)return true;
	return false;
}
//void swap(ll a,ll b){
//	ll d;
//	d=a;
//	a=b;
//	b=d;
//	return;
//}
ll mypow(ll x,ll m){
	if(m==0)return 1;
	if(m%2==0){
		ll x2=mypow(x,m/2);
		return x2*x2;
	}else{
		ll x2=mypow(x,m/2);
		return x2*x2*x;
	}
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
//    	cout<<b<<endl;
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll n;
int numx[10]={0,1,1,1,2,2,2,3,3,3},numy[10]={0,0,1,2,0,1,2,0,1,2};
int cost[10][100005];
int main() {
	cin>>n;
	if(n%2==1){
		cout<<0<<endl;
		return 0;
	}
	ll ans=0;
	n/=2;
	while(n){
		ans+=n/5;
		n/=5;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			var b = cin.ArrayInt(n - 1);
			long sum = 0;
			for (int i = 0; i < n; i++) {
				if (i == 0) {
					sum += b[i];
				} else if (i == n - 1) {
					sum += b[n - 2];
				} else {
					sum += Math.Min(b[i], b[i - 1]);
				}
			}

			Console.WriteLine(sum);
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

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

		public long Long()
		{
			return long.Parse(Next());
		}

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

		public double Double()
		{
			return double.Parse(Next());
		}

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

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

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

    int n;
    cin >> n;

    int p[60] = {};

    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;

        ll t = 1;
        for (int k = 0; k < 60; k++) {
            if (a & t) p[k]++;
            t <<= 1;
        }
    }

    ll r = 0;
    for (int k = 0; k < 60; k++) {
        r += (1LL << k) % P * p[k] % P * (n - p[k]) % P;
    }
    r %= P;

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
 
using namespace std;
int MOD = 1000000007;
#define N 100010
int par[N];
int rnk[N];

void init(int n){
    for(int i=0;i<n;i++){
        par[i] = i;
        rnk[i] = 0;
    }
}

int find(int x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
}

void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(rnk[x] < rnk[y]) par[x] = y;
    else{
        par[y] = x;
        if(rnk[x] == rnk[y]) rnk[x]++;
    }
}

bool same(int x,int y){
    return find(x) == find(y);
}


signed main(){

    int n;
    cin >> n;
    init(n);

    vector<pair<int,int>> px(n);
    vector<pair<int,int>> py(n);
    vector<pair<int,pair<int,int>>> e(2*(n-1));
    
    rep(i,n){
        int x,y;
        cin >> x >> y;
        px[i] = MP(x,i);
        py[i] = MP(y,i);
    }
    SORT(px);
    SORT(py);
    rep(i,n-1){
        e[i] = MP(px[i+1].fi-px[i].fi,MP(px[i+1].se,px[i].se));
        e[n-1+i] = MP(py[i+1].fi-py[i].fi,MP(py[i+1].se,py[i].se));
    }
    SORT(e);
    int ans = 0;
    rep(i,2*(n-1)){
        if(!(same(e[i].se.fi,e[i].se.se))){
            ans += e[i].fi;
            unite(e[i].se.fi,e[i].se.se);
        }
    }

    cout << ans << endl;

    return 0;   
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://ddcc2019-final.contest.atcoder.jp/tasks/ddcc2019_final_a
// rm -r -f test;oj dl http://arc076.contest.atcoder.jp/tasks/arc076_b

Measured memory_bytes: 9728
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    string s; cin >> s;
    string t;
    int n = s.size();
    rep(i,n){
        if(s[i] != 'x') t += s[i];
    }
    int m = t.size();
    bool ok = true;
    rep(i,m){
        if(t[i] != t[m-i-1]) ok = false;
    }
    if(!ok){
        cout << -1 << endl;
        return 0;
    }
    vector<int> v;
    int cnt = 0;
    rep(i,n){
        if(s[i] == 'x') cnt++;
        else{
            v.push_back(cnt);
            cnt = 0;
        }
    }
    v.push_back(cnt);
    int k = v.size();
    ll ans = 0;
    rep(i,k/2){
        ans += abs(v[i]-v[k-i-1]);
    }
    cout << ans << endl;
}



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

int main() {
    int n, m, q;
    int baton_count, query, idx=0;
    cin >> n >> m >> q;
    vector<int> previous_node(n);
    vector<int> next_node(n);
    vector<int> rem(n, 1);

    // n = 5:
    // previous_node = [4, 0, 1, 2, 3]
    // next_node     = [1, 2, 3, 4, 0]
    //
    // erase idx 3:
    // previous_node = [4, 0, 1, 2, 2]
    // next_node     = [1, 2, 4, 4, 0]

    for (int i=0; i<n; i++) {
        previous_node[i] = (i + n - 1) % n;
        next_node[i] = (i + 1) % n;
    }

    for (int i=0; i<m; i++) {
        cin >> baton_count;
        if (baton_count % 2 == 0) {
            baton_count %= n - i;
            while (baton_count--) {
                // clockwise
                idx = next_node[idx];
            }
        }
        else {
            baton_count %= n - i;
            while (baton_count--) {
                // counterclockwise
                idx = previous_node[idx];
            }
        }
        previous_node[next_node[idx]] = previous_node[idx];
        next_node[previous_node[idx]] = next_node[idx];
        rem[idx] = 0;
        idx = next_node[idx];
    }

    for (int i=0; i<q; i++) {
        cin >> query;
        if (rem[query]) {
            cout << 1 << endl;
        } else {
            cout << 0 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3380
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define plll pair<pll,ll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;


int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll n;
    cin>>n;
    
    ll arr1[n];
    for(ll i=0;i<n;i++)
    {
        cin>>arr1[i];
    }
    sort(arr1,arr1+n);
    ll negcount=1;
    ll count1=0;
    for(ll i=0;i<(n-1);i++)
    {
        if(arr1[i]<0)
        {
            count1++;
        }
        else
        {
            break;
        }
    }
    negcount=max(negcount,count1);
    pll step[n-1];
    ll result,val;
    if(negcount==(n-1))
    {
        step[0].first=arr1[n-1];
        step[0].second=arr1[n-2];
        result=arr1[n-1]-arr1[n-2];
        for(ll i=0;i<(n-2);i++)
        {
            step[i+1].first=result;
            step[i+1].second=arr1[i];
            result-=arr1[i];
        }
        cout<<result<<endl;
        for(ll i=0;i<(n-1);i++)
        {
            cout<<step[i].first<<" "<<step[i].second<<endl;
        }
        exit(0);
    }
    result=0;
    for(ll i=0;i<n;i++)
    {
        if(i<negcount)
        {
            result-=arr1[i];
        }
        else
        {
            result+=arr1[i];
        }
    }
    cout<<result<<endl;
    cout<<arr1[0]<<" "<<arr1[negcount]<<endl;
    result=arr1[0]-arr1[negcount];
    for(ll i=negcount+1;i<(n-1);i++)
    {
        cout<<result<<" "<<arr1[i]<<endl;
        result-=arr1[i];
    }
    cout<<arr1[n-1]<<" "<<result<<endl;
    result=arr1[n-1]-result;
    for(ll i=1;i<negcount;i++)
    {
        cout<<result<<" "<<arr1[i]<<endl;
        result-=arr1[i];
    }
    return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string a,b;
    cin >> a >> b;
    if(a.size() > b.size()){
      	//aの文字列がbの文字列の長さより大きい時
        cout << "GREATER" << endl;
    }else if(a.size() < b.size()){
      	//aの文字列がbの文字列の長さより小さい時
        cout << "LESS" << endl;
    }else{//サイズが同じ時
        if(a.compare(b) > 0){
            //aの方が大きい時
            cout << "GREATER" << endl;
        }else if(a.compare(b) < 0){
          	//aの方が小さい時
            cout << "LESS" << endl;
        }else{
            cout << "EQUAL" << endl;
        }
    }
}

Measured memory_bytes: 256
N, M = input().split()
N = int(N)
M = int(M)

pdic = {i:[] for i in range(N)}
ppdic = {i:[] for i in range(N)}
outidx = {}
pl = []

for i in range(M):
    p, y = input().split()
    p = int(p)-1
    y = int(y)
    pl.append(p)
    pdic[p].append(y)
    outidx[i] = y

for i in range(N):
    if len(pdic[i]) ==0:
        continue

    pdic[i] = sorted(pdic[i])
    ppdic[i] = {jj : j for j, jj in enumerate(pdic[i])}
#print(ppdic)
#print(pdic)
for i, j in enumerate(pl):
    #print(pdic[j])
    ii = ppdic[j][outidx[i]]
    ##print(ii)
    print('{:06}{:06}'.format(1+j, ii+1))

Measured memory_bytes: 80236
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<deque>
#include<iomanip>
#include<tuple>
#include<stack>

#define _USE_MATH_DEFINES
#include<math.h>


using namespace std;
typedef long long ll;

typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef tuple<int, int, int> ti3;

const ll MOD_CONST = 1000000007;
//const ll MOD_CONST = 998244353;


const int BIG_NUM = 1000000005;
const ll INF = 1000000000000000000;

//const vector<vector<int>> DIR{ {1,0},{0,1},{-1,0},{0,-1} };

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
	cout << x << " " << y << " " << z << endl;
}


Measured memory_bytes: 256
def f(i):
    if i == ls + 1:
        for j in range(ls + 1):
            if u[j] == 1:
                t[2 * j] = "A"
            else:
                t[2 * j] = ""
        if "".join(t) == "AKIHABARA":
            print("YES")
            exit()
        return
    u[i] = 1
    f(i + 1)
    u[i] = 0
    f(i + 1)

s = list(input())
ls = len(s)
if ls >= 10:
    print("NO")
    exit()
t = ["" for _ in range(2 * ls + 1)]
for i in range(ls):
    t[2 * i + 1] = s[i]
n = ls + 1
u = [0] * n
f(0)
print("NO")

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

int main() {
  // 入力
  string S;
  cin >> S;

  int digit = S.size(); // 入力の桁数
  int ans = 1000;
  
  // 数字列を左から順に3桁の数値へ変換
  for (int i = 0; i < digit - 2; i++) {
    int X = 0;
    X = S[i] - '0';
    for (int j = 1; j < 3; j++) {
      X = X * 10 + S[i + j] - '0';
    }
    ans = min(abs(753 - X), ans);
  }
  // 出力
  cout << ans << endl;
}


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

int main(){
    int n;
    cin >> n;
    vector <int> a(n);
    vector <int> num(100001,0);
    ll ans=0;
    rep(i,n){
    cin >> a[i];
    ans+=a[i];
    ++num[a[i]];
    }
    int q;
    cin >> q;
    vector <int>  b(q),c(q);
    rep(i,q){
        cin >> b[i] >> c[i]; 
    }
    vector <ll> ans2(q);
    sort(a.begin(),a.end());
    rep(i,q){
        ans+=(c[i]-b[i])*num[b[i]];
        ans2[i]=ans;
        num[c[i]]+=num[b[i]];
        num[b[i]]=0;
    }

    rep(i,q){
        cout << ans2[i] << endl;
    }


    

    return 0;
}

Measured memory_bytes: 5540
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int input[n];
  for(int i=0;i<n;i++)
  {
    cin >> input[i];
  }
  // 10, 30, 40, 20
  // 0,  20, 30  30
  int dp [n+1];
  dp[0]=0;
  dp[1]=abs(input[1]-input[0]);
  for(int i=2;i<n;i++)
  {
    dp[i]=min(dp[i-1]+abs(input[i]-input[i-1]),dp[i-2]+abs(input[i]-input[i-2]));
  } 
  cout << dp[n-1];
}

Measured memory_bytes: 4324
N,L = map(int, input().split())

List = [0]*N
c = 10**6
for i in range(N):
    List[i] = L+i
    c = min(c, abs(L+i))
    
for i in range(N):
    if List[i] == c or List[i] == -c:
        List[i] = 0
        break
        
print(sum(List))

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

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

    if(in == "Sunny"){
        cout << "Cloudy" << endl;
    }
    else if(in == "Cloudy")
    {
        cout << "Rainy" << endl;
    }
    else if(in == "Rainy")
    {
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
ll pow1(ll a, ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
		{
			ans=ans*a;
		}
		a=a*a;
		b=b>>1;
	}
	return ans;
}
ll dp[1005][1005];
char arr[1005][1005];
ll mod = 1000000007;
int main()
{
	int n,m,i,j;
	cin>>n>>m;
	for(i=0;i<n;i++)
		for(j=0;j<m;j++)
			cin>>arr[i][j];
	dp[0][0] = 1;
	for(i=1;i<n;i++)
		if(arr[i][0] == '.' && arr[i-1][0] != '#')
			dp[i][0] = dp[i-1][0];
		else
			break;
	for(i=1;i<m;i++)
		if(arr[0][i] == '.' && arr[0][i-1] != '#')
			dp[0][i] = dp[0][i-1];
		else
			break;
	for(i=1;i<n;i++)
		for(j=1;j<m;j++)
			if(arr[i][j] == '.')
				dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod;
	cout<<dp[n-1][m-1]<<endl;
	return 0;
}

Measured memory_bytes: 9088
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')

def main():
  c = input()
  print(chr(ord(c)+1))
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 5076
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<61;
const double pi=acos(-1);
const double eps=1e-10;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll n,l;
vs a;

int f(string s,string t){
	int i=0;
	while(s[i]==t[i]) i++;
	return i;
}

ll g(ll x){
	if(!x) return 0;
	ll y=1,t=0;
	while(y<x){
		y*=2;
		t++;
	}
	if(y==x) return 1ll<<t;
	return g(x-y/2);
}

int main(){
	cin>>n>>l;
	a=vs(n);
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a.begin(),a.end());
	ll x=0;
	for(int i=0;i<n-1;i++){
		int t=f(a[i],a[i+1]);
		for(int j=t;j<=a[i].size()-1;j++) x^=g(l-j);
	}
	for(int i=0;i<a[n-1].size();i++) x^=g(l-i);
	if(x) cout<<"Alice"<<endl;
	else cout<<"Bob"<<endl;
}

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

using namespace std ;

int main() {

    long long int a, b ,c , l,m,n, ans1=0 ,ans2=0 ;

    cin >> a >> b >> c ;

    l= b+c ;


//    cout << l<<m;

    if (a+b>=c-1)
    {
        cout << l <<endl ;
        return 0;
    }
    else
        cout << a+1+b*2 <<endl ;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int N, a[100010];

    cin >> N; 

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

    int ans = 0;
    
    for (int i = 0; i < N; i++)
    {
        while (a[i] % 2 == 0)
        {
            a[i] = a[i] / 2;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
#define rint register int
#define rep(i,l,r) for(rint i=l;i<=r;i++)
#define per(i,l,r) for(rint i=l;i>=r;i--)
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define fir first
#define sec second
#define mset(s,t) memset(s,t,sizeof(s))
template<typename T1,typename T2>void ckmin(T1 &a,T2 b){if(a>b)a=b;}
template<typename T1,typename T2>void ckmax(T1 &a,T2 b){if(a<b)a=b;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
int read(){
  int x=0,f=0;
  char ch=getchar();
  while(!isdigit(ch))f|=ch=='-',ch=getchar();
  while(isdigit(ch))x=10*x+ch-'0',ch=getchar();
  return f?-x:x;
}
const int mod=1e9+7;
const int N=2005;
int qpow(int a,int b){
  int res=1;
  while(b>0){
    if(b&1)res=1ll*res*a%mod;
    a=1ll*a*a%mod;
    b>>=1;
  }
  return res;
}
int fac[N],ifac[N];
void init(int n){
  fac[0]=ifac[0]=1;
  for(int i=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%mod;
  ifac[n]=qpow(fac[n],mod-2);
  for(int i=n-1;i>=1;i--)ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
}
int C(int n,int m){
  if(n<m)return 0;
  else return 1ll*fac[n]*ifac[n-m]%mod*ifac[m]%mod;
}
int main(){
  init(2000);
  int n;
  cin>>n;
  int ans=0;
  for(int i=1;i<=n/3;i++){
    ans=(ans+C(n-2*i-1,i-1))%mod;
  }
  cout<<ans<<'\n';
}

Measured memory_bytes: 3648
x=input().split()

answer=[]
for i in range(len(x)):
    if x[i].isdigit():
        answer.append(int(x[i]))
    elif x[i]=="+":
        t=answer.pop()+answer.pop()
        answer.append(t)
    elif x[i]=="-":
        t=-1*(answer.pop()-answer.pop())
        answer.append(t)
    elif x[i]=="*":
        t=answer.pop()*answer.pop()
        answer.append(t)

print(*answer)
    

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

const int kN = 200'000 + 5;
const int kInf = 1'000'000'000;
vector<int> g[kN];
int d[kN], ed[kN], w[kN];
bool used[kN];
char ans[kN];

int main() {
    int n, m; scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i) scanf("%d", &d[i]);
    for (int i = 0; i < m; ++i) {
        int u, v; scanf("%d%d", &u, &v);
        u--, v--;
        ed[i] = u ^ v;
        g[u].push_back(i);
        g[v].push_back(i);
        w[i] = kInf;
    }
    set<pair<int, int>> s;
    for (int i = 0; i < n; ++i) s.insert(make_pair(d[i], i));
    while (!s.empty()) {
        int r = s.begin()->second;
        s.erase(s.begin());
        bool ok = false;
        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
        ans[r] = 'B';
        used[r] = true;
        for (int e : g[r]) {
            int u = ed[e] ^ r; 
            if (used[u]) continue;
            used[u] = true;
            ok |= d[u] == d[r];
            w[e] = d[u];
            pq.emplace(d[u], u);
            ans[u] = 'W';
        }
        if (!ok) {
            puts("-1");
            return 0;
        }
        while (!pq.empty()) {
            int x = pq.top().second;
            pq.pop();
            s.erase(make_pair(d[x], x));
            for (int e : g[x]) {
                int u = ed[e] ^ x;
                if (used[u]) continue;
                if (d[u] < d[x]) continue;
                used[u] = true;
                w[e] = d[u];
                ans[u] = ans[x] ^ 'B' ^ 'W';
                pq.emplace(d[u], u);
            }
        }
    }
    printf("%s\n", ans);
    for (int i = 0; i < m; ++i) printf("%d\n", w[i]);
}


Measured memory_bytes: 18204
#include <iostream>
using namespace std;
int a,b,c,x,ans;
int main(void){
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(i*500+j*100+k*50==x)ans++;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int main()
{
	fastIO
	//inp_out();
	ll n;
	cin>>n;
	vll a(n);
	umll mp;
	for(ll i=0;i<n;++i)
	{
		cin>>a[i];
		mp[a[i]]++;
	}

	ll ans=0;
	for(auto i:mp)
	{
		ans+=(i.se*(i.se-1))/2;
	}

	for(ll i=0;i<n;++i)
	{
		ll cnt=mp[a[i]],val=ans;
		val-=((cnt*(cnt-1)))/2;
		val+=((cnt-1)*(cnt-2))/2;
		cout<<val<<"\n";
	}

	return 0;
}



Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> v;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        v.push_back(x);
    }
    
    int dp[n+1];
    dp[0]=0;
    dp[1]=abs(v[1]-v[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
       // cout<<dp[i];
    }
    cout<<dp[n-1];

}


Measured memory_bytes: 1144
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int[] a = new int[n];
    int sum = 0;
    int ans = 0;
    double mingap = Double.MAX_VALUE;

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
      sum += a[i];
    }

    double ave = (1.0 * sum) / n;
    for (int i = 0; i < n; i++) {
      double gap = Math.abs(ave - a[i]);
      if (gap < mingap) {
        mingap = gap;
        ans = i;
      }
    }

    System.out.println(ans);

  }
}

Measured memory_bytes: 36036
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s = sc.next();
		char arr[] = s.toCharArray();
		int wcount=0;
		int count=0;
		for(int i=0;i<N;i++){
		    if(arr[i]=='W'){
		        wcount++;
		    }
		}
		for(int i=N-wcount;i<N;i++){
		    if(arr[i]=='R'){
		        count++;
		    }
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 41068
#include <stdio.h>
int main(void){
   int n;
  int data[4][3][10] = {{{0}}};
  scanf("%d", &n);
  for(int i = 0; i < n; i++) {
    int b, f, r, v;
    scanf("%d %d %d %d", &b, &f, &r, &v);
    data[b-1][f-1][r-1] += v;
  }
 for(int i=0;i<4;i++){
     for(int j=0;j<3;j++){
         for(int k=0;k<10;k++){
             printf(" %d",data[i][j][k]);
         }
         printf("\n");
     }
     if(i!=3)
     printf("####################\n");
 }
 return 0;
}



Measured memory_bytes: 2040
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int n,c;
int D[31][31];
int C[501][501];
int A[3][31];

int main() {
  in(n),in(c);
  loop(i,1,c+1) loop(j,1,c+1) in(D[i][j]);
  loop(i,1,n+1) loop(j,1,n+1) in(C[i][j]);
  loop(i,1,n+1) loop(j,1,n+1) A[(i+j)%3][C[i][j]]++;
  ll ans = 100000000000000000;
  loop(color0,1,c+1) loop(color1,1,c+1) loop(color2,1,c+1) {
    if (color0 == color1 or color1 == color2 or color2 == color0) continue;
    int CC[3] = {color0, color1, color2};
    ll sum = 0;
    loop(original_color,1,c+1) loop(mod,0,3) {
      sum += A[mod][original_color] * D[original_color][CC[mod]];
    }
    ans = min(ans, sum);
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 4612
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int a,b,c;
	std::cin >> a >> b >> c; 
	if(a==b && a!=c) print("Yes");
	else if(a==c && a!=b) print("Yes");
	else if(b==c && a!=b) print("Yes");
	else print("No");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <memory.h>
using namespace std;
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define red(i, a, b) for(int i = (a); i >= (b); i--)
#define ll long long
#define FI first
#define SE second
#define MP make_pair
#define PB push_back

int ans = 1;
int n, m;

int main()
{
	scanf("%d%d", &n, &m);
	rep(i, 1, m) ans *= 2;
	ans *= (1900 * m + 100 * (n - m));
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

using namespace std;
typedef long long int  ll;
typedef pair<int, int> P;

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////

int main() {
ll n;
cin>>n;
ll a[n+1];
ll b[n];
rep(i, n){
cin>>a[i];
b[i-1]=a[i];
}

ll cnt=0;

sort(b,b+n);

rep(i, n){
	ll k=-1;
	ll l=0;
	ll r=n-1;
	for(int w=1;w<=40;w++){
ll mid=(l+r)/2;
if(b[mid]==a[i]) {k=mid+1;
break;}
if(b[mid]>a[i]) r=mid;
if(b[mid]<a[i]) l=mid;

	}
	if(k==-1) k=n;


if((i-k+MOD+1)%2==1){
cnt++;
}
}


cout<<cnt/2<<endl;




}




Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
ll n;
bool flag;
ll dp[200000];
vector<ll> ar = {1,6,9,36,81,216,729,1296,6561,7776,46656,59049};
const ll MOD = 1000000007;
void Main(){    
    cin>>n;
    dp[0]=0;
    For(i,1,n+1){
        dp[i]=i;
        for(auto j:ar){
            if(i-j>=0){
                dp[i]=min(dp[i],dp[i-j]+1);
            }
        }
    }
    cout<<dp[n]<<endl;
}
int main(){
    Main();
    return 0;
}


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

using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (int)n; i++)

const int inf = 1000000000;

int main() {
  int n;
  cin >> n;
  std::vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  int ans = inf;
  for (int i = 1; i <= 100; i++) {
    int cost = 0;
    rep(j,n) cost += (vec.at(j) - i) * (vec.at(j) - i);
    ans = min(ans, cost);
  }
  cout << ans << endl;
  return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int n, m, p;
	string s;
	cin >> n >> m;

	vector<int> problems(n, -1);
	for(int i = 0; i < m; ++i)
	{
		cin >> p >> s;
		p--;
		if (problems[p] <= 0)
		{
			if (s == "WA")
			{
				problems[p]--;
			}
			else if(s == "AC")
			{
				problems[p] *= -1;
			}
		}
	}

	int ans_ac = 0;
	int ans_wa = 0;
	for(const auto& v : problems)
	{
		if (v > 0)
		{
			++ans_ac;
			ans_wa += v - 1;
		}
	}

	cout << ans_ac << " " << ans_wa;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,n;
    cin>>h>>n;
    int a[n+10];
    long long int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum>=h)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 640
bingo = []
bingo.append(list(map(int, input().split(' '))))
bingo.append(list(map(int, input().split(' '))))
bingo.append(list(map(int, input().split(' '))))
matched = [[False for _ in range(3)] for _ in range(3)]
N = int(input())
for n in range(N):
    num = int(input())
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == num:
                matched[i][j] = True
is_bingo = False
if matched[0][0] and matched[1][1] and matched[2][2]:
    is_bingo = True
if matched[0][2] and matched[1][1] and matched[2][0]:
    is_bingo = True
if matched[0][0] and matched[0][1] and matched[0][2]:
    is_bingo = True
if matched[1][0] and matched[1][1] and matched[1][2]:
    is_bingo = True
if matched[2][0] and matched[2][1] and matched[2][2]:
    is_bingo = True
if matched[0][0] and matched[1][0] and matched[2][0]:
    is_bingo = True
if matched[0][1] and matched[1][1] and matched[2][1]:
    is_bingo = True
if matched[0][2] and matched[1][2] and matched[2][2]:
    is_bingo = True
if is_bingo:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: i64 = read();
    let m: i64 = read();

    let n_fact = (2..n + 1).fold(1, |x, a| a * x % MOD);
    let m_fact = (2..m + 1).fold(1, |x, a| a * x % MOD);

    println!(
        "{}",
        if (n - m).abs() > 1 {
            0i64
        } else if n == m {
            n_fact * m_fact * 2 % MOD
        } else {
            n_fact * m_fact % MOD
        }
    );
}

const MOD: i64 = 1_000_000_007;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstring>
#define N 100010
#define mod 1000000007
#define ll long long
using namespace std;
char str[N];
ll f[N];
int nxt[3];
int main()
{
	scanf("%s",str+1);
	int n=strlen(str+1);
	bool same=false;
	for(int i=1;i<n && !same;i++) same=str[i]==str[i+1];
	if(!same){puts("1");return 0;}
	int u=0;
	f[0]=1;
	nxt[1]=nxt[2]=-1;
	for(int i=1;i<=n;i++)
	{
		if(str[i]=='a') u=(u+1)%3;
		else u=(u+2)%3;
		if(!u && i!=n) f[i]=1;
		for(int _=0;_<=1;_++)
		if(nxt[u=(u+1)%3]>=0) f[i]=(f[i]+f[nxt[u]])%mod;
		u=(u+1)%3;
		nxt[u]=i;
	}
	printf("%lld\n",f[n]);
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    LL A,B; cin >> A >> B;

    LL divisor = 2;
    LL half1 = 0;
    LL half2 = 0;
    while(1) 
    {
        dump(divisor)
        if(divisor == 2)
        {
            if(B % 4 == 1 || B % 4 == 2)
            {
                half1 += 1;
            }
            dump(half1)
        }
        else
        {
            half1 += (max(0LL,((B+1) % divisor) - divisor / 2 ) % 2) * (divisor / 2);
            dump(half1)
        }
        
        divisor *= 2;

        if(divisor > B * 2) break;
    }
    divisor = 2;

    if(A != 0)
    {
        while(1) 
        {
            dump(divisor)
            if(divisor == 2)
            {
                if((A-1) % 4 == 1 || (A-1) % 4 == 2)
                {
                    half2 += 1;
                }
                dump(half1)
            }
            else
            {
                half2 += (max(0LL,((A) % divisor) - divisor / 2 ) % 2) * (divisor / 2);
                dump(half2)
            }
            
            divisor *= 2;
    
            if(divisor > (A-1) * 2) break;
        }
    }
    else
    {
        half2 = 0;
    }

    LL ans = half1^half2;

    cout << ans << endl;


}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
            
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        
        //aが一番大きいとき
        if( a > b && a > c && a == b + c )System.out.println("Yes");
        
        //bが
        else if( b > a && b > c && b == a + c )System.out.println("Yes");
            
        //cが
        else if( c > a && c > b && c == a + b )System.out.println("Yes");
        
        else System.out.println("No");
	  }
}

Measured memory_bytes: 21844
package main

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

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for B - Different Distribution
	var N int
	fmt.Scanf("%d", &N)

	sc.Split(bufio.ScanWords)
	var A, B int
	var max int = 0
	var maxnum int
	for i := 0; i < N; i++ {
		A = nextInt()
		B = nextInt()
		if max < A {
			max = A
			maxnum = B
		}
	}

	fmt.Println(max + maxnum)
}


Measured memory_bytes: 5092