akhauriyash/Code-Regression huggingface dataset:
<?php
# 入力部
// fscanf(STDIN, "%d", $a);
// fscanf(STDIN, "%d %d", $a, $b);
// $s1 = fgets(STDIN); //"\n"の2文字
// $s2 = fgets(STDIN);
// fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%s", $s1);
fscanf(STDIN, "%s", $s2);

# 処理部
$arr1 = str_split($s1);
$arr2 = str_split($s2);
// $arr1 = explode(" ", $s1);
// $arr2 = explode(" ", $s2);
// for ($i = 0; $n > $x * $i; $i++) {
// }
// if (strpos($s, 'RRR') !== false) {
//   $r = 3;
// } elseif (strpos($s, 'RR') !== false) {
//   $r = 2;
// } elseif (strpos($s, 'R') !== false) {
//   $r = 1;
// } else {
//   $r = 0;
// }
// $s = "No";
// if ($x >= 30) {
//   $s = "Yes";
// }
// for ($i = 0; $i * 1000 < $n; $i++) {
// }
// $c = "a";
// if (ctype_upper($a)) {
//   $c = "A";
// }
$s = "Yes";
// echo count($arr1);
for ($i = 0; $i < strlen($s1); $i++) {
  if ($arr1[$i] != $arr2[$i]) {
    $s = "No";
  }
}
// $unit;
// switch ($n % 10) {
//   case 0:
//   case 1:
//   case 6:
//   case 8:
//     $unit = "pon";
//     break;
//   case 3:
//     $unit = "bon";
//     break;
//   default:
//     $unit = "hon";
//     break;
// }

# 出力部
echo $s . "\n";
// echo ($i * 1000) - $n . "\n";

Measured memory_bytes: 15764
I=lambda : list(map(int,input().split()))
n,m = I()
l=I();s=sum(l);l.sort();d=[]
for _ in range(m):
    b,c=I()
    d.append([c,b])
p=s=0    
for i in sorted(d,reverse=True):
    while i[1]:
        if p>=n or l[p]>=i[0]:
            break
        i[1]-=1
        s+=i[0]
        p+=1
    if p>=n:
        break
s+=sum(l[p:])
print(s)

Measured memory_bytes: 25196
#!usr/bin/env python3
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    x = I()
    if 599 >= x >= 400:
        print(8)
    elif 799 >= x >= 600:
        print(7)
    elif 999 >= x >= 800:
        print(6)
    elif 1199 >= x >= 1000:
        print(5)
    elif 1399 >= x >= 1200:
        print(4)
    elif 1599 >= x >= 1400:
        print(3)
    elif 1799 >= x >= 1600:
        print(2)
    elif 1999 >= x >= 1800:
        print(1)
    return


# Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 65708
import java.util.*;
import java.io.*;
public class Main
{
  public static void main(String args[])throws Exception
  {
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    PrintWriter pw=new PrintWriter(System.out);
    String str[]=br.readLine().split(" ");
    int n=Integer.parseInt(str[0]);
    int m=Integer.parseInt(str[1]);
    int hw=0;
    str=br.readLine().split(" ");
    for(int i=0;i<m;i++)
    hw+=Integer.parseInt(str[i]);
    if(hw>n)
    pw.println(-1);
    else
    pw.println(n-hw);
    pw.flush();
    pw.close();
  }
}

Measured memory_bytes: 34872
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>

#include <unordered_map>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <sstream>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll pow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = pow(N, P/2);
        return t*t;
    }
    return N * pow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    n=abs(n);
    m=abs(m);
    if(n*m==0)return max(n,m);
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}

int main() {
    int n;cin>>n;
    n%=10;
    if(n==3){
        cout<<"bon"<<endl;
        return 0;
    }
    if(n==0||n==1||n==6||n==8){
         cout<<"pon"<<endl;
        return 0;
    }
    else {
         cout<<"hon"<<endl;
        return 0;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int,int> P;

int main() {
  int n;
  cin>>n;
  int ans=1e9;
  vector<int> a,b;
  int m=1;
  for (int i=0; i<5; i++) {
    m*=9;
    a.push_back(m);
  }
  m=1;
  for (int i=0; i<6; i++) {
    m*=6;
    b.push_back(m);
  }
  sort (a.begin(),a.end());
  reverse (a.begin(),a.end());
  sort (b.begin(),b.end());
  reverse (b.begin(),b.end());
  for (int i=0; i<=n; i++) {
    int sum=0;
    int na=i,nb=n-i;
    for (auto x:a) {
      sum+=na/x;
      na%=x;
    }
    sum+=na;
    for (auto x:b) {
      sum+=nb/x;
      nb%=x;
    }
    sum+=nb;
    ans=min(ans,sum);
  }
  cout<<ans<<endl;     
  return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pl;


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

  bool ans=1;
  for(int i=0;i<s.size();i++){
    if(i%2==0&&(s[i]=='L')){
      ans=0;
      break;
    }else if(i%2==1&&(s[i]=='R')){
      ans=0;
      break;
    }
  }

  if(ans)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;

}


Measured memory_bytes: 256
n,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
diff = []
for i in range(n):
  diff.append(x[i+1] - x[i])
gcd = diff[0]
for i in range(1,n):
  big = diff[i]
  small = gcd
  while small != 0:
    tmp1 = big % small
    tmp2 = small
    big = tmp2
    small = tmp1
  gcd = big
print(gcd)

Measured memory_bytes: 14224
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
#include <deque>
using namespace std;
using Int = int64_t;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    Int n; cin >> n;
    vector<Int> A(n);
    for(int i = 0; i < n; i++) cin >> A[i];
    sort(A.rbegin(), A.rend());
    Int ans = 0;
    int nn = n / 2;
    if(n % 2) nn++;
    vector<Int> v;
    v.push_back(A.front());
    for (int i = 0; i < nn - 1; i++)
    {
        Int a = v.front();
        Int b = v.back();
        ans += min(a, b);
        v.push_back(A[i + 1]);
    }
    v.push_back(v.front());
    vector<Int> tmp;
    for(int i = 0; i < (int)v.size() - 1; i++)
    {
        tmp.push_back(min(v[i], v[i + 1]));
    }
    sort(tmp.rbegin(), tmp.rend());
    for(int i = 0; i < n - nn; i++) ans += tmp[i];
    cout << ans << endl;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<ll> bricks(n);
    rep(i, n) cin >> bricks[i];

    int next = 1;
    int count = 0;
    for (int i = 0; i < n; i++) {
        if (bricks[i] == next) {
            next++;
        } else {
            count++;
        }
    }
    if (count == n) {
        cout << -1 << endl;
    } else {
        cout << count << endl;
    }
}


Measured memory_bytes: 1792
X = list(map(int, input().split()))
K = int(input())
flg = False;
for i in range(K):
    if X[0] < X[1]*2**i & X[1]*2**i < X[2]*2**(K-i):
        flg = True;
if flg:
    print('Yes')
else:
    print('No')
        

Measured memory_bytes: 9164
import math
A,B,H,M = list(map(int,input().split()))

thun = M / 60 * 2 * math.pi
tzi = (60 * H + M)/ 720 * 2 * math.pi

chun = [B * math.cos(thun), B * math.sin(thun) ]
czi = [A * math.cos(tzi), A * math.sin(tzi) ]

print( ( (chun[0]-czi[0])**2 + (chun[1]-czi[1])**2 )**0.5 )

Measured memory_bytes: 9524
N=int(input())
A=list(map(int,input().split()))
a=[]
b=[]
for i in A:
    if i%2==0:
        a.append(i)
for n in a:
    if n%3==0 or n%5==0:
        b.append(n)
if len(a)==len(b):
    print('APPROVED')
else:
    print('DENIED')

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

const int N=800005;
const long long MOD=1e9+7;
int n;
long long a[N],h[N];
long long dp[N],s[N],ans;

void modify(int x,int l,int r,int k,long long val)
{
	if(l==r)
	{
		s[x]=val;
		return;
	}
	int mid=(l+r)>>1;
	if(k<=mid) modify(x<<1,l,mid,k,val);
	else modify(x<<1|1,mid+1,r,k,val);
	s[x]=max(s[x<<1],s[x<<1|1]);
}

long long query(int x,int l,int r,int L,int R)
{
	if(l>=L&&R>=r) return s[x];
	int mid=(l+r)>>1;
	long long res=0;
	if(L<=mid) res=max(res,query(x<<1,l,mid,L,R));
	if(R>mid) res=max(res,query(x<<1|1,mid+1,r,L,R));
	return res;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&h[i]);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)
	{
		dp[i]=query(1,1,n,1,h[i])+a[i];
		modify(1,1,n,h[i],dp[i]);
		ans=max(ans,dp[i]);
	}
	printf("%lld\n",ans);
}

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

const int MAXN = 2e5+5;
const int INF = 1e9+7;
#define ll long long
#define pb push_back
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

ll MOD(ll a){
    return ((a%INF)+INF)%INF;
}
int main()
{
    fast_io;
    //cout << fixed << setprecision(15);

    int a,b;cin >> a >> b;
    set<int> s;
    for(int i=1;i<=3;++i) s.insert(i);
    s.erase(a);s.erase(b);
    cout << *(s.begin());
}


Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() int {
	n := scanInt(sc)
	ds := nextIntSlice(sc, n)
	sort.Sort(sort.IntSlice(ds))
	return ds[n/2] - ds[n/2-1]
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

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

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 3308
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int x = stdIn.nextInt();
			int h = stdIn.nextInt();
			if(x == 0 && h == 0)
			{
				break;
			}
			double surfaceArea = x * x;
			surfaceArea += 2 * (Math.sqrt((x / 2.0) * (x / 2.0) + h * h) * x);
			System.out.printf("%.6f\n", surfaceArea);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 10000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
typedef pair<double, double> doup;

int main(void) {
    ll H, W;
    cin >> H >> W;
    char c[100][100];
    bool R[100], C[100];
    ll i, j;
    
    for(i=0; i<H; i++) {
        for(j=0; j<W; j++) {
            cin >> c[i][j];
        }
    }
    
    for(i=0; i<H; i++) {
        R[i]=false;
        for(j=0; j<W; j++) {
            if(c[i][j]=='#')
                R[i]=true;
        }
    }
    for(j=0; j<W; j++) {
        C[j]=false;
        for(i=0; i<H; i++) {
            if(c[i][j]=='#')
                C[j]=true;
        }
    }
    
    for(i=0; i<H; i++) {
        if(R[i]) {
            for(j=0; j<W; j++) {
                if(C[j]) {
                    cout << c[i][j];
                }
            }
            cout << endl;
        }
        
    }
}


Measured memory_bytes: 256
a = {1, 3, 5, 7, 8, 10, 12}
b = {4, 6, 9, 11}
c = {2}
x, y = map(int, input().split())

for i in a, b, c:
    if x in i and y in i:
        print('Yes')
        quit()
print('No')


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(){
  int n,b,f,r,v,b1[4][11],b2[4][11],b3[4][11],b4[4][11],i,j;
  for(i=0;i<4;i++){
    for(j=0;j<11;j++){
      b1[i][j]=b2[i][j]=b3[i][j]=b4[i][j]=0;
    }
  }
  cin >> n;
  for(i=0;i<n;i++){
    cin >> b >> f >> r >> v;
    if(b==1) b1[f][r]+=v;
    else if(b==2) b2[f][r]+=v;
    else if(b==3) b3[f][r]+=v;
    else b4[f][r]+=v;
  }
  for(i=1;i<4;i++){
    for(j=1;j<11;j++){
      cout << ' ' << b1[i][j];
    }
    cout << endl;
  }
  for(i=0;i<20;i++) cout << '#';
  cout << endl;
  for(i=1;i<4;i++){
    for(j=1;j<11;j++){
      cout << ' ' << b2[i][j];
    }
    cout << endl;
  }
  for(i=0;i<20;i++) cout << '#';
  cout << endl;
  for(i=1;i<4;i++){
    for(j=1;j<11;j++){
      cout << ' ' << b3[i][j];
    }
    cout << endl;
  }
  for(i=0;i<20;i++) cout << '#';
  cout << endl;
  for(i=1;i<4;i++){
    for(j=1;j<11;j++){
      cout << ' ' << b4[i][j];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1168
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define inf1 1e18+1
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(a>b)swap(a,b);if(!a)return b;return gcd(b%a,a);}

void solve(){
	map<char,int>mp;
	string s;
	cin>>s;
	rep(i,s.length())mp[s[i]]++;
	int c=0;
	for(auto p:mp){
		if(p.se!=2){cout<<"No";return;}
		else if(p.se)c++;
	}
	if(c==2)cout<<"Yes";
	else cout<<"No";
}
int main()
{
	waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 256
H, W = map(int,input().split())
A = [list(input()) for i in range(H)]

#from queue import Queue #キューを使ったら1ケースだけTLEになった。
from collections import deque

dj = [1, 0, -1, 0]
di = [0, 1, 0, -1]

sum_sharp = sum([A[i].count('#') for i in range(H)])

fin_d_max = 1

for s_i in range(H):
    for s_j in range(W):
        d_max = 0
        q_i = deque()
        q_j = deque()
        D = [[-1]*W for i in range(H)]
        flag = 1

        if A[s_i][s_j] == '.':
            D[s_i][s_j] = 0
            q_i.append(s_i)
            q_j.append(s_j)
            while len(q_i)!=0:
                i = q_i.popleft()
                j = q_j.popleft()
                for x in range(4):
                    ni = i+di[x]
                    nj = j+dj[x]
                    if ni<0 or ni>=H or nj<0 or nj>=W or A[ni][nj]== '#' or D[ni][nj]!=-1:
                        continue
                    else:
                        D[ni][nj] = D[i][j]+1
                        d_max = max(d_max, D[ni][nj])
                        q_i.append(ni)
                        q_j.append(nj)
        fin_d_max = max(fin_d_max, d_max)
                
print(fin_d_max)

Measured memory_bytes: 3316
a,b,c=map(int,input().split())
visited={}
for i in range(b):
    visited[i]=-1#あまりiがでたら0に変換

sum=0
while True:
    sum+=a
    rest=sum%b
    if visited[rest]==0:
        print("NO")
        exit()
    visited[rest]=0
    if rest==c:
        print("YES")
        exit()


Measured memory_bytes: 61848
// abc146_b
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define FOR(i, a) for (auto i : a)
#define pb push_back
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)
#define show1d(v)                                                              \
  rep(i, v.size()) cout << " " << v[i];                                        \
  cout << endl << endl;
#define show2d(v)                                                              \
  rep(i, v.size()) {                                                           \
    rep(j, v[i].size()) cout << " " << v[i][j];                                \
    cout << endl;                                                              \
  }                                                                            \
  cout << endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def, Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def, pii> pip;
typedef vector<pip> vip;
template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int main(int argc, char *argv[]) {
  int n;
  string s;
  cin >> n >> s;
  int s_size = s.size();
  rep(i, s_size) { cout << (char)('A' + ((s[i] - 'A' + n) % 26)); }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 2e9;

int main()
{
    string ans = "Good";
    string s;
    cin >> s;
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == s[i + 1])
        {
            ans = "Bad";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
/**方針
//層の数が、Stringの桁数を溢れるかいなかの判断が必要。
//レベルN+1のバーガーには、レベルNのバーガーが2つ含まれるので、
//ざっくりレベルNのバーガーは、2^Nの文字数になる。（レベル０のバーガーが１文字なので）
//N<50なので、文字数の最大は2^50≒10^15。
//Stringは大体1億文字（10^8程度）までしか使えないので、単純にバーガーを文字で作ることはできない。
//
//そこで、バーガーの対称性や、再帰性に注目して、以下の作業を繰り返す。
//（ア）XがレベルNバーガーの中心層より、下のとき、
//レベルNバーガーのX番目だが、これはレベルN-1バーガーのX-1番目である。
//（イ）XがレベルNバーガーの中心層より、上のとき、
//レベルNバーガーのX番目は、レベルN-1バーガーの"X-(レベルN-1バーガーの層数)"層目である。
//ただし、このときはレベルN-1バーガーに含まれるパテ数＋１枚のパテを食べていることに注意（足していく）。
//この作業を繰り返していき、「1層目までを食べる。」等の計算できる状態となったときに計算して終了する。それまでに食べたパテ数が答え。
//ただし繰り返しの中で、もしも途中でXがレベルNバーガーの中心層になったら、簡単に計算できるので求めて、終わり。
*/

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		long X = sc.nextLong();
		long ans = 0;
		sc.close();
		
		//レベルNバーガーの中心の層の数が格納された配列。
		long mid[] = new long[N+1];
		mid[0]=1;
		for(int i=1;i<=N;i++) {
			mid[i]=(mid[i-1]*2-1)+2;
		}
		
		int levelcount=N;//バーガーのレベル数(ループの度に小さくなる。)
		while (true) {
			//Xがバーガーの中心に当たる場合
			//1つ低いレベルのバーガーのパテ数＋１枚食べて終わり
			if(X==mid[levelcount]) {
				ans += getPuttyNum(levelcount-1)+1;
				break;
			}
			//Xがバーガーの中心より上にある場合
			else if(X>mid[levelcount]) {
				//Xがバーガーの一番上だった場合は、そのバーガーを食べきって終了
				if(X==mid[levelcount]*2-1) {
					ans += getPuttyNum(levelcount);
					break;
				}else {
				ans += getPuttyNum(levelcount-1)+1;
				X -= mid[levelcount];
				}
			}
			//Xがバーガーの中心より下にある場合
			else{
				//Xがバーガーの一番下だった場合は、終了
				if(X==1) {
					break;
				}else {
				X --;
				}
			}
			levelcount--;
		}		
		System.out.println(ans);
	}
	
	//入力したレベルのバーガーのパテ数を教えてくれる。
	//繰り返し呼び出されるので、これは毎回計算するのではなく、記録すべき。
	//配列に入れればいいが、一旦このまま実行してみて、配列にする場合と比較してみる。
	static long getPuttyNum(int level) {
		long putty_num=0;
		for(int i=0;i<=level;i++) {
			if(i==0) {
				putty_num=1;
			}else {
				putty_num = 2*putty_num+1;
			}
		}
		return putty_num;
	}
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define ll long long int
#define fip(arr, si, en) for (ll i = si; i<en; i++){cin >> arr[i];}
#define fop(arr, si, en) for (ll i = si; i<en; i++){cout << arr[i] << " "; if(i==en-1) cout << endl;}
#define f first
#define s second
#define vi vector<int>
#define vll vector<ll>

using namespace std;

int f(vi &a, vi &b, vi &c, int n) {
	vector<vector<int>> dp(3, vi (n, INT_MIN));
	dp[0][0] = a[0]; dp[1][0] = b[0]; dp[2][0] = c[0];
	for (int i = 1; i < n; ++i)
	{
		dp[0][i] = a[i] + max(dp[1][i-1], dp[2][i-1]);
		dp[1][i] = b[i] + max(dp[0][i-1], dp[2][i-1]);
		dp[2][i] = c[i] + max(dp[0][i-1], dp[1][i-1]);
	}
	return max(dp[0][n-1], max(dp[1][n-1], dp[2][n-1]));
}

int main(){
	std::ios::sync_with_stdio(false);
	int n; cin >> n;
	vi a(n),b(n),c(n);
	for (int i = 0; i < n; ++i)
		{
			cin >> a[i] >> b[i] >> c[i];
		}
	cout << f(a,b,c,n);
}	

Measured memory_bytes: 6180
#include<stdio.h>
#include<stdlib.h>
#define FREE -1
#define NOT_FREE 1
#define TRUE 1
#define FALSE 0

int matrix[8][8];
int col[8],row[8],dpos[15],dneg[15];
void putQueen(int i);
void printBoard();

void initialize()
{
  int i;
  for(i=0;i<8;i++)
    {
      col[i]=FREE;
      row[i]=FREE;
     }
  for(i=0;i<15;i++)
    {
      dpos[i]=FREE;
      dneg[i]=FREE;
    }
 }
void printBoard()
{
  int i,j;
  for(i=0;i<8;i++)
    {
      for(j=0;j<8;j++)
        {
          if(matrix[i][j])
            {
              if(row[i]!=j)
                return;
            }
        }
    }
  for(i=0;i<8;i++)
    {
      for(j=0;j<8;j++)
        {
          if(row[i]==j)
            {
            printf("Q");
            }
            else printf(".");
        }
      printf("\n");
    }
}


   
void putQueen(int i)
{
  int j;
  if(i==8)
    {
    printBoard();
  return;
    }
  for(j=0;j<8;j++)
    {
      if(col[j]==NOT_FREE || dpos[i+j]==NOT_FREE || dneg[i-j+7]==NOT_FREE)
        continue;
      row[i]=j;
      col[j]=dpos[i+j]=dneg[i-j+7]=NOT_FREE;
      putQueen(i+1);
      row[i]=col[j]=dpos[i+j]=dneg[i-j+7]=FREE;
    }
}
              
int main()
{
  int i,j,n,r,c;
  initialize();
  for(i=0;i<8;i++)
    for(j=0;j<8;j++)
      matrix[i][j]=FALSE;
   scanf("%d",&n);
   for(i=0;i<n;i++)
    {
      scanf("%d%d",&r,&c);
      matrix[r][c]=TRUE;
    }
  putQueen(0);
  return 0;
}



Measured memory_bytes: 2108
N = int(input())
H = list(map(int, input().split()))

count = 0
ans = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
        count += 1
    else:
        if ans < count:
            ans = count
        count = 0
        
if ans < count:
    ans = count

print(ans)

Measured memory_bytes: 14224
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        FFrogJump solver = new FFrogJump();
        solver.solve(1, in, out);
        out.close();
    }

    static class FFrogJump {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long[] arr = new long[n];
            for (int i = 0; i < n; i++)
                arr[i] = in.nextLong();
            //long res = solveSimple(n, arr);
            long res = solveMe(n, arr);
            out.println(res);
        }

        private long solveMe(int n, long[] arr) {
            HashSet<Integer> used = new HashSet<>();
            long res = 0;
            //n-1 = a+(k-1)c
            for (int c = 1; c < n; c++) {
                used = new HashSet<>();
                long score = 0;
                res = Math.max(res, score);
                for (int k = 1; (k + 1) * c < n; k++) {
                    if (k * c == n - 1 - k * c)
                        break;
                    if (used.contains(k * c) || used.contains(n - 1 - k * c))
                        break;
                    score += arr[k * c] + arr[n - 1 - k * c];
                    used.add(k * c);
                    used.add(n - 1 - k * c);
                    res = Math.max(score, res);
                }
            }
            return res;
        }

    }
}



Measured memory_bytes: 101936
s = input()
#import sys
#s = '1222'
n = len(s)
for i in range(2**(n-1)):
  #print(i)
  f = ''
  b = format(i, 'b').zfill(n-1) + '0'
  #print(b)
  for j in range(n):
    f += s[j]
    if b[j] == '0':
      f += '-'
    else:
      f += '+'
  f = f[:len(f)-1]
  #print(f)
  if eval(f) == 7:
    print(f+'=7')
    break


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define rep(i, x) for (ll i = 0; i < (x); i++)

using namespace std;
typedef long long int ll;


int main(void) {
  for (int i = 1; i <= 5; i++) {
    ll x;
    cin >> x;
    if (x != i) {
      cout << i << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3516
fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: i32 = n.trim().parse().unwrap();

    let mut a = String::new();
    std::io::stdin().read_line(&mut a).ok();
    let a: Vec<i32> = a.trim().split(' ').map(|x| x.parse::<i32>().unwrap()).rev().collect();

    let mut b = vec![0; n as usize];
    for i in a {
        b[(i-1) as usize] += 1;
    }

    for i in b {
        println!("{}", i);
    }
}

Measured memory_bytes: 4796
#include <iostream>
#include <complex>
#include <cmath>
using namespace std;
typedef complex<double> C;

#define EPS (1e-8)
#define EQ(a,b) (abs((a)-(b)) < EPS)

double dot(C a, C b) {
	return a.real() * b.real() + a.imag() * b.imag();
}

double xa, ya, xb, yb, xc, yc, xd, yd;

void solve() {
	C a(xa, ya), b(xb, yb), c(xc, yc), d(xd, yd);
	
	if (EQ(dot(a-b, c-d), 0.0)) {
		cout<<"YES";
	} else {
		cout<<"NO";
	}
	cout<<endl;
}

int main(int argc, const char *argv[]) {
	while (cin>>xa>>ya>>xb>>yb>>xc>>yc>>xd>>yd) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define INFTY 10000000000
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
using ipair = pair<ll,ll>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
#define rep(i,n) for (ll i = 0; i < (n); ++i)
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;}

int main(){
    int n;cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    int cnt2=0,cnt4=0,ot;
    rep(i,n){
        if(a[i]%2==0&&a[i]%4!=0)cnt2++;
        else if(a[i]%4==0)cnt4++;
    }
    ot = n-cnt4-cnt2;
    if(ot<=cnt4+1&&cnt2==0&&cnt4>0||ot<=cnt4&&cnt2>0&&cnt4||n>1&&cnt2==n){
        cout<<"Yes";
    }else cout<<"No";
    return 0;
}

Measured memory_bytes: 4036
// In the name of God
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <bitset>
#define sqr(a) (a)*(a)
#define all(a) (a).begin(), (a).end()
using namespace std;
 
template <typename T>
T next_int() {
    T x = 0, p = 1;
    char ch;
    do { ch = getchar(); } while(ch <= ' ');
    if(ch == '-') {
        p = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9') {
        x = x * 10 + (ch - '0');
        ch = getchar();
    }
    return p * x;
}
 
string next_token() {
    char ch;
    string ans = "";
    do { ch = getchar(); } while(ch <= ' ');
    while(ch > ' ') {
        ans += ch;
        ch = getchar();
    }
    return ans;
}
 
const long long INF = (long long)1e18;
const int INFINT = (int)1e9 + 227 + 1;
const int MAXN = (int)1e6 + 227 + 1;    
const int MOD = (int)1e9 + 7;
const long double EPS = 1e-9;
 
long long bin_pow(long long a, long long b) {
    if(!b) return 1;
    long long ans = bin_pow(a, b / 2);
    ans = ans * ans;
    if(b % 2) ans = ans * a;
    return ans;
}

int main() {
    // freopen(".in", "r", stdin);

    int n; cin >> n;

    vector<pair<long long, long long> > a(n);
    for(int i = 0; i < n; i++)
        a[i] = make_pair(next_int<int>(), i);

    sort(all(a));

    vector<long long> ans(n, 0);

    long long kol = 0;
    long long mn = n;
    for(int i = n - 1; i >= 1; i--) {
        mn = min(mn, a[i].second);
        kol++;

        long long dl = a[i].first - a[i - 1].first;
    
        ans[mn] += dl * kol;
    }

    mn = min(mn, a[0].second);
    kol++;

    ans[mn] += a[0].first * kol;

    for(int i = 0; i < n; i++)
        cout << ans[i] << "\n";
}


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

int main() {
    long long n, m, l;
    scanf("%lld%lld%lld", &n, &m, &l);
    long long a[100][100], b[100][100];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            scanf("%lld",&a[i][j]);
        }
        
    }
    
    for (int f = 0; f < m; f++)
    {
        for (int h = 0; h < l; h++)
        {
            scanf("%lld",&b[f][h]);
        }
        
    }

    long long c[100][100];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < l; j++)
        {
            c[i][j]=0;
            for (int k = 0; k < m; k++)
            {
                c[i][j]+=a[i][k]*b[k][j];
            }
            (j==l-1)?printf("%lld",c[i][j]):printf("%lld ",c[i][j]);
        }
        printf("\n");
   }
}



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

typedef struct Card{
    char suit;
    int value;
} CARD;

void print(CARD C[], int N){
    for(int i=0; i<N; i++){
        if(i) cout << " ";
        cout << C[i].suit << C[i].value;
    }
    cout << endl;
}

void isStable(CARD A[], CARD B[], int N){
    for(int i=0; i<N; i++){
        if(A[i].suit != B[i].suit){
            cout << "Not stable" << endl;
            return;
        }
    }
    cout << "Stable" << endl;
}

void BubbleSort(CARD C[], int N){
    for(int i=0; i<N; i++){
        for(int j=N-1; j>i; j--){
            if(C[j].value < C[j-1].value){
                CARD temp = C[j];
                C[j] = C[j-1];
                C[j-1] = temp;
            }
        }
    }
}

void SelectionSort(CARD C[], int N){
    for(int i=0; i<N; i++){
        int minj = i;
        for(int j=i; j<N; j++){
            if(C[j].value < C[minj].value)
                minj = j;
        }
        CARD temp = C[i];
        C[i] = C[minj];
        C[minj] = temp;
    }
}

int main(){
    CARD C1[100], C2[100];
    int N;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> C1[i].suit >> C1[i].value;
        C2[i] = C1[i];
    }
    BubbleSort(C1, N);
    print(C1, N);
    cout << "Stable" << endl;
    
    SelectionSort(C2, N);
    print(C2, N);
    isStable(C1, C2, N);
}



Measured memory_bytes: 3124
#include <stdio.h>
#include <stdlib.h>

int main(){
  int n;
  int *list;
  int flag = 1;
  scanf("%d", &n);
  list =(int *) malloc(sizeof(int)*n);
  for (int i = 0; i < n; i++){
    scanf("%d", &list[i]);
  }
  for (int i = 0; i < n; i++){
    if (list[i]%2 == 0){
      int cnt = 0;
      if (list[i]%3 == 0 || list[i]%5 == 0){
        cnt += 1;
      }
      if (cnt == 0){
        flag = 0;
        break;
      }
    }
  }
  if (flag == 0){
    printf("DENIED\n");
  }else{
    printf("APPROVED\n");
  }
  free(list);
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	static int[] fact = new int[9];


	public static void main(String[] args) {
		fact[1] = 1;
		for(int i = 2; i <= 8; i++)
			fact[i] = fact[i-1] * i;

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] p = new int[n];
		for(int i = 0; i < n; i++)
			p[i] = sc.nextInt();

		int[] q = new int[n];
		for(int i = 0; i < n; i++)
			q[i] = sc.nextInt();

		int ans = Math.abs(getPosi(p) - getPosi(q));
		System.out.println(ans);
        return;
    }

	static private int getPosi(int[] x) {

			int l = x.length;
			int p = 1;

			for(int i = 0; i < l; i++) {
				p += fact[l-i-1] * (x[i]-1);
				for(int j = i+1; j < l; j++) {
					if(x[j] > x[i])
						x[j]--;
				}
			}
		return p;

	}

}



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

public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			String[] arr = str.split(" ");
			
			int a = Integer.parseInt(arr[0]);
			int b = Integer.parseInt(arr[1]);
			int c = Integer.parseInt(arr[2]);
			int temp;
			
			if (a < b);
			else {
				temp = a;
				a = b;
				b = temp;
			}
			
			if (b < c);
			else {
				temp = b;
				b = c;
				c = temp;
			}
			
			if (a < b);
			else {
				temp = a;
				a = b;
				b = temp;
			}
			System.out.println(String.valueOf(a) + " " + String.valueOf(b) + " " + String.valueOf(c));
			
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}

	}
}

Measured memory_bytes: 17008
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define FRE freopen("in.txt", "r", stdin);
#define endl "\n"
#define PI acos(-1.0)
typedef long long LL;
typedef pair<int, int> PII;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10, M = 1010;

int cnt[N];

void solve() {
	int n, l, r;
	cin >> n >> l >> r;
	for(int i = l; i <= r; i++) {
		if(i % n == 0) {
			puts("OK");
			return;
		}
	}
	puts("NG");
	return;
}

int main() {
	//FRE;
	int t;
	solve();
	return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>

int main()
{
	char a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;
	char s[16] = "CODEFESTIVAL2016";
	scanf("%c",&a);
	scanf("%c",&b);
	scanf("%c",&c);
	scanf("%c",&d);
	scanf("%c",&e);
	scanf("%c",&f);
	scanf("%c",&g);
	scanf("%c",&h);
	scanf("%c",&i);
	scanf("%c",&j);
	scanf("%c",&k);
	scanf("%c",&l);
	scanf("%c",&m);
	scanf("%c",&n);
	scanf("%c",&o);
	scanf("%c",&p);

	int ans = 0;
		if(a == s[0]){}
		else	ans++;
		if(b == s[1]){}
				else	ans++;
		if(c == s[2]){}
				else	ans++;
		if(d == s[3]){}
				else	ans++;
		if(e == s[4]){}
				else	ans++;
		if(f == s[5]){}
				else	ans++;
		if(g == s[6]){}
				else	ans++;
		if(h == s[7]){}
				else	ans++;
		if(i == s[8]){}
				else	ans++;
		if(j == s[9]){}
				else	ans++;
		if(k == s[10]){}
				else	ans++;
		if(l == s[11]){}
				else	ans++;
		if(m == s[12]){}
				else	ans++;
		if(n == s[13]){}
				else	ans++;
		if(o == s[14]){}
				else	ans++;
		if(p == s[15]){}
				else	ans++;


	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
N = input()
ans = 0
if N =="SUN":
    ans = 7
if N =="MON":
    ans = 6
if N =="TUE":
    ans = 5
if N =="WED":
    ans = 4
if N =="THU":
    ans = 3
if N =="FRI":
    ans = 2
if N =="SAT":
    ans = 1
print(ans)


Measured memory_bytes: 2940
/*******************************\
   Name:    REAJUL HAQUE REAYZ  |
   School:  COMILLA UNIVERSITY  |
            CSE (5TH BATCH)     |
********************************/
#include<bits/stdc++.h>
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define mem(x,y) memset(x , y , sizeof(x))
using namespace std;
typedef long long ll;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const ll MOD = 1000000007;
const int MAX = 200005;

ll n, a[MAX];
ll check(ll b){
    ll ret=0;
    for(ll i=1; i<=n; i++){
        ret += abs(a[i]-b-i);
    }
    return ret;
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for(ll i=1; i<=n; i++) cin>>a[i];
    ll low=-100000000000, high=100000000000, ans=1e18, loop=100;
    while(loop--){
        ll mid1 = low + (high-low)/3;
        ll mid2 = mid1 + (high-low)/3;
        ll tmp1 = check(mid1);
        ll tmp2 = check(mid2);
        if(tmp1>tmp2) low=mid1;
        else high=mid2;
        ans = min(ans, tmp1);
        ans = min(ans, tmp2);
    }
    ll mid = (low+high)/2;
    for(ll i=mid-5; i<mid+5; i++){
        ans = min(ans, check(i));
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    
    //縦の変数：H と 横の変数：W を宣言する
    int H, W;
    
    //縦の変数：H と 横の変数：W に値を代入する
    cin >> H >> W;
    
    //縦の変数：H と 横の変数：W の値が両方とも 0 になるまで繰り返す。
    while(H != 0 && W != 0){
        
        //一行づつ「 # 」を置いて行くから繰り返し処理を使用する。
        //今回は繰り返し処理の中に繰り返し処理がある！!　➡　考えよう！！！！！
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                
                //ここで「 * 」を出力する。
                cout << "#";
            }
            
            // 1行が終了したら改行が必要なので、改行を出力する。
            cout << endl;
        }
        
        // 1つの四角形が終了したら改行が必要なので、改行を出力する。
        cout << endl;
        
         //縦の変数：H と 横の変数：W に値を代入する
        cin >> H >> W;

    }
    
    return 0;
}



/****************************************　for文　***************************************************


☆繰り返し処理をしたいときは「　for文　」を使用する


    〇書き方
    for(始まりの値； 条件式；　増加 or 減少の式){
        
    }
        
    
*********************************************************************************************************/



/****************************************　コメント無し回答　***************************************************

#include <iostream>
using namespace std;
 
int main() {
 
    int H, W;
 
    cin >> H >> W;
 
    while (H != 0 && W != 0)
    {
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
        cin >> H >> W;
    }
 
    return 0;
} 
    
*********************************************************************************************************/


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{
    ll n;
    cin >> n;
    n *= 100;
    ll x;
    cin >> x;
    n += x * 10;
    cin >> x;
    n += x;
    if(n % 4)
        cout << "NO";
    else
        cout << "YES";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main() {
    int n;
    vector<int> a;

    int m = 0;

    cin >> n;

    for (int i=0; i < n; i++) {
        int aa;
        cin >> aa;
        a.push_back (aa);
    }

    vector<int> c(n);

    for (int i = n; i > 0; i--) {
        c[i-1] = a[i-1];

        int d = n / i;

        for (int j = 2; j <= d; j++) {
            c[i-1] = (c[i-1] + c[j*i-1]) % 2;
        }
        m += c[i-1];
    }

    cout << m << endl;

    for (int i=0; i < n; i++) {
        if (c[i] > 0) cout << i+1 << endl;
    }
}


Measured memory_bytes: 2676
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N = I()
X = LI()

#  N = 200000
#  X = [i*10 for i in range(1,N+1)]

"""
まずは偶数時の中央値のidxを求める
偶数時の中央値より小さいものが抜かれたときは、そのまま、
大きいものが抜かれたときはidx-1が中央値となる
"""
#見つかったメディアンを保存
found = {}
sorted_X = sorted(X)
median = sorted_X[int(len(X)/2)]
for x in X:
    #  print('x', x)
    #  print('found', found)
    if x < median:
        if found.get('small',None):
            print(found['small'])
        else:
            print(median)
            found['small'] = median
    elif x > median:
        if not found.get('big', None):
            tmp = [i for i in sorted_X]
            tmp.remove(x)
            #奇数長になっている
            m = tmp[int(len(tmp)//2)]
            print(m)
            found['big'] = m
        else:
            print(found['big'])
    else:
        if not found.get('equal', None):
            tmp = [i for i in sorted_X]
            tmp.remove(x)
            m = tmp[int(len(tmp)//2)]
            print(m)
            found['equal'] = m
        else:
            print(found['equal'])


Measured memory_bytes: 27620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int n_2[110];
  int x = 1;
  int num = 0;
  rep(i,110){
    if(i<2*x)n_2[i] = x;
    else{
      x*=2;
      n_2[i] = x;
    }
  }
  int N;cin >> N;
  cout << n_2[N] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	int n,a[21];
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	int highest=a[0];
	int ans=0;
	for(int i=0;i<n;i++){
		if(a[i]>=highest)ans++;
		if(a[i]>highest)highest=a[i];
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3596
n, k = gets.split.map(&:to_i)
points = []
n.times { points << gets.split.map(&:to_i) }
areas = []
points.combination([k, 4].min).each do |combination|
  xs = []
  ys = []
  combination.each do |x, y|
    xs << x
    ys << y
  end
  xs.sort!
  ys.sort!
  x_first = xs.first
  x_last = xs.last
  y_first = ys.first
  y_last = ys.last
  inner_points = 0
  points.each_with_index do |(x, y), index|
    inner_points += 1 if (x_first <= x && x <= x_last) && (y_first <= y && y <= y_last)
    break if inner_points >= k || inner_points + (n - index - 1) < k
  end
  areas << (x_last - x_first) * (y_last - y_first) if inner_points >= k
end
puts areas.min


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

int main() {
	ll a, b, k;
	cin >> a >> b >> k;
	ll tk = min(a, k);
	a -= tk;
	k -= tk;
	ll ao = min(b, k);
	b -= ao;
	k -= ao;
	cout << a << ' ' << b << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
struct code{
  char s[10];
  char c;
};
void set(struct code a[]){
  int i,j,n,t;
  char c,s[6];
  for(i=0,c='A';i<26;i++,c++){
    a[i].c=c;
    n=16;
    t=c-'A';
    for(j=0;j<5;j++){
      s[4-j]='0'+(t&1);
      t>>=1;
    }    
    sprintf(a[i].s,"%s",s);
    a[i].s[5]=0;
  }
}
int main(void){
  struct code in[32],out[32]={
    {"101",' '},
    {"000000",'\''},
    {"000011",','},
    {"10010001",'-'},
    {"010001",'.'},
    {"000001",'?'},
    {"100101",'A'},
    {"10011010",'B'},
    {"0101",'C'},
    {"0001",'D'},
    {"110",'E'},
    {"01001",'F'},
    {"10011011",'G'},
    {"010000",'H'},
    {"0111",'I'},
    {"10011000",'J'},
    {"0110",'K'},
    {"00100",'L'},
    {"10011001",'M'},
    {"10011110",'N'},
    {"00101",'O'},
    {"111",'P'},
    {"10011111",'Q'},
    {"1000",'R'},
    {"00110",'S'},
    {"00111",'T'},
    {"10011100",'U'},
    {"10011101",'V'},
    {"000010",'W'},
    {"10010010",'X'},
    {"10010011",'Y'},
    {"10010000",'Z'}
  };
  int i,j,a,cnt;
  char str[256],tmp[2000];
  set(in);
  sprintf(in[26].s,"11010");in[26].c=' ';
  sprintf(in[27].s,"11011");in[27].c='.';
  sprintf(in[28].s,"11100");in[28].c=',';
  sprintf(in[29].s,"11101");in[29].c='-';
  sprintf(in[30].s,"11110");in[30].c='\'';
  sprintf(in[31].s,"11111");in[31].c='?';
  while(fgets(str,256,stdin)!=NULL){
    cnt=0;a=0;
    for(i=0;i<strlen(str);i++){
      for(j=0;j<32;j++){
	if(str[i]==in[j].c){
	  sprintf(tmp+a,"%s",in[j].s);
	  a+=5;
	  break;
	}
      }
    }
    a=0;
    while(1){
      for(i=0;i<32;i++){
	if(tmp+a==strstr(tmp+a,out[i].s)){
	  putchar(out[i].c);
	  a+=strlen(out[i].s);
	  break;
	}
      }
      if(i==32)
	break;
    }
    puts("");
    memset(str,0,sizeof(str));
    memset(tmp,0,sizeof(tmp));
  }
  return 0;
}

Measured memory_bytes: 524
import java.util.Scanner;

//Railway Lines
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String[] s = sc.next().split(",");
			int[] a = new int[11];
			int sum = 0;
			for(int i=0;i<10;i++){
				a[i]=Integer.parseInt(s[i]);
				sum += a[i];
			}
			double v1 = Double.parseDouble(s[10]);
			double v2 = Double.parseDouble(s[11]);
			int d = 0;
			for(int i=0;i<10;i++){
				d += a[i];
				double t = d/v1;
				if(d + t*v2 >= sum){
					System.out.println(i+1);
					break;
				}
			}
		}
	}
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	int n, m;
	cin >> n >> m;
	vector<string> a(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a.begin(), a.end());
	for (string i : a)
		cout << i;



}

Measured memory_bytes: 256