akhauriyash/Code-Regression huggingface dataset:
f :: [Int] -> [String]
f (n:k:_)
    | node < 0  = ["-1"]
    | otherwise = (show (node + n - 1)) : map show2 (zip (replicate (n-1) 1) [2..n] ++ take node [ (x,y) | x <- [2..n], y <- [2..n], x < y])
    where
      show2 (x,y) = shows x " " ++ show y
      node = (n-1) * (n-2) `div` 2 - k

main :: IO()
main = interact $ unlines . f . map read . words


Measured memory_bytes: 1020
## C - Prison
N, M = map(int, input().split())
valL = 0
valR = 10 ** 5
ans = 0
for m in range(M):
    L, R = map(int, input().split())
    valL = max(valL, L)
    valR = min(valR, R)
if valL > valR:
    ans = 0
else:
    ans = valR - valL + 1
print(ans)

Measured memory_bytes: 9156
#include<iostream>

using namespace std;

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

  int N;
  cin >> N;
  int res = N;

  for (int i = 0; i <= N; ++i) {
    int cc = 0;

    // pay (i) yen by 6
    int t = i;
    while (t > 0) {
      cc += t % 6;
      t /= 6;
    }

    // pay (N - i) yen by 9
    t = N - i;
    while (t > 0) {
      cc += t % 9;
      t /= 9;
    }

    if (res > cc) res = cc;
  }

  cout << res << endl;
  return 0;
}

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }



signed main() {

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

	cout << min(N * A, B) << endl;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n, m, k, a, ctr, ans;
  cin >> n >> m;
  vector<int> v;
  vector<int> tmp;

  cin >> k;
  for(int j=0;j<k;j++){
    cin >> a;
    v.push_back(a);
  }

  for(int i=1;i<n;i++){
    cin >> k;
    for(int j=0;j<k;j++){
      cin >> a;
      ctr = count(v.begin(), v.end(), a);
      if(ctr != 0){
        tmp.push_back(a);
      }
    }
    v.erase(v.begin(), v.end());
    for(int i=0;i<tmp.size();i++){
      v.push_back(tmp[i]);
    }
    tmp.erase(tmp.begin(), tmp.end());
  }
  ans = v.size();
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 100000


int main(void){
long long n,m;
long long t;
long long s,tt;
long long a[2000][30];
long long b[2000];
long long b2[2000];
f(i,2000){
f(j,30)a[i][j]=-1;
b[i]=-1;
b2[i]=-1;
}
a[0][0]=0;
long long x,y,z;
scanf("%lld %lld %lld",&n,&m,&t);
f(i,n){
scanf("%lld",&x);
if(a[(x%t)][0]<x)a[(x%t)][0]=x;
}
f(ii,29){
f(i,t)a[i][ii+1]=a[i][ii];
f(i,t){
f(j,t){
if(a[i][ii]!=-1&&a[j][ii]!=-1){
s=(i+j)%t;
if(a[s][ii+1]<a[i][ii]+a[j][ii])a[s][ii+1]=a[i][ii]+a[j][ii];
}
}
}
}
tt=0;
f(ii,30){
if(m%2==1){
if(tt==0){
f(i,t)b[i]=a[i][ii];
}
else{
f(i,t)b2[i]=b[i];
f(i,t){
f(j,t){
if(b[i]!=-1&&a[j][ii]!=-1){
s=(i+j)%t;
if(b2[s]<b[i]+a[j][ii])b2[s]=b[i]+a[j][ii];
}
}
}
f(i,t)b[i]=b2[i];
}
tt++;
}
m=m/2;
}
f(i,t)if(b[i]!=-1)b[i]=b[i]/t;
f(i,t-1)b[t-i-2]=max(b[t-i-2],b[t-i-1]);
long long q;
long long aa;
long long bb;
scanf("%lld",&q);
f(i,q){
scanf("%lld %lld",&aa,&bb);
if(bb<=b[aa])printf("yes\n");
else printf("no\n");

}

return 0;
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define bgn begin()
#define sz size()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define all(a)  (a).begin(),(a).end()
#define ff first.first
#define fs first.second

signed main(){
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  V<int> X(n);
  fo(i,n){
    cin >> X[i];
  }
  V<int> Y(m);
  fo(i,m){
    cin >> Y[i];
  }
  Sort(X);
  Sort(Y);

  int Max_x = X[n-1];
  int Min_y = Y[0];

  bool can = 0;
  for(int i = x+1; i <= y; i++){
    if(Max_x < i && Min_y >= i){
      can = 1;
      break;
    }
  }
  if(can)
    cout << "No War" << endl;
  else
    cout << "War" << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true){
			int n = scan.nextInt();
			if(n==0)break;

			int[] arr = new int[n];
			for(int i = 0; i < n; i++) arr[i] = scan.nextInt();
			int[][] dp = new int[n][n];

			for(int interval = 0; interval<n; interval += 2) {
				for(int start = 0, end = start + interval + 1; end < n; start++, end++) {
					//System.out.printf("start:%3d , end:%3d\n",start,end);

					if(Math.abs(arr[start]-arr[end])<2) {
						if(dp[start+1][end-1]==interval) {
							dp[start][end] = interval+2;
							continue;
						}
					}
					dp[start][end] = dp[start+1][end-1];

					for(int innerInterval = 0; innerInterval<interval; innerInterval+=2) {/*
						if(dp[start][end]<dp[start][start+innerInterval+1]+dp[start+innerInterval+2][end]) {
							System.out.println("\t kakoikomi");
						}*/
						dp[start][end] = Math.max(
							(
								dp[start][end]
							),
							(
								dp[start][start+innerInterval+1] +
								dp[start+innerInterval+2][end]
							)
						);
					}
				}
					//System.out.println("------\n");
			}

			int result = 0;
			for(int i = 0; i < dp.length; i++) {
				for(int j = 0; j < dp[i].length; j++) {
					//System.out.printf("%3d",dp[i][j]);
					result = Math.max(result,dp[i][j]);
				}
				//System.out.println();
			}
			System.out.println(result);
		}
	}
}

Measured memory_bytes: 60020
N, M = gets.split.map(&:to_i)

E = Hash.new { |h, k| h[k] = {} }

counter = Hash.new(0)

M.times do
  a, b = gets.split.map(&:to_i)

  counter[a] += 1
  counter[b] += 1

  E[a][b] = true
  E[b][a] = true
end

left = 1
right = E[left].keys.first

VISITED = Hash.new

def find_unvisited_neighbor(v)
  E[v].each_key do |u|
    return u unless VISITED[u]
  end

  nil
end

path = [left, right]
VISITED[left] = true
VISITED[right] = true

loop {
  updated = false
  u = find_unvisited_neighbor(left)

  if u
    VISITED[u] = true
    path.unshift(u)
    left = u
    updated = true
  end

  t = find_unvisited_neighbor(right)

  if t
    VISITED[t] = true
    path.push(t)
    right = t
    updated = true
  end

  break unless updated
}

puts path.size
puts path.join(' ')


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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			int n2 = 2 << (n - 1);
			long[] s = new long[n2];
			for (int i = 0; i < n2; i++) {
				s[i] = cin.Long();
			}

			List<long> ps = s.OrderByDescending(x => x).ToList();
			List<long> temp = new List<long>();
			temp.Add(ps[0]);
			ps[0] = 0;
			for (int i = 0; i < n; i++) {
				var temp2 = temp.OrderByDescending(x => x).ToList();
				int cnt = 0;
				int index = 0;
				for (int j = 0; j < n2; j++) {
					if (ps[j] != 0 && ps[j] < temp2[index]) {
						++cnt;
						temp.Add(ps[j]);
						ps[j] = 0;
						index++;
						if (index >= temp2.Count()) {
							break;
						}
					}
				}

				if (cnt != temp2.Count()) {
					Console.WriteLine("No");
					return;
				}
			}

			Console.WriteLine("Yes");
		}
	}

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

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

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

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

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

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

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

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

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

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

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

Measured memory_bytes: 54136
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

def rl(proc=None):
    if proc is not None:
        return proc(sys.stdin.readline())
    else:
        return sys.stdin.readline().rstrip()

def srl(proc=None):
    if proc is not None:
        return list(map(proc, rl().split()))
    else:
        return rl().split()

M = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

def main():
    m1, d1 = srl(int)
    print("1" if M[m1-1] == d1 else "0")

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
/*** akshaykumar99 ***/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD = 998244353;
const long double PI = acos(-1);
const long long INF = INT_MAX;
const long long LINF = LLONG_MAX;
const long long N = 2e5+1;
 
typedef long long ll;
typedef long double ld;  

ll fact[N], inv[N];

ll binpow(ll a, ll b, ll m)
{
    ll res = 1; 
    while(b)
    {
        if(b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll invv(ll a)
{
    return binpow(a, MOD-2, MOD);
}
void find()
{
    fact[0] = 1;
    inv[0] = invv(1);
    for(ll i = 1; i < N; i++)
    {
        fact[i] = fact[i-1] * i % MOD;
        inv[i] = invv(fact[i]);
    }
}
ll ncr(ll n, ll r)
{
    return fact[n] * inv[n-r] % MOD * inv[r] % MOD;
}
void test_case()
{
    ll n,m,k,i,j, ans = 0;
    cin>>n>>m>>k;
    find();
    f(i,0,k+1)
    {
        ans = (ans + ncr(n-1, i) * m % MOD * binpow(m-1, n-1-i, MOD) % MOD) % MOD;
    }
    cout<<ans<<'\n';

}

int32_t main()
{
    IOS(); 
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a+b == c){
    cout << "Yes" << endl;
  }
  else if(c+b == a){
    cout << "Yes" << endl;
  }
  else if(a+c == b){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<int,int>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector< tuple<int,int,char,ll,string> > data(n);
	int v,w;
	ll d;
	string s;
	char t;
	FOR(i,0,n){
		cin>>v>>w>>t>>d>>s;
		data[i] = tie(v,w,t,d,s);
	}
	sort(data.begin(), data.end());
	FOR(i,0,n){
		tie(v,w,t,d,s)=data[i];
		cout<<v<<" "<<w<<" "<<t<<" "<<d<<" "<<s<<"\n";  
	}
}


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

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int len = sc.nextInt();
        String a = sc.next();
        char[] chars = a.toCharArray();
        System.out.println(countermin(chars));
    }

    static int countermin(char[] chars) {
        int left = 0, tc = 0;
        int right = chars.length - 1;
        while (left < right) {
            while (left < right && chars[left] == 'R') {
                left++;
            }
            while (right > left && chars[right] == 'W') {
                right--;
            }
            if (left < right) {
                tc++;
                left++;
                right--;
            }
        }
        return tc;
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 36672
#include <stdio.h>

int main(void)
{
	for(;;)
	{
		int a,n;
		scanf("%d",&a);
		if(a==0)
		{
			break;
		}
		for(n=0;;n++)
		{
			if(a==1)
			{
				break;
			}
			else if(a%2==1)
			{
				a=a*3+1;
			}
			else if(a%2==0)
			{
				a=a/2;
			}
		}
		printf("%d\n",n);
	}
	return 0;
}

Measured memory_bytes: 2752
#include <bits/stdc++.h>
#include <vector>
#include <map>
using namespace std;
#define rep(k, n) for(int i=k;i< n;i++)
#define LL long long int
#define L long
#define INF numeric_limits<int>::max() // double INF numeric_limits<double>::infinity()

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
    int n, k;cin>>n >>k;
    int v[n];
    rep(0, n)cin>> v[i];
    int dp[n];
    dp[0]= 0;dp[1]= abs(v[0]-v[1]);
    rep(2, n)dp[i]= INF;
    rep(2, n){
        for(int j=1;j<=k;++j){
            dp[i]= min(dp[i], dp[i-j]+ abs(v[i]-v[i-j]));
        }
    }
    cout<< dp[n-1];
}

Measured memory_bytes: 4392
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

const int INF = 1001001001;

int main(){
    int n;  cin >> n;
    vector<int>dp(n+1);
    vector<int>p_9(7, 1);
    vector<int>p_6(7, 1);
    rep(i, 6)   p_9[i+1] = 9*p_9[i];
    rep(i, 6)   p_6[i+1] = 6*p_6[i];
    for(int i = 1; i <= n; i++){
        dp[i]++;
        int tmp = INF;
        rep(j, 7){
            if(i - p_9[j] >= 0){
                tmp = min(tmp, dp[i-p_9[j]]);
            }
            if(i - p_6[j] >= 0){
                tmp = min(tmp, dp[i-p_6[j]]);
            }
        }
        dp[i] += tmp;
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 640
O = input()
E = input()
ans = []
cnt = 0

for i in range(len(O) + len(E)):
    if i == 0 or i % 2 == 0:
        ans.append(O[cnt])
    else:
        ans.append(E[cnt])
        cnt += 1

print(''.join(ans))


    

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		//int n = sc.nextInt();
		String s = sc.next();
		
		if(s.length() <= 3) {
			int n = Integer.parseInt(s);
			System.out.println(1000-n);
			return;
		}
		
		s = s.substring(s.length()-3);
		
		int n = Integer.parseInt(s);
		
		if(n == 0) {
			System.out.println(0);
			return;
		}
		//long n = sc.nextLong();
		//double n = sc.nextDouble();
		
		System.out.println(1000 - n);
		//for(int i = 0; i < ; i++)

		//System.out.println("Yes");
		//System.out.println("No");
		

	}
}


Measured memory_bytes: 35572
x=[[]*3]*3
o=[[0] * 3 for i in range(3)]

for i in range(0,3):
  x[i] = list(map(int,input().split()))

n=int(input())

for i in range(0,n):
  b=int(input())
  for j in range(0,3):
    for k in range(0,3):
      if x[j][k]==b:
        o[j][k]=1

for i in range(0,3):
  if o[i][0]==1 and o[i][1]==1 and o[i][2]==1:
    print("Yes")
    exit()

  if o[0][i]==1 and o[1][i]==1 and o[2][i]==1:
    print("Yes")
    exit()

if o[0][0]==1 and o[1][1]==1 and o[2][2]==1:
    print("Yes")
    exit()

if o[0][2]==1 and o[1][1]==1 and o[2][0]==1:
    print("Yes")
    exit()
print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define N 110
using namespace std;
long long f[N][10],p[N][11],op[10];
long long n,i,j,k,t,ans=-1e18,sum,num;
int main(){
	cin>>n;
	for(i=0;i<n;i++)
	{
		for(j=0;j<10;j++)
		{
			cin>>f[i][j];
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<11;j++)
		{
			cin>>p[i][j];
		}
	}
	for(i=1;i<1024;i++)
	{
		t=i;
		for(j=0;j<10;j++)
		{
			op[j]=t%2;
			t/=2;
		}
		sum=0;
		for(j=0;j<n;j++)
		{
			num=0;
			for(k=0;k<10;k++)
			{
				num+=f[j][k]&&op[k];
			}
			sum+=p[j][num];
		}
		ans=max(ans,sum);
	}
	cout<<ans<<endl;
	return 0;
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const char EOL = '\n';

void solve();

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

void solve() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    char p = '*';
    REP(i, n) {
        if (p != s[i]) ans++;
        p = s[i];
    }
    cout << ans << EOL;
}

Measured memory_bytes: 512
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var n = sc.nextInt();
		var a = IntStream.range(0, n).map(i -> sc.nextInt()).toArray();
		var q = sc.nextInt();
		var b = new int[q];
		var c = new int[q];
		for (int i = 0; i < q; i++) {
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		sc.close();

		var sum = 0L;
		var count = new int[100001];
		for (int i = 0; i < n; i++) {
			sum += a[i];
			count[a[i]]++;
		}

		for (int i = 0; i < q; i++) {
			sum += (c[i] - b[i]) * count[b[i]];
			count[c[i]] += count[b[i]];
			count[b[i]] = 0;
			System.out.println(sum);
		}
	}
}


Measured memory_bytes: 60768
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
constexpr ll INF = 1e18;

int main(void) {
    ll D;
    cin >> D;
    vector<ll> c(26);
    vector<vector<ll>> s(D, vector<ll>(26));
    for (int i = 0; i < 26; i++) {
        cin >> c[i];
    }
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }

    vector<ll> last(26);
    ll v = 0;
    for (int day = 0; day < D; day++) {
        vector<ll> tmp_v(26);
        ll max_t = 0;
        ll max_v = -INF;
        for (int t = 0; t < 26; t++) {
            tmp_v[t] += s[day][t];
            tmp_v[t] += c[t] * (day+1 - last[t]);
            if (max_v < tmp_v[t]) {
                max_v = tmp_v[t];
                max_t = t;
            }
        }
        v += tmp_v[max_t];
        for (int i = 0; i < 26; i++) {
            v -= c[i] * (day+1 - last[i]);
        }
        last[max_t] = day+1;
        cout << max_t+1 << endl;
    }

    return 0;
}



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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<char, int>;

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

const int INF = 1e18;
const int MOD = 1e9 + 7;

signed main(){
    string s; cin >> s;
    if( s[0] == 'S' ) cout << "Cloudy" << endl;
    else if( s[0] == 'C' ) cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan=new Scanner(System.in);
		int N=scan.nextInt();
		int M=scan.nextInt();

		int[][] ab = new int[N][2];
		int[][] cd = new int[M][2];

		for(int i=0;i<N;i++){
			ab[i][0]=scan.nextInt();
			ab[i][1]=scan.nextInt();

		}
		for(int i=0;i<M;i++){
			cd[i][0]=scan.nextInt();
			cd[i][1]=scan.nextInt();
		}

		int[] chk = new int[N];
		for(int i=0;i<N;i++){
			int min = 1000000000;
			for(int j=0;j<M;j++){
				int dis=Math.abs(ab[i][0]-cd[j][0])+Math.abs(ab[i][1]-cd[j][1]);
				if(dis<min){
					min = dis;
					chk[i]=j+1;
				}

			}
			System.out.println(chk[i]);


		}


	}

}


Measured memory_bytes: 21972
// clang-format off
#include <cassert>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <iomanip>
#include <queue>
#include <map>

#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 pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T>& p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T>& vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
constexpr ll MOD = 1000000007;



int main()
{
    int W;cin >> W;
    int a,b;
    cin >> a >> b;
    if(a <= b and b <= a +W){
        cout << 0 << endl;
        return 0;
    }
    if(a <= b + W and b+W <= a+W){
        cout << 0 << endl;
        return 0;
    }
    if(b+W < a){
        cout << a-b-W << endl;
        return 0;
    }
    if(a+W < b){
        cout << b - a -W << endl;
        return 0;
    }
    return 0;
}


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

using ll=long long; 

int norm(vector<int> a){
	int ret=0;
	for(int i=0; i<a.size(); i++){
		ret+=a[i]*a[i];
	}
	return ret;
}

void solve(){
	int n;
	cin>>n;
	vector<int>a(n);
	int minv=100000000;
	for(int i=0; i<n; i++)cin>>a[i];
	for(int i=-100; i<=100; i++){
		vector<int>b(n,i);
		for(int j=0; j<n; j++){
			b[j]-=a[j];
		}
		int rece=norm(b);
		minv=min(minv, rece);
	}
	cout<<minv<<endl;
}

signed main(){
	//while(1)
	solve();
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  vector<bool> v(60,false);
  int now=60-c;
  int k = 0;
  while(1){
    if(v[now]) break;
    v[now]=true;
    if(60<=now+a){
      cout << k+60-now << endl;
      return 0;
    }
    now=(now+a+b)%60;
    k+=a+b;
  }
  cout << -1 << endl;
  return 0;
}



Measured memory_bytes: 3092
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

long comb(long a,long cnt);

int main(void) {
    long  N,M;

    scanf("%ld %ld",&N,&M);

    printf("\n%ld\n",comb(N,2)+comb(M,2));
    return 0;
}

long comb(long a,long cnt){
	 int  i;
	 long b=1;

	 if(a==cnt) return(1);
	 if(a<cnt ) return(0);

     for(i=1;i<cnt;i++)
     {a*=(a-i); b*=(b+i);}

	return(a/b);
}


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


int A[15]={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1};

int ans[10][10];
int tmp[10][10];

int main(){
  for(int i=15;i>=0;i--){

    for(int a=0;a<15;a++){

      int from=A[a];
      int to=A[ (a+i)%15 ];
      
      ans[ from ][ to ]=i;
      tmp[ from ][ to ]=a;
    }
  }

  int tc;
  cin>>tc;

  for(int Tc=0;Tc<tc;Tc++){

    int from;
    int to;
    cin>>from>>to;

    for(int i=0;i<=ans[from][to];i++){
      if(i>0)cout<<' ';

      cout<< A[ (tmp[from][to]+i)%15 ];
    }
    cout<<endl;
    
  }
  
  return 0;
}



Measured memory_bytes: 3084
#!/usr/bin/perl
my ($n) = map { $_ - 0 } split(/\s+/,<STDIN>);
if($n==1){
  print "Hello World\n";
} elsif($n==2){
  my ($a) = map { $_ - 0 } split(/\s+/,<STDIN>);
  my ($b) = map { $_ - 0 } split(/\s+/,<STDIN>);
  my $res = $a + $b;
  print "$res\n";
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"YES":"NO")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    ll a,v,b,w,t;
    bool ans=false;
    cin >>a>>v>>b>>w>>t;

    ll ma,mb;
    
    if(v <=w){
        ans=false;
    }else {
        if(((abs(a-b)+(v-w-1))/(v-w)) <=t){
            ans=true;
        }
        
    }
    cout<<solve(ans)<<endl;
}

Measured memory_bytes: 3528
#include <iostream>
#include <vector>

int main(){
    int N;
    std::cin >> N;
    std::vector<int> A(N);
    for(auto i = 0; i < N - 1; i++){
        std::cin >> A.at(i);
    }

    std::vector<int> ans(N, 0);
    for(auto i = 0; i < N - 1; i++){
        ans.at(A.at(i) - 1) += 1;
    }

    for(auto i = 0; i < N; i++){
        std::cout << ans.at(i) << std::endl;
    }

    return 0;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
#include <limits>
#include <math.h>
#include <cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vvi = vector<vector<int>> ;
using vll = vector<long long>;
using vvll = vector<vector<long long >>;
#define PI 3.141592653
#define rep(i, n) for(ll i = 0; i < n; i++)



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

  if(k >= 65 && k <= 90){
    cout << "A" << endl;
  }
  else{
    cout << "a" << endl;
  }

}

Measured memory_bytes: 3560
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
using namespace std;
using ll =long long;
const int mod = 1000000007;

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
void ini_func(vector<ll>& a, vector<ll>& b,ll N) {
	ll k, c;
	for (ll i = 0; i < N; i++) {
		cin >> k >> c;
		a.push_back(k);
		b.push_back(c);
	}


}
int num[6]= { 105,135,165,189,195,201};
int main() {
	ll N;
	cin >> N;
	for(int i=0;i<6;i++){
		if (N < num[i]) {
			cout << i;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <complex>
#include <iostream>
#include <cmath>

using namespace std;

typedef complex<double> P;

//XYÀW
#define X real()
#define Y imag()

double tri2s(double xa, double ya, double xb, double yb, double xc, double yc){
     double a, b, c, s;
    
     a = sqrt((xb - xc) * (xb - xc) + (yb - yc) * (yb - yc));
     b = sqrt((xa - xc) * (xa - xc) + (ya - yc) * (ya - yc));
     c = sqrt((xb - xa) * (xb - xa) + (yb - ya) * (yb - ya));
    
     s = (a+b+c) / 2;

	 cout << sqrt(s * (s - a) * (s - b) * (s - c)) << endl;
    
     return sqrt(s * (s - a) * (s - b) * (s - c));
}

double p2deg(double xa, double ya, double xb, double yb, double xc, double yc){
  double a, b, c, s, cos;
    
     a = sqrt((xb - xc) * (xb - xc) + (yb - yc) * (yb - yc));
     b = sqrt((xa - xc) * (xa - xc) + (ya - yc) * (ya - yc));
     c = sqrt((xb - xa) * (xb - xa) + (yb - ya) * (yb - ya));

	 cos = (b * b + c * c - a * a) / 2 * b * c;

	 return acos(cos);

}

// ¼üp1,p2Æüªp3,p4Ìð·»è
// (n < 0)<=>ð· , (n == 0)<=>¼üã, (n > 0)<=>ð·µÄ¢È¢  
double isIntersect(P p1, P p2, P p3, P p4){  
    return ( (p1.X-p2.X)*(p3.Y-p1.Y) + (p1.Y-p2.Y)*(p1.X-p3.X)) * ((p1.X-p2.X)*(p4.Y-p1.Y) + (p1.Y-p2.Y)*(p1.X-p4.X));  
}

int main(void){
     double x[4], y[4];
     double sq;
     double tri[4];
     bool isok = true;
    
     while(cin >> x[0]){
          cin.ignore(); cin >> y[0];
          cin.ignore(); cin >> x[1]; cin.ignore(); cin >> y[1];
          cin.ignore(); cin >> x[2]; cin.ignore(); cin >> y[2];
          cin.ignore(); cin >> x[3]; cin.ignore(); cin >> y[3];
		  
		  P a(x[0], y[0]);
		  P b(x[1], y[1]);
		  P c(x[2], y[2]);
		  P d(x[3], y[3]);
		  /*
          sq = tri2s(x[0], y[0], x[1], y[1], x[2], y[2]) + tri2s(x[0],y[0],x[2],y[2],x[3],y[3]);
         
          tri[0] = tri2s(x[0], y[0], x[1], y[1], x[2], y[2]);
          tri[1] = tri2s(x[0], y[0], x[1], y[1], x[3], y[3]);
          tri[2] = tri2s(x[0], y[0], x[2], y[2], x[3], y[3]);
          tri[3] = tri2s(x[1], y[1], x[2], y[3], x[3], y[3]);
         
          for(int i=0;i<4;i++){
               if(tri[i] > sq) isok = false;
          }
          if(tri2s(x[0],y[0],x[1],y[1],x[2],y[2]) + tri2s(x[0],y[0],x[2],y[2],x[3],y[3]) ==
			 tri2s(x[0],y[0],x[1],y[1],x[3],y[3]) + tri2s(x[2],y[2],x[1],y[1],x[3],y[3]) ){
               cout << "YES" << endl;
          }else{
               cout << "NO" << endl;
          }
          isok = true;
		  */
		  
		  if( isIntersect(a,c,b,d) > 0.0 || isIntersect(b,d,a,c) > 0.0 ){
			cout << "NO" << endl;
		  }else{
			cout << "YES" << endl;
		  }
	 }
	 return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include<cmath> 
using namespace std ;
int main()
{ 
long long R=0;
long long t,i,N,M;
cin>>N;
M=N-1;
  long long*a= new long long[N];
  long long*b= new long long[M];
  for(i=0;i<N;i++)
   {
   cin>>a[i];
    R+=a[i];
   }
    b[0]=a[0];
    for(i=1;i<N-1;i++)
    b[i]=b[i-1]+a[i];
    for(i=0;i<N-1;i++)
    if(abs(R-2*b[i])<t||i==0)
      t=abs(R-2*b[i]);
cout<<t;
delete[] a;
delete [] b;
return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<bits/stdc++.h>
#define ll long long int

using namespace std;
ll a[100009] , dp[100009]={0};
ll jump(ll n)
{   
    if(dp[n]>=0)return dp[n];

    if(n==1) 
    {   
        dp[n]=0;
    }
    else if(n==2)   
    {   
        dp[n]=abs(a[2]-a[1]);
    }
    else
    {
        dp[n]=min(jump(n-1)+abs(a[n]-a[n-1]),jump(n-2)+abs(a[n-2]-a[n]));
    }

    return dp[n];
}
int main()
{   
    ll i , n ;
    cin>>n;
    for( i = 0 ; i <=n ; i++)dp[i]=-1;
    for( i = 1 ; i <= n ; i++)cin>>a[i];
    cout<<jump(n)<<endl;

}

Measured memory_bytes: 3328
#include <stdio.h>
#include <string.h>

int main(void)
{
	int n;
	char event[8];
	int out = 0;
	int base[3] = {0};
	int i;
	int score;
	
	scanf("%d", &n);
			 
	while (n != 0){
		score = 0;
		base[0] = 0;
		base[1] = 0;
		base[2] = 0;
		out = 0;
		while (out < 3){
			scanf("%s", event);
			if (strcmp(event, "HIT") == 0){
				base[0]++;
				for (i = 0; i < 3; i++){
					if (base[i] > 1){
						if (i < 2){
							base[i + 1]++;
						}
						else {
							score++;
						}
						base[i]--;
					}
					
				}
			}
			else if (strcmp(event, "HOMERUN") == 0){
				for (i = 0; i < 3; i++){
					if (base[i] == 1){
						score++;
						base[i] = 0;
					}
				}
				score++;
			}
			else if (strcmp(event, "OUT") == 0){
				out++;
			}
		}
		printf("%d\n", score);
		n--;
	}
	
	return 0;
}

Measured memory_bytes: 596
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <random>
#include <iterator>
 
using namespace std;
 
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)
int sigma(int n) {
	return n*(n + 1) / 2;
}
 
 
int main() {
	int n, k;
	cin >> n >> k;
 
	long long cnt = 0;
	FOR(b, 1, n) {
		int q = n / b;
		int r = n%b;
		cnt += q*max(0, b - k) + max(0, r - k + 1);
	}
	if (k == 0) {
		cnt -= n;
	}
 
	ANS(cnt);
 
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  int step = 0;
  int maxstep = 0;
  for(int i=0;i<N;i++){
    cin >> A[i];
    if(i>0&&A[i]<=A[i-1]){
      step ++;
      if(step > maxstep){
        maxstep = step;
      }
    }
    else if(i>0&&A[i]>A[i-1]){
      step = 0;
    }
  }
  cout << maxstep << endl;
  return 0;
}

Measured memory_bytes: 640
n, k, c = map(int, input().split())
s = input()

left = [0 for i in range(n + 1)]
right = [0 for i in range(n + 1)]

left[0] = 0
i = 1
cnt = 0
while i <= n:
    if s[i - 1] == 'o':
        cnt += 1
        for j in range(c + 1):
            left[i] = cnt
            i += 1
            if i == (n + 1):
                break
    else:
        left[i] = cnt
        i += 1

right[n] = 0
i = n - 1
cnt = 0
while i >= 0:
    if s[i] == 'o':
        cnt += 1
        right[i] = cnt
        for j in range(c + 1):
            right[i] = cnt
            i -= 1
            if i == -1:
                break
    else:
        right[i] = cnt
        i -= 1

# print(left)
# print(right)
for i in range(n):
    # skip i th element
    if left[i] + right[i + 1] >= k:
        continue
    print(i + 1)

Measured memory_bytes: 20632
var i,j,n,m,kkk:longint;
    s1,s2,s3:string;
 begin
  readln(s1);
  readln(s2);
  i:=length(s1);
  j:=length(s2);
  if i<j then
  begin
   n:=i;
   m:=j;
  end
  else
  begin
   n:=j;
   m:=i;
  end;
  for kkk:=1 to n do
   write(s1[kkk],s2[kkk]);
  if i>j then
   for kkk:=n+1 to m do
    write(s1[kkk])
    else
   for kkk:=n+1 to m do
    write(s2[kkk]);
  writeln;
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#define pob pop_back
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main(){
int n,k;
  cin >> n>>k;
  cout <<n-k+1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = (int)1e7;  
using  p = pair<int,int>;

int main(){
   int n;
   cin >> n;
   auto x = vector<int>(n,0);
   for (int i = 0; i < n; i++)
   {
     cin >> x[i];
   }
   auto xx =x;
   sort(x.begin(),x.end());
   auto c1 = next(x.begin(),n/2);
   auto c2 = next(x.begin(),n/2-1);
   for (int i = 0; i < n; i++)
   {
     auto s = lower_bound(x.begin(),x.end(),xx[i])-x.begin();
      if(s<n/2)
        cout << *c1 << endl;
      else
        cout << *c2 << endl;
   }
}
  
  

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

typedef long long ll;

int main() {
    int A, B;
    cin >> A >> B;
    int ans;
    if (A <= 5) ans = 0;
    else if (A >= 6 && A <=12) ans = B/2;
    else ans = B;

    cout << ans << endl;


}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_Challenge
{
    class _002_C
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nl = ReadInts();
            int n = nl[0];
            int l = nl[1];
            int[] array = ReadInts();
            int maxI = 0;
            for(int i = 0; i + 1 < n; i++)
            {
                if (array[maxI] + array[maxI + 1] < array[i] + array[i + 1])
                    maxI = i;
            }
            if (array[maxI] + array[maxI + 1] < l)
            {
                Console.WriteLine("Impossible");
                return;
            }
            Console.WriteLine("Possible");
            for(int i = 0; i < maxI; i++)
            {
                Console.WriteLine(i + 1);
            }
            for(int i = n-1; i-1 >maxI; i--)
            {
                Console.WriteLine(i);
            }
            Console.WriteLine(maxI+1) ;
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 28124
import java.io.*;
import java.util.Arrays;
class Main{
	public static void main(String[] args) throws IOException {
		int i,j;
		int[] n = new int[990];
		String[] str = new String[990];
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		for(;;){
			str = in.readLine().split(" ");
			for(i=0;i<2;i++){
				n[i] = Integer.parseInt(str[i]);
			}
			if(n[0]+n[1]==0) break;
			for(i=0;i<n[0];i++){
				for(j=0;j<n[1];j++){
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}

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

signed main() {
    ll n;
    cin >> n;
    ll cnta[n]={}, cntc[n]={};
    vector<ll> a(n), b(n), c(n);
    for (ll i=0;i<n;i++) cin >> a[i];
    for (ll i=0;i<n;i++) cin >> b[i];
    for (ll i=0;i<n;i++) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    for (ll i=0;i<n;i++) {
        // cout << a[i] << b[i] << c[i] << endl;
        auto ai = upper_bound(a.begin(), a.end(), b[i]-1);
        cnta[i] = ai - a.begin();
        auto ci = lower_bound(c.begin(), c.end(), b[i]+1);
        cntc[i] = c.end() - ci;
        // cout << cnta[i] << " " << cntc[i] << endl;
    }
    ll sum=0;
    for (ll i=0;i<n;i++) {
        sum += cnta[i]*cntc[i];
    }
    cout << sum << endl;
}

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

int main(){
	vector<string> divi = {"dream", "dreamer", "erase", "eraser"};
	string s;
	cin >> s;

	rep(i, 4) reverse(divi.at(i).begin(), divi.at(i).end());
	reverse(s.begin(), s.end());

	bool can = true;
	for(int i = 0; i < s.size();){
		bool can2 = false;
		for(int j = 0; j < 4; j++){
			string d = divi.at(j);
			if(d == s.substr(i, d.size())){
				i += d.size();
				can2 = true;
			}
		}

		if(!can2){
			can = false;
			break;
		}
	}
	if(can) cout << "YES" << endl;
	else cout << "NO" << endl;
	
}

Measured memory_bytes: 512
import java.util.Scanner;

class Main{
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        if(a%2==0){
            System.out.println("0.5000000000");
        }else{
            int shou = a / 2;
            System.out.println((double)(a-shou)/a);
        }

    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>                          
using namespace std;
int n,m,flg;
char s[55][55];
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++) 
            cin>>s[i][j];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
		    if(s[i][j]=='#'&&s[i][j+1]=='.'&&s[i+1][j]=='.'&&s[i-1][j]=='.'&&s[i][j-1]=='.') 
                {flg=1;break;}
        }
    if(flg==0) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]
cnt = cnta = cntb = cntba =  0
for i in range(n):
    for j in range(len(s[i])-1):
        if s[i][j:j+2] == "AB":
            cnt += 1
    if s[i][0] == 'B' and s[i][-1] == 'A':
        cntba += 1
    elif s[i][0] == 'B':
        cntb += 1
    elif s[i][-1] == 'A':
        cnta += 1
if cnta == 0 and cntb == 0:
    print(max(0, cntba-1)+cnt)
elif cnta == 0 or cntb == 0:
    print(cntba+cnt)
else:
    print(cntba+1+min(cnta-1, cntb-1)+cnt)

Measured memory_bytes: 3828
def main():
    N = int(input())
    V = map(int, input().split())
    C = map(int, input().split())
    ans = 0
    for v, c in zip(V, C):
        if v - c > 0:
            ans += v - c
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61816
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
//#include <vector>
//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 
int main(){
    
    string S;
    cin >> S;

    string tmp;
    tmp = S.substr(0,1);
    if(tmp!="A"){
        cout << "WA";
    }else{
        int count = 0;
        for( int si = 2 ; si < S.length()-1 ; si++ ){
            tmp = S.substr(si,1);
            if(tmp=="C") count++;
        }
        int count2 = 0;
        for( int si = 0 ; si < S.length() ; si++ ){
            if(isupper(S[si])) count2++;
        }
        if(count2 > 2) cout << "WA";
        else if(count==1) cout << "AC";
        else cout << "WA";
    }

}

Measured memory_bytes: 256
s = gets.chomp

s0 = "01" * (s.size/2 + 1)
s1 = "10" * (s.size/2 + 1)

c0 = 0
c1 = 0

s.size.times do |i|
  if s0[i] != s[i]
    c0 += 1
  end
  if s1[i] != s[i]
    c1 += 1
  end
end

puts [c0, c1].min

  

Measured memory_bytes: 2172
let a, b, c, x = Scanf.scanf " %d %d %d %d" @@ fun a b c d -> a, b, c, d
let ans = ref 0
let _ = for i = 0 to a do
  for j = 0 to b do
    for k = 0 to c do if 500 * i + 100 * j + 50 * k = x then incr ans done done done; Printf.printf "%d\n" !ans

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a < 10 && b < 10){
    cout << a*b << endl;
  }
  else cout << -1 << endl;
}


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

#define ll long long
#define fr(i, n) for(int i=0;i<n;i++)
#define forall(i, j, n) for(int i=j; i<n; i++)
#define all(c) c.begin(), c.end()
#define tr(container, it) for (__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define rt(container, it) for (__typeof(container.rbegin()) it = container.rbegin(); it != container.rend(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresetn(container, element) (find(all(container)), element) != container.end())
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define si(n) scanf("%d", &n)
#define sll(n) scanf("%lld", &n)
#define pi(n) 0*printf("%d\n", n)
#define pll(n) 0*printf("%lld\n", n)
#define SET(container, value) memset(container, value, sizeof container)
#define MP make_pair
#define F first
#define S second

#define scan_all(...) __s(__VA_ARGS__)
template <typename Arg1>
void __s(Arg1&& arg1) {
  cin >> arg1;
}
template <typename Arg1, typename... Args>
void __s(Arg1&& arg1, Args&&... args) {
  cin >> arg1 ; __s(args...);
}

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names+1, ',');
	cerr.write(names, comma-names) << " : " << arg1 << " | "; __f(comma+1, args...);
}

std::vector<std::string> tokenize(
				  const std::string& s,
				  const std::string& delims){
  std::vector<std::string> tokens;
  size_t offset = 0;

  while (true) {
    size_t nonDelim = s.find_first_not_of(delims, offset);

    if (nonDelim == std::string::npos) {
      break; // Nothing left.
    }

    size_t delim = s.find_first_of(delims, nonDelim);

    // Finish tokenizing if this is the last token,
    // or we've found enough tokens.
    if (delim == std::string::npos) {
      tokens.push_back(s.substr(nonDelim));
      break;
    }

    tokens.push_back(s.substr(nonDelim, delim - nonDelim));
    offset = delim;
  }

  return tokens;
}

int main(){
  ll n, W;
  scan_all(n, W);
  vector<ll> weights(n);
  vector<ll> values(n);
  for(ll i=0; i<n; i++) scan_all(weights[i], values[i]);
  vector < vector<ll> > dp(n+1, vector<ll>(W+1, 0));
  for (ll i=0; i<=n; i++) {
    for (ll w=0; w<=W; w++) {
      if (!i || !w) continue;
      else if (weights[i-1] <= w)
	dp[i][w] = max(dp[i-1][w], values[i-1] + dp[i-1][w-weights[i-1]]);
      else dp[i][w] = dp[i-1][w];
    }
  }
  cout << dp[n][W] << endl;
  return 0;
}


Measured memory_bytes: 80256