akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define W(x) cout<<x<<endl;
#define Debug(x) cout<<"#DEBUG "<<x<<endl;
#define INF (1<<29)
using namespace std;
int min(int x,int y){if(y<x)return y;else return x;}
int max(int x,int y){return x+y-min(x,y);}
int fact(int x){int i=1;rep(j,x){i*=(j+1);} return i;}
int main()
{
    bool use[51];
    int n;
    cin>>n;
    int a[n],b[n];
    rep(i,n)
    {
        cin>>a[i];
    }
    rep(i,n)
    {
        cin>>b[i];
    }
    rep(i,51)
    {
        use[i]=true;
    }
    bool path[51][51],flag=true,able=true;
    for(int i=50;i>=0&&flag&&able;i--)
    {
        use[i]=false;
        rep(j,51)
        {
            rep(k,51)
            {
                path[j][k]=false;
            }
            path[j][j]=true;
        }
        rep(i,51)
        {
            for(int rr=0;rr<i;rr++)if(use[rr])
            {
                path[i][i%(rr+1)]=true;
            }
        }
        rep(k,51)
        {
            rep(j,51)
            {
                rep(e,51)
                {
                    if(e>=k&&k>=j)path[e][j]=path[e][j]||(path[e][k]&&path[k][j]);
                }
            }
        }
        rep(k,n)
        {
            flag=flag&&path[a[k]][b[k]];
        }
        if(i==50){able=flag;}
        else if(!flag){use[i]=true;flag=true;}
        else{}
    }
    if(!able){W(-1)}
    else
    {
        long long ww=0;
        rep(i,50)
        {
            if(use[i])ww+=pow(2,(int)(i+1));
            else{}
        }
        W(ww)
    }
    
    return 0;
}

Measured memory_bytes: 256
"""
Problem A: 次期町長
https://onlinejudge.u-aizu.ac.jp/problems/1159
 3 ≤ n ≤ 50, 2 ≤ p ≤ 50
"""

def solve(n, q):
    have = [0]*n
    now = 0
    stone = q

    while(True):
        #print(n)
        if stone != 0:
            have[now] += 1
            stone -= 1
        else:
            stone = have[now]
            have[now] = 0

        if q in have:
            return have.index(q)

        now = (now+1)%n


if __name__ == '__main__':
    ans = []
    while(True):
        n, q = map(int, input().split())
        if n == 0 and q == 0:
            break
        ans.append(solve(n, q))
    print(*ans, sep='\n')



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

class Program
{
    static void Main(string[] args)
    {
        int count = Parse(ReadLine());
        WriteLine(ReadLine().Split().Sum(Parse) - count);
    }

//    static string ReadLine()
//    {
//        return _inputs[_inIndex++];
//    }

//    static string[] _inputs = @"7
//994 518 941 851 647 2 581".Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

//    static int _inIndex = 0;
}


Measured memory_bytes: 11328
import java.util.*;

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 aMax = 0;
//		int lcm = 1;
		int sum = 0;

		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt() - 1;
			sum += a[i];
//			aMax = Math.max(aMax, a[i]);
//			lcm = lcm(lcm, a[i]);
		}

//		System.out.println(aMax);
//		System.out.println(lcm);

		int fMax = sum;
//		for (int m = 1; m <= lcm; m++) {
//			int f = 0;
//			for (int i = 0; i < N; i++) {
//				f += m % a[i];
//			}
//			fMax = Math.max(fMax, f);
//		}

		System.out.println(fMax);
	}
	
	static int lcm (int a, int b) {
		int temp;
		long c = a;
		c *= b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (int)(c/b);
	}
}

Measured memory_bytes: 27196
/*
 * main.c
 *
 *  Created on: 2019/06/15
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int N = 0, K = 0;
	int ans = 0;
	scanf("%d %d", &N, &K);
	ans = N%K;
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <bitset>
#include <tuple>
#include <stack>
#include <utility>

using namespace std;
typedef long long ll;

int main(){
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    int st=0, ed=0, k=0, mem=1, ans=0;
    while(ed < N){
        if(S[ed] == '0'){
            if(mem == 1){
                k += 1;
                mem = 0;
            }
            ans = max(ans, ed-st+1);
        }
        else if(S[ed] == '1'){
            if(mem == 0) mem = 1;
            ans = max(ans, ed-st+1);
        }
        if(k < K) ed += 1;
        else if(S[ed+1]=='0' && mem==1){
            if(S[st]=='0' && S[st+1]=='1') k -= 1;
            st += 1;
        }
        else ed += 1;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

double dot(cdouble a, cdouble b) {
	return (a * b.conj).re;
}

void main()
{
	immutable EPS = 10e-12;
	foreach (line; stdin.byLine) {
		auto p = line.chomp.split.map!(to!double);
		auto a = p[2] - p[0] + (p[3] - p[1]) * 1i;
		auto b = p[6] - p[4] + (p[7] - p[5]) * 1i;
		if (dot(a, b).fabs < EPS) writeln("YES");
		else writeln("NO");
	}
}

Measured memory_bytes: 1084
#include <iostream>
#include <math.h>

using namespace std;

int main() {
    int N;
    int Y;
    cin >> N;
    cin >> Y;
    int x = 0;
    int y = 0;
    int z = 0;
    z = Y / 1000;
    if (z > N) {
        for (x = 0;x <= N;x++) {
            for (y = 0;y <= N-x;y++) {
                z = N - x - y; 
                if (10000*x+5000*y+1000*z == Y) {
                    cout << x << " " << y << " " << z << endl;
                    return 0;
                }
            }
        }
        cout << "-1 -1 -1" << endl;
    } else if (z < N) {
        cout << "-1 -1 -1" << endl;
    } else {
        cout << "0 0 " << z << endl;
    }
}

Measured memory_bytes: 256
package main

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

func main() {
	var a, b, c string
	fmt.Scan(&a, &b, &c)
	fmt.Println(strings.ToUpper(string(a[0])) + strings.ToUpper(string(b[0])) + strings.ToUpper(string(c[0])))
}

/*　入力方法
１、簡単に書く
fmt.Scan
2,たくさん読む()
bufio.Scanner
(テキストを1行ずつ読み込む。fileからscannerを生成し、scan()が末尾に達してfalseを返すまで読み込む。Text()を呼ぶことで文字列として取り出すことができる)
3,長い行を読む
bufio.ReadLine
4, スペース区切りのデータを読み込む
sc.Split(bufio.ScanWords)
#########バッファの最大読み込みの数を変更するには
sc.Buffer(buf,MaxBuf)#MAXBUFのところにサイズをしていする
*/

/* 書き込み
１、接頭辞F（前）
書き込み先を指定できる
2,接頭辞S(前)
出力ではなくフォーマットした結果を文字列で返す
3,接頭辞 f（後ろ）
フォーマット（文字列型など）を指定することができる
４、接頭辞 ln（後ろ）
オペランドの間に半角スペースが入り、文字列の最後に開業が追加

・interface{}型
どのような型がくるかわからないときに演算はできないが全ての型を受ける
new(T)
任意の型

*/
/*
フォーマット文字列
%c 1文字を出力　　　%d　　整数を10進む
%s 文字列を出力

指定子	対応する型	説明	使用例
%c	char	１文字を出力する
%s	char *	文字列を出力する
%d	int, short	整数を10進で出力する
%u	unsigned int, unsigned short	符号なし整数を10進で出力する
%o	int, short,unsigned int, unsigned short	整数を8進で出力する
%x	int, short,unsigned int, unsigned short	整数を16進で出力する
%f	float	実数を出力する
%e	float	実数を指数表示で出力する
%g	float	実数を最適な形式で出力する
%ld	long	倍精度整数を10進で出力する
%lu	unsigned long	符号なし倍精度整数を10進で出力する
%lo	long, unsigned long	倍精度整数を8進で出力する
%lx	long, unsigned long	倍精度整数を16進で出力する
%lf	double	倍精度実数を出力する
*/
/*
文字
*/
const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()

}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

/*strings.Splitで入力したものを分ける*/
func Scanner() []string {
	var s string
	if sc.Scan() {
		s = sc.Text()
	}
	slice := strings.Split(s, " ")
	return slice

}

/*"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""*/



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

int main() {
	int m,f,r;
	char grade;
	while (cin >> m >> f >> r) {
		if (m == -1 && f == -1 && r == -1) {
			break;
		} else if (m == -1 || f == -1) {
			grade = 'F';
		} else {
			int total = m + f;
			if (total >= 80) {
				grade = 'A';
			} else if (total < 80 && total >= 65) {
				grade = 'B';
			} else if (total < 65 && total >= 50) {
				grade = 'C';
			} else if (total < 50 && total >= 30) {
				grade = r >= 50 ? 'C' : 'D';
			} else {
				grade = 'F';
			}
		}
		cout << grade << endl;
	}
}

Measured memory_bytes: 3064
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();

    if( "H".equals(a) ){
      if( "H".equals(b) ){
        System.out.println("H");
      }else{
        System.out.println("D");
      }
    }else{
      if( "H".equals(b  ) ){
        System.out.println("D");
      }else{
        System.out.println("H");
      }
    }
  }
}


Measured memory_bytes: 21844
class UnionFind:
    def __init__(self, n: int):
        self.nodes = n
        self.parents = [-1] * n
        self.rank = [0] * n

    # retrun the root of element x
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # unite the group include element x and group include element y
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parents[y] += self.parents[x]
            self.parents[x] = y
        else:
            self.parents[x] += self.parents[y]
            self.parents[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # get size of the gourp which element x belongs
    def get_size(self, x):
        return -self.parents[self.find(x)]

    # check if element x and element y is same group
    def same(self, x, y):
        return self.find(x) == self.find(y)


n, m = [int(i) for i in input().split()]
union = UnionFind(n)
for _ in range(m):
    s, t = [int(i) for i in input().split()]
    union.unite(s, t)

q = int(input())
for _ in range(q):
    s, t = [int(i) for i in input().split()]
    if union.same(s, t):
        print("yes")
    else:
        print("no")



Measured memory_bytes: 7956
#include <iostream>
#include <string>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
bool kaibun(string v){
	int n = v.size();
	for(int i=0;i<n;i++){
		if(v[i]!=v[n-1-i])return false;
	}
	return true;
}

int main(){
	string s;
	cin >> s;
	int n = s.size();
	string a = s.substr(0,(n-1)/2),b=s.substr((n+3)/2-1,n-(n+3)/2+1);
	if(kaibun(s)&&kaibun(a)&&kaibun(b))cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,i,a=0,b=0,c=0,d=0;
	char k;
	scanf("%d",&n);
	getchar();
	for(i=0;i<n;i++){
	scanf("%c",&k); 
	getchar();
	if(k=='P') a++;
	if(k=='W') b++;
	if(k=='G') c++;
	if(k=='Y') d++;}
	if(d>0) printf("Four\n");
	 else printf("Three\n");
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//文字列を宣言して読み込む
		String A = sc.next();
		String ans = "No";
		if(A.charAt(0)==A.charAt(1)){
			if((A.charAt(2)==A.charAt(3))&&(A.charAt(1)!=A.charAt(2))){			
				ans="Yes";
				System.out.println(ans);
				}
			}
	if(A.charAt(0)!=A.charAt(1)){
		if((A.charAt(0)==A.charAt(3))&&(A.charAt(1)==A.charAt(2))||(A.charAt(0)==A.charAt(2))&&(A.charAt(1)==A.charAt(3))){
			ans="Yes";
			System.out.println(ans);		
		}
	}
	if(ans=="No"){
System.out.println(ans);
	}
	
	}
}

Measured memory_bytes: 22740
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	int n,m;
	List<List<Integer>> graph;
	List<Integer> V;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	void solve() {
		n = nextInt();
		m = nextInt();
		graph = new ArrayList<List<Integer>>();

		for(int i=0;i<=n;i++) {
			V = new ArrayList<Integer>();
			graph.add(V);
		}

		for(int i=0;i<m;i++) {
			int a = nextInt();
			int b = nextInt();
			graph.get(a).add(b);
			graph.get(b).add(a);
		}
		sc.close();

		//for(Object a:graph)System.out.println(a);

		int res = 0;
		for(int i=1;i<=1;i++)res += SearchforAllVerticesPass(i);

		System.out.println(res);
	}

	private int SearchforAllVerticesPass(int gi) {
		boolean[] f = new boolean[n+1];
		return SearchforAllVerticesPass(gi,0+1,f);
	}

	private int SearchforAllVerticesPass(int gi,int cnt, boolean[] f) {
		List<Integer> VL=graph.get(gi);
		f[gi]=true;
		int sum=0;
		for(int i=0;i<VL.size();i++) {
			if(f[VL.get(i)])continue;
			if(cnt+1==n)sum++;
			else sum+=SearchforAllVerticesPass(VL.get(i),cnt+1,f);
		}
		f[gi]=false;
		return sum;
	}

	private int nextInt() {
		return Integer.parseInt(sc.next());
	}

}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  vector<int> vec(n);
  for(int i=0;i<n;i++) cin>>vec[i];
  int dp[n+1];
  for(int i=0;i<=n;i++) dp[i]=INT_MAX;
  dp[0]=0;
  dp[1]=0;
  
  for(int j=2;j<=n;j++)
  {
    for(int i=1;i<=k;i++)
    if(j>i)
  dp[j]=min(dp[j-i]+abs(vec[j-1]-vec[j-i-1]),dp[j]);
    //else dp[j]=dp[j-1]+abs(vec[j-1]-vec[j-2]);
  }
  cout<<dp[n]%INT_MAX<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	unordered_set<int> s;
	for (auto& i : A) {
		cin >> i;
		s.insert(i);
	}
	auto k = s.size();
	cout << (k & 1 ? k : k - 1) << endl;
}


Measured memory_bytes: 4772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++) 
#define ltype int
#define rep(i,j,k) for(ltype (i)=(j);(i)<=(k);(i)++)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,
mod=1000000007;
const double pi=3.1415926535897932,
eps=1e-6;
int n,a[100005],f[100005],ans;map<int,int> m;
struct segtree{
    int dat[262150],n;
    void build(int nn)
    {
        n=1;
        while(n<=nn) n<<=1;
        for(int i=0;i<2*n-1;i++) dat[i]=-inf;
    }
    void update(int k,int a){
        k+=n-1;
        dat[k]=a;
        while(k>0){
            k=(k-1)/2;
            dat[k]=max(dat[(k<<1)+1],dat[(k<<1)+2]);
        }
    }
    int query(int l,int r){
        return query(l,r+1,0,1,n);
    }
    int query(int a,int b,int k,int l,int r){
        if(r<=a||b<=l) return -inf;
        if(a<=l&&r<=b) return dat[k];
        return max(query(a,b,(k<<1)+1,l,(l+r)>>1),query(a,b,(k<<1)+2,(l+r)>>1,r));
    }
}seg;
int main()
{
    scanf("%d",&n);
    rep(i,1,n) scanf("%d",a+i),m[a[i]]=0;int b=0;
    itrm(it,m) it->se=++b;
    seg.build(b);
    rep(i,1,n) a[i]=m[a[i]];
    seg.update(b,0);
    rep(i,1,n){
        f[i]=seg.query(a[i],b)+1;
        seg.update(a[i],f[i]);
        ans=max(ans,f[i]);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 6656
/*
    Author : Simanta Deb Turja
*/
#include <bits/stdc++.h>
using namespace std;

#define Professor

using ll = long long;
using i64 = unsigned long long;

template <typename T> inline T Min (T a, T b, T c) { return min(a, min(b, c)); }
template <typename T> inline T Min (T a, T b, T c, T d) { return min(a, min(b, min(c, d))); }
template <typename T> inline T Max (T a, T b, T c) { return max(a, max(b, c)); }
template <typename T> inline T Max (T a, T b, T c, T d) { return max(a, max(b, max(c, d))); }

template <typename T> inline T Ceil(T a, T b) { return ((a % b == 0) ? (a / b) : (a / b + 1)); } 
template <typename T> inline T Floor(T a, T b) { return a / b; }

template <typename T> inline T Power (T a, T p) { T res = 1, x = a; while ( p ) { if ( p & 1 ) res = ( res * x ); x = ( x * x ); p >>= 1;}return res; }
template <typename T> inline T BigMod (T a,T p,T M) { a %= M;T ret = 1; while (p) { if (p & 1) ret = (ret * a) % M; a = (a * a) % M; p = p >> 1; } return ret; }
template <typename T> inline T InverseMod (T a,T M) { return BigMod (a, M - 2, M); }

template <typename T> inline T gcd ( T a, T b ) { a = abs(a); b = abs(b); while ( b ) { a = a % b; swap ( a, b ); } return a; }
template <typename T> inline T lcm(T x,T y) { return (((x)/gcd((x),(y)))*(y)); }


#define endl '\n'
#define eb emplace_back

const int N = (int)4e5 + 10;
const double EPS = 1e-7;
const double PI = acos(-1.0);
const ll LLINF = (ll)1e18+1;
const int INF = (int)1e9+1;
const ll MOD = (ll)1e9 + 7;

template <typename T> bool cmp (const pair <T, T> &a, const pair <T, T> &b) { return a.first < b.first; }


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    auto Solve = [&]() {
        #ifdef __APPLE__
            cout << "Running\n";
        #endif
        int n;
        cin >> n;
        vector <int> a(n + 1), b(n + 1), c(n + 1);
        for (int i = 0; i < n; ++i) {
            cin >> a[i] >> b[i] >> c[i];
        }
        vector <vector <int> > dp(n, vector <int>(3));
        dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];
        for (int i = 1; i < n; ++i) {
            dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
            dp[i][1] = b[i] + max(dp[i - 1][2], dp[i - 1][0]);
            dp[i][2] = c[i] + max(dp[i - 1][0], dp[i - 1][1]);
        }
        cout << Max(dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]) << endl;
    };
    Solve();
    
    return 0;
}



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

typedef long long ll;
typedef long double ld;

using namespace std;

#define rep(i,n) for(auto i=0*(n);i<(n);++i)

int main(){
    while(true){
        ll n;
        cin >> n;
        if(n==0) break;
        
        vector<ll> t(n), c(n);
        rep(i, n){
            cin >> t[i] >> c[i];
        }
        
        using P = tuple<ll,ll,ll,ll>;
        priority_queue<P, vector<P>, greater<P> > q;
        ll btm[2] = { 0, 0 };
        
        rep(i, n) {
            q.push(P(t[i], t[i], i, 1ll));
            btm[0] = max(btm[0], t[i]);
        }
        
        while(!q.empty()){
            ll tm, speed, id, turn;
            tie(tm, speed, id, turn) = q.top(); q.pop();
            ll ntm = max(tm + speed, btm[turn%2]);
            btm[turn%2] = max(btm[turn%2], ntm);
            if(turn+1 == c[id]*2) continue;
            q.push(P(ntm, speed, id, turn+1));
        }
        
        cout << max(btm[0], btm[1]) << endl;
    }
    return 0;
}

Measured memory_bytes: 3068
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;

int main()
{
    int N,K;cin >> N >>K;
    int p[N];
    double s[N];
    vector<double> v;
    for(int i=0;i<N;++i)
    {
        cin >> p[i];
    }
    s[0] = (double) (p[0] + 1)/2;
    cout<<fixed;
    cout << setprecision(12);
    for(int j=1;j<N;++j)
    {
        s[j] = s[j-1] + (double)(p[j]+1)/2;
    }
    v.push_back(s[K-1]);
    for(int a =0;a+K<N;++a)
    {
        v.push_back(s[K+a]-s[a]);
    }
    sort(v.begin(),v.end());
    cout << v.back()<<endl;

}

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

const int maxn=1e3+5;
const int INF=1e9;

char a[maxn],b[maxn];

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

    int ans=INF;
    cin>>a+1>>b+1;
    int lena=strlen(a+1),lenb=strlen(b+1);
    for(int i=1;i<=lena-lenb+1;i++)
    {
        int res=0;
        for(int j=1;j<=lenb;j++) if(a[i+j-1]!=b[j]) res++;
        ans=min(ans,res);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int N, Y, t;
  cin >> N >> Y;

  rep(i, N + 1){
    rep(j, N + 1) {
      t = Y - 10000*i - 5000*j;
      if(t < 0) continue;
      if(t/1000 + i + j == N){
        printf("%d %d %d\n", i, j, t/1000);
        return 0;
      }
    }
  }

  cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
//Nは0
//Mは1
//2つで偶数 n+n m+m
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int m = int.Parse(input[1]);
		n += 1/2;
		m += 1/2;
		if (n == 0){
			Console.WriteLine(m * (m - 1) / 2);
		} else if (m == 0){
			Console.WriteLine(n * (n - 1) / 2);
		} else {
			//Console.WriteLine(((n / 2 * (n - 1) / n + 1) * n+ (m / 2 * (m - 1) / n + 1) * m) - 2);
			Console.WriteLine(n * (n - 1) / 2 + m * (m - 1) / 2);
		}
	}
}

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

using namespace std;

int main()
{
    string a, b;
    cin >> a >> b;

    if( a.size() + 1 != b.size())
        cout << "No" << endl;
    else
    {
        bool f = true;
        for( int i = 0; i < a.size(); i++ )
            if( a[ i ] != b[ i ] )
            {
                f = false;
                break;
            }
        
        if( f )
            cout << "Yes" << endl;
        else    
            cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
let () = Scanf.scanf "%s\n%s\n%d\n" @@ fun s t q ->
  let count_s = Array.make (String.length s + 1) 0 in
  let count_t = Array.make (String.length t + 1) 0 in
  String.iteri (fun i c ->
    count_s.(i + 1) <- count_s.(i) + if c = 'A' then 1 else 2) s;
  String.iteri (fun i c ->
    count_t.(i + 1) <- count_t.(i) + if c = 'A' then 1 else 2) t;
  for i = 0 to q - 1 do
    Scanf.scanf "%d %d %d %d\n" @@ fun a b c d ->
      print_endline @@ 
      if (count_s.(b) - count_s.(a - 1)) mod 3 = (count_t.(d) - count_t.(c - 1)) mod 3 then "YES" else "NO"
  done


Measured memory_bytes: 6656
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <bitset>
#include <climits>
#include <utility>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#define REP(i,n) for(int (i)=0;i<(int)(n);++(i))
#define REPIT(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define PB push_back
#define FT first
#define SD second
#define ZERO(x) memset(x,0,sizeof(x))
#define NEG(x) memset(x,-1,sizeof(x))
#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d%d",&(x),&(y))
#define RIII(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define OIII(x,y,z) printf("%d %d %d\n",(x),(y),(z))
#define OII(x,y) printf("%d %d\n",(x),(y))
#define OI(x) printf("%d\n",(x))
#define OL(x) cout<<(x)<<endl
#define OLL(x,y) cout<<(x)<<" "<<(y)<<endl
#define OLLL(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define RS(s) scanf("%s",(s))
#define MP(x,y) make_pair((x),(y))
#define SZ(x) ((int)(x).size())
#define FIN(f) freopen(f,"r",stdin)
#define FOUT(f) freopen(f,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<int,int> PII;
const int MOD = 1e9+7;
const int maxn = 222222;
int n;
int a[maxn],b[maxn];
int main(int argc, char const *argv[])
{
    RI(n);
    REP(i,n){
        RI(a[i]);
        b[i+1] = a[i];
    }
    sort(a,a+n);
    map<int,int> m;
    for(int i=0;i<n;++i){
        int c = SZ(m) + 1;
        m[a[i]] = c;
    }
    for(int i=1;i<=n;++i)b[i] = m[b[i]];
    int ans = 0;
    for(int i=1;i<=n;++i)if((b[i]%2) != (i%2) )ans++;
    OL(ans/2);
    return 0;
}

Measured memory_bytes: 5760
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		ArrayList<Character> caca = new ArrayList<Character>();
		String n = scn.next();
		for(int i = 0;i<n.length();i++) {
			if(n.charAt(i)=='1')caca.add('1');
			else if(n.charAt(i)=='0')caca.add('0');
			else if(n.charAt(i)=='B') {
				if(!caca.isEmpty())caca.remove(caca.size()-1);
			}
		}for(int i = 0;i<caca.size();i++)System.out.print(caca.get(i));
		System.out.println();
		scn.close();
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
#define fi first
#define sc second
#define mp make_pair
#define pb push_back
#define INF 100000000
int a[(1<<18)],n,ans[(1<<18)];
bool used[(1<<18)],bad;
vector<int>G[(1<<18)],R[(1<<18)];
int rev[(1<<18)],in[(1<<18)];
void solve(int L,int R,vector<int>zan){
	if(L == R){
		ans[L] = zan[0];
		return;
	}
	vector<int>lb,ub;
	for(int i=L;i<R;i+=2){
		if(zan[i-L] > zan[i+1-L]) bad = 1;
		lb.push_back(zan[i-L]);
		ub.push_back(zan[i+1-L]);
	}
	solve(L,(L+R)/2,lb);
	solve((L+R)/2+1,R,ub);
}
int mn[(1<<18)],mx[(1<<18)];
vector<P>vec[(1<<18)];
vector<int>zan;
int main() {
	cin>>n;
	for(int i=0;i<(1<<n);i++){
		cin>>a[i];
		a[i]--;
		if(a[i] >= 0){
			used[a[i]] = 1;
		}
	}
	for(int i=0;i<(1<<n);i++) if(!used[i]) zan.pb(i);
	for(int i=0;i<(1<<n);i++){
		mn[i] = 0;
		mx[i] = INF;
		if(a[i] >= 0){
			mn[i] = mx[i] = a[i];
		}
	}
	for(int i=0;i<(1<<n);i++){
		for(int j=0;j<n;j++){
			if(((i>>j)&1)){
				mn[i] = max(mn[i],mn[i-(1<<j)]);
			}
		}
	}
	for(int i=(1<<n)-1;i>=0;i--){
		for(int j=0;j<n;j++){
			if(!((i>>j)&1)){
				mx[i] = min(mx[i],mx[i+(1<<j)]);
			}
		}
	}
	for(int i=0;i<(1<<n);i++){
		if(mn[i] > mx[i]){
			puts("NO"); return 0;
		}
		if(a[i] == -1) vec[mn[i]].pb(mp(mx[i],i));
	}

	for(int i=0;i<(1<<n);i++) sort(vec[i].begin(),vec[i].end());
	priority_queue<P,vector<P>,greater<P> >que;
	for(int i=0;i<(1<<n);i++){
		for(int j=0;j<vec[i].size();j++){
			que.push(vec[i][j]);
		}
		if(used[i]) continue;
		if(que.empty() || que.top().fi < i){
		    puts("NO"); return 0;
		}
		a[que.top().sc] = i; que.pop();
	}
	//for(int i=0;i<(1<<n);i++) cout<<a[i]<<endl;
	vector<int>zip;
	for(int i=0;i<(1<<n);i++) zip.push_back(a[i]);
	solve(0,(1<<n)-1,zip);
	if(bad) puts("NO");
	else{
		puts("YES");
		for(int i=0;i<(1<<n);i++) printf("%d ",ans[i]+1);
		puts("");
	}
}


Measured memory_bytes: 34928
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int N;
vector<plint> A;

int main()
{
    cin >> N;
    A.resize(N);
    REP(i, N)
    {
        lint a;
        cin >> a;
        A[i] = plint(a, i);
    }
    sort(A.begin(), A.end());

    vector<lint> As(N);
    As[0] = A[0].first;
    FOR(i, 1, N) As[i] = As[i - 1] + A[i].first;

    set<int> ans;
    int now = N - 1;
    while (now >= 0)
    {
        ans.insert(A[now].second);
        if (now == 0 || A[now].first > 2 * As[now - 1]) break;
        now--;
    }
    cout << ans.size() << endl;
}


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

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

    for (int i = 0; i < s.length(); i++)
    {
        if ((!(i & 1) && (s[i] == 'L')) || ((i & 1) && (s[i] == 'R')))
        {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 3628
main(){
  int i,j,key,n,c;
  int A[101];
 
  scanf("%d",&n); /* The n is the number of elements in the sequence. */
   
  if(n<1||n>100){
    return 0;
  }               /* Constraints: 1 <= n <= 100 */
   
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }               /* Scanning n elements of the sequence */
   
  for(i=1;i<=n-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  /* Printing scaned n elements of the sequence */
 
  for(j=2;j<=n;j++){
    key = A[j];
    i = j - 1;
    while(i>0&&A[i]>key){
      A[i+1]=A[i];
      i = i - 1;
    }
    A[i+1]=key;   /* Insertion Sort */
 
    for(c=1;c<=n-1;c++){
      printf("%d ",A[c]);
    }
    printf("%d\n",A[c]);
  }               /* Printing sorted the sequence */
 
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define ll long long
#define rep(i, a, b) for(int i = a; i < b; i++)
using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  int mx = 0;
  vector<vector<int>> v(h+2, vector<int>(w+2, -2));
  queue<pair<int,int>> q;
  rep(i, 1, h+1) {
    rep(j, 1, w+1) {
      char c;
      cin >> c;
      if(c == '#') {
        v[i][j] = 0;
        q.push(make_pair(i, j));
      } else v[i][j] = -1;
    }
  }
  while(!q.empty()) {
    pair<int, int> f = q.front();
    q.pop();
    int x = f.first, y = f.second;
    if(v[x+1][y] == -1) {
      v[x+1][y] = v[x][y] + 1;
      q.push(make_pair(x+1, y));
      if(v[x+1][y] > mx) mx = v[x+1][y];
    }
      if(v[x-1][y] == -1) {
      v[x-1][y] = v[x][y] + 1;
      q.push(make_pair(x-1, y));
      if(v[x-1][y] > mx) mx = v[x-1][y];
    }
      if(v[x][y+1] == -1) {
      v[x][y+1] = v[x][y] + 1;
      q.push(make_pair(x, y+1));
      if(v[x][y+1] > mx) mx = v[x][y+1];
    }
      if(v[x][y-1] == -1) {
      v[x][y-1] = v[x][y] + 1;
      q.push(make_pair(x, y-1));
      if(v[x][y-1] > mx) mx = v[x][y-1];
    }
  }
  cout << mx << "\n";
}
    
    

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(Int64.Parse).ToArray();
            var N = input[0];
            var Y = input[1];

            JudgeMoney(N, Y);
        }

        static private void JudgeMoney(Int64 N, Int64 Y)
        {
            for (Int64 i = 0; i <= N; i++)
            {
                for (Int64 j = 0; j <= (2000 - i); j++)
                {
                    for (Int64 k = 0; k <= (2000 - i - j); k++)
                    {
                        if (i + j + k != N)
                        {
                            continue;
                        }

                        if (Y == (10000 * i + 5000 * j + 1000 * k))
                        {
                            Console.WriteLine($"{i} {j} {k}");
                            return;
                        }
                    }
                }
            }

            Console.WriteLine("-1 -1 -1");
            return;
        }
    }
}



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

int main() {
    int A, B, C, D; cin >> A >> B >> C >> D;
    while(1) {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            break;
        }
    }
}


Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main(){
	long long int N,x=100000,y;
	cin >> N;
	for(int i=0;i<N;i++){
		x = x * 105 / 100;
		y = x/1000;
		if((x%1000)!=0)	x = (y+1)*1000;
	}
	cout << x << endl;
}

Measured memory_bytes: 2964
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int s, w;
    cin >> s >> w;
    if(s <= w)
        cout << "unsafe" << endl;
    else
        cout << "safe" << endl;
    return 0;
}

Measured memory_bytes: 3132
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))

L = []
for i in range(N):
    n = bin(A[i])[::-1].find('1')
    if n != 0:
        L.append(n)
if not L:
    print(0)
else:
    print(sum(L))


Measured memory_bytes: 10140
import           Control.Applicative
import           Data.Array
import           Data.List

main = do
  [h, w] <- fmap read . words <$> getLine :: IO [Int]
  dist <- (fmap (read :: String -> Int) . concatMap words . lines) <$> getContents :: IO [Int]
  let a = listArray ((1, 1), (h, w)) dist
  print $ minCost a

cost (i, j) = sum . fmap (\((i', j'), p) -> min (abs $ i - i') (abs $ j - j') * p) . assocs
minCost a = minimum $ fmap (`cost` a) $ indices a



Measured memory_bytes: 4704
<?php
fscanf(STDIN,'%s%s',$X,$Y);
$x=0;
$y=0;
if($X=='A'){
  $x=10;
}
if($X=='B'){
  $x=11;
}
if($X=='C'){
  $x=12;
}
if($X=='D'){
  $x=13;
}
if($X=='E'){
  $x=14;
}
if($X=='F'){
  $x=15;
}
if($Y=='A'){
  $y=10;
}
if($Y=='B'){
  $y=11;
}
if($Y=='C'){
  $y=12;
}
if($Y=='D'){
  $y=13;
}
if($Y=='E'){
  $y=14;
}
if($Y=='F'){
  $y=15;
}
if($x==$y){
  echo '=';
}elseif($x<$y){
  echo '<';
}else{
  echo '>';
}
 ?>

Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<50);
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    ll ix,iy;cin>>ix>>iy;
   
    if(abs(ix-iy)>1)cout<<"Alice"<<endl;
    else cout<<"Brown"<<endl;
    
    return 0;
}












Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから
void solve(){
  vector<vector<int>>a(3,vector<int>(3));
  rep(i,3){
    rep(j,3)cin>>a[i][j];
  }
  int n;
  cin>>n;
  vector<int>b(n);
  rep(i,n)cin>>b[i];
  vector<vector<bool>>v(3,vector<bool>(3));
  rep(i,n){
    rep(j,3){
      rep(k,3){
        if(b[i]==a[j][k])v[j][k]=true;
      }
    }
  }
  bool ok=false;
  rep(i,3){
    if(v[i][0]&&v[i][1]&&v[i][2])ok=true;
    if(v[0][i]&&v[1][i]&&v[2][i])ok=true;
    if(v[0][0]&&v[1][1]&&v[2][2])ok=true;
    if(v[0][2]&&v[1][1]&&v[2][0])ok=true;
  }
  if(ok)cout<<"Yes";
  else cout<<"No";
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
void trace(int n, vector<ll> arr){for(int i = 0; i < n; i++){cout << arr[i] << " ";} cout << endl << endl;}
const ll mod = 1e9 + 7;
int main()
{
    Hello
    int ans = 0;
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < s.size(); i++)
        if(s[i] != t[i])
            ans++;
    cout << ans;
    return 0;
}

Measured memory_bytes: 3844
#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 req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}



  








      

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

    vector <ll> s(n+1,0);
    map <ll,ll> nums;
    rep (i,n) s[i+1] = s[i]+ a[i];
    rep (i,n+1) nums[s[i]]++;
    long long res = 0;
    for (auto it : nums) {
        long long num = it.second; // it.first が it.second 個ある
        res += num * (num - 1) / 2;
    }
    cout << res << endl;
}




Measured memory_bytes: 18716
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int t[] = new int[n];
    for(int i = 0 ; i < n ; ++i){
      t[i] = sc.nextInt();
    }
    int m = sc.nextInt();
    
    for(int i = 0 ; i < m ; ++i){
      int x[] = new int[n];
      for(int j = 0 ; j < n ; ++j){
        x[j] = t[j];
      }
      int p = sc.nextInt();
      x[p-1] = sc.nextInt();
      int ans = 0;
      for(int j = 0 ; j < n ; ++j){
        ans += x[j];
      }
      System.out.println(ans);
    }
    
    
  }
}


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

using namespace std;

int main() {
    string s;
    cin>>s;
    
    int ans=0,n=s.size();
    int i=0;
    while(i<n){
        if(s[i]=='R'){
            int c=0;
             while(s[i]=='R'&&i<n){
                c++;
                i++;
            }
            
            ans=max(ans,c);
        }
        else
            i++;
        
       
    }
    
    cout<<ans;
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
template <typename T> using vec = vector<T>;
typedef vec<int> vi;
typedef vec<ll> vl;


template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

string s,t;

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

  int res = 0;
  forn(i,3)
    res += s[i] == t[i];

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
///
// File:  2565.cpp
// Author: ymiyamoto
//
// Created on Sun Nov 26 23:04:35 2017
//

#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int32_t main()
{
  while (true) {
    int32_t n;
    cin >> n;

    if (n == 0) break;

    vector<string> signals(n + 1);
    for (int32_t i = 1; i <= n; i++) {
      cin >> signals[i];
    }

    bool invalid = false;
    int64_t xodd = INT32_MAX;
    int64_t xeven = INT32_MIN;
    for (int32_t i = 1; i <= n; i++) {
      if (i + 1 <= n && signals[i] == signals[i + 1]) {
        invalid = true;
      }

      if (signals[i] != "x") {
        if (i % 2 == 1) {
          int64_t s = stoll(signals[i]);
          if (i - 1 >= 1 && signals[i - 1] != "x" && s >= stoll(signals[i - 1])) {
            invalid = true;
          }
          if (i + 1 <= n && signals[i + 1] != "x" && s >= stoll(signals[i + 1])) {
            invalid = true;
          }
        } else {
          int64_t s = stoll(signals[i]);
          if (i - 1 >= 1 && signals[i - 1] != "x" && s <= stoll(signals[i - 1])) {
            invalid = true;
          }
          if (i + 1 <= n && signals[i + 1] != "x" && s <= stoll(signals[i + 1])) {
            invalid = true;
          }
        }
      } else {
        if ((i - 1 >= 1 && signals[i - 1] == "x") || (i + 1 <= n && signals[i + 1] == "x")) {
          invalid = true;
        } else {
          if (i % 2 == 1) {
            int64_t x1 = i - 1 >= 1 ? stoll(signals[i - 1]) : INT64_MAX;
            int64_t x2 = i + 1 <= n ? stoll(signals[i + 1]) : INT64_MAX;
            xodd = min(xodd, min(x1, x2) - 1);
          } else {
            int64_t x1 = i - 1 >= 1 ? stoll(signals[i - 1]) : INT64_MIN;
            int64_t x2 = i + 1 <= n ? stoll(signals[i + 1]) : INT64_MIN;
            xeven = max(xeven, max(x1, x2) + 1);
          }
        }
      }
    }
    if (invalid) {
      cout << "none" << endl;
    } else if (xodd == xeven) {
      cout << xodd << endl;
    } else if (xodd < xeven) {
      cout << "none" << endl;
    } else {
      cout << "ambiguous" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=10000000007;

int main(){
  ll d,g;cin>>d>>g;
  g/=100;
  ll sc[d];
  ll b[d];
  rep(i,d){
    cin>>sc[i]>>b[i];
    b[i]/=100;
  }
  ll cnt=INF;
  rep(i,(1<<d)){
    ll now=0;
    ll c=0;
    rep(j,d){
      if(1&(i>>j)){
        now+=sc[j];
        c+=sc[j]*(j+1);
        c+=b[j];
      }
    }
    if(c>=g) {cnt=min(cnt,now);}
    else{
      rep(j,d){
        if(!(1&(i>>(d-j-1)))){
          ll a=(g-c)/(d-j);
          if((g-c)%(d-j)!=0) a++;
          if(a<sc[d-j-1]){
            now+=a;
            cnt=min(cnt,now);
          }
          break;
        }
      }
    }
  }
  
  cout<<cnt<<endl;
}
           

Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for(ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<typename S, typename T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<typename S, typename T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

template <typename T> bool print_(const T& a) {
    cout << a;
    return true;
}

template <typename T> bool print_(const vector<T> &vec) {
    for(auto &a : vec) {
        cout << a;
        if(&a != &vec.back()) cout << " ";
    }
    return false;
}

template <typename T> bool print_(const vector<vector<T>>& vv) {
    for(auto &v : vv) {
        for(auto &a : v) {
            cout << a;
            if(&a != &v.back()) cout << " ";
        }
        if(&v != &vv.back()) cout << "\n";
    }
    return false;
}

void print() { cout << "\n"; }

template <typename Head, typename... Tail> 
void print(Head &&head, Tail &&... tail) {
    bool f = print_(head);
    if(sizeof...(tail) != 0) cout << (f ? " " : "\n");
    print(forward<Tail>(tail)...);
}

#pragma endregion

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vvll ans;
    repr(i, 1, n+1)repr(j, i+1, n+1){
        if(i+j != (n%2==0 ? n+1 : n)){
            ans.emplace_back(vll{i, j});
        }
    }
    print(SZ(ans));
    print(ans);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    int n,q;
    cin >> n >> q;
    queue<tuple<string,int,int>> que;
    rep(i,n){
        string s;
        int t;
        cin >> s >> t;
        que.push(make_tuple(s,t,0));
    }
    int past = 0;
    while(!que.empty()){
        auto a = que.front();
        que.pop();
        if(get<1>(a) - q <= 0){
            past += get<1>(a);
            cout << get<0>(a) << " " << past << endl;
            continue;
        }else{
            get<1>(a) -= q;
            int& time = get<2>(a);
            time++;
            que.push(a);
        }
        past += q;
    }
    return 0;
}


Measured memory_bytes: 6180