akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int A[2][101],p,i,n,l;
char d;

main(){
	while(cin>>n>>l,n||l){
		memset(A,0,sizeof(A));
		rep(j,n){
			cin>>d>>p;
			A[d=='L'][p]=j+1;
		}
		i=0;
		while(++i){
			bool end=1;
			for(int j=l;j>=1;j--){ A[0][j]=A[0][j-1];A[0][j-1]=0;}
			rep(j,l){ A[1][j]=A[1][j+1];A[1][j+1]=0;}
			rep(j,l+1) if(A[0][j]&&A[1][j])swap(A[0][j],A[1][j]);
			for(int j=l-1;j>=1;j--)if(A[0][j]||A[1][j])end=0,p=A[0][j]?A[0][j]:A[1][j];
			if(end)break;
		}
		printf("%d %d\n",i,p);
	}
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    int n; cin >> n;
    ll ans = 0;
    rep(i, n){
        int x; cin >> x;
        ans += x-1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
N, K = map(int, input().split())
MAXP = (N - 1) * (N - 2) // 2
res = MAXP - K

if res < 0:
    print(-1)
    sys.exit()

M = (N - 1) + res

root = 2
end = root + 1

print(M)
for i in range(2,N+1):
    print(1, i)

for _ in range(res):
    if end > N:
        root += 1
        end = root + 1
    print(root, end)
    end += 1

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

int main()
{
    string n;
    cin >> n;
    long long sum=0;
    for(int i=0; i<n.size(); i++)
        sum=sum+(n[i]-'0');
    if(sum%9==0)
        cout << "Yes"<<endl;
    else
        cout << "No"<<endl;
    return 0;
}


Measured memory_bytes: 3768
N,D,A=map(int, input().split())
XH=[list(map(int, input().split())) for _ in range(N)]

XH.sort()

B=0
Bt=[0]*N
Bx=[0]*N
l=0
r=-1

ans=0
for i in range(N):
    x,h = XH[i]
    if h<=0: continue
    #今までの爆弾ダメージを計算
    while l<=r:
        if Bx[l]<x: #もう届かない
            B-=Bt[l]*A
            l+=1
        else: #まだ届く
            break
    h-=B
    if h>0:
        t=(h+A-1)//A #ここで爆弾を使う回数
        ans+=t
        r+=1
        Bt[r]=t
        Bx[r]=x+(2*D)
        B+=A*t

print(ans)


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

#define MAX 80

char a[MAX+1], b[MAX+1];
int sum[MAX+1];
int a_size, b_size, sum_size;

void culc(int carry) {
	if(sum_size<a_size && sum_size<b_size)
		sum[sum_size] = a[a_size-sum_size-1]-'0' + b[b_size-sum_size-1]-'0' + carry;
	else if(sum_size>=a_size && sum_size<b_size)
		sum[sum_size] = b[b_size-sum_size-1]-'0' + carry;
	else if(sum_size<a_size && sum_size>=b_size)
		sum[sum_size] = a[a_size-sum_size-1]-'0' + carry;
	else if(sum_size>=a_size && sum_size>=b_size)
		sum[sum_size] = carry;

	if(sum[sum_size]>9) {
		sum[sum_size] -= 10;
		carry = 1;
	} else {
		carry = 0;
	}
	if( (++sum_size<a_size || sum_size<b_size) || carry==1  )
		culc(carry);
	return;
}

int main(void) {
	int n, i, j;
	scanf("%d", &n);
	for(i = 0; i < n; i++) {
		scanf("%s %s", a, b);
		a_size = strlen(a);
		b_size = strlen(b);

		if(a_size>=MAX+1 || b_size>=MAX+1) {
			printf("overflow\n");
			continue;
		}
		sum_size = 0;
		culc(0);
		if(sum_size > MAX) {
			printf("overflow\n");
			continue;
		} else {
			for(sum_size--; sum_size >= 0; sum_size--) {
				printf("%d", sum[sum_size]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdlib>
#include <iostream>


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

  int a, b;
  std::cin >> a >> b;

  auto sum = a + b;
  if (sum < 10) {
    std::cout << sum << std::endl;
  } else {
    std::cout << "error" << std::endl;
  }

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
/*
 * シカのAtCoDeerくんは友達のTopCoDeerくんとあるゲームをして対戦しています。 このゲームは N ターンからなります。各ターンではそれぞれのプレイヤーはじゃんけんのグーかパーを出します。
 * ただし、各プレイヤーは次の条件を満たす必要があります。
 * 
 * (※) 各ターンの後で、(今までにパーを出した回数)≦(今までにグーを出した回数)　を満たす
 * 
 * このゲームでの各プレイヤーの得点は、(勝ったターンの数) − (負けたターンの数) です。 
 * AtCoDeerくんは特殊能力を持っているので、ゲームが始まる前にTopCoDeerくんの出す N ターンの手を全て知ることが出来ました。
 * AtCoDeerくんの各ターンでの手を決めて、AtCoDeerくんの得点を最大化してください。 TopCoDeerくんの出す手の情報は文字列 s で与えられます。
 * s の i(1≦i≦N) 文字目が gのときは i ターン目でTopCoDeerくんがグーを出すことを、 pのときはパーを出すことを表します。
 */

import java.util.*;
	public class Main{
		public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            String s = sc.next();
            int n = String.valueOf(s).length();
            int count = 0;
            
            for(int i=0; i<n; i++){
            	if(s.substring(i,i+1).equals("p")){
            		count++;
            	}
            }
            
            System.out.println(n/2 - count);
            sc.close();
		}
    }
	

Measured memory_bytes: 30416
// Created by Krishna Ashok
#include <bits/stdc++.h>
using namespace std;

#define dbg(x) cout<<#x<<"="<<x<<'\n'
#define ll long long int
#define pr pair<int,int>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);++i)
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#define fin ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define MOD 1000000007



void solve(){
    int n;
    cin>>n;
    if(n%1000==0) cout<<0;
    else{
        int ans=1000-(n%1000);
        cout<<ans;
    }
}



int main()
{
    fin;
    solve();
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<utility>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define INF 1e18
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,pii> plii;

int main(){
	int n;
	long long x,ans=INF;
	cin>>n>>x;
	long long a[n];
	rep(i,n)cin>>a[i];
	long long b[n][n];
	rep(i,n)b[i][0]=a[i];
	rep(i,n){
		rep(j,n){
			if(j==0)b[i][j]=a[(i-j+n)%n];
			else b[i][j]=min(b[i][j-1],a[(i-j+n)%n]);
		}
	}
	rep(k,n){
		long long sum=k*x;
		rep(i,n)sum+=b[i][k];
		ans=min(ans,sum);
	}
	cout<<ans<<endl;
	return 0;
}

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

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

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const int MAX_H = 10;
const int MAX_W = 10;
const int C = 5;
int h, w, c;
int p[MAX_H][MAX_W];
int used[MAX_H][MAX_W];

inline bool check(int hx, int hy){ return 0 <= hx && hx < h && 0 <= hy && hy < w; }

int dfs(int color)
{
  int ret = 0;
  int prev = p[0][0];
  stack<pair<int, int> > st;
  rep(i, h) rep(j, w) used[i][j] = 0;
  p[0][0] = color;
  used[0][0] = 1;
  st.push(make_pair(0, 0));
  while(!st.empty()){
    pair<int, int> here = st.top();  st.pop();
    int hx = here.first;
    int hy = here.second;
    ret += 1;
    rep(k, 4){
      int nx = hx + dx[k];
      int ny = hy + dy[k];
      if(!check(nx, ny)) continue;
      if(used[hx][hy] == 2){
        if(!used[nx][ny] && p[nx][ny] == color){
          used[nx][ny] = 2;
          st.push(make_pair(nx, ny));
        }
        continue;
      }
      if(!used[nx][ny] && p[nx][ny] == color){
        used[nx][ny] = 2;
        st.push(make_pair(nx, ny));
      }
      if(!used[nx][ny] && p[nx][ny] == prev){
        p[nx][ny] = color;
        used[nx][ny] = 1;
        st.push(make_pair(nx, ny));
      }
    }
  }
  return ret;
}

int solve(int cnt)
{
  int ret = 0;
  int prev[MAX_H][MAX_W];
  rep(i, h) rep(j, w) prev[i][j] = p[i][j];
  if(cnt){
    rep(k, 6){
      dfs(k + 1);
      ret = max(ret, solve(cnt - 1));
      rep(i, h) rep(j, w) p[i][j] = prev[i][j];
    }
    return ret;
  }
  else return dfs(c);
}

int main()
{
  while(cin >> h >> w >> c, h){
    rep(i, h) rep(j, w) cin >> p[i][j];
    cout << solve(C - 1) << endl;
  }

  return 0;
}

Measured memory_bytes: 1200
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc078.contest.atcoder.jp/tasks/arc078_a>
問題文============================================================
 すぬけくんとアライグマは N 枚のカードの山を作りました。
 カードの山の上から i 番目のカードには整数 ai が書かれています。
 
 N 枚のカードを分け合うことにしました。
 すぬけくんがカードの山の上から何枚かのカードを取ったあと、アライグマは残ったカード全てを取ります。
 このとき、すぬけくんもアライグマも 1 枚以上のカードを取る必要があります。
 
 すぬけくんとアライグマが持っているカードに書かれた数の総和をそれぞれ x,y として、
 |x−y| を最小化したいです。 |x−y| としてありうる値の最小値を求めなさい。

=================================================================

解説=============================================================

 累積和を用意れば,各山の総和がO(1)でもとまる
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    for(auto &in:a) cin >> in;
    vector<ll> cusum(n+1,0);
    for(int i = 0; i < n;i++){
        cusum[i+1] = cusum[i] + a[i];
    }
    ll ans = LINF;
    for(int i = 1; i < n;i++){
        ans = min(ans,abs(cusum[i] - (cusum[n] - cusum[i])));
    }
    cout << ans << endl;
	return 0;
}


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

namespace ProgramingStudying2
{
    class Program
    {
        static int n;
        static int m;
        static List<List<int>> G;
        static int ans;

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split();
            n = int.Parse(input[0]);
            m = int.Parse(input[1]);

            G = new List<List<int>>();

            for(int i = 0; i < n; i++)
            {
                G.Add(new List<int>());
            }

            for(int i = 0; i < m; i++)
            {
                var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var a = ab[0] - 1;
                var b = ab[1] - 1;

                G[a].Add(b);
                G[b].Add(a);
            }

            var visited = new bool[n];
            visited[0] = true;
            ans = 0;

            dfs(0, 1, visited);

            Console.WriteLine(ans);
        }

        static void dfs(int x, int count, bool[] visited)
        {
            if(count == n)
            {
                ans++;
            }

            else
            {
                foreach(int nx in G[x])
                {
                    if (visited[nx])
                    {
                        continue;
                    }
                    var newCount = count + 1;

                    visited[nx] = true;

                    dfs(nx, newCount, visited);
                }
            }
            visited[x] = false;
        }
    }
}


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

const ll INF = 1LL << 60;

int main() {
    ll N, K;
    cin >> N >> K;
    if (N % K == 0) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = INF;
    if (N > K) {
        ll syo = N / K;
        N -= syo * K;
        ans = N;
        if (abs(ans - K) < ans) {
            ans = abs(ans - K);
        }
    } else {
        ans = N;
        if (abs(ans - K) < ans) {
            ans = abs(ans - K);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
dp = [10**5]*(10**5+1)
dp[0] = 0
for i in range(n+1):
  if i >= 1:
    dp[i] = min(dp[i-1]+1,dp[i])
  if i >= 6:
    dp[i] = min(dp[i-6]+1,dp[i])
  if i >= 9:
    dp[i] = min(dp[i-9]+1,dp[i])
  if i >= 36:
    dp[i] = min(dp[i-36]+1,dp[i])
  if i >= 81:
    dp[i] = min(dp[i-81]+1,dp[i])
  if i >= 216:
    dp[i] = min(dp[i-216]+1,dp[i])
  if i >= 729:
    dp[i] = min(dp[i-729]+1,dp[i])
  if i >= 1296:
    dp[i] = min(dp[i-1296]+1,dp[i]) 
  if i >= 6561:
    dp[i] = min(dp[i-6561]+1,dp[i])
  if i >= 7776:
    dp[i] = min(dp[i-7776]+1,dp[i])
  if i >= 46656:
    dp[i] = min(dp[i-46656]+1,dp[i])
  if i >= 59049:
    dp[i] = min(dp[i-59049]+1,dp[i])
print(dp[n])

Measured memory_bytes: 3956
while True:
    N,M=map(int,input().split())
    if N==0 and M==0:
        break
    curnumlis = [0]*M
    use = [[-1]*1261 for i in range(M)]
    r = int(input())
    for _ in range(r):
        t,n,m,s=map(int,input().split())
        if s==0:
            s=-1
        curnumlis[m-1]+=s
        use[m-1][t]=curnumlis[m-1]
    q = int(input())
    for _ in range(q):
        ans = 0
        ts,te,m=map(int,input().split())
        start = 0
        for i in range(540,ts):
            if use[m-1][i] != -1:
                start = use[m-1][i]
        cur = "off"
        if start>0:
            cur = "on"
        for i in range(ts,te):
            if use[m-1][i]==0:
                cur="off"
            elif use[m-1][i]>0:
                cur="on"
            if cur == "on":
                ans += 1
        print(ans)


Measured memory_bytes: 162012
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	private	static	BufferedReader	br = null;

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

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int[]	sum   = new int[2];
		int[]	table = null;
		int		nCnt  = 0;

		while ((table = parseHanbai()) != null) {
			sum[0] += table[0] * table[1];
			sum[1] += table[1];
			nCnt++;
		}

		if (nCnt > 0) {
			System.out.println(sum[0]);
			System.out.println((int)Math.round((double)sum[1] / (double)nCnt));
		}
	}

	private static int[] parseHanbai() {
		String	strIn = null;
		int[]	table = null;

		if ((strIn = parseStdin()) != null) {
			String[]	line = strIn.split(",");

			table    = new int[2];
			table[0] = Integer.parseInt(line[0]);
			table[1] = Integer.parseInt(line[1]);
		}
		
		return table;
	}

	private static String parseStdin() {
		String	strNum = null;

		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					strNum = line;
				}
			}
		}
		catch (IOException e) {}

		return strNum;
	}
}

Measured memory_bytes: 16912
import java.util.Scanner;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int table[] = new int[128];

		for(int i = 0; i < table.length; i++){
			table[i] = 0;
		}

		StringBuilder sb = new StringBuilder();

		while(scanner.hasNext()){
			sb.append(scanner.nextLine());
		}

		String line = sb.toString();

		for(int i = 0; i < line.length(); i++){
			table[line.charAt(i)]++;
		}

		for(int i = 0; i < 26; i++){
			System.out.printf("%c : %d\n", 'a'+i,table['a'+i]+table['a'+i-32]);
		}
	}
}


Measured memory_bytes: 26256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define int long long

typedef long long ll;
typedef pair<int, int> Pair;

// const int kMaxN;

string S;
string ans;

string Ans() {
  if (S.length() < 26) {
    REP(i, 26) {
      if (S.find('a'+i) == string::npos) {
        S.push_back('a'+i);
        return S;
      }
    }
  } else {
    if (S == "zyxwvutsrqponmlkjihgfedcba") { return "-1"; }

    priority_queue<char, vector<char>, greater<char>> q;
    char m = 'a'-1;
    while (true) {
      char lst = S[S.length()-1];
      q.push(lst);
      m = MAX(m, lst);
      S.pop_back();

      if (S[S.length()-1] < m) {
        while (true) {
          if (S[S.length()-1] < q.top()) {
            S[S.length()-1] = q.top();
            return S;
          } else {
            q.pop();
          }
        }
      }
    }
  }
  return "-1";
}

signed main() {
  cin >> S;

  ans = Ans();

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


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

		//一列をintのArrayListに変換
		List<String> l = Arrays.asList(sc.nextLine().split(" "));
		ArrayList<Integer> nl = new ArrayList<Integer>();
		for(String s: l) {
			nl.add(Integer.parseInt(s));
		}

		System.out.println(nl.get(0)-nl.get(1)+1);
	}
}

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

int main()
{
  int a;
  int b;
  int c;
  int d;
  int e = 0;
  
  cin >> a >> b >> c >> d;
  
  e = a * b - (c * b + d * (a - c));
  
  cout<<e<<endl;
}

Measured memory_bytes: 256
import Foundation

var input = readLine()!.split(separator: " ")
var n = Int(input[0])!
var k = Int(input[1])!

var snuke = [Bool](repeating: false, count: n)

for _ in 0 ..< k {
    _ = Int(readLine()!)!
    let snacks = readLine()!.split(separator: " ").map({Int($0)!});
    for i in snacks {
        snuke[i-1] = true;
    }
}

var ans = 0
for i in snuke { ans += i ? 0 : 1 }

print(ans)

Measured memory_bytes: 13648
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int n;
  long long k;
  cin >> n >> k;
  long long a[n];
  int b[40];
  memset(b, 0, sizeof(b));
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (int j = 0; j < 40; j++) {
      if (a[i] & (1LL << j)) b[j]++;
    }
  }
  int kk[40];
  for (int i = 0; i < 40; i++) {
    if ((k + 1) & (1LL << i)) kk[i] = 1;
    else kk[i] = 0;
  }

  long long ans = 0;
  for (int i = 0; i < 40; i++) {
    long long x = 0;
    for (int j = 0; j < i; j++) {
      if (b[j] <= n - b[j]) x += pow(2, j);
    }
    for (int j = i + 1; j < 40; j++) {
      if (kk[j]) x += pow(2, j);
    }
    if (x > k) continue;
    long long t = 0;
    for (int j = 0; j < n; j++) {
      t += a[j] ^ x;
    }
    ans = max(ans, t);
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 3005;

inline int add(int x,int y)
{
    return (x + y)%MOD;
}

inline int sub(int x,int y)
{
    return (x+MOD-y)%MOD;
}

inline int mul(int x,int y)
{
    return (ll)x*y%MOD;
}

int dp[MAX_N][MAX_N];
int sm[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    dp[0][0] = 1;
    rep(i,n-1){
        rep(j,i+2){
            sm[j] = 0;
        }
        rep(j,i+1){
            if(dp[i][j] == 0) continue;
            if(s[i] == '<'){
                sm[j+1] = add(sm[j+1], dp[i][j]);
                sm[i+2] = sub(sm[i+2], dp[i][j]);
            }else{
                sm[j+1] = sub(sm[j+1], dp[i][j]);
                sm[0] = add(sm[0], dp[i][j]);
            }
        }
        rep(j,i+2){
            sm[j+1] = add(sm[j+1], sm[j]);
        }
        rep(j,i+2){
            dp[i+1][j] = sm[j];
        }
    }
    int ans = 0;
    rep(i,n){
        ans = add(ans, dp[n-1][i]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 34176
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
const lld MAXN = 200000;

int main()
{
	lld n,t,a[MAXN] = {0};

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

	lld sol = 0;

	//int i = 0,j = 0;
	lld prev = a[0],now = a[0];

	if (n == 1)
	{
		cout << t << endl;
		return 0;
	}

	for(int i = 0; i < n-1; i++)
	{

		if (a[i] + t < a[i+1])
		{
			sol += t;
			if (i == n-2)
			{
				sol += t;
			}
		}else
		{
			sol += a[i+1] - a[i];
			if (i == n-2)
			{
				sol += t;
			}
		}
		// if (a[i] < prev + t)
		// {
		// 	now = a[i];
		// 	if (i == n-1)
		// 	{
		// 		sol += (a[i] - prev) + t;
		// 	}
		// }else
		// {
		// 	// if (i == n-1)
		// 	// {
		// 	// 	sol += (a[i] - prev) + t;
		// 	// 	break;
		// 	// }
		// 	sol += (a[i-1] - prev) + t;
		// 	cout << "sol = " << sol << endl;
		// 	prev = a[i];
		// 	now = a[i];
		// }
	}

	cout << sol << endl;

	return 0;
}

Measured memory_bytes: 1792
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Stack;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            Stack<Integer> st = new Stack<Integer>();

            for (int i = 0; i < s.length(); i++) {
                char at = s.charAt(i);
                if ('B' == at) {
                    if(!st.empty()) st.pop();
                } else {
                    st.push(Character.getNumericValue(at));
                }
            }

            Object[] a = st.toArray();

            for (int i = 0; i < a.length; i++)
                System.out.print(a[i].toString());

            System.out.println();
        }
    }
}


Measured memory_bytes: 22484
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int n; cin>>n;
  set<int> s;
  rep(i,n){
    int a; cin>>a;
    if(s.count(a)){
      s.erase(a);
    }else{
      s.insert(a);
    }
  }
  cout<<s.size()<<endl;

  return 0;
}


Measured memory_bytes: 4864
#include<iostream>
#include<cstdio>
#include<cstring>
#include <fstream>
#include<string>
#include<sstream>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
#include <math.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const long long int MOD = 1000000007;
const int INF = 1000000007;
const double EPS = 1e-10;
const double PI = 3.14159265359;
const int N = 100005;
//cout << fixed << std::setprecision(9)
//--------------------------


int n, k;
ll a[102];
ll dp[102][N];

int main()
{
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= k; j++) {
			if (j == 0) { 
				dp[i][j] = 1ll;
				continue;
			}
			if (j - 1 >= a[i]) 
				dp[i][j] = (dp[i][j - 1] + dp[i - 1][j] + MOD - dp[i - 1][j -1 - a[i]]) % MOD;
			else
				dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % MOD;
		}
	}

	cout << dp[n][k] << endl;

	return 0;
}


Measured memory_bytes: 78336
//package Contest088;

import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String []args)
    {
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(),a=sc.nextInt();
        if(n%500<=a)
            out.println("Yes");
        else
            out.println("No");

        out.flush();
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <numeric>

using namespace std;

typedef long long ll;

ll A[100000];

int main() {
    int n; cin >> n;
    bool r = 0;
    bool o = 0;
    for(int i = 0; i < n; ++i) {
        cin >> A[i];
        if(A[i] < 0) r = !r;
        if(A[i] == 0) o = 1;
    }
    
    ll mn = 0;
    if(r && o == 0) mn = accumulate(A, A + n, 1e9, [](ll x, ll y) -> ll { return (abs(x) < abs(y) ? x : y); });
    
    cout << accumulate(A, A + n, 0LL, [](ll x, ll y) -> ll{ return abs(x) + abs(y); }) - 2 * abs(mn);
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		if(((a*b)%2)==0)System.out.println("Even");
		else System.out.println("Odd");
		in.close();
	}

}


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

using namespace std;
#define long long long

const int N = 3e3 + 10;
const int MOD = 1e9 + 7;

int n;
long f[N][N], s[N][N];
char str[N];

int main()
{
//    freopen("tam.inp", "r", stdin);
    cin.tie(nullptr); ios_base::sync_with_stdio(false);

    cin >> n >> str + 1;
    for (int i = 0; i < n; ++i)
        for (int j = 1; j <= n - i; ++j) {
            if (!i) {f[i][j] = 1; s[i][j] = (s[i][j - 1] + f[i][j]) % MOD; continue;}

            if (str[i] == '>') f[i][j] = ((f[i][j] + s[i - 1][n - i + 1] - s[i - 1][j]) % MOD + MOD) % MOD;
            else f[i][j] = s[i - 1][j] % MOD;
            s[i][j] = (s[i][j - 1] + f[i][j]) % MOD;
        }

    cout << f[n - 1][1];

    return 0;
}


Measured memory_bytes: 141696
#include <iostream>
#include <algorithm>
#define rep(i,s,n)for(int i = s;i<n;i++)
using namespace std;
typedef long long ll;

ll a[100001] = {};
int main() {
	ll n; cin >> n;
	ll negativeCnt = 0;
	ll minAbsolute = 1e10;
	rep(i, 0, n) {
		ll A; cin >> A;
		a[i] = A;
		if (A < 0) {
			negativeCnt++;
		}
		minAbsolute = min(minAbsolute, abs(A));
	}

	ll sum = 0;
	rep(i, 0, n) {
		sum += abs(a[i]);
	}

	if (negativeCnt & 1) {
		sum -= 2 * minAbsolute;
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1024
s = input()
n = len(s)

l = []
tmp = []
i = 0
ans = 0
while i < n-1:
	if s[i] != s[i+1]:
		ans += 1
		num = 2
		while i+num < n:
			if len(l) == 0:
				break
			left = l.pop()
			right = s[i+num]
			if s[left] != right:
				ans += 1
				num += 1
			else:
				l.append(left)
				break
		i += num
	else:
		l.append(i)
		i += 1

print(2*ans)


Measured memory_bytes: 7188
import java.math.BigInteger;
import java.util.Scanner;

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

        Scanner scanner = new Scanner(System.in);

        BigInteger A = scanner.nextBigInteger();
        BigInteger B = scanner.nextBigInteger();
        BigInteger C = scanner.nextBigInteger();
        BigInteger D = scanner.nextBigInteger();

        BigInteger countC = countDivNum(A, B, C);
        BigInteger countD = countDivNum(A, B, D);
        BigInteger countCD = countDivNum(A, B, lcm(C, D));

        BigInteger rangeNum = B.subtract(A).add(BigInteger.valueOf(1));
        BigInteger divideNum = countC.add(countD).subtract(countCD);

        System.out.println(rangeNum.subtract(divideNum));

    }

    private static BigInteger countDivNum(BigInteger A, BigInteger B, BigInteger Divide){


        BigInteger minValue = A;
        BigInteger[] valMin = minValue.divideAndRemainder(Divide);
        BigInteger minRemainder = valMin[1];
        if(!minRemainder.equals(BigInteger.valueOf(0))){
            BigInteger diff = Divide.subtract(minRemainder);
            minValue = minValue.add(diff);
        }

        BigInteger maxValue= B;
        BigInteger[] valMax = maxValue.divideAndRemainder(Divide);
        BigInteger maxRemainder = valMax[1];
        if(!minRemainder.equals(BigInteger.valueOf(0))){
            maxValue = maxValue.subtract(maxRemainder);
        }

        if(maxValue.compareTo(minValue) == -1){
            return BigInteger.valueOf(0);
        }else {
            BigInteger range = maxValue.subtract(minValue);
            BigInteger countRqw = range.divide(Divide);

            BigInteger countDivNum = countRqw.add(BigInteger.valueOf(1));

            return countDivNum;
        }
    }

    private static BigInteger gcb(BigInteger A, BigInteger B){

        if(A.compareTo(B) == -1){
            BigInteger C = A;
            A = B;
            B = C;
        }

        BigInteger[] valFirst = A.divideAndRemainder(B);
        if(valFirst[1] == BigInteger.valueOf(0)){
            return B;
        }

        while(true){
            BigInteger[] val = A.divideAndRemainder(B);

            if(val[1] == BigInteger.valueOf(0)){
                break;
            }

            BigInteger tmp = B;
            B = val[1];
            A = tmp;
        }

        BigInteger gcb = B;

        return gcb;
    }

    private static BigInteger lcm(BigInteger A, BigInteger B){
        BigInteger lcm = A.multiply(B.divide(gcb(A, B)));
        return lcm;
    }
}


Measured memory_bytes: 22740
# -*- coding: utf-8 -*-

a = {}
b = {}
c = {}
d = {}

for i in range(1, 31):
    a[i] = 0
    b[i] = 0
    c[i] = 0
    d[i] = 0

n = int(input())

for j in range(n):
    m = list(map(int, input().split()))

    if m[0] == 1:
        a[m[2] + 10 * (m[1] - 1)] = a[m[2] + 10 * (m[1] - 1)] + m[3]

    elif m[0] == 2:
        b[m[2] + 10 * (m[1] - 1)] = b[m[2] + 10 * (m[1] - 1)] + m[3]

    elif m[0] == 3:
        c[m[2] + 10 * (m[1] - 1)] = c[m[2] + 10 * (m[1] - 1)] + m[3]

    elif m[0] == 4:
        d[m[2] + 10 * (m[1] - 1)] = d[m[2] + 10 * (m[1] - 1)] + m[3]

for i in range(1, 4):
    for j in range(1, 11):
        print(' {0}'.format(a[j + 10 * (i - 1)]), end='')
    print()

print('####################')

for i in range(1, 4):
    for j in range(1, 11):
        print(' {0}'.format(b[j + 10 * (i - 1)]), end='')
    print()

print('####################')

for i in range(1, 4):
    for j in range(1, 11):
        print(' {0}'.format(c[j + 10 * (i - 1)]), end='')
    print()

print('####################')

for i in range(1, 4):
    for j in range(1, 11):
        print(' {0}'.format(d[j + 10 * (i - 1)]), end='')
    print()



Measured memory_bytes: 5640
#include <stdio.h>

int main(void){
  int A,B,C,X,Y,ans;
  scanf("%d%d%d%d%d",&A,&B,&C,&X,&Y);

  if(A+B < 2*C){
    ans = A*X+B*Y;
  }
  else{
    int temp=Y;
    if(X < Y)temp = X;
    ans = temp*2*C;
    if(X < Y){
      if(B < 2*C)
        ans += (Y-temp)*B;
      else
        ans += (Y-temp)*2*C;
    }
    else{
      if(A < 2*C)
        ans += (X-temp)*A;
      else
        ans += (X-temp)*2*C;
    }
  }
  printf("%d\n",ans);

  return 0;
}

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define SUBL freopen("/home/ajinkya/Desktop/input.txt","r",stdin); freopen("/home/ajinkya/Desktop/output.txt","w",stdout); 
#define ll long long
#define ull unsigned long long
#define FI(i,a,n) for(int i=a; i<=n; i++)
#define RFI(i,n,a) for(int i=n; i>=a; i--)
#define FLL(i,a,n) for(ll i=a; i<=n; i++)
#define RFLL(i,n,a) for(ll i=n; i>=a; i--)
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define pi pair<int, int>
#define GCD(a,b) __gcd(a,b)
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define debug(x) cout << x << endl
#define MOD 1000000007
#define INF LLONG_MAX
#define PI 3.14159265359
using namespace std;




int main()
{
    fastio 
   // SUBL
  	ll n, a, b;
  	cin >> n >> a >> b;
  	cout << min(n*a,b);
    return 0;
}         	

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

using ll = long long;
const ll MOD = 1000000007;
const int MAXXYZ = 17;

int n,x,y,z;

inline bool hasXYZ(int a){
	return (a >> (z - 1)) & (a >> (y + z - 1)) & (a >> (x + y + z - 1)) & 1;
}

signed main(){
	ll dp[50][1 << MAXXYZ] = {};
	cin >> n >> x >> y >> z;
	dp[0][0] = 1;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < (1 << MAXXYZ);j++){
			for(int k = 1;k <= 10;k++){
				int nxt = ((j << k) + (1 << (k - 1))) % (1 << MAXXYZ);
				if(!hasXYZ(nxt)) (dp[i + 1][nxt] += dp[i][j]) %= MOD;
			}
		}
	}
	ll ans = 1;
	for(int i = 0;i < n;i++) ans = ans * 10 % MOD;
	for(int i = 0;i < (1 << MAXXYZ);i++) ans = (ans - dp[n][i] + MOD) % MOD;
	cout << ans << endl;
}

Measured memory_bytes: 51456
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;


constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
    template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
    template<typename T> void chadd(T& a, T b) { a = a + b; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    void CCout(long long x, const char* end = "\n") { std::cerr << x << end; }
    template <typename T> void CCout(const T& x, const char* end = "\n") { std::cerr << x << end; }
    template <typename T> void CCout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cerr << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t sz;
        inp(std::size_t _sz = 1) : sz(_sz) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
        template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
    };

    inp inp1; // input one
}

int main() {

    int n, m;
    cin >> n >> m;
    vector<ll> x = inp(n);
    vector<ll> y = inp(m);

    ll left = 0;
    ll right = 0;
    rep(i, n) {
        // x[i]が足される回数
        ll add = i + 1;
        // x[i]が引かれる回数
        ll rem = n - i;
        left += (add - rem) * x[i];
        left %= mod;
    }

    rep(i, m) {
        // y[i]が足される回数
        ll add = i + 1;
        // y[i]が引かれる回数
        ll rem = m - i;
        right += (add - rem) * y[i];
        right %= mod;
    }
    
    cerr << "left : " << left << " , right : " << right << endl;
    Cout((right* left) % mod);

    return 0;
}


Measured memory_bytes: 1792
<?php
fscanf(STDIN, "%d", $N);
fscanf(STDIN, "%d %d", $A, $B);

$answer = 'NG';
for($i = $A; $i <= $B; $i++) {
  if ($i % $N === 0) {
    $answer = 'OK';
    break;
  }
}
echo $answer;

Measured memory_bytes: 16116
N, MA, MB = list(map(int, input().split()))
abc = [list(map(int, input().split())) for _ in range(N)]

inf = 1000 * N
M = N * 10 + 1
DP = [[[inf] * M for _ in range(M)] for _ in range(N)]

a, b, c = abc[0]
DP[0][a][b] = c

for i in range(1, N):
  a, b, c = abc[i]
  DP[i][a][b] = min(DP[i - 1][a][b], c)
  for j in range(M - 10):
    for k in range(M - 10):
      DP[i][j][k] = min(DP[i][j][k], DP[i - 1][j][k])
      if DP[i - 1][j][k] < inf:
        jj = j + a
        kk = k + b
        DP[i][jj][kk] = min(DP[i - 1][jj][kk], DP[i - 1][j][k] + c)
ans = inf
i = MA
j = MB
while i < M and j < M:
  ans = min(ans, DP[-1][i][j])
  i += MA
  j += MB

if ans == inf:
  print(-1)
else:
  print(ans)


Measured memory_bytes: 96604
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

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

    int[] array;
    int N ;
    long count = 0;
    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        N = scanner.nextInt();
        array = new int[N];
        for (int i = 0; i < N; i++) {
            array[i] = scanner.nextInt();
        }
        dfs(0, 1);
        System.out.println(count);
    }

    private void dfs(int depth, long v) {
        if (depth == N) {
            if (v % 2 == 0) {
                count++;
            }
            return;
        }
        for (int i = -1; i < 2; i++) {
            dfs(depth+1, v * (array[depth] + i));
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {
                    line = br.readLine();
                }
                s = line.split(reg, 0);
                i = 0;
                return s[i++];
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public int nextInt() {
            try {
                return Integer.parseInt(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public double nextDouble() {
            try {
                return Double.parseDouble(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public long nextLong()  {
            try {
                return Long.parseLong(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }
    }
}


Measured memory_bytes: 21076
#[allow(unused_imports)]
use std::cmp::Reverse;

#[allow(unused_imports)]
use proconio::{fastout, input, marker::Chars};

#[allow(unused_imports)]
use itertools::Itertools;

#[fastout]
pub fn main() {
    input! {
        a: f64,
        b: f64,
        h: f64,
        m: f64,
    }

    let theta = (-(h / 12.0 + m / (12.0 * 60.0)) * 2.0 * std::f64::consts::PI
        - -m / 60.0 * 2.0 * std::f64::consts::PI)
        .abs();
    println!("{}", (a * a + b * b - 2.0 * a * b * theta.cos()).sqrt());
}


Measured memory_bytes: 3004
def read():
    N, A, B = map(int, input().strip().split())
    return N, A, B


def solve(N, A, B):
    intersect_max = min(A, B)
    intersect_min = max(0, A + B - N)
    return intersect_max, intersect_min


if __name__ == '__main__':
    inputs = read()
    print("%d %d" % solve(*inputs))


Measured memory_bytes: 2940
import java.lang.reflect.Array;
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

  static int N;
  static int K;
  static long Q;
  static int A;
  static int B;
  static long C;
  static double min = 9999999;
  static long ans = 0;

  public static void main(String[] args) {
//    Scanner scanner = new Scanner(System.in);

//    int A = scanner.nextInt();
//    int B = scanner.nextInt();



    if(get()){
        System.out.println("Yay!");
      }else{
        System.out.println(":(");
    }

  }

  public static boolean get(){
    Scanner scanner = new Scanner(System.in);

    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int C = scanner.nextInt();
    int D = scanner.nextInt();
    int E = scanner.nextInt();
    int K = scanner.nextInt();


    if(B - A > K)return false;
    if(C - A > K)return false;
    if(D - A > K)return false;
    if(E - A > K)return false;
    if(C - B > K)return false;
    if(D - B > K)return false;
    if(E - B > K)return false;
    if(D - C > K)return false;
    if(E - C > K)return false;
    if(E - D > K)return false;





    return true;
  }

}


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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

string s;
int a;
int b;
int c;
int n;
int m;
vector<int> v;


int main(){
    CININIT;

    cin >> s;
    string s1 = s.substr(0,4);
    string s2 = s.substr(4);
    cout << s1 << " " << s2 << endl;
}


Measured memory_bytes: 384
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int a, b; readV(a, b);
  writeln(a*b%2 == 0 ? "No" : "Yes");
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(void)
{
    while(1){
        int n;
        scanf(" %d", &n);
        if(n == 0)
            break;
        vector<int> s;

        for(int i = 0; i < n; i++){
            int tmp;
            scanf(" %d", &tmp);
            s.push_back(tmp);
        }
        sort(s.begin(), s.end());

        int sum = 0;
        for(int i = 1; i < n - 1; i++)
            sum += s[i];
        printf("%d\n", sum / (n-2));
    }
    return 0;
}

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

int main()
{
    int H, W;
    
    for (int i = 0; ; i++) {
        scanf("%d %d", &H, &W);
        if (H == 0 and W == 0) break;
        
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (i == 0 or j == 0
                    or i == H-1 or j == W-1) putchar('#');
                else putchar('.');
            }
            putchar('\n');
        }
        putchar('\n');
    }
}



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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const ll LINF = 1e11;

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

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


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

    int ans = INF;
    int s1, s2;
    for (int t = 0; t < n - 1; ++t) {
        s1 = 0;
        s2 = 0;
        for (int i = 0; i <= t; ++i) {
            s1 += w[i];
        }
        for (int i = t + 1; i < n; ++i) {
            s2 += w[i];
        }
        ans = min(ans, abs(s1 - s2));
    }

    cout << ans << "\n";
}


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

    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cassert>

#include<cmath>
#include<functional>
#include<algorithm>

#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<bitset>
#include<tuple>

#define TEST {IS_TEST=true;}

using namespace std;
using ll = int_fast64_t;
using v_bool = vector <bool>;
using v_ll = vector <ll>;
using v_std = vector <string>;
using p_ll = pair <ll,ll>;
using vv_ll = vector <vector <ll> >;
using vp_ll = vector < p_ll >;

bool IS_TEST=false;
ll ll_min=1LL<<63;
ll ll_max=~ll_min;
ll MOD = 1000000007;

ll A,B;
int main(){
    cin >> A >> B;
    if (A%3==0||B%3==0||(A+B)%3==0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

int main() {
  int n,d[110][2];
  cin >> n;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < 2; j++)
      cin >> d[i][j];
  }

  int cnt = 0;
  for(int i = 0; i < n; i++) {
    if(d[i][0] == d[i][1]) cnt++;
    else cnt = 0;
    if(cnt >= 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
}

Measured memory_bytes: 3632