akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

ll gcd(ll a, ll b){
    if(b==0)return a;
    return gcd(b, a%b);
}

int main(){
    ll N;
    string S;
    cin>>N>>S;
    vector<ll> A(N);
    vector<vector<ll>> T(3, vector<ll>(N, 0));
  	ll RR, GG, BB;
  	RR=0;
  	GG=0;
  	BB=0; 
    rep(i, N){
        if(S.at(i)=='R'){
            RR++;
            A[i]=1;
        }
        if(S.at(i)=='G'){
            GG++;
            A[i]=0;
        }
        if(S.at(i)=='B'){
            BB++;
            A[i]=-1;
        }
      	T[0][i]=RR;
      	T[1][i]=GG;
      	T[2][i]=BB;
    }
  	vector<ll> W(3);
  	W[0]=RR;
  	W[1]=GG;
  	W[2]=BB;
    ll Sum=0;
    rep(i, N){
        rep(j, N){
          	if(i>j)continue;
            if(A[i]==A[j])continue;
            Sum+=W[A[i]+A[j]+1]-T[A[i]+A[j]+1][j];
            
            if(2*j-i<=N-1&&A[2*j-i]+A[i]+A[j]==0){
                Sum--;
            }
          	//cout<<Sum<<endl;

        }
    }
    cout<<Sum<<endl;
    return 0;

}



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

int n, ans=0;
long long d;

int main(){
	cin >> n >> d;
	d*=d;
	for (int i=0;i<n;i++){
		long long x, y;
		cin >> x >> y;
		if (x*x+y*y<=d) ans++;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3620
#include <stdio.h>
 
int main(void)
{
    int a,b,c;
     
    scanf("%d %d %d\n",&a,&b,&c);
    if (a<b){
        if(b<c){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    else{
        printf("No\n");
    }
}

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

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

Measured memory_bytes: 3584
#include<stdio.h>
int main()
{
	long long a,b,c=0,d=0,e;
	scanf("%lld %lld",&a,&b);
	c=a*b;
	if(a<b){
		e=a;
		a=b;
		b=e;
	}
	d=a%b;
	while(d!=0){
		a=b;
		b=d;
		d=a%b;
	}
	printf("%lld\n",c/b);
	return 0;
}

Measured memory_bytes: 1688
n, m, X, Y = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

if max(x) < min(y) and X < min(y) and Y > max(x):
    print("No War")
    exit()
else:
    print("War")

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  for (int x = 0; x <= 50000; x++) {
    int result = x * 108;
    int tval = result / 100;
    if (tval == n) {
      printf("%d\n", x);
      return 0;
    }
  }
  printf(":(\n");
  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
 #include <cstdlib>
 #include <iostream>
 #include <fstream>
 #include <sstream>
 #include <set>
 #include <map>
 #include <vector>
 #include <list>
 #include <algorithm>
 #include <cstring>
 #include <cmath>
 #include <string>
 #include <queue>
 #include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
 #include <cassert>
 #include <iomanip>        //do setprecision
 #include <ctime>
 #include <complex>
 using namespace std;

 #define FOR(i,b,e) for(int i=(b);i<(e);++i)
 #define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
 #define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
 #define REP(x, n) for(int x = 0; x < (n); ++x)

 #define ST first
 #define ND second
 #define PB push_back
 #define PF push_front
 #define MP make_pair
 #define LL long long
 #define ULL unsigned LL
 #define LD long double
 #define pii pair<int,int>
 #define pll pair<LL,LL>

 const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
 const int mod=1000000007;

 int main(){
	 int n,m;
	 string str;
	 cin>>n>>m>>str;
	 vector<LL> a(m),b(m),s(n+1,0),v(n+1,1);
	 v[0]=0;
	 vector<vector<LL>> cnt=vector<vector<LL>>(n+1,vector<LL>(2,0));
	 vector<vector<LL>> g=vector<vector<LL>>(n+1,vector<LL>());
	 map<pll,int> mp;
	 FOR(i,0,n){
		 if(str[i]=='A'){
			 s[i+1]=1;
		 }
	 }
	 FOR(i,0,m){
		 cin>>a[i]>>b[i];
		 if(mp[MP(a[i],b[i])]==1)continue;
		 mp[MP(a[i],b[i])]=1;
		 mp[MP(b[i],a[i])]=1;
		 g[a[i]].PB(b[i]);
		 g[b[i]].PB(a[i]);
		 cnt[a[i]][s[b[i]]]++;
		 cnt[b[i]][s[a[i]]]++;

		 if(a[i]==b[i])cnt[b[i]][s[b[i]]]+=1000000;
	 }

	 FOR(t,0,2){
		 FORQ(i,1,n){
			 if(v[i]==0||(cnt[i][0]>0&&cnt[i][1]>0))continue;
			 queue<int> bad;
			 bad.push(i);
			 v[i]=0;
			 while(bad.size()){
				 int ii=bad.front();
				 bad.pop();
				 //cerr<<"bad:"<<ii<<endl;
				 int l=g[ii].size();
				 FOR(j,0,l){
					 int nw=g[ii][j];
					 cnt[nw][s[ii]]--;
					 if(v[nw]==1&&cnt[nw][s[ii]]<=0){
						 v[nw]=0;
						 bad.push(nw);
					 }
				 }
			 }
		 }
	 }
	 FORQ(i,1,n){
		 if(v[i]==1){
			 cout<<"Yes"<<endl;
			 return 0;
		 }
	 }
	 cout<<"No"<<endl;

   return 0;
 }


Measured memory_bytes: 51520
//
// Created by Akifumi Ohata on 2017/09/27.
//
#include<iostream>
#include <vector>

using namespace std;

struct xypoint{
    int _x;
    int _y;
    int _index;
};

int main(){

    int N ,M;

//    1≦N,M≦50
//    −108≦ai,bi,cj,dj≦108
//    入力は全て整数である。

    cin >> N >> M ;

    //cout <<  " "<< endl;

    std::vector<xypoint> students;

    for(int i =1;i <=N;i++){

        int a,b;

        cin >> a >> b;

        xypoint tmp{};
         tmp._x= a;
        tmp._y=b;
        tmp._index=i;

        students.push_back(tmp);

        //cout << a << " "<< b << endl;
    }


    std::vector<xypoint> checkpoints;

    for(int j =1;j <=M ;j++){

        int c,d;

        cin >> c >> d;

        xypoint tmp{};
        tmp._x= c;
        tmp._y=d;
        tmp._index=j;

        checkpoints.push_back(tmp);
       // cout << c << " "<< d << endl;
    }


    std::vector<xypoint> answer;

    for (const xypoint &current_student : students) {


        int min_distance;
        min_distance = static_cast<int>(10e9);
        xypoint min_checkpoint{};

        min_checkpoint._index= 51;
        for(const xypoint &current_checkpoint : checkpoints){

            int tmp_distance = abs(current_student._x - current_checkpoint._x) + abs(current_student._y - current_checkpoint._y);


                if(tmp_distance == min_distance){
                    if (min_checkpoint._index < current_checkpoint._index){


                    } else if(min_checkpoint._index > current_checkpoint._index){

                        min_checkpoint = current_checkpoint;
                    }
                    min_distance=tmp_distance;


                }else if(tmp_distance < min_distance){
                    min_checkpoint = current_checkpoint;
                    min_distance=tmp_distance;
                }


        }

        answer.push_back(min_checkpoint);

    }



    if (answer.size()==N){

        for(const xypoint &ans_cp : answer){
            cout << ans_cp._index << endl;

        }

    }



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> seen;
vector<int> p;
vector<vector<int>> G;

void BFS(int a){
  seen.at(a)++;
  for(int x:G.at(a)){
    if(seen.at(x)==0){
      p.at(x)+=p.at(a);
      BFS(x);
    }
  }
}
int main() {
  int N,Q;
  cin>>N>>Q;
  seen.resize(N);
  p.resize(N);
  G.resize(N);
  for(int i=0;i<N-1;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }
  for(int i=0;i<Q;i++){
    int a,b;
    cin>>a>>b;
    a--;
    p.at(a)+=b;
  }
  BFS(0);
  for(int i=0;i<N;i++){
    cout<<p.at(i);
    if(i!=N-1){
      cout<<" ";
    }
    else{
      cout<<endl;
    }
  }
}

Measured memory_bytes: 24320
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
jobs = [inpl() for _ in range(n)]
jobs.sort()
can = []
ind = 0
res = 0
for i in range(1,m+1):
    while ind < n:
        a,b = jobs[ind]
        if a == i:
            heappush(can,-b)
            ind += 1
            continue
        break
    if can != []:
        res -= heappop(can)
print(res)

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

signed main() {
  int n;
  cin >> n;

  map<string, int> mp;
  int maxv = 0;
  rep(i,n) {
    string s;
    cin >> s;
    mp[s]++;
    maxv = max(maxv, mp[s]);
  }

  vector<string> answer;
  for (auto it : mp) {
    if(it.second == maxv) {
      answer.push_back(it.first);
    }
  }
  sort(answer.begin(),answer.end());
  for (auto it : answer) {
    cout << it << '\n';
  }
  return 0;
}



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

class B
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var n = int.Parse(Console.ReadLine());
		var a = read();
		var b = read();
		var c = read();
		Console.WriteLine(b.Sum() + Enumerable.Range(0, n - 1).Where(i => a[i] + 1 == a[i + 1]).Sum(i => c[a[i] - 1]));
	}
}


Measured memory_bytes: 13524
X, Y = list(map(int, input().split()))
M = 10**9 + 7

if (X+Y)%3 != 0:
    ans = 0
else:
    p = (2*Y - X)//3
    q = (2*X - Y)//3
    if p<0 or q<0:
        ans = 0
    else:
        a = b = 1
        pq = min(p,q)
        for i in range(0,pq):
            a *= (p+q-i)
            b *= (pq-i)
            a %= M
            b %= M
        ans = a*pow(b,M-2,M)%M
print(ans)

Measured memory_bytes: 3064
use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [u64; n],
    }
    let mut s = vec![0; n - k + 1];
    s[0] = a[0..k].iter().fold(0, |sum, x| sum + x);
    for i in 1..=n - k {
        s[i] = s[i - 1] - a[i - 1] + a[i - 1 + k];
    }
    for w in s.windows(2) {
        println!("{}", if w[0] < w[1] { "Yes" } else { "No" });
    }
}


Measured memory_bytes: 7184
open Printf open Scanf
open Array

module UnionFind = struct
  let init n = Array.make n (-1)
  let is_root i a = a.(i) < 0
  let rec root_destructive x a =
    if a.(x) < 0 then x
    else (a.(x) <- root_destructive a.(x) a; a.(x))
  let size_destructive i a = let r = root_destructive i a in -a.(r)
  let same_destructive x y a = root_destructive x a = root_destructive y a
  let connect_destructive x y a =
    let p,q = root_destructive x a,root_destructive y a
    in if p = q then () else (
      let p,q = if a.(p) > a.(q) then q,p else p,q
      in
      a.(p) <- a.(p) + a.(q); a.(q) <- p)
end module UF = UnionFind

let () = scanf " %d %d" @@ fun n m ->
  let uf = UF.init n in
  let a = init m (fun _ -> scanf " %d %d %d" @@ fun x y z ->
    UF.connect_destructive (x-1) (y-1) uf;
  ) in
  init n (fun i ->
    if UF.is_root i uf then 1 else 0
  )
  |> fold_left (+) 0
  |> print_int


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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

ll A, B, N;

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

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

  cin >> A >> B >> N;
  ll x = N;
  if (N >= B-1) x = B-1;
  ll ans = A*x/B - A*(x/B);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3588
N = int(input())
F = [int("".join(input().split()), 2) for i in range(N)]
P = [list(map(int, (input().split()))) for i in range(N)]

ans = float('-inf')
for bit in range(1,1024):
    sum_p = 0
    for shop in range(N):
        time = bin(F[shop] & bit).count('1')
        sum_p += P[shop][time]

    ans = max(sum_p, ans)
print(ans)

Measured memory_bytes: 3064
# 20-7-30 再トライ
import sys

def binomial_p(n, k, p):
    k = min(k, n - k)
    if k == 0: return 1
    numer = 1
    denom = 1
    for i in range(k):
        numer = numer * (n - i) % p
        denom = denom * (k - i) % p
    return numer * pow(denom, p - 2, p) % p


X, Y = [int(x) for x in input().split()]
p = 10 ** 9 + 7

if (2 * X - Y) % 3 != 0 or (2 * Y - X) % 3 != 0 or\
    2 * X - Y < 0 or 2 * Y - X < 0:
    print(0)
    sys.exit()

m = (2 * X - Y) // 3
n = (2 * Y - X) // 3
print(binomial_p(m + n, m, p))

Measured memory_bytes: 9220
#include<bits/stdc++.h>
using namespace std;
#define MAXN 300

int N, d[MAXN + 3][MAXN + 3];

int main() {
    cin >> N;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++)
            cin >> d[i][j];
    }

    long long int answer = 0;
    for (int i = 1; i <= N; i++) {
        for (int j = i + 1; j <= N; j++) {
            bool isNeeded = true;
            for (int k = 1; k <= N; k++) {
                if (k == i || k == j)
                    continue;

                if (d[i][j] > d[i][k] + d[k][j]) {
                    cout << -1 << endl;
                    return 0;
                }

                if (d[i][j] == d[i][k] + d[k][j])
                    isNeeded = false;
            }

            if (isNeeded)
                answer += d[i][j];
        }
    }

    cout << answer << endl;
}


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

int main() {
int x,m,n,j=0;
cin>>x;
m=x;
	n=m;

while(m>=1){
	int f=0;
	while(x%2==0){
		f++;
		x/=2;
	}
	
if(f>j){
	n=m;
j=f;
}
	m--;
	x=m;
	
}
cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int x, a, b;
  
  scanf("%d %d %d", &x, &a, &b);
  
  x = x - a;
  while(x >= 0){
    x = x - b;
  }
  
  printf("%d\n", x + b);
  
  return 0;
}

Measured memory_bytes: 128
#include "vector"
#include "set"
#include "map"
#include "unordered_set"
#include "unordered_map"
#include "string"
#include "iostream"
#include "algorithm"
#include "queue"

using namespace std;

#define ll long long
#define INF 2e9
#define MOD 998244353

typedef vector<int> vi;
typedef pair<int, int> pii;


template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    bool first = true;
    for (const auto& x : v) {
        if (!first) {
            os << " ";
        }
        first = false;
        os << x;
    }
    return os;
}

template<typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& elem : v) {
        is >> elem;
    }
    return is;
}


void solve() {
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;

    vi a;
    vi b;

    int last = -c-1;
    for (int i=0; i<n; i++) {
        if (s[i] == 'o' && i-last > c) {
            a.push_back(i);
            last = i;
            if (a.size() == k) {
                break;
            }
        }
    }

    last = n + c + 1;
    for (int i=n-1; i>=0; i--) {
        if (s[i] == 'o' && last-i > c) {
            b.push_back(i);
            last = i;
            if (b.size() == k) {
                break;
            }
        }
    }

    for (int i=0; i<k; i++) {
        if (a[i] == b[k-i-1]) {
            cout << a[i]+1 << ' ';
        }
    }
}

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

    if (0) {
        int tests;
        cin >> tests;
        for (int i=1; i<= tests; i++) {
            //cout << "Case #" << i << ": ";
            solve();
            cout << endl;
        }
    } else {
        solve();
        cout << endl;
    }

    return 0;
}

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

using ll = long long;

int X, Y, Z, K;
vector<ll> A, B, C;

void solve() {
    vector<ll> E(X*Y);
    int e = 0;
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            E[e++] = A[i] + B[j];
        }
    }
    sort(E.begin(), E.end(), greater<ll>());
    int lim = min((int)E.size(), K);
    vector<ll> EC(lim*Z);
    int ec = 0;
    for (int i = 0; i < lim; i++) {
        for (int j = 0; j < Z; j++) {
            EC[ec++] = E[i] + C[j];
        }
    }
    sort(EC.begin(), EC.end(), greater<ll>());
    for (int i = 0; i < K; i++) {
        cout << EC[i] << endl;
    }
}

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    
    cin >> X >> Y >> Z >> K;
    A.resize(X); for (auto& a : A) cin >> a;
    B.resize(Y); for (auto& b : B) cin >> b;
    C.resize(Z); for (auto& c : C) cin >> c;

    solve();
}


Measured memory_bytes: 31616
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int N, H[101010], dp[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> H[i];
    
    rep(i, 0, N) dp[i] = inf;
    dp[0] = 0;

    rep(i, 0, N) {
        chmin(dp[i + 1], dp[i] + abs(H[i] - H[i + 1]));
        chmin(dp[i + 2], dp[i] + abs(H[i] - H[i + 2]));
    }

    cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1024
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

xmax = max(x)
ymin = min(y)
if (xmax<ymin) and (xmax<Y) and (X<ymin):
  print('No War')
else:
  print('War')


Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
k = int(input())
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[k - 1])

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define FOR(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
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(6) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    cin >> n;
    int ans = 0;
    REP(i,n){
        int tmp = i+1;
        int cnt=0;
        while(tmp!=0){
            cnt++;
            tmp/=10;
        }
        if(cnt%2==1){
            ans++;
        }
    }
    print(ans);


    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 256
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    X = int(input())
    res = 1000 * (X // 500)
    X = X % 500
    res += 5 * (X // 5)
    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 64240
import queue


class XY:
    def __init__(self, x, y):
        self.x = x
        self.y = y


def compress(x1, x2, _w):
    xs = []
    for i in range(0, N):
        for d in range(-1, 2):
            tx1 = x1[i] + d
            tx2 = x2[i] + d
            if 0 <= tx1 <= _w:
                xs.append(tx1)
            if 0 <= tx2 <= _w:
                xs.append(tx2)
    xs = list(set(xs))
    xs.sort()

    for i in range(0, N):
        x1[i] = xs.index(x1[i])
        x2[i] = xs.index(x2[i])

    return len(xs) -1


if __name__ == '__main__':
    while True:
        W, H = list(map(int, input().split()))
        if W == 0 and H == 0: break
        N = int(input())
        X1 = []
        X2 = []
        Y1 = []
        Y2 = []
        for i in range(0, N):
            inputs = list(map(int, input().split()))
            X1.append(inputs[0])
            Y1.append(inputs[1])
            X2.append(inputs[2])
            Y2.append(inputs[3])

        W = compress(X1, X2, W)
        H = compress(Y1, Y2, H)
        # print(str(W) + " " + str(H))
        fld = [[False for i in range(6 * N)] for i in range(6 * N)]
        for i in range(0, N):
            for y in range(Y1[i], Y2[i]):
                for x in range(X1[i], X2[i]):
                    fld[y][x] = True
        ans = 0
        dx = [0, 1, 0, -1]
        dy = [-1, 0, 1, 0]

        # for i in range(0, 6):
        #     for j in range(0, 15):
        #         if fld[i][j]:
        #             if j != 14:
        #                 print("???", end="")
        #             else:
        #                 print("???")
        #         else:
        #             if j != 14:
        #                 print("???", end="")
        #             else:
        #                 print("???")

        for y in range(0, H):
            for x in range(0, W):
                if fld[y][x]:
                    continue
                # print("xy" + str(x) + " " + str(y))
                ans += 1

                que = []
                que.append(XY(x, y))

                while len(que) != 0:
                    xy = que.pop()
                    sx = xy.x
                    sy = xy.y
                    for i in range(0, 4):
                        tx = sx + dx[i]
                        ty = sy + dy[i]
                        if tx < 0 or W <= tx or ty < 0 or H <= ty:
                            continue
                        if fld[ty][tx]: continue
                        que.append(XY(tx, ty))
                        # print("txty" + str(tx) + " " + str(ty))
                        fld[ty][tx] = True

        print(ans)

Measured memory_bytes: 114616
package main

import (
	"fmt"
)

var aMap map[int]bool
var memo map[int]int

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	a := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&a[i])
	}
	aMap = make(map[int]bool)
    memo = make(map[int]int)
	for _, num := range a {
		aMap[num] = true
	}
	_, exist1 := aMap[1]
	_, exist2 := aMap[2]
	if exist1 && exist2 {
		memo[1] = 0
		memo[2] = 0
	} else if exist1 && !exist2 {
		memo[1] = 0
		memo[2] = 1
	} else if !exist1 && exist2 {
		memo[1] = 1
		memo[2] = 0
	} else {
		memo[1] = 1
		memo[2] = 2
	}
	if 2 < n {
		fmt.Println(calc(n))
	} else {
		fmt.Println(memo[n])
	}
}

func calc(n int) int {
	if value, exist := memo[n]; exist {
		return value
	}
	if _, exist := aMap[n]; exist {
      	memo[n] = 0
		return 0
	}
  result := calc(n-2) + calc(n-1)
  for 1000000007 <= result {
  	result %= 1000000007
  }
  memo[n] = result
	return result
}


Measured memory_bytes: 18844
import Data.List

splitRec _ [] = []
splitRec n xs = let (h, t) = splitAt n xs in h : splitRec n t

counting = (++[(0, 0)]) . sortBy (flip compare) . map (\es -> (length es, head es)) . group . sort 

calc n [os, es] = if ov /= ev then n - oc - ec else min (n - oc - secondc es) (n - ec - secondc os)
  where
    (oc, ov) = head os
    (ec, ev) = head es
    secondc = fst . head . tail

main = calc <$> readLn <*> (map counting . transpose . splitRec 2 . map (read :: String -> Int) . words <$> getLine) >>= print

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

typedef long long ll;

#define F first 
#define S second 
#define PB push_back
#define MP make_pair 
#define rep(i,a,b) for (ll i=a;i<b;i++)

typedef vector<int> vi;
typedef pair<int,int> pi;


int main()
{

    int n;
    string s,t; 
    cin >>n;
    cin>>s>>t;

    string res;
    rep(i,0,n)
    {
            cout<<s[i];
            cout<<t[i];
    }
    cout<<endl; 
    return 0; 
}



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


int main(){
  int a,b,x;
  cin >> a >>b >>x;
  int ans =x-a;
    if(ans>=0&&b-ans>=0){

      cout <<"YES" << endl;
    }
    else{
      cout <<"NO"<<endl;
    }
  }


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}


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


Measured memory_bytes: 640
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
#define sum(a,b,c,d) (rui[c+1][d+1]-rui[a][d+1]-rui[c+1][b]+rui[a][b])
char mm[50][50];
int rui[50][50];
int dp[50][50][50][50];
int main()
{
	int mx, my;
	scanf("%d%d", &mx, &my);
	for (int i = 0; i < mx; i++)scanf("%s", mm[i]);
	int px, py;
	for (int i = 0; i < mx; i++)
	{
		for (int j = 0; j < my; j++)
		{
			rui[i + 1][j + 1] = rui[i + 1][j] + rui[i][j + 1] - rui[i][j] + (mm[i][j] == '#');
			if (mm[i][j] == 'P')px = i, py = j;
		}
	}
	for (int i = 0; i < mx; i++)for (int j = 0; j < my; j++)for (int k = 0; k < mx; k++)for (int l = 0; l < my; l++)dp[i][j][k][l] = 1000000000;
	for (int i = px; i >= 0; i--)
	{
		for (int j = py; j >= 0; j--)
		{
			for (int k = px; k < mx; k++)
			{
				for (int l = py; l < my; l++)
				{
					dp[i][j][k][l] = min(dp[i][j][k][l], sum(i, j, px, py));
					dp[i][j][k][l] = min(dp[i][j][k][l], sum(i, py, px, l));
					dp[i][j][k][l] = min(dp[i][j][k][l], sum(px, j, k, py));
					dp[i][j][k][l] = min(dp[i][j][k][l], sum(px, py, k, l));
					for (int m = 0; m <= i; m++)for (int n = 0; n <= j; n++)dp[m][n][k][l] = min(dp[m][n][k][l], dp[i][j][k][l] + sum(m, j, i - 1, l) + sum(i, n, k, j - 1));
					for (int m = k; m < mx; m++)for (int n = 0; n <= j; n++)dp[i][n][m][l] = min(dp[i][n][m][l], dp[i][j][k][l] + sum(k + 1, j, m, l) + sum(i, n, k, j - 1));
					for (int m = 0; m <= i; m++)for (int n = l; n < my; n++)dp[m][j][k][n] = min(dp[m][j][k][n], dp[i][j][k][l] + sum(m, j, i - 1, l) + sum(i, l + 1, k, n));
					for (int m = k; m < mx; m++)for (int n = l; n < my; n++)dp[i][j][m][n] = min(dp[i][j][m][n], dp[i][j][k][l] + sum(k + 1, j, m, l) + sum(i, l + 1, k, n));
					//printf("%d %d %d %d    %d\n", i, j, k, l, dp[i][j][k][l]);
				}
			}
		}
	}
	printf("%d\n", dp[0][0][mx - 1][my - 1]);
}

Measured memory_bytes: 20352
#include <stdio.h>

//Compiler version gcc  6.3.0

int main()
{
  int a,b;
  scanf("%d%d",&a,&b);
  int count=0,x=1;
  while(x<b)
  {
    x--;
    x+=a;
    count++;
  }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
using namespace std;

int main(){
  int N,M,x,y;
  int L = 0,R = 1000000;
  cin >> N >> M;
  for(int i = 1;i <= M;i++){
    cin >> x >> y;
    L = max(L,x);
    R = min(R,y);
  }
  int count = R - L + 1;
  //cout << R << L << endl;
  count  = max(count,0);
  cout << count << endl;
}

/*int main(){
  vector<int> ID(100005);
  for(int i = 0;i < 100005;i++){
    ID.at(i) = 0;
  }
  int N,M,x,y;
  cin >> N >> M;
  cin >> x >> y;
  for(int i = x;i <= y;i++){
    ID.at(i) = 1;
  }
  for(int i = 1;i < M;i++){
    cin >> x >> y;
    for(int j = 1;j <= N;j++){
      if(ID.at(j) == 1){
        if(x <= j && j <= y){
          ID.at(j) = 1;
        }else{
          ID.at(j) = 0;
        }
      }
    }
  }
  int count = 0;
  for(int i = 1;i <= N;i++){
    if(ID.at(i) == 1){
      count++;
    }
  }
  cout << count << endl;
}*/


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int main(){
  int n;
  cin >> n;
  
  cout << n*800-n/15*200 << endl;
  
}

Measured memory_bytes: 256
# 月のフォーマットによる場合分け。
s = list(input())
# 前二桁
s1 = int("".join(s[:2]))
# 後二桁
s2 = int("".join(s[2:]))

# 前二桁と後二桁に月の可能性がある。
if 1 <= s1 <= 12 and 1 <= s2 <= 12:
    print('AMBIGUOUS')
elif 1 <= s1 <= 12:
    print('MMYY')
elif 1 <= s2 <= 12:
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 9180
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n,m;
int s[10],c[10],a[10];
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	memset(a,-1,sizeof(a));
	bool f=true;
	rep(i,m){
		cin>>s[i]>>c[i];
		if(a[s[i]-1]==-1)
		a[s[i]-1]=c[i];
		if(a[s[i]-1]!=c[i]){
			f=false;
		}
		if(s[i]==1&&c[i]==0&&n!=1){
			f=false;
		}
	}
	if(!f){
		cout<<-1;
		re 0;
	}
	if(n==1&&a[0]==-1){
		cout<<0;
		re 0;
	}
	rep(i,n){
		if(a[i]!=-1)
		cout<<a[i];
		else{
			if(i==0)
			cout<<1;
			else
			cout<<0;
		}
	}
	re 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

int main() {
  ll a, b, m;
  cin >> a >> b >> m;

  vll as(a), bs(b);
  ll amin = LONG_LONG_MAX;
  ll bmin = LONG_LONG_MAX;
  rep(i, a) {
    cin >> as[i];
    chmin(amin, as[i]);
  }

  rep(i, b) {
    cin >> bs[i];
    chmin(bmin, bs[i]);
  }

  ll ans = amin + bmin;

  rep(i, m) { ll x, y,c;
    cin >> x >> y >> c;
    x--;
    y--;
    chmin(ans, as[x] + bs[y] - c);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;

	vi bs(n+1);
	rep(i,1,n+1) cin >> bs[i];
	rep(i,1,n+1){
		if(bs[i] > i){
			cout << -1 << endl;
			return 0;
		}
	}
	vi ans(n+1, -1);
	rrep(i,1,n+1){
		int t = 0, seen = 0;
		while(seen < bs[i]){
			++t;
			seen += ans[t] == -1;
		}
		ans[t] = bs[i];
	}
	rep(i,1,n+1) cout << ans[i] << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000
struct Card{
	char suit;
	int value;
};

int A[MAX], n;
struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[],int n, int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	int i,j,k;
	for (i = 0; i < n1; i++){
		L[i] = A[left + i];
	}
	for (i = 0; i < n2; i++){
		R[i] = A[mid + i];
	}
	L[n1].value = SENTINEL;
	R[n2].value = SENTINEL;
	i = 0;
	j = 0;
	for (k = left; k < right; k++){
		if (L[i].value <= R[j].value){
			A[k] = L[i];
			i = i + 1;
		}
		else{
			A[k] = R[j];
			j = j + 1;
		}
	}
}

void mergeSort(struct Card A[], int n, int left, int right){
	int mid;
	if (left + 1 < right){
		mid = (left + right) / 2;
		mergeSort(A, n, left, mid);
		mergeSort(A, n, mid, right);
		merge(A, n, left, mid, right);
	}
}

int partition(struct Card A[],int n,int p, int r){
	struct Card tmp,x = A[r];
	int j,i = p - 1;
	for (j = p; j < r; j++){
		if (A[j].value <= x.value){
			i = i + 1;
			tmp = A[i];
			A[i] = A[j];
			A[j] = tmp;
		}
	}
	tmp = A[i+1];
	A[i+1] = A[r];
	A[r] = tmp;
	return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r){
	int q;
	if (p < r){
		q = partition(A, n, p, r);
		quickSort(A, n, p, q - 1);
		quickSort(A, n, q + 1, r);
	}
}

int main(){
	int i, j, v, stable = 0;
	char S[10];
	struct Card A[MAX],B[MAX];
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%s %d", S, &v);
		A[i].suit = B[i].suit = S[0];
		A[i].value = B[i].value = v;
	}
	quickSort(B, n, 0, n - 1);
	mergeSort(A, n, 0, n);
	for (i = 0; i < n; i++){
		if (A[i].suit != B[i].suit){
			stable = 1;
			break;
		}
	}
	if (stable == 0){
		printf("Stable\n");
	}
	else{
		printf("Not stable\n");
	}
	for (i = 0; i < n; i++){
		printf("%c %d\n", B[i].suit, B[i].value);
	}
	return 0;
}

Measured memory_bytes: 4916
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    int N;
    cin>>N;
for(int a=0;a<=N/4;++a){
for(int b=0;b<=N/7;++b){
if(4*a+7*b==N){
cout<<"Yes"<<endl;
goto xyz;
}
}
}
cout<<"No"<<endl;
xyz:;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int w,h,x,y,r;
	scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
	
	if(x-r>=0 && y-r>=0 && x+r<=w && y+r<=h){
		printf("Yes\n");}
	else{printf("No\n");}
	
	return 0;
}

Measured memory_bytes: 584
h, w = gets.chomp.split.map(&:to_i)
s = []
h.times do |i|
  s[i] = gets.chomp.split("").map(&:to_s)
end

h.times do |i|
  w.times do |j|
    if s[i][j] != "."
      # 右側に探索
      if j + 1 < w && s[i][j + 1] != "."
        s[i][j] = "@"
        x = 1
        while (j + x < w) do
          break if s[i][j + x] == "."
          if s[i][j + x] != "."
            s[i][j + x] = "@"
            y = 1
            while (i + y < h) do
              break if s[i + y][j + x] == "."
              s[i + y][j + x] = "@" if s[i + y][j + x] != "."
              y += 1
            end
          end
          x += 1
        end
      end
      # 下側に探索
      if i + 1 < h && s[i + 1][j] != "."
        s[i][j] = "@"
        y = 1
        while (i + y < h) do
          break if s[i + y][j] == "."
          s[i + y][j] = "@" if s[i + y][j] != "."
          y += 1
        end
      end
    end
  end
end

result = "Yes"
s.each do |si|
  result = "No" if si.include?("#")
end

puts result

Measured memory_bytes: 2684
#include<stdio.h>
int main(){
  int s[8][8],t,i,j,l;
  while(1){
    l = t = -1;
    for(i=0;i<8;i++){
      for(j=0;j<8;j++){
	if(scanf("%1d",&s[i][j]) == EOF) return 0;
	if(s[i][j] == 1 && t == -1){
	  t = i;
	  l = j;
	}
      }
    }
    if(s[t][l+1] == 1 && s[t+1][l] == 1 && s[t+1][l+1] == 1){
      puts("A");
    }
    if(s[t+1][l] == 1 && s[t+2][l] == 1 && s[t+3][l] == 1){
      puts("B");
    }
    if(s[t][l+1] == 1 && s[t][l+2] == 1 && s[t][l+3] == 1){
      puts("C");
    }
    if(s[t+1][l-1] == 1 && s[t+1][l] == 1 && s[t+2][l-1] == 1){
      puts("D");
    }
    if(s[t][l+1] == 1 && s[t+1][l+1] == 1 && s[t+1][l+2] == 1){
      puts("E");
    }
    if(s[t+1][l] == 1 && s[t+1][l+1] == 1 && s[t+2][l+1] == 1){
      puts("F");
    }
    if(s[t][l+1] == 1 && s[t+1][l-1] == 1 && s[t+1][l] == 1){
      puts("G");
    }
  }
  return 0;
}
       

Measured memory_bytes: 580
#include <stdio.h>

int main(void)
{
    int m, f, r;

    while (1) {
        scanf("%d %d %d", &m, &f, &r);
        if (m == -1 && f == -1 && r == -1) {
            break;
        }
        if (m == -1 || f == -1) {
            puts("F");
        } else {
            int mf = m + f;
            if (mf >= 80) {
                puts("A");
            } else if (mf >= 65) {
                puts("B");
            } else if (mf >= 50) {
                puts("C");
            } else if (mf >= 30) {
                puts(r >= 50 ? "C" : "D");
            } else {
                puts("F");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 584
/*
17D8101013F 森田　匡博
JOI0652.cpp 2019/10/31
ID:key4 使用言語:C++
*/

#include <iostream>
#include <cmath>

int main()
{
  int A, B;
  long long int C, sum, day;

  std::cin >> A >> B >> C;

  sum = 0, day = 1;
  while(sum < C) {
    sum += A;
    if(day % 7 == 0) {
      sum += B;
    }
    day++;
  }

  std::cout << day - 1 << "\n";
  return 0;
}



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

using namespace std;


void solve() {
    int n; cin >> n;
    vector<vector<int>> g(n);
    vector<int> deg(n, 0);
    for (int i = 1; i < n; i++) {
        int x,y;
        cin >> x >> y;
        x--; y--;
        deg[x]++; deg[y]++;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
    }
    string s; cin >> s;
    vector<bool> blk(n, false);
    queue<int> q;
    for (int i = 0; i < n; i++) {
        if (deg[i]==1 && s[i]=='B') {
            blk[i] = true;
            q.push(i);
        }
    }
    while (!q.empty()) {
        int v = q.front(); q.pop();
        for (int u: g[v]) {
            if (blk[u]) continue;
            deg[u]--;
            if (deg[u]==1 && s[u]=='B') {
                blk[u] = true;
                q.push(u);
            }
        }
    }
    vector<bool> dust(n);
    int sum = 0, root = -1;
    for (int i = 0; i < n; i++) {
        if (blk[i]) continue;
        sum += 2;
        dust[i] = (s[i]=='W') ^ (deg[i]&1);
        sum += dust[i];
        root = i;
    }
    sum -= 2;
    if (root == -1) {
        cout << 0; return;
    }
    if (sum == 1) {
        cout << 1; return;
    }
    vector<int> arm(n);
    int mx = 0;
    function<void(int,int)> dfs = [&](int u, int p){
        int a1=0, a2=0;
        for (int v: g[u]) {
            if (v==p || blk[v]) continue;
            dfs(v, u);
            int a = arm[v];
            if (a > a1) swap(a,a1);
            if (a > a2) swap(a,a2);
        }
        mx = max(mx, a1+a2+dust[u]);
        arm[u] = a1 + dust[u];
    };
    dfs(root, -1);
    int res = sum - 2*mx;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

using namespace std;

int main(){
  int x[100], i = 0;
  char s[100];

  while(1){
    cin >> s;
    if(cin.eof())break;
    if(s[0] == '+'){
      x[i-2] = x[i-2]+x[i-1];
      i--;
    }
    else if(s[0] == '-'){
      x[i-2] = x[i-2]-x[i-1];
      i--;
    }
    else if(s[0] == '*'){
      x[i-2] = x[i-2]*x[i-1];
      i--;
    }
    else {
      x[i] = atoi(s);
      i++;
    }
  }
  cout << x[0] << endl;
  
  

  return 0;
}



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

int a[500];

int main(void){
  int i;
  char str[10];
  
  fgets(str,sizeof(str),stdin);
  
  for(i=0;i<4;i++){
    a[str[i]]++;
  }
  
  for(i=0;i<4;i++){
    if(a[str[i]]!=2){
      printf("No\n");
      return 0;
    }
  }
  
  printf("Yes\n");
  
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int K = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        for (int i = A; i <= B; i++) {
            if (i % K == 0) {
                System.out.println("OK");
                return;
            }
        }

        System.out.println("NG");
    }
}


Measured memory_bytes: 35744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    sort(a.begin(), a.end());
    ll m = a[n-1];
    ll mn = 1e18, r;
    rep(i, 0, n-1){
        ll up = abs(a[i] - (m+1)/2);
        ll bt = abs(a[i] - m/2);
        ll d = min(up, bt);
        if(mn > d){
            mn = d;
            r = a[i];
        }
    }
    cout << m << " " << r << endl;
    return 0;
}

Measured memory_bytes: 4024
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>

using namespace std;

int main() {
	int n;
	cin >> n;

	int ans = 0;

	int a[200011];
	vector<int>b(n + 1);

	//a,bを入力
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	//bを大きい順に並び替え
	/*for (int j = 0; j < n-1; j++) {
		for (int k = j + 1; k < n; k++) {
			if (b[j] < b[k]) {
				int tmp = b[j];
				b[j] = b[k];
				b[k] = tmp;
			}
		}
	}*/

	sort(b.rbegin(), b.rend());

	for (int l = 0; l < n; l++) {
		if (a[l] == b[0]) {
			cout << b[1] << endl;
		}
		else {
			cout << b[0] << endl;
		}
	}


	return 0;
}






Measured memory_bytes: 3200
package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

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

var sc = newScanner()

func main() {
	x, y, a, b, c := scanInt(), scanInt(), scanInt(), scanInt(), scanInt()
	p := scanInts(a)
	q := scanInts(b)
	r := scanInts(c)
	sort.Sort(sort.Reverse(sort.IntSlice(p)))
	sort.Sort(sort.Reverse(sort.IntSlice(q)))
	sort.Sort(sort.Reverse(sort.IntSlice(r)))

	d := make([]int, 0, x+y+c)
	d = append(d, p[:x]...)
	d = append(d, q[:y]...)
	d = append(d, r...)
	sort.Sort(sort.Reverse(sort.IntSlice(d)))

	ans := int64(0)
	for i := 0; i < x+y; i++ {
		ans += int64(d[i])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 10900
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int k=in.nextInt();
		int x=in.nextInt();
		for(int i=x-(k-1);i<=x+(k-1);i++)
		{
			System.out.print(i+" ");
		}
	}
}

Measured memory_bytes: 38556
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int MAXN=1e5+5;
int f[MAXN], ans[MAXN], siz[MAXN];
struct edge{
	int from, to;
}e[MAXN]; 
int find(int x){
	if (f[x]==x) return x;
	return f[x]=find(f[x]);
}
int merge(int x,int y){
	f[x]=y;
}
signed main()
{
	int n, m;
	cin >> n >> m;
	for (int i=1;i<=n;i++) f[i]=i, siz[i]=1;
	int x, y;
	for (int i=1;i<=m;i++){
		cin >> x >> y;
		e[i].from=x, e[i].to=y;
	}
	ans[m]=n*(n-1)/2;
	for (int i=m;i>1;i--){
		int u=e[i].from, v=e[i].to;
		int fu=find(u), fv=find(v);
		if (fu==fv) ans[i-1]=ans[i];
		else{
			ans[i-1]=ans[i]-siz[fu]*siz[fv];
			merge(fu,fv);
			siz[fv]+=siz[fu];
		}
	}
	for (int i=1;i<=m;i++)
		cout << ans[i] << endl;
	return 0;
} 

Measured memory_bytes: 5248
import itertools
n,m  = map(int, input().split())
l = list()
ans = 0

for i in range(n):
  l.append(2)
for i in range(m):
  l.append(1)

for v in itertools.combinations(l, 2):
  if sum(v)%2 == 0:
    ans += 1

print(ans)




Measured memory_bytes: 3060
#include <stdio.h>
 
int main(void)
{
    int m, n, a[100][100], b,i,j;
 
    scanf("%d %d\n", &n, &m);
 
    for (i = 0; i < n; i++)
        for (j = 0; j < m; j++) {
            if (j < m - 1)
                scanf("%d ", &a[i][j]);
            else
                scanf("%d\n", &a[i][j]);
        }
 
    for (j = 0; j < m; j++) {
        scanf("%d", &b);
        for (i = 0; i < n; i++)
            a[i][j] *= b;
    }
 
    for (i = 0; i < n; i++) {
        b = 0;
        for (j = 0; j < m; j++)
            b=a[i][j]+b;
        printf("%d\n", b);
    }
 
    return 0;
}

Measured memory_bytes: 644