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

#define 	pi 						3.1415926536
#define 	mod 					1000000007
#define 	lli 					long long int
#define 	rep(i, n) 				for(int i = 0 ; i < n ; i++)
#define 	repn(i, n) 				for(int i = n - 1 ; i >= 0 ; i--)
#define 	loop(i, a, b)			for(int i = a ; i < b ; i++)
#define		loopn(i, a, b) 			for(int i = a ; i >= b ; i--)
#define 	mod1 					1000003
#define 	hello 					"hello"
#define 	nl 						"\n"
#define 	ws 						" "
#define 	F 						first
#define 	S 						second
#define 	pb 						push_back
#define 	mp						make_pair
#define 	B 						begin()
#define 	E 						end()
#define 	all(v) 					v.begin(), v.end()
#define 	reset(a, val) 			memset(a, val, sizeof(a))
#define 	vi 						vector<int>
#define 	vs 						vector<string>
#define 	print(a) 				for(auto i : a)cout<<i<<" ";cout<<"\n"
#define     ispresent(hmp, val)  	(hmp.find(val) != hmp.end()) //for set and map
#define 	boost 					ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;

//g++ -std=c++14
//fixed<<setprecision(9);
//max_element(mp.begin(), mp.end(), compare)
//greater<int>()


bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }

bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second < b.second; }

int main()
{
	int n, m, s, c, a;
	cin>>n>>m;
	vi arr(n, -1);
	bool flag = true;
	rep(i, m)
	{
		cin>>s>>c;
		if(arr[s-1] == -1 || arr[s-1] == c)
			arr[s-1] = c;
		else
		{
			flag = false;	
		}

	}
	
	if(n > 1 && arr[0] == -1)
		arr[0] = 1;
	rep(i, n)if(arr[i] == -1)arr[i] = 0;
	if(flag)
	{
		if(n>1 && !arr[0] && !arr[1])
			cout<<-1<<nl;
		else
		{		
			rep(i, n)cout<<arr[i];
			cout<<nl;
		}
	}
	else
	{
		cout<<-1<<nl;
	}
	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    vector<ll> CumulativeSum(n + 1);
    CumulativeSum[0] = 0;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        CumulativeSum[i + 1] = CumulativeSum[i] + a[i];
    }
    vector<int> m(n + 1);
    for(int i = 0; i <= n; ++i) m[i] = (CumulativeSum[i] - i) % k;
    map<int, int> mp;
    int left = 0, right = 0;
    ll ans = 0;
    while(right <= n){
        if(right - left >= k)   --mp[m[left++]];
        ans += mp[m[right++]]++;
        // cerr << left << ' ' << right << ' ' << ans << endl;
        // for(auto it : mp){
        //     cerr << "val:" << it.first << ",cnt:" << it.second << endl;
        // }
    }
    cout << ans << endl;
}

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

int main() {
  string S;
  cin >> S;
  int n = 0;
  int m = 0;
  for (int i = 0; i < 3; i++) {
    if (S[i] == 'R') n++;
    else n = 0;
    m = max(n,m);
  }
  cout << m << endl;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  double c = a, d = b;
  if ((c + d)/2 - (a + b)/2 == 0)
  	cout << (a + b)/2 << endl;
  else 
    cout << (a + b)/2 + 1 << endl;
}

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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int a, b;
	cin >> a >> b;
	if (a == 1 && b == 1) {
		print(1);
		return 0;
	}
	set<int>primea;
	set<int>primeb;
	int i = 2;
	while (a >= i * i) {
		if (a % i == 0) {
			primea.insert(i);
			a /= i;
		}
		else {
			i++;
		}
	}
	primea.insert(a);
	i = 2;
	while (b >= i * i) {
		if (b % i == 0) {
			primeb.insert(i);
			b /= i;
		}
		else {
			i++;
		}
	}
	primeb.insert(b);

	int ans = 1;
	for (auto tmp : primea) {
		auto it = primeb.find(tmp);
		if (it != primeb.end()) {
			ans++;
		}
	}
	println(ans);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int c[MAXN],f[MAXN],s[MAXN];
int main(){
    //~ freopen("file.in", "r", stdin);
	int n;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
		scanf("%d%d%d",c+i,s+i,f+i);
	for(int i=1;i<=n;i++){
		int now=0;
		for(int j=i;j<n;j++){
			if(now<=s[j])
				now=s[j]+c[j];
			else{
				int dif=(now-s[j]+f[j]-1)/f[j];
				now=s[j]+dif*f[j]+c[j];
			}	
		}
		printf("%d\n",now);
	}	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a;
		for (int i = 1; i <= n; i++) {
			if (i % 3 == 0 || i % 10 == 3) {
				System.out.print(" " + i);
			} else if (i >= 30) {
				a = i;
				while (a >= 30) {
					a /= 10;
					if (a == 3 || a % 10 == 3) {
						System.out.print(" " + i);
						break;
					}
				}
			}
		}
		System.out.println();
	}
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s;
int n;

int main() {
	cin >> s;
	n = s.size();
	
	reverse(ALL(s));
	
	LL ans = 0, w = 0;
	inc(i, n) {
		if(s[i] == 'W') { w++; } else { ans += w; }
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int x, y;
	cin >> x >> y;
	
	cout << x + y / 2 << endl;
	
	return 0;
}


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


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)


def main():
    N, M = map(int, input().split())
    P = list(map(int, input().split()))
    uf = UnionFind(N)
    for i in range(M):
        x, y = map(int, input().split())
        uf.union(x-1, y-1)
    ans = 0
    for i in range(N):
        if uf.same(P[i]-1, i):
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 84368
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
ll m=1000000007;
ll sieve[1000001]={0},i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p)%m;
p=(p*p)%m;
k>>=1;
}
return a;
}
using namespace std;
int main()
{
 
 int tc=1;
// cin>>tc;
 while(tc--)
 {
	ll n;
	cin>>n;
	ll a[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	map<ll,ll> m;
	ll ans=0;
	for(i=0;i<n;i++)
	m[a[i]]++;
	for(auto x: m)
	if(x.second>=1)
	ans+= x.second*(x.second-1)/2;
	for(i=0;i<n;i++)
	{
		ll y=m[a[i]];
		ll sum=ans;
		if(y>=1)
		sum-=y*(y-1)/2;
		if(y>=2)
		sum+=(y-1)*(y-2)/2;
		cout<<sum<<"\n";
	}
	 //cout<<"\n";
 }
}


Measured memory_bytes: 11008
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

typedef pair<int,int> s;

int abs(int x){
  return x > 0 ? x : -x;
}

int length(char c[]){
  int cnt=0;
  for(cnt=0;c[cnt]!='\0';cnt++){
  }
  return cnt;
}
char ss[7];
int sum=0;
int main(){
  scanf("%s",ss);
  for(int i=0;i<6;i++){
    sum+=ss[i]-'0';
  }
  printf("%d\n",sum );
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    double a[n];
    double sum = 0;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        sum += 1.0 / a[i];
    }
    
    cout << 1.0 / sum << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String arga[]){
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int c = sc.nextInt();
		
		int[] b = new int[a];
		int[] d = new int[c];
		
		int ans =0;
		
		
		boolean[] z = new boolean[a];
		
		for(int i= 0;i<c;i++){
			d[i] = sc.nextInt();
			
			for(int n=0;n<d[i];n++){
				b[n] = sc.nextInt();
				z[b[n]-1] = true;  /*ここを-1にしなければ、z[0]にtrueが入ることがなくなる*/
			}
		}
		
		
		 for(int j = 0; j < a; j++) {
        	if(z[j] == false) ans++; 
        }
		System.out.println(ans);
		
	}
}

	
		

Measured memory_bytes: 46056
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		ArrayList<Integer>[] candyList = new ArrayList[N];
		for (int i = 0; i < candyList.length; i++) {
			candyList[i] = new ArrayList<>();
		}
		for (int i = 0; i < K; i++) {
			int d = sc.nextInt();
			for (int j = 0; j < d; j++) {
				candyList[Integer.parseInt(sc.next()) - 1].add(i);
			}
		}
		int cnt = 0;
		for (List l : candyList) {
			if(l.isEmpty()) cnt++;
		}
		pw.println(cnt);
		pw.close();
	}	

	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

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

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

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

		public String nextLine() throws IOException {return br.readLine();}

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

		public double nextDouble(String x) 
		{

			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}


	}
}

Measured memory_bytes: 33732
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var A = cin.ReadLong;
            var B = cin.ReadLong;
            var ans = Lcm(A, B);
            Console.WriteLine(ans);
        }

        public static long Lcm(long a, long b) {
            return a * b / Gcd(a, b);
        }

        public static long Gcd(long a, long b) {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0) {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 13268
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        
        String a = str.substring(0,1);
        String b = str.substring(1,2);
        String c = str.substring(2,3);
        String d = str.substring(3,4);
        
        boolean ok = true;
        if (a.equals(b)) {
            ok = false;
        }
        if (b.equals(c)) {
            ok = false;
        }
        if (c.equals(d)) {
            ok = false;
        }
        
        if (ok) {
            System.out.println("Good");
        } else {
            System.out.println("Bad");
        }
    }
}


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

int main()
{
  long long n;
  cin>>n;
  long long h[n],a[n];
  long long i;
  for(i=0;i<n;i++){
    cin>>h[i];
    a[n-1-i]=h[i];
  }
  bool flag=0;
  for(i=1;i<n;i++){
    if(a[i]-a[i-1]==1) a[i]--;
    else if(a[i]-a[i-1]>1){
      flag=1;break;
    }
  }
  string ans;
  if(flag==0) ans="Yes";
  else ans="No";
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
n, yen = map(int, input().split())
yen //= 1000

for noguchi in range(n + 1):
    for higuchi in range(n + 1 - noguchi):
        yukichi = n - noguchi - higuchi
        if noguchi + higuchi *  5 + yukichi * 10 == yen:
            print(yukichi, higuchi, noguchi)
            exit(0)
print("-1 -1 -1")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
const LL mod=1e9+7;
const LL LL_MAX=9223372036854775807;
using namespace std;
int l,r;
struct node{
    int x,y;
}a[Max];
bool cmp(node a,node b){
    return a.x<b.x;
}
int ans=0;
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d%d",&a[i].x,&a[i].y);
    }
    sort(a,a+m,cmp);
    if(m==1)
        printf("%d\n",a[0].y-a[0].x+1);
    else{
        l=a[0].x,r=a[0].y;
        for(int i=1;i<m;i++){
            l=max(l,a[i].x);
            r=min(r,a[i].y);
        }
        printf("%d\n",max(0,r-l+1));
    }
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		new Main().solve(new Scanner(System.in));
	}
	
	public void solve(Scanner sc) {
		int h = sc.nextInt();
		int w = sc.nextInt();
		
		while(sc.hasNextLine()) {
			String c = sc.nextLine();
			System.out.println(c);
			System.out.println(c);
		}
	}
}


Measured memory_bytes: 11344
N, Y = map(int, input().split())
ans = 0
for noguchi in range(N + 1):  # 1000円札の枚数
    if ans == 1:
        break
    for higuchi in range(N - noguchi+1):  # 5000円札の枚数
        if 1000 * noguchi + 5000 * higuchi + 10000 * (N - higuchi - noguchi) == Y:
            ans = 1
            print("{} {} {}".format(N - noguchi - higuchi, higuchi, noguchi))
            break
if ans == 0:
    print("-1 -1 -1")


Measured memory_bytes: 2940
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

typedef pair<ll,ll> p;

int main(){
  ll n;
  cin >> n;
  vector<p> x;
  REP(i,n){
    ll xi; cin >> xi;
    x.push_back(p(xi,i));
  }
  sort(x.begin(),x.end());
  ll smaller = x[n/2-1].first;
  ll larger = x[n/2].first;
  map<ll,ll> mp;
  REP(i,n){
    mp[x[i].second] = (i<=n/2-1) ? larger : smaller;
  }
  REP(i,n){
    cout << mp[i] << endl;
  }
  return 0;
}


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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll a,b,k;
	cin>>a>>b>>k;
	a-=k;
	if(a<0){
		k=-1*a;
		a=0;
	}else k=0;
	b-=k;
	if(b<0)b=0;
	cout<<a<<" "<<b<<'\n';
	return 0;
}


// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""
 


Measured memory_bytes: 3620
// @author: arch_

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

int main(void) {
    int n; cin >> n;
    long a_min = 1000000, a_max = -1000000, a_sum = 0;

    long x;
    for (int i = 0; i < n; i++) {
        cin >> x;
        a_min = min(a_min, x);
        a_max = max(a_max, x);
        a_sum += x;
    }

    printf("%ld %ld %ld\n", a_min, a_max, a_sum);
    return 0;
}

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

int main(){
	string s;
	vector<int> data;
	while(cin >> s){
		data.clear();
		for(int i=0;i<s.length();i++){
			data.push_back(s[i]-'0');
		}
		int n = 10;
		while(n != 1){
			vector<int> hoge;
			for(int i=0;i+1<n;i++){
				hoge.push_back((data[i]+data[i+1])%10);
			}
			data = hoge;	
			n--;
		}
		cout << data[0] << endl;
	}
}

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

ll k;

ll ksm(ll a, ll b) {
    ll res = 0;
    for(; b; b <<= 1, a = a * a % k) if(b & 1) res = res * a % k;
    return res;
}

inline void solve(int T) {

    cin >> k;
    ll tmp = 0;
    rep(i, 1, k) {
        tmp = (tmp * 10 + 7) % k;
        if(tmp == 0) {
            cout << i << endl;
            return;
        }
    }
    cout << "-1\n";

}   
int main()
{
    // ios_base::sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);
 
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
 
    int T = 1;
    // cin >> T;
    rep(i, 1, T) solve(i);
    // system("pause");
}

Measured memory_bytes: 3528
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
ll inf = 100000000;
typedef pair<ll, ll> P;
int main() {
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	ll count = 0;
	for (int i = 0; i <= n / r; i++) {
		for (int j = 0; j <= n / g; j++) {
			int z = n - (i * r + j * g);
			if (z % b == 0&&z>=0) {
				count++;
				
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int n=in();int K=in();
	int x[n],y[n];
	for(int i=0;i<n;i++){x[i]=in();y[i]=in();}
	int ans=4e18;int ct=0;
	for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	{
		if(x[i]>=x[j])continue;
		
		for(int k=0;k<n;k++)
		for(int l=0;l<n;l++)
		{
			if(y[k]<=y[l])continue;
			ct=0;
			for(int g=0;g<n;g++)
			{
				if(x[i]<=x[g] and x[g]<=x[j] and y[l]<=y[g] and y[g]<=y[k])ct++;
			}
			if(ct>=K)ans=min(ans,(x[j]-x[i])*(y[k]-y[l]));
		}	
	}
	cout<<ans;
	
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
int n,y; 
int main()
{
	cin>>n>>y;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=n-i;j++)
		{
			if(i*10000+j*5000+(n-i-j)*1000==y)
			{
				cout<<i<<' '<<j<<' '<<n-i-j<<endl;
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1"<<endl;
	return 0;
}


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

#define int long long

vector<pair<int, int> > v[200010];
int level[200010];
int dist[200010];
int table[20][200010];
int parent[200010];

void dfs(int par, int node, int d, int depth)
{
    dist[node]=d;
    level[node]=depth;
    parent[node]=par;
    for(int i=0; i<v[node].size(); i++) {
        int cur=v[node][i].first;
        if(par!=cur) {
            dfs(node, cur, d+v[node][i].second, depth+1);
        }
    }
}

void make_table(int n)
{
    for(int i=0; i<20; i++) {
        for(int j=1; j<=n; j++) {
            table[i][j]=-1;
        }
    }
    for(int i=1; i<=n; i++) {
        table[0][i]=parent[i];
    }
    for(int i=1; i<20; i++) {
        for(int j=1; j<=n; j++) {
            int mid=table[i-1][j];
            if(mid!=-1) {
                table[i][j]=table[i-1][mid];
            }
        }
    }
}

pair<int, int> walk(int a, int b)
{
    if(level[a]>level[b]) swap(a, b);
    int k=level[b]-level[a];
    for(int i=19; i>=0; i--) {
        if(k&(1<<i)) {
            b=table[i][b];
        }
    }
    return {a, b};
}

int __lca(int a, int b)
{
    pair<int, int> fnl=walk(a, b);
    a=fnl.first, b=fnl.second;
    if(a==b) return a;
    for(int i=19; i>=0; i--) {
        if(table[i][a]!=table[i][b]) {
            a=table[i][a], b=table[i][b];
        }
    }
    return parent[a];
}

int get_distance(int a, int b)
{
    return dist[a]+dist[b]-2*dist[__lca(a, b)];
}


int32_t main () {
	int n; cin>>n;
	for(int i=1; i<n; i++) {
		int uu, vv, w;
		cin>>uu>>vv>>w;
		v[uu].push_back({vv, w});
		v[vv].push_back({uu, w});
	}
	dfs(-1, 1, 0, 0);
    make_table(n);
    int Q, k; cin>>Q>>k;
    while ( Q-- ) {
    	int x, y; cin>>x>>y;
    	cout<<get_distance(x, k)+get_distance(k, y)<<endl;
    }
    //system("pause");
	return 0;
}

Measured memory_bytes: 54144
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC163B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = RInt;
            var M = RInt;
            var A = RInts;

            int ans = N - A.Sum();
            if (ans < 0) ans = -1;
            Console.WriteLine(ans);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String RNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int RInt => int.Parse(RNext());
        public static long RLong => long.Parse(RNext());
        public static int[] RInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] RLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
        public static string RString => RNext();
        //以下未テスト
        public static int[] RIntsC(int c) => Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
        public static long[] RLongsC(int c) => Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
        public static char[][] RMap(int h) => Enumerable.Repeat(0, h).Select(x => Console.ReadLine().ToCharArray()).ToArray();
    }

    static class Debug
    {
        static public void Draw2D<T>(T[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            T[,] map2 = new T[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = (T)(object)0;
                    else if (i == 0) map2[i, j] = (T)(object)(j - 1);
                    else if (j == 0) map2[i, j] = (T)(object)(i - 1);
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write((dynamic)map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

int N;
int B[105];

signed main()
{
  cin >> N;
  N--;
  REP(n,N) cin >> B[n];

  int ans = B[0] + B[N-1];
  REP(n,N-1) {
    ans += min(B[n], B[n+1]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

#define Maxn 1000050
#define Maxm 1000050
#define Maxnum 1000001

using namespace std;

using namespace std;

inline int read() {
    int x = 0, f = 1;
    char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while('0' <= c && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

int n, m, a[Maxn], c[Maxn], nex, old[Maxnum];

struct Ask{
	int id, l, r, ans;
}
ask[Maxm];

int comp1(Ask x, Ask y) {
	return x.r < y.r;
}

int comp2(Ask x, Ask y) {
	return x.id < y.id;
}

int lowbit(int x){
	return x & (-x);
}

void add(int x, int val) {
	while(x <= n) {
		c[x] += val;
		x += lowbit(x);
	}
}

int query(int x) {
	int sum=0;
	while(x) {
		sum += c[x];
		x -= lowbit(x);
	}
	return sum;
}

int main()
{
	n = read(); m = read();
	for(int i = 1;i <= n; i++) a[i] = read();
	for(int i=1; i <= m; i++) {
		ask[i].id = i;
		ask[i].l = read();
		ask[i].r = read();
	}
	sort(ask + 1, ask + m + 1, comp1);
	nex = 1;
	for(int i = 1; i <= m; i++) {
		for(int k = nex; k <= ask[i].r; k++) {
			if(old[a[k]]) add(old[a[k]], -1);
			add(k, 1);
			old[a[k]] = k;
		}
		ask[i].ans = query(ask[i].r) - query(ask[i].l-1);
		nex = ask[i].r + 1;
	}
	sort(ask + 1, ask + m + 1, comp2);
	for(int i = 1; i <= m; i++) printf("%d\n", ask[i].ans);
	return 0;
}

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

int main() {
	int x,y;
  	cin>>x>>y;
  	if(2*x<=y && y<=4*x && y%2==0) cout<<"Yes"<<endl;
  	else cout<<"No"<<endl;
  	
}

Measured memory_bytes: 3652
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx")
#include <bits/stdc++.h>

constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int a;
	cin >> a;
	cout << 3 * a * a << endl;

}

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

int main(){
	double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
	while( cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2 ){
		if( xa1 <= xb2 && ya1 <= yb2 && xb1 <= xa2 && yb1 <= ya2)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

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

		int n = Integer.parseInt(sc.next());
		int[] s = new int[n];
		ArrayList<Integer> arr = new ArrayList<Integer>();
		int sum = 0;

		for (int i = 0; i < n; i++) {
			s[i] = Integer.parseInt(sc.next());
			sum += s[i];
			if (s[i] % 10 != 0)
				arr.add(s[i]);
		}
		Collections.sort(arr);

		if (sum % 10 != 0) {
			System.out.println(sum);
		} else if (arr.isEmpty()) {
			System.out.println(0);
		} else {
			System.out.println(sum - arr.get(0));
		}
	}

}


Measured memory_bytes: 22740
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		String s = sc.next();

		if (a >= 3200)
			System.out.println(s);
		else
			System.out.println("red");

	}

}

Measured memory_bytes: 21204
use proconio::input;

const M: u64 = 1000_000_007;

fn main() {
    input! { n: usize }

    let mut a = vec![0; n];
    for i in 0..n {
        for j in 0..n {
            input! { aij: usize };
            a[i] |= aij << j;
        }
    }

    println!("{}", DP::new(n, a).calc(0));
}

struct DP {
    dp: Vec<Vec<Option<u64>>>,
    n: usize,
    a: Vec<usize>,
}

impl DP {
    fn new(n: usize, a: Vec<usize>) -> DP {
        DP {
            dp: vec![vec![None; 1 << n]; n + 1],
            n: n,
            a: a,
        }
    }

    fn calc(&mut self, p: usize) -> u64 {
        let i = p.count_ones() as usize;
        if let Some(v) = self.dp[i][p] {
            v
        } else {
            let v = if i == self.n {
                1
            } else {
                let rest = self.a[i] & !p;
                let mut v = 0;
                for j in 0..self.n {
                    let b = 1 << j;
                    if rest & b == b {
                        v = (v + self.calc(p | b)) % M;
                    }
                }
                v
            };
            self.dp[i][p] = Some(v);
            v
        }
    }
}


Measured memory_bytes: 722976
n, a, b = map(int, input().split())
S = input()

for s in S:
    if s == 'c':
        print('No')
    elif s == 'b':
        if b:
            print('Yes')
            b -= 1
        else:
            print('No')
    else:
        if a:
            print('Yes')
            a -= 1
        elif b:
            print('Yes')
            b -= 1
        else:
            print('No')


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

using namespace std;

#define ll       long long

#define  sci(x)   scanf("%d", &x)
#define  scl(x)   scanf("%lld", &x)
#define  scd(x)   scanf("%lf", &x)

#define  pfi(x)   printf("%d", x)
#define  pfl(x)   printf("%lld", x)
#define  pfd(x)   printf("%lf", x)
#define  pfc(x)   printf("Case %d: ", x++)
#define  ps       printf(" ")
#define  pn       printf("\n")

#define  pb       push_back
#define  ppb      pop_back
#define  pf       push_front
#define  ppf      pop_front
#define  In       insert
#define  All(a)   a.begin(), a.end()

int dp[3005][3005];
pair<int, int> path[3005][3005];

char s[3005], t[30005];

int solve(int i, int j)
{
	if(s[i] =='\0' || t[j] == '\0')
		return 0;

	if(dp[i][j] != -1)
		return dp[i][j];

	if(s[i] == t[j])
	{
		path[i][j] = make_pair(i + 1, j + 1);
		return dp[i][j] = 1 + solve(i + 1, j + 1);
	}
	else
	{
		int p = solve(i + 1, j), q = solve(i, j + 1);
		if(p > q)
			path[i][j] = make_pair(i + 1, j);
		else
			path[i][j] = make_pair(i, j + 1);
		return dp[i][j] = max(p, q);
	}
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    memset(dp, -1, sizeof dp);
    scanf(" %s", s);
    scanf(" %s", t);

    solve(0, 0);

    pair<int, int> curr;
    while(1)
    {
    	if(s[curr.first] == '\0' || t[curr.second] == '\0')
    		return 0;
    	if(s[curr.first] == t[curr.second])
    		printf("%c", s[curr.first]);
    	curr = path[curr.first][curr.second];
    }

    return 0;
}

Measured memory_bytes: 106496
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <climits>
#include <iomanip>
#include <sstream>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

template <typename T>
T gcd(T a, T b) {
	while (b != 0) {
		T temp = a;
		a = b;
		b = temp % b;
	}

	return a;
}

// cout << setfill('0') << setw(5) << number < endl;
// while(getline(cin, s)) { .. } | `s` is a string

void solve() {
	int n;
	cin >> n;
	std::vector<ull> a(n);
	ull sum = 1, limit = 1e18;
	bool flag = true;
	for (auto &it : a) {
		cin >> it;
	}

	sort(a.rbegin(), a.rend());
	if (a.back() == 0) {
		cout << 0 << endl;
		return ;
	}
	sum = a.back();
	for (int i = a.size() - 2; i >= 0; --i) {
		if (a[i] > limit / sum) {
			flag = false;
			break;
		} else {
			sum *= a[i];
		}
	}

	if (flag) {
		cout << sum << endl;
	} else {
		cout << -1 << endl;
	}
}	

int main(){
	IOS;
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif
	
	
	int t = 1;
	// cin >> t;
	while(t--)
		solve();
	
	return 0;
}





























Measured memory_bytes: 3992
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
#include <set>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}



int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/


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

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int A,B,C,D,E,F;

	cin >> A >> B >> C >> D >> E >> F;
	set <int> water;
	set <int> sugar;
	for (int i = 0; i <= F + 1; i += 100 * A)
	{
		for (int j = 0; j <= F -i + 1; j += 100 * B)
		{
			water.insert(i + j);
		}
	}

	for (int i = 0; i <= F + 1; i += C)
	{
		for (int j = 0; j <= F - i + 1; j += D)
		{
			sugar.insert(i + j);
		}
	}
 
	int vol = 0;
	int sugar_max = 0;
	for (auto & w : water)
	{
		for (auto& s : sugar)
		{
			if (w + s > F)
			{
				break;
			}
			if ((w + s) * E < (100 + E) * s)
			{
				break;
			}
			if (sugar_max * (w + s) <= s * vol)
			{
				sugar_max = s;
				vol = w + s;
			}
		}
	}

	
	
		cout << vol << " " << sugar_max << endl;
	return 0;

}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	
	int a,b,l=0;
	while(1){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0)return 0;
		if(l==1)cout<<endl;
		int k=0;
		for(int i=0;i<b-a+1;i++){
			if((a+i)%4==0&&(a+i)%400!=100&&(a+i)%400!=200&&(a+i)%400!=300){cout<<a+i<<endl;k=1;}
		}
		if(k==0)cout<<"NA"<<endl;
		l=1;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    std::string s; std::cin >> s;
    std::vector<std::string> ss = { "Sunny", "Cloudy", "Rainy" };
    for (int i = 0; i < 3; i++) {
        if (s == ss[i]) {
            std::cout << ss[(i + 1) % 3] << std::endl;
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) {
    int temp = x;
    x = y;
    y = temp;
  }
  while (1) {
    if (x % y == 0)
      break;
    else {
      int temp = x % y;
      x = y;
      y = temp;
    }
  }
  return y;
}

int main(void)
{
  int n, i;
  scanf("%d", &n);

  int a[100005];
  int l[100000];
  int r[100000];
  int ans = 0;
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (i == 0)
      l[i] = a[i];
    else
      l[i] = gcd(a[i], l[i-1]);
  }
  for (i = n-1; i >= 0; i--) {
    if (i == n-1)
      r[i] = a[n-1];
    else
      r[i] = gcd(a[i], r[i+1]);
  }
  for (i = 0; i < n-2; i++) {
    if (ans < gcd(l[i], r[i+2]))
      ans = gcd(l[i], r[i+2]);
  }
  if (ans < l[n-2])
    ans = l[n-2];
  if (ans < r[1])
    ans = r[1];
  printf("%d\n", ans);

}


Measured memory_bytes: 1280
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if op == "?":
        break
    else:
        if op == "+":
            print(a+b)
        elif op == "-":
            print(a-b)
        elif op == "*":
            print(a*b)
        else:
            print(a//b)


Measured memory_bytes: 5596
N = int(raw_input())
p = 0
b = [0,0,0]
o = 0
while True:
    try:
        e = raw_input()
        if e == 'HIT':
            if b[-1] == 1:
                p += 1
            b[0],b[1],b[2] = 1,b[0],b[1]
        elif e == 'HOMERUN':
            p += sum(b)+1
            b = [0,0,0]
        elif e == 'OUT':
            o += 1
            if o == 3:
                print p
                p = 0
                b = [0,0,0]
                o = 0
    except EOFError:
        break

Measured memory_bytes: 4232
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	n, s := nextInt(), next()
	up, down := make([][]bool, n), make([][]bool, n)
	for i := 0; i < n; i++ {
		up[i], down[i] = make([]bool, 26), make([]bool, 26)
	}

	up[0][s[0]-'a'] = true
	for i := 1; i < n; i++ {
		for j := 0; j < 26; j++ {
			up[i][j] = up[i-1][j]
		}
		up[i][s[i]-'a'] = true
	}
	down[n-1][s[n-1]-'a'] = true
	for i := n - 2; i >= 0; i-- {
		for j := 0; j < 26; j++ {
			down[i][j] = down[i+1][j]
		}
		down[i][s[i]-'a'] = true
	}

	ans := 0
	for i := 1; i < n-1; i++ {
		cnt := 0
		for j := 0; j < 26; j++ {
			if up[i][j] == true && down[i+1][j] == true {
				cnt++
			}
		}
		if cnt > ans {
			ans = cnt
		}
	}
	puts(ans)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

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

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


Measured memory_bytes: 640
#include<stdio.h>

#define Max 100000

int a[Max], n;

int partition(int p, int r){
  int x, i, j, t;
  x = a[r];
  i = p - 1;

  for(j = p ; j < r ; j++){
    if(a[j] <= x){
      i++;
      t = a[i] ;
      a[i] = a[j];
      a[j] = t;
    }
  }

  t = a[i + 1];
  a[i + 1] = a[r];
  a[r] = t;

  return i + 1;
}


int main(){
  int i, q;

  scanf("%d", &n);
  for(i = 0 ; i < n ; i++) scanf("%d", &a[i]);

  q = partition(0, n - 1);

  for(i = 0 ; i < n ; i++){
    if(i) printf(" ");
    if(i == q) printf("[");
    printf("%d", a[i]);
    if(i == q) printf("]");
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 2120
n,k = map(int,input().split())
a = list(map(int,input().split()))
imos = [0 for _ in range(n+1)]
"""
座標xに光の強さdの電球→[x-d, x+d] てらす
強さ0でもそれには適用.
"""
for _ in range(k):
	imos = [0 for _ in range(n+1)]
	for i in range(n):
		imos[max(i-a[i], 0)] += 1
		imos[min(i+a[i]+1, n)] -= 1
	cnt = 0
	alln = 0
	for i in range(n):
		cnt += imos[i]
		a[i] = cnt
		if a[i] == n:
			alln += 1
	if alln == n:
		break
print(*a)

Measured memory_bytes: 170740
#include <bits/stdc++.h>
using namespace std;
#define lli long long int 
int main() {
	// your code goes here
	lli n,a;
	cin>>n;
	a=n%1000;
	if(a==0)
	cout<<a;
	else
	cout<<1000-a;
	return 0;
}

Measured memory_bytes: 3628
import java.util.*;
import java.io.*;

public class Main {
	
	public void sort(int[][] x){
		for(int i = 0; i < x.length; i++){
			int max = i;
			for(int j = i+1; j < x.length; j++){
				if( x[max][1] < x[j][1] ){
					max = j;
				} else if( x[max][1] == x[j][1] ){
					if( x[max][0] > x[j][0] ){
						max = j;
					}
				}
			}
			for(int j = 0; j < 2; j++){
				int temp = x[max][j];
				x[max][j] = x[i][j];
				x[i][j] = temp;
			}
		}
	}
	public int score(int[] x){
		int sum = 0;
		int frame = 1;
		for(int i = 0; i < x.length; i++){  
			if( frame == 10 ){
				sum += x[i];
			} else {
				if( x[i] == 10 ){  // strike
					sum += x[i] + x[i+1] + x[i+2];
				} else if( (x[i] + x[i+1]) == 10 ){  // spare
					sum += x[i] + x[i+1] + x[i+2];
					i++;
				} else {
					sum += x[i] + x[i+1];
					i++;
				}
				frame++;
			}
		}
		return sum;
	}
				 
	public  void solve() throws IOException{
		int n;
		while( (n = stdIn.nextInt() ) != 0 ){
			stdIn.nextLine();
			String[][] s = new String[n][];
			for(int i = 0; i < n; i++){
				s[i] = stdIn.nextLine().split(" ");
			}
			int[][] data = new int[n][];
			for(int i = 0; i < n; i++){
				data[i] = new int[s[i].length-1];
				for(int j = 0; j < s[i].length-1; j++){
					data[i][j] = Integer.parseInt(s[i][j+1]);					
				}
			}
			int[][] ans = new int[n][2];
			for(int i = 0; i < n; i++){
				ans[i][0] = Integer.parseInt(s[i][0]);
				ans[i][1] = score(data[i]);
			}
			sort(ans);
			for(int[] x : ans){
				writer.println(x[0] + " " + x[1]);
			}
		}
		writer.flush();
	}
	public static void main (String args[]) throws IOException{
		new Main().run();
	}
	
	Scanner stdIn;
	PrintWriter writer;
	
	public void run() throws IOException{
		stdIn = null;
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			writer = new PrintWriter(System.out);
			solve();
			stdIn.close();
			writer.close();
		} catch (Exception e){
			e.printStackTrace();
			System.exit(1);
		}
	}	
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define MAXN 2010
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const ll mod = 1e9 + 7;

int main (){
    ios_base::sync_with_stdio(false);
    ll n, x, ans = 0;

    cin >> n >> x;

    vector<int> v(n);

    for (int i=0; i<n; i++){
        cin >> v[i];
    }
    for (int i=0; i<n-1; i++){
        if (v[i] + v[i+1] > x){
            int differ = v[i] + v[i+1] - x;
            ans += differ;
            if (differ > v[i+1]){
                differ -= v[i+1];
                v[i+1] = 0;
                v[i] -= differ;
            }
            else {
                v[i+1] -= differ;
            }
        }
    }

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

Measured memory_bytes: 640