akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String s = sc.next();
	String t = sc.next();
	int index = -1;
	int firstIndex = -1;
	for(int i = s.length() - 1; i>=0; i--) {
	    String sb;
	    firstIndex = i-t.length()+1;
	    if(firstIndex<0) break;
	    if(i+1 > s.length()-1) {
		sb = s.substring(firstIndex);
	    }else {
		sb = s.substring(firstIndex, i+1);
	    }
	    for(int j = t.length() - 1; j>=0; j--) {
		char cs = sb.charAt(j);
		char ct = t.charAt(j);

		if(cs == '?' && j == 0) index = firstIndex;
		if(cs == '?') continue;
		if(cs != ct) break;
		if(j == 0) index = firstIndex;
	    }
	    if(index != -1) break;
	}
	if(index == -1) {
	    System.out.println("UNRESTORABLE");
	    return;
	}
	StringBuilder builder = new StringBuilder();
	for(int i = 0; i < s.length(); i++) {
	    if(i == firstIndex) {
		builder.append(t);
		i= i+t.length()-1;
		continue;
	    }
	    char c = (s.charAt(i)=='?')? 'a' : s.charAt(i);
	    builder.append(c);
	}
	System.out.println(builder.toString());

    }
}

Measured memory_bytes: 21844
import java.util.*;

public class Main {
    public static void main(String[] args) {
      Scanner s = new Scanner(System.in);
        final int K = s.nextInt();
        final String S = s.next();

        if (S.length() <= K) {
            System.out.println(S);
        } else {
            System.out.println(S.substring(0, K) + "...");
        }
    }
}

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

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        int H = sc.nextInt();
        int W = sc.nextInt();
        var c = new int[10, 10];
        var A = new int[H, W];
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                c[i, j] = sc.nextInt();
            }
        }
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                A[i, j] = sc.nextInt();
            }
        }

        for (int k = 0; k < 10; k++) {
            for (int i = 0; i < 10; i++) {
                for (int j = 0; j < 10; j++) {
                    c[i, j] = Math.Min(c[i, j], c[i, k] + c[k, j]);
                }
            }
        }

        long ans = 0;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (A[i, j] == -1) continue;
                ans += c[A[i, j], 1];
            }
        }
        WriteLine(ans);
    }

}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        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] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        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] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        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] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13228
N = int(input())

A, B = [], []

a, b = None, None

sum = [0 for i in range(N)]

for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()

if N % 2 == 1:
    print(B[N//2] - A[N//2] + 1)
else:
    print(B[N//2-1]+B[N//2] - A[N//2-1]-A[N//2]+1)

Measured memory_bytes: 26976
#include<bits/stdc++.h>
using namespace std;
#define test(t) int t;cin>>t;while(t--)
#define lli long long int
#define pb push_back
#define MAX 10000007
#define mod 1000000007
//a.push_back(i+'0');convert i to char;
//cout << fixed << setprecision(2) << pi ;
const lli infl=0x3f3f3f3f3f3f3f3fLL;
int prime(lli n)
{int f=1;
    for(lli i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {f=0;break;}
    }if(f==0) return 0;
    return 1;

}
int power(int a,int b)
{
   int result=1;
    while(b>0)
    {  if(b%2)
        result=(a*result)%mod;
        a=(a*a)%mod;
        b=b/2;
    }
    return result%mod;
}
int find_par(int parent[],int d)
{
    if(parent[d]==d)
        return d;
   return parent[d]=find_par(parent,parent[d]);

}
void union_(int parent[],int x,int y,lli a[])
{
    int c=find_par(parent,x);
    int d=find_par(parent,y);
    if(c==d)return;
    if(c!=d) parent[d]=c;

}
int main()
{  ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
    //test(t)
    {
       lli ans=infl,c,d,x,y,z,n,q,m,r,f=0,i=0,j=0,odd=0,even=0;
      lli sum=0,sum1=0,sum2=0,res=0,cur,l,k,area,maxm=-infl,minm=infl,low,high=0,r1,r2,c1,c2;
       string s1,s2,s3,str,s;
       vector<int>v,u;
       cin>>n>>k;
       lli a[n];
        for(i=0;i<n;i++)
            cin>>a[i];
       lli pre[n];
        pre[0]=0;
        pre[1]=abs(a[1]-a[0]);
        for(i=2;i<n;i++)
        {  pre[i]=INT_MAX; for(j=1;j<=k;j++)
             {  if(i>=j)
                pre[i]=min(pre[i-j]+abs(a[i-j]-a[i]),pre[i]);
            }
        }cout<<pre[n-1];
       cout<<endl;
    }
}


Measured memory_bytes: 5192
import java.util.Scanner;

public class Main {
    private static final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        final String[] XKD = sc.nextLine().split(" ");
        final Long X = Math.abs(Long.parseLong(XKD[0]));
        final Long K = Long.parseLong(XKD[1]);
        final Long D = Long.parseLong(XKD[2]);

        final Long M = X / D;
        final Long R = X % D;

        if (M > K) {
            System.out.println((M - K) * D + R);
        } else if ((K - M) % 2 == 0){
            System.out.println(R);
        } else {
            System.out.println(D - R);
        }
    }
}


Measured memory_bytes: 35860
/*
dijodjos
agjiopgs
gjiogjag
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
/*
dijodjos
agjiopgs
gjiogjag
*/
	ios::sync_with_stdio(false);
	int n,l=0,s=0;
	char c;
	cin>>n;
/*
dijodjos
agjiopgs
gjiogjag
*/
	for(register int i=1;i<=n;i++)
	{
		cin>>c;
		if(c=='I') l++;
		if(c=='D') l--;
		s=max(s,l);
	}
/*
dijodjos
agjiopgs
gjiogjag
*/
	cout<<s<<endl;
	return 0;
}
/*
dijodjos
agjiopgs
gjiogjag
*/

Measured memory_bytes: 256
/* author   : mpily :-()
title : Competing.cpp
time :Sat May 30 13:38:34 2020

*/
#include<bits/stdc++.h>
using namespace std;
void solve(){
	int64_t n;
	cin >> n;
	vector<int>can;
	int64_t lim = n;
	for(int64_t i = 2; i * i <= lim && n > 1; ++i){
		if(n%i == 0){
			int cnt = 0;
			while(n%i == 0){
				n/=i;
				cnt++;
			}
			can.push_back(cnt);
		}
	}
	if(n > 1){
		can.push_back(1);
	}
	vector<int>times(64);
	int csum = 1;
	int pos = 2;
	while(csum < 64){
		times[csum] ++;
		csum+=pos;
		pos++;
	}
	for(int i = 1; i < 64; ++i){
		times[i]+=times[i-1];
	}
	int ans = 0;
	for(int x : can){
		ans+=times[x];
		//cout << "adding "<<times[x] <<"\n";
	}
	cout << ans;
}
int main(){
	int t;
	t = 1;
	while(t--){
		solve();
		cout << "\n";
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
#define debug(x) cerr << x << "\n"
#define all(x) (x).begin(),(x).end()
#define exist(s, e)((s).find(e) != (s).end())

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int w, a, b;
    
    cin >> w >> a >> b;
    
    if (a+w < b) cout << b - (a+w) << '\n';
    else if (b+w < a) cout << a - (b+w) << '\n';
    else cout << "0\n";

    return 0;
}

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

using namespace std;
using ll = long long;
using lli = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vlli = vector<lli>;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i > 0; i--)
#define all(v) v.begin(), v.end()
#define debug(x) cout << x << endl
#define vout(v) rep(i, v.size()) cout << v[i] << " ";

int X;

void solve() {
	int ans = 0;
	ans += 1000 * (X / 500);
	X = X % 500;
	ans += 5 * (X / 5);
	X = X % 5;
	cout << ans;
}

int main() {
	cin >> X;

	solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

typedef long long ll;
using namespace std;

ll modpow(ll a, ll b, ll m) {
  if (b==0) return 1;
  ll tmp = modpow(a*a%m,b/2,m);
  if (b&1) tmp = tmp*a%m;
  return tmp;
}

ll mperm(ll a, ll b, ll m) {
  if (a < b) {
    return 0;
  }
  ll ret=1;
  while(b--) {
    ret = (ret*(a--)) % m;
  }
  return ret;
}

ll pminv(ll a, ll p) {
  return modpow(a,p-2,p);
}

ll mcomb(ll a, ll b, ll m) {
  return (mperm(a,b,m)*pminv(mperm(b,b,m),m))%m;
}

int main() {
  ll n,k,mod=1e9+7;
  cin>>n>>k;
  cout<<mcomb(n+k-1,k-1,mod)<<endl;
  return 0;
}


Measured memory_bytes: 3104
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val m = sc.nextLong()
    val v = sc.nextInt()
    val p = sc.nextInt()
    val a = Array(n) { sc.nextInt() }
    a.sortDescending()
    var l = 0
    var r = n
    while (r - l > 1) {
        val mid = (l + r) / 2
        var safe = m * (p - 1 + n - mid)
        for (i in p - 1 until mid) {
            safe += a[mid] + m - a[i]
        }
        if (mid < p || (a[mid] + m >= a[p - 1] && safe >= m * v)) {
            l = mid
        } else {
            r = mid
        }
    }
    println(r)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 48124
N = int(input())
H = list(map(int, input().split())) + [10**10]

cnt = -1
pre = 10**10
ans = -1

for h in H:
    if pre >= h:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
    pre = h
print(ans)


Measured memory_bytes: 20516
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;



int main() {
  long long n, m, ans = 0;
  cin >> n >> m;
  set<long long> s;
  vector<pair<long long, long long> > a(n);
  for(int i = 0; i < n; ++i) cin >> a[i].second >> a[i].first;
  sort(a.begin(), a.end());
  for(int i = 1; i <= m; ++i) s.insert(i);
  for(int i = n - 1; i >= 0; --i){
    auto k = s.lower_bound(a[i].second);
    if(k != s.end()){
      ans += a[i].first;
      s.erase(k);
    }
  }
  cout << ans;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
 
using namespace std;
 
#define REP(i,last) for (int i=0;i<last;i++)
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)
#define prints(str) cout << str << " ";
#define printn(str) cout << str << endl;
 
typedef long long ll;
 
ll table_comb[51][51];
 
int main(){
  int N, A, B;
  cin >> N >> A >> B;
  vector<ll> v;
  ll t;
  for(int i = 0; i < N; i++){
    scanf("%lld", &t);
    v.push_back(t);
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  double max_average = 0.0;
  for(int i = 0; i < A; i++){
    max_average += v[i];
  }
  max_average /= A;

  cout << fixed << max_average << endl;
 
  REP(i,N+1){
    for (int j=0;j<=i;++j) {
      if (i == 0 || j == 0) {
        table_comb[i][j] = 1;
      } else {
        table_comb[i][j] = table_comb[i-1][j-1] + table_comb[i-1][j];
      }
    }
  }
 
  if (v[0] != v[A]) {
    if (v[A-1] != v[A]) {
      printn(1);
    } else {
      int bigger = 0;
      int cnt = 0;
      REP(i,N){
        if (v[A-1] < v[i]) ++bigger;
        if (v[i] == v[A-1]) ++cnt;
      }
      ll ans = table_comb[cnt][A-bigger];
      printn(ans);
    }
  } else {
    int cnt = 0;
    REP(i,N){
      if (v[i] < v[0]) break;
      ++cnt;
    }
    ll ans = 0;
 
    for (int i=A;i<=B;++i) {
      if (i <= cnt) {
        ans += table_comb[cnt][i];
      }
    }
    printn(ans);
  }
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)      //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++)    //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int,int> PII;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/
long long GCD(long long a, long long b){
    return (b ? GCD(b, a%b) : a);
}

/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);
    
    int n; cin >> n;
    vi a(n); rep(i,n) cin >> a[i];
    //前計算として、「両側から」累積GCDをとる <- point!! "両側から"前計算
    vi left(n);
    left[0] = a[0];
    for(int i = 1; i < n; ++i) {
        left[i] = GCD(left[i-1], a[i]);
    }
    vi right(n);
    right[n-1] = a[n-1];
    for(int i = n-2; i >= 0; --i) {
        right[i] = GCD(right[i+1], a[i]);
    }

    int maxi = -inf;
    for(int i = 0; i < n; ++i) {
        int num;
        if(i==0) num = right[i+1];
        else if(i==n-1) num = left[i-1];
        else num = GCD(left[i-1], right[i+1]);
        chmax(maxi, num);
    }
    cout << maxi << endl;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  vector<int> vs(n);
  int sum = 0, min_s = 101;
  for (int i = 0; i < n; ++i) {
    cin >> vs[i];
    sum += vs[i];

    if (vs[i] % 10 != 0) {
      min_s = min(min_s, vs[i]);
    }
  }

  if (min_s > 100) {
    cout << 0 << '\n';
  } else if (sum % 10 == 0) {
    cout << sum - min_s << '\n';
  } else {
    cout << sum << '\n';
  }

  return 0;
}

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

int main() {

	string S, T; 
	cin >> S >> T;
	bool ans = false;
	for (int i = 0; i < S.size(); ++i) {
		if (S == T) {
			ans = true;
			break;
		}
		S = S.back() + S.substr(0, S.size() - 1);
	}
	if (ans) {
		cout << " Yes " << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

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

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

	long long curr = 1;
	long long pairs = 0;
	for (int i = 1; i < n; ++i) {
		if (s[i] == s[i - 1]) {
			++curr;
		} else {
			pairs += curr * (curr - 1) / 2;
			curr = 1;
		}
	} 

	pairs += curr * (curr - 1) / 2; 

	cout << pairs << "\n";

	return 0;

}

Measured memory_bytes: 5760
#39
import copy
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
    
Max = max(a)
b = copy.copy(a)
b.remove(Max)
sub = max(b)

for i in a:
    if i !=Max:
        print(Max)
    else:
        print(sub)

Measured memory_bytes: 18708
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <ctime>
#include <climits>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <utility>
#include <cstdlib>

using namespace std;
long int pow107 = (int)pow(10, 9) + 7;
int ilimit = INT_MAX;
long int llimit = LONG_MAX;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

//最大limit
//10^9+7    pow107
//素数pn
//n乗jou
//コンビネーションfactorial
//

int main(){
    int max = -1,min = ilimit;
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        if(min > a)
            min = a;
        if(max < a)
            max = a;
    }
    cout << max - min << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long long int a;
    map<long long int,int> mp;
    for(int i=0;i<n;i++){
        cin >> a;
        a *= (-1);
        mp[a]++;
    }
    long long int tmp=0;
    for(auto u:mp){
        if(u.second>=4){
            if(tmp<0){
                cout << tmp*u.first;
                return 0;
            }
            else{
                cout << u.first*u.first;
                return 0;
            }
        }
        else if(u.second>=2){
            if(tmp<0){
                cout << tmp*u.first;
                return 0;
            }
            else tmp=u.first;
        }
    }
    cout << 0;
}

Measured memory_bytes: 9676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n,m;
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<endl;
    
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define ll long long int
#define lim 100010
#define INF 1e9
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define ABS(x) ((x)>0?(x):-(x))

int main(void){
	int n,m;
	scanf("%d%d",&n,&m);
	int l,r;
	int max=1,min=n;
	for(int i=0;i<m;i++){
		scanf("%d%d",&l,&r);
		max = MAX(max,l);
		min = MIN(min,r);
	}
	int ans=min-max+1;
	if(ans<0)ans=0;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

const int MAX = 200000;
int a[MAX], dp[MAX+2][17], p[31];
void init(){
  p[0] = 1;
  repi(i,1,31)p[i] = p[i-1]*4;
}

vi solve(int n, int idx){
  rep(i,n+2)rep(j,17)dp[i][j] = INF;
  vector<int> vec(n+2);
  rrep(i,n)vec[i] = a[i-1];
  if(idx)reverse(all(vec));
  
  rep(i,17)dp[n][i] = i;
  drep(i,n-1,1){
    rep(j,16)rep(k,inf){
      if(vec[i]*p[j] > vec[i+1]*p[k])continue;
      if(k <= 15)chmin(dp[i][j], j+dp[i+1][k]);
      else chmin(dp[i][j], j+dp[i+1][15]+(n-i)*(k-15));
      break;
    }
  }
  
  vi res(n+2);
  rrep(i,n)res[i] = dp[i][0];
  if(idx)reverse(all(res));
  return res;
}

signed main(){
  int n;
  init();
  scanf("%lld", &n);
  rep(i,n)scanf("%lld", &a[i]);
  vi vec[2];
  vec[0] = solve(n, 0);
  vec[1] = solve(n, 1);
  int ans = INF;
  // cout << vec[0] << endl;
  // cout << vec[1] << endl;
  rep(i,n+1){
    // printf("%lld %lld %lld\n", vec[0][i+1], vec[1][i], i);
    ans = min(ans, 2*(vec[0][i+1]+vec[1][i])+i);
  }
  cout << ans << endl;
  return 0;
}






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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  vector<int> vp(n);
  for (int i = 0; i < n; ++i) {
    cin >> vp[i];
  }

  int ans = 0;
  for (int i = 0; i < vp.size() - 1; ++i) {
    if (vp[i] == i + 1) {
      swap(vp[i], vp[i + 1]);
      ans++;
    }
  }

  if (vp.back() == n) {
    ans++;
  }

  cout << ans << '\n';
  return 0;
}

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

#define Fast cin.tie(0), ios::sync_with_stdio(0)
#define All(x) x.begin(), x.end()
#define louisfghbvc int t; cin >> t; while(t--)
#define sz(x) (int)(x).size()
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<LL> vi;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep = ""; for(const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << "\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

const int V = 1e5+5;
int dp[105][V];
int cost[105], val[105];

void solve(){
    int n, w;
    cin >> n >> w;
    for(int i = 0; i < n; ++i) cin >> cost[i] >> val[i];

    memset(dp, 0x3f, sizeof dp);
    dp[0][0] = 0;
    for(int i = 1; i <= n; ++i){
        for(int j = 0; j <= 1e5; ++j)
            dp[i][j] = dp[i-1][j];
        for(int j = val[i-1]; j <= 1e5; ++j){
            dp[i][j] = min(dp[i-1][j-val[i-1]] + cost[i-1], dp[i][j]);
        }
    }

    for(int v = 1e5; v >= 0; --v){
        if(dp[n][v] <= w){
            cout << v << "\n";
            return;
        }
    }
}

int main()
{
    Fast;
    //louisfghbvc{
        solve();
    //}
    return 0;
}


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(){
    int n, k; cin >> n >> k;
    ll ans = k;
    REP(i, 1, n){
        ans *= (k-1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>

int main(void){
	int n; std::cin>>n;
	int m;
	int answer=1;
	std::vector<int> v;
	for(int l=0;l<n;l++){
		scanf("%d",&m);
		v.push_back(m);
	}
	std::sort(v.begin(),v.end());
	int prev=v[0];
	int next;
	for(int l=1;l<n;l++){
		//std::cout<<"next is "<<v[l]<<std::endl;
		next=v[l];
		if(prev!=next) answer++;
		prev=next;
	}
	std::cout<<answer<<std::endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
k = int(input())
for i in range(k):
  x, y = map(int,input().split())
  if n % 2:
    c = n // 2 + 1
    if x > c:
      x = c * 2 - x
    if y > c:
      y = c * 2 - y
  else:
    c = n // 2
    if x > c:
      x = c * 2 - x + 1
    if y > c:
      y = c * 2 - y + 1
  print((min(x, y) - 1) % 3 + 1)


Measured memory_bytes: 5608
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

#include "bits/stdc++.h"
using namespace std;

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

	if (A + B < 10) {
		cout << A + B << endl;
	}
	else {
		cout << "error" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

int main() {
    int n, capacity;
    cin >> n >> capacity;

    int weight[n], value[n];
    for (int i = 0; i < n; i++) cin >> weight[i] >> value[i];

    // 今回の問題では、i番目の品物はi - 1番目より前の品物の重さやvalueが
    // なんであれ、直前のものしか関係ないので、DPでいけんじゃね？って感じになる。
    // 状態としては、それぞれの品物と合計の重さが存在するので、これらを次元にとり、
    // 値を価値にすると良さそう。
    long long dp[n + 1][capacity + 1];

    // 初期値を入れる。
    for (int i = 0; i <= n; i++) for (int j = 0; j <= capacity; j++) dp[i][j] = 0;

    // ループを回す。
    // どういう場合があるか考えるが、ナップザックにいれるかいれないかのどちらかなので、
    // 使う場合は二次元に増やして、価値も増やす。
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < capacity; j++) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (j + weight[i] <= capacity) dp[i + 1][j + weight[i]] = max(dp[i + 1][j + weight[i]], dp[i][j] + value[i]);
        }
    }

    long long res = 0;
    for (int i = 0; i <= capacity; i++) res = (res < dp[n][i]) ? dp[n][i] : res;

    cout << res << endl;
}


Measured memory_bytes: 79104
from fractions import gcd

N = int(input())
a = [int(i) for i in input().split()]

L = []
R = []
L.append(a[0])
R.append(a[-1])

for i in range(N-2):
    L.append(gcd(L[-1], a[i+1]))
    R.append(gcd(R[-1], a[-(i+2)]))

ans = max(L[-1], R[-1])
for i in range(N-2):
    tmp = gcd(L[i], R[-(i+2)])
    if tmp > ans:
        ans = tmp

print(ans)

Measured memory_bytes: 16160
function Main( input ){

    input = input.split( '\n' )
    
    var o = [].slice.call( input[0] )
    var e = [].slice.call( input[1] )
    
    var pass = ''
    
    for( ;; ){
        if( o.length ) pass += o.shift()
        if( e.length ) pass += e.shift()
        if( o.length === 0 && e.length === 0 ) break
    }
    
    console.log( pass )

}

Main( require( 'fs' ).readFileSync( '/dev/stdin', 'utf8' ) )

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

int main(){
    int N; cin >> N;
    vector<int> time(N);
    int sum_original=0;
    for (int i=0; i<N; i++){
        cin >> time.at(i);
        sum_original+=time.at(i);
    }
    int M; cin >> M;
    vector<pair<int, int>> drink(M);
    for (int i=0; i<M; i++){
        cin >> drink.at(i).first >> drink.at(i).second;
    }
    for (int i=0; i<M; i++){
        cout << sum_original-time.at(drink.at(i).first-1)+drink.at(i).second << endl;
    }
    return 0;
}

Measured memory_bytes: 256
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();
		String t=sc.next();
		StringBuilder sb=new StringBuilder();
		for(int i=0; i<n; i++){
			sb.append(s.charAt(i));
			sb.append(t.charAt(i));
		}
		System.out.println(sb);
	}
}


Measured memory_bytes: 21844
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int main(){
  std::ios_base::sync_with_stdio(false);
  set<string> st;
  int n;
  cin >> n;
  while(n--){
    string BUFF,c;
    cin >> BUFF >> c;
    if(BUFF=="insert") st.insert(c);
    else cout << (st.find(c)!=st.end()?"yes":"no") << endl;
  }
}


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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int tama=a%b,tama1=tama;
    bool uo=false;
    int i=2;
    while(i<10000){
        if(tama1==c){
            uo=true;
            break;
        }
        tama1=tama*i;
        tama1%=b;
        i++;
    }
    if(uo){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ri register int
using namespace std;
typedef long long ll;
#define pb push_back
const int rlen=1<<18|1;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
inline int read() {
  int ans=0;
  bool f=1;
  char ch=gc();
  while(!isdigit(ch)) f^=ch=='-',ch=gc();
  while(isdigit(ch)) ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
  return f?ans:-ans;
}
const int N=3e5+5;
int n,a[N],id1,id2,b[N],c[N];
vector<int>e[N];
int main() {
  #ifdef ldxcaicai
  freopen("lx.in","r",stdin);
  #endif
  n=read();
  for(ri i=1;i<=n;++i) a[i]=i;
  int mt=1;
  for(ri i=1;i<=n;++i) b[i]=read(),mt*=i;
  for(ri i=1;i<=n;++i) c[i]=read();
  int ct=1;
  while(mt--) {
    bool ff=1;
    for(ri i=1;i<=n;++i) if(a[i]!=b[i]) { ff=0;break; }
    if(ff) id1=ct;
    ff=1;
    for(ri i=1;i<=n;++i) if(a[i]!=c[i]) { ff=0;break; }
    if(ff) id2=ct;
    next_permutation(a+1,a+n+1);
    ++ct;
  }
  cout<<max(id1,id2)-min(id1,id2);
  return 0;
}

Measured memory_bytes: 10496
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

signed main() {
	int a, b;
	
	cin >> a >> b;
	if (a <= 9 && b <= 9) { cout << a * b << endl; }
	else { cout << "-1" << endl; }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <list>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ll N;cin >> N;
    vector<ll> P(N);
    for(int i=0;i<N;i++) cin >> P[i];
    ll ans=0;
    ll ct=0;
    for(int i=0;i<N;i++){
        if(ct==1){
            ans++;
            ct=0;
        }
        else if(P[i]==i+1) ct++;
        else ct=0;
    }
    if(ct==1) ans++;
    if(P[0]==1 && P[1]!=2 && P[2]!=3)ans++;
    else if(P[N-1]==N && P[N-2]!=N-1 && P[N-3]!=N-2)ans++;
    cout << ans << endl;
}

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

string divs[4] = {"dream", "dreamer", "erase", "eraser"};

int main() {
  string s; cin >> s;
  reverse(s.begin(), s.end());
  for (int i = 0; i < 4; i++) reverse(divs[i].begin(), divs[i].end());
  int i = 0;
  while(i<s.size()) {
    bool flag = false;
    for (int j = 0; j < 4; j++) {
      if (s.substr(i, divs[j].size()) == divs[j]) {
        flag = true;
        i += divs[j].size();
      }
    }
    if (!flag) {
      cout << "NO" << endl; return 0;
    }
  }
  cout << "YES" << endl; return 0;
}

Measured memory_bytes: 512
class UnionFind:
    __slots__ = ["N", "root", "rank"]

    def __init__(self, N):
        """
        N:要素数
        root:各要素の親要素の番号を格納するリスト.
             ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数.
        rank:ランク
        """
        self.N = N
        self.root = [-1] * N
        self.rank = [0] * N

    def __repr__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    def find(self, x):
        """頂点xの根を見つける"""
        while self.root[x] >= 0:
            x = self.root[x]
        return x

    def union(self, x, y):
        """x,yが属する木をunion"""
        # 根を比較する
        # すでに同じ木に属していた場合は何もしない.
        # 違う木に属していた場合はrankを見てくっつける方を決める.
        # rankが同じ時はrankを1増やす
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.rank[x] > self.rank[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def same(self, x, y):
        """xとyが同じグループに属するかどうか"""
        return self.find(x) == self.find(y)

    def count(self, x):
        """頂点xが属する木のサイズを返す"""
        return - self.root[self.find(x)]

    def members(self, x):
        """xが属する木の要素を列挙"""
        _root = self.find(x)
        return [i for i in range(self.N) if self.find == _root]

    def roots(self):
        """森の根を列挙"""
        return [i for i, x in enumerate(self.root) if x < 0]

    def group_count(self):
        """連結成分の数"""
        return len(self.roots())

    def all_group_members(self):
        """{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す"""
        return {r: self.members(r) for r in self.roots()}


import sys
input = sys.stdin.readline
n, q = map(int, input().split())
uf = UnionFind(n)
res = []
for i in range(q):
    t, u, v = map(int, input().split())
    if t:
        res.append(int(uf.same(u, v)))
    else:
        uf.union(u, v)
print("\n".join(map(str, res)))


Measured memory_bytes: 84188
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a, b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f ;
  int maxsu = e*f/100;
  int anssu = 0 ;
  int answa = a*100;
  double nodo = 0;
  for(int i = 0; i <= maxsu / c ; i++){
    for(int j = 0; j <= maxsu / d ;j++){
      int su = c*i + d*j;
      for(int k = 0 ; k <= f/(100*a) ; k++){
        for(int l = 0; l <= f /(100*b);l++){
          int wa = k*100*a + l*100*b;
          if( wa == 0){
            break;
          }
          if( su + wa > f){
            break;
          }
          if( (wa*e) < 100* su){
            break;
          }
          if( nodo < 100.0*su/(su + wa)  ){
            nodo = 100.0*su/(su + wa);
            anssu = su;
            answa = wa;
          }
        }
      }
    }
  }
  cout << anssu + answa << " " << anssu << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};



int main() {
	int W,H,T;cin>>W>>H>>T;
	int Q;cin>>Q;
	vector<vector<int>>field(H,vector<int>(W));
	while (Q--) {
		int x,y,t;cin>>x>>y>>t;
		field[y][x]++;
	}
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			int a;cin>>a;
			field[i][j]*=a;
		}
	}
	int ans = accumulate(field.begin(), field.end(), 0,
		[](const int a, const vector<int>&v) {
		return a+accumulate(v.begin(),v.end(),0);
	});
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int64_t N, A, B;
  cin >> N >> A >> B;
  int64_t ans = 0;
  if ((A==0)&&(B==0)) {
    cout << ans << endl;
  }

  else {

    int64_t  M = N / (A+B);
    
    ans = M*A;

    if (N-(A+B)*M >= A) {
      ans+=A;
    }
    else {
      ans += N-(A+B)*M;
    }

    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int max(int i, int j)
{
    return i > j? i: j;
}

int min(int i, int j)
{
    return i < j? i: j;
}

int main(void)
{
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    int l = max(a, c), r = min(b, d);
    printf("%d\n", max(0, r - l));
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long A = inputLongArray[0];
            long B = inputLongArray[1];
            Console.WriteLine(Lcm(A, B));

        }
        // 最小公倍数
        public static long Lcm(long a, long b)
        {
            long x = Gcd(a, b);

            return a * b / x;
        }
        public static long Gcd(long a, long b)
        {
            long x = 0;

            while (true)
            {
                // 割り切れたら
                if (a % b == 0)
                {
                    return b;
                }
                else
                {
                    x = a % b;
                    a = b;
                    b = x;

                }
            }

        }
    }
}

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

int a;
int main(){
  set<char> s;
  string t;
  cin>>t;
  for(int i=0;i<t.size();i++){
    s.insert(t[i]);
  }
  for(auto ite=s.begin();ite!=s.end();++ite){
    if(*ite=='E')a++;
    if(*ite=='W')a++;
    if(*ite=='N')a+=3;
    if(*ite=='S')a+=3;
  }
  if(a==2||a==6||a==8)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [[] for _ in range(n)]
for i in range(n):
  num = int(input())
  for j in range(num):
    person, state = map(int, input().split())
    a[i].append([person-1, state])
honest = 0
for i in range(1, 2**n):
  flag = True
  for j in range(n):
    if (i>>j)&1 == 1:
      for x, y in a[j]:
        if (i>>x)&1 != y:
          flag = False
          break
  if flag:
    honest = max(honest, bin(i)[2:].count('1'))
print(honest)

Measured memory_bytes: 9200
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(x, y):
	return x * y // gcd (x, y)

num = int(input())
A = [int(s) for s in input().split()]
ans = A[0]
for i in range(1,num):
    ans = lcm(ans,A[i])
B = [ans//A[s] for s in range(num)]
print(sum(B)%(10**(9)+7))

Measured memory_bytes: 262644
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
struct area{
  int bx, by, ex, ey;
  area(int bx, int by, int ex, int ey) :
    bx(bx), by(by), ex(ex), ey(ey) {}
  bool operator < (const area& a) const {
    if(bx != a.bx) return bx < a.bx;
    if(by != a.by) return by < a.by;
    if(ex != a.ex) return ex < a.ex;
    return ey < a.ey;
  }
  bool contain(int x, int y){
    return (bx <= x && x <= ex && by <= y && y <= ey);
  }
  void print(){
    printf("x: %d->%d y: %d->%d\n", bx, ex, by, ey);
  }
};
void print(int S){
  REP(y, 4){
    REP(x, 4) cout<<(bool)(S & (1 << (y * 4 + x)))<<" ";
    cout<<endl;
  }
}

int main(){
  int N;
  while(cin>>N){
    set<area> cand_s;
    REP(i, N){
      int w, h; cin>>h>>w;
      for(int x = -(w - 1); x < 4; x++){
        for(int y = -(h - 1); y < 4; y++){
          cand_s.insert(area(max(0, x), max(0, y), min(3, x + w - 1), min(3, y + h - 1)));
        }
      }
    }
    vector<area> cand(cand_s.begin(), cand_s.end());
    int bitmap[100][4] = {};
    char mapset[4] = "RGB";

    int grid[4][4];
    for(int y = 0; y < 4; y++){
      string s; cin>>s;
      for(int x = 0; x < 4; x++){
        for(int c = 0; c < 3; c++){
          if(s[x] == mapset[c]) grid[y][x] = c; 
        }
      }
    }
    for(int i = 0; i < cand.size(); i++){
      for(int y = 0; y < 4; y++){
        for(int x = 0; x < 4; x++){
          if(cand[i].contain(x, y)){
            bitmap[i][3] |= (1 << (4 * y + x));
            bitmap[i][grid[y][x]] |= (1 << (4 * y + x));
          }
        }
      }
    }
    int dist[1<<16];
    fill(dist, dist + (1<<16), INF);
    dist[0] = 0;
    queue<int> que;
    que.push(0);
    while(!que.empty()){
      int S = que.front(); que.pop();
      //printf("S:%d dist:%d\n", S, dist[S]);
      //print(S);
      //cout<<endl;
      if(S == (1<<16) - 1) break;
      for(int i = 0; i < cand.size(); i++){
        for(int c = 0; c < 3; c++){
          int nS = (S & ~bitmap[i][3]) | bitmap[i][c];
          if(dist[nS] != INF) continue;
          dist[nS] = dist[S] + 1;
          que.push(nS);
        }
      }
    }
    cout<<dist[(1<<16) - 1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1624
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int N; string s;
int cntE[300010], cntW[300010];
signed main() {
    cin >> N >> s;
    
    for(int i=0; i<N; i++) {
        cntE[i+1] = cntE[i] + (s[i] == 'E');
        cntW[i+1] = cntW[i] + (s[i] == 'W');
    }

    int ans = INF;
    for(int i=1; i<=N; i++) {
        int tmp = 0;
        // 左にある W
        tmp += cntW[i-1] - cntW[0];

        // 右にある E
        tmp += cntE[N] - cntE[i];

        chmin(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5380
#include<stdio.h>
int main()
{
	int A,B,C;
        int temp,temp1;
	scanf("%d %d %d",&A,&B,&C);
	temp=A;
	A=B;
	B=temp;
	temp1=A;
	A=C;
	C=temp1;
	printf("%d %d %d\n",A,B,C);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
using namespace std;
typedef long long ll;
int main() {
    int n, m;
    scanf("%d%d", &n, &m);

    if (n == 1 && m == 1) puts("1");
    else if (n == 1) printf("%d\n", m-2);
    else if (m == 1) printf("%d\n", n-2);
    else printf("%lld\n", (ll)(n-2) * (ll)(m-2));
}



Measured memory_bytes: 128
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    int a, b, c;
    cin >> a >> b >> c;
    int pa = a % 2;
    int pb = b % 2;
    int pc = c % 2;

    int num = 0;
    if (pa != pb && pa != pc) {
        b++;
        c++;
        num++;
    }
    if (pb != pa && pb != pc) {
        a++;
        c++;
        num++;
    }
    if (pc != pa && pc != pb) {
        a++;
        b++;
        num++;
    }

    int maxn = max({a, b, c});
    num += (maxn - a) / 2 + (maxn - b) / 2 + (maxn - c) / 2;
    cout << num << endl;

    return 0;
}


Measured memory_bytes: 256
/**
 *   
 *   Date: 30 March 2020
 *   Time: 12:20:05
**/
#pragma GCC optimize("O3")
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cmath>
#include <cstring>
#include<queue>
#include<stack>
#include<climits>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vec;
typedef vector<vector<ll> > matrix;
ll const mod=1000000007;

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll n,d,d1;
	cin>>n;
	ll dp[n+2],ar[n+2];
	for(ll i=1;i<=n;i++)
	{
		cin>>ar[i];
	}
	dp[1]=0;
	dp[2]=abs(ar[2]-ar[1]);
	for(ll i=3;i<=n;i++)
	{
		d=abs(ar[i]-ar[i-1]);
		d1=abs(ar[i]-ar[i-2]);
		dp[i]=min(dp[i-1]+d,dp[i-2]+d1);
	}
	cout<<dp[n]<<endl;

return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>
inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    string s;cin>>s;
    ll k;cin>>k;

    char ans;
    rep(i,s.size()){
        if(s[i]!='1'){
            ans=s[i];
            break;
        }
        if(i+1==k){
            ans='1';
            break;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3612