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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int turn = 0;
    while(a > 0 && c > 0){
        if(turn % 2 == 0) c -= b;
        if(turn % 2 == 1) a -= d;
        turn += 1;
    }
    if(a <= 0) cout << "No" << endl;
    if(c <= 0) cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3644
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define endl "\n"
#define all(x) (x).begin(),(x).end()
const int MOD = 1e9+7;
const int mxN = 2e5+3;

void solve(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans = max({a*c, a*d, b*c, b*d});
	cout << ans << endl;
}

int32_t main(){
	IO;
	
	int nT = 1;
	//cin >> nT;
	for(int i = 1; i <= nT; ++i)
		solve();
	return 0;
}


Measured memory_bytes: 3664
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/*
 public class agc021a {

 }

 */
public class Main{
  public void solve() throws FileNotFoundException {
    InputStream inputStream = System.in;

    InputHelper in = new InputHelper(inputStream);

    // actual solution
    long n = in.readLong();

    String ns = String.valueOf(n);

    int sz = ns.length();

    String s = "";

    for (int i = 0; i < sz; i++) {
      s += "9";
    }

    if (Long.valueOf(s) <= n) {
      System.out.println(9 * sz);
      return;
    } else {
      StringBuilder sb = new StringBuilder(s);
      for (int i = 8; i >= 1; i--) {
        sb.replace(0, 1, String.valueOf((char) (i + '0')));
        if (Long.valueOf(sb.toString()) <= n) {
          System.out.println((sz - 1) * 9 + i);
          return;
        }
      }
    }

    System.out.println((sz - 1) * 9);
    // end here
  }

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

  class InputHelper {
    StringTokenizer tokenizer = null;
    private BufferedReader bufferedReader;

    public InputHelper(InputStream inputStream) {
      InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
      bufferedReader = new BufferedReader(inputStreamReader, 16384);
    }

    public String read() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          String line = bufferedReader.readLine();
          if (line == null) {
            return null;
          }
          tokenizer = new StringTokenizer(line);
        } catch (IOException e) {
          e.printStackTrace();
        }
      }

      return tokenizer.nextToken();
    }

    public Integer readInteger() {
      return Integer.parseInt(read());
    }

    public Long readLong() {
      return Long.parseLong(read());
    }
  }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pp=pair<ll,pair<int,int>>;
using Graph=vector<vector<int>>;

int main(){
  int N,M;
  cin>>N>>M;
  Graph G(N);
  for(int i=0;i<M;i++){
    int A,B;
    cin>>A>>B;
    A--;B--;
    G.at(A).push_back(B);
    G.at(B).push_back(A);
  }

  vector<bool> seen(N,false);
  vector<int> ans;
  bool flag=true;
  seen.at(0)=true;
  int v=0;
  ans.push_back(0);
  while(flag){
    flag=false;
    for(auto nv:G.at(v)){
      if(seen.at(nv)){
        continue;
      }
      flag=true;
      seen.at(nv)=true;
      ans.push_back(nv);
      v=nv;
      break;
    }
  }
  flag=true;
  v=0;
  vector<int> ans2;
  while(flag){
    flag=false;
    for(auto nv:G.at(v)){
      if(seen.at(nv)){
        continue;
      }
      flag=true;
      seen.at(nv)=true;
      ans2.push_back(nv);
      v=nv;
      break;
    }
  }

  cout<<ans.size()+ans2.size()<<endl;
  for(int i=ans2.size()-1;i>=0;i--){
    cout<<ans2.at(i)+1<<" ";
  }
  for(int i=0;i<ans.size();i++){
    cout<<ans.at(i)+1<<" ";
  }
  cout<<endl;
}


Measured memory_bytes: 6776
N = int(input())
a = []
b = []
c = []
for i in range(N):
    ai, bi, ci = list(map(int, input().split()))
    a.append(ai)
    b.append(bi)
    c.append(ci)

dp = [[a[0], b[0], c[0]]]

for i in range(1, N):
    dp.append([0, 0, 0])
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i]
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i]
    dp[i][2] = max(dp[i-1][1], dp[i-1][0]) + c[i]
    
print(max(dp[N-1]))


Measured memory_bytes: 34588
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main(){
	ios_base::sync_with_stdio(false);
	ll t, n;
	cin >> t >> n;
	vector<pll> ranges(n);
	for(ll i = 0; i < n; ++i){
		cin >> ranges[i].first >> ranges[i].second;
	}
	vector<ll> sum(n + 1);
	for(ll i = 0; i < n; ++i){
		sum[i + 1] = sum[i] + ranges[i].second - ranges[i].first;
	}
	ll answer = 0;
	for(ll i = 0; i < n; ++i){
		const ll begin = ranges[i].first, end = begin + t;
		const ll j = partition_point(
			ranges.begin(), ranges.end(),
			[end](const pll &p){ return p.first < end; }) - ranges.begin() - 1;
		if(ranges[j].second <= end){
			answer = max(answer, sum[j + 1] - sum[i]);
		}else{
			answer = max(answer, sum[j] - sum[i] + end - ranges[j].first);
		}
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 5208
#include<bits/stdc++.h>
using namespace std;
#define  forloop for(int i=0;i<n;i++)
#define pb push_back 
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define MOD 998244353;
#define unmap unordered_map
#define pi 3.1415926536
#define testcases ll t;cin>>t;while(t--)
#define  mp make_pair
#define  vcp vector<pair<ll,ll>>
#define preci(x,y)  fixed<<setprecision(y)<<x
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define fast ios::sync_with_stdio(false);   cin.tie(0); cout.tie(0);
#define preinc priority_queue <ll, vector<ll>, greater<ll>>
#define predec priority_queue<ll> 
#define vll vector<ll>
#define f(a,b) for(ll i=a;i<=b;i++)
double coins( double a[],int n,vector<vector<double>>&v)
{
    v[0][0]=1.0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(j==0)
                v[i][j]=(1-a[i-1])*v[i-1][j];
            else
                v[i][j]=(a[i-1])*v[i-1][j-1]+(1-a[i-1])*v[i-1][j];
        }
    }
    double ans=0.0;
    for(int i=n/2+1;i<=n;i++)
    {
        ans+=v[n][i];
    }
    return ans;

}
int main() {
    #ifndef ONLINE_JUDGE
   freopen("inp.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
   #endif
   fast
   int n;
   cin>>n;
   double a[n];
   forloop
   cin>>a[i];
   vector<vector<double>>v(n+1,vector<double>(n+1,0.0));
   cout<<preci(coins(a,n,v),10);
    // your code goes here
    return 0;
}

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

int main(){
    int N;
    cin >> N ;
    vector<int> a(4);
    a.at(3) =N/1000;
    a.at(2) =N/100 -a.at(3)*10;
    a.at(1) =N/10 -a.at(3)*100 -a.at(2)*10;
    a.at(0) =N%10;
    
    
    if((a.at(0)!=a.at(1))&&(a.at(0)!=a.at(2))&&(a.at(0)!=a.at(3))&&(a.at(1)==a.at(2))&&(a.at(2)==a.at(3))){
        cout << "Yes" << endl;
    }
    else if((a.at(3)!=a.at(0))&&(a.at(3)!=a.at(1))&&(a.at(3)!=a.at(2))&&(a.at(0)==a.at(1))&&(a.at(0)==a.at(2))){
        cout << "Yes" << endl;
    }
    else if((a.at(0)==a.at(1))&&(a.at(1)==a.at(2))&&(a.at(2)==a.at(3))){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 1e+6+5;
int big = 1e+18+3;
int mod = 1e+9+7;

signed main()
{
    IOS;
        
    string s,t;
    cin>>s>>t;
    if (s.length()>t.length())
        cout<<"No"<<endl;
    else
    {
        for (int i=0; i<s.length(); i++)
        {
            if (s[i]!=t[i])
            {
                cout<<"No"<<endl;
                return 0;
            }
        }

        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final int[] a = new int[N];
		final int[] b = new int[N];
		
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			b[i] = -1;
		}
		
		for (int i = N; i > 0; i--) {
			if (i > N / 2) {
				b[i - 1] = a[i - 1];
				continue;
			}
			
			int rightSum = 0;
			for (int j = i * 2; j <= N; j += i) {
				rightSum += b[j - 1];
			}
			
			int mod = rightSum % 2;
			if (mod == a[i - 1]) {
				b[i - 1] = 0;
			} else {
				b[i - 1] = 1;
			}
		}
		
		int balls = 0;
		for (int i = 0; i < N; i++) {
			balls += b[i];
		}
		
		System.out.println(balls);
		
		for (int i = 0; i < N; i++) {
			if (b[i] == 1) {
				System.out.print(i + 1);
				System.out.print(" ");
			}
		}
	}

}


Measured memory_bytes: 72764
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

typedef pair<LL, int> PLI;

int N;
LL A[4003];
LL x;
int main()
{
	scanf("%d %lld", &N, &x);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &A[i]);
		A[i + N] = A[i];
	}

	LL ans = 1000000000;
	ans *= ans;

	for (int cx = 0; cx < N; cx++) {
		priority_queue<pair<LL, int> > PQ;
		for (int i = 0; i < N; i++) {
			PQ.push(PLI(-A[i], i));
		}

		LL now = 0;
		for (int i = N; i < 2 * N; i++) {
			PQ.push(PLI(-A[i], i));
			PLI z = PQ.top();
			while (PQ.top().second < i - cx)
				PQ.pop();
			now -= PQ.top().first;
		}
		now += cx * x;
		ans = MIN(ans, now);
	}

	printf("%lld\n", ans);

	return 0;
}


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

int main(){
  string str;
  char left[]={'q','a','z','w','s','x','e','d','c','r','f','v','t','g','b'};
  char right[]={'y','h','n','u','j','m','i','k','o','l','p'};
  int flag=2;
  int cnt;

  while(1){
    
    cin >> str;
    if(str == "#") break;
    cnt=0;
    flag=2;
    
    for(int i=0;i < str.size();i++){

      for(int j=0;j < 15;j++){
	if(str[i] == left[j]){
	  if(flag == 1) cnt++;
	  flag=0;
	}
      }
      for(int j=0;j < 11;j++){
	if(str[i] == right[j]){
	  if(flag == 0) cnt++;
	  flag=1;
	}
      }
    }
    cout << cnt << endl;
  }
  return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
int n;
vi arr;
int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 0, z;i <n;i++) {
        cin >> z;
        arr.pb(z);
    }
    sort(arr.begin(), arr.end());
    cout << arr[n/2] - arr[n/2-1] <<"\n";
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);

  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int l;
      cin >> l, l--;
      s[i].push_back(l);
    }
  }
  vector<int> p(m);
  rep(i, m) cin >> p[i];

  ll ans = 0;
  for (int i = 0; i < (1 << n); ++i) {
    bool flg = true;
    for (int j = 0; j < m; ++j) {
      int cn = 0;
      for (auto ss : s[j])
        if (i & (1 << ss)) cn++;
      if (cn % 2 != p[j]) flg = false;
    }
    if (flg) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
int main(){
  int coin[] = {1,5,10,50,100,500};
  int c,sum=0;
  for(int i=0; i<6; i++){
    std::cin >> c;
    sum += c*coin[i];
  }
  if(sum >= 1000)
    std::cout << 1 << std::endl;
  else
    std::cout << 0 << std::endl;
  return 0;
}

Measured memory_bytes: 1160
n = int(input())
h = list(map(int, input().split()))
res = 0
for i in range(max(h)):
    f = False
    for j in range(n):
        if h[j] >= 1:
            h[j] -= 1
            f = True
        elif f and h[j] == 0:
            f = False
            res += 1
    if f:
        res += 1
print(res)


Measured memory_bytes: 3060
import numpy as np
from collections import deque
infinity = 10**5
H,W = map(int,input().split())

A = np.zeros((H+1,W+1))

for i in range(H):
    s = input()
    for j in range(W):
        if s[j] == ".":
            A[i][j] = 1
        else:
            A[i][j] = -1
#print(A)
N = H*W
G=[[] for i in range(N)]

for i in range(H):
    for j in range(W):
        if A[i+1][j] == 1:
            #if W*(i+1)+j ==1:
                #print("a")
            #G[W*(i+1)+j].append(W*i+j)
            G[W*i+j].append(W*(i+1)+j)

        if i>=1:
            if A[i-1][j] == 1:
                #if W*(i-1)+j ==1:
                    #print("b")
                #G[W*(i-1)+j].append(W*i+j)
                G[W*i+j].append(W*(i-1)+j)            
            
        
        if A[i][j+1] == 1:
            #if W* ==1:
                #print("c")
            #G[W*i+(j+1)].append(W*i+j)
            G[W*i+j].append(W*i+(j+1))
        
        if j>=1:
            if A[i][j-1] == 1:
                #if W*(i+1)+j ==1:
                    #print("d")
                #G[W*i+(j-1)].append(W*i+j)
                G[W*i+j].append(W*i+(j-1))

def BFS (s):
    queue = deque()
    d = [infinity]*N
    
    queue.append(s)
    d[s]= 0
    
    while len(queue)!=0:
      u = queue.popleft()
      for v in G[u]:
      	if d[v] == infinity:
        	d[v] = d[u]+1
        	queue.append(v) 	  
  
    return d

ans = 0

#print(G)

for i in range(N):
    #print(i)
    I = i//W
    J = i%W
    #print(I,J)
    if A[I][J] == 1:
        d = BFS(i)
        for k in range(N):
            if d[k] == infinity:
                d[k] = -1
        ans = max(ans,max(d))

print(ans)

    


Measured memory_bytes: 12512
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var a = new int[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = int.Parse(Console.ReadLine());
        }

        var set = new HashSet<int>();
        var x = 1;
        var k = 0;
        while (set.Add(x))
        {
            if (x == 2)
            {
                Console.WriteLine(k);
                return;
            }
            x = a[x - 1];
            k++;
        }
        Console.WriteLine(-1);
    }
}


Measured memory_bytes: 18016
import itertools

n, m, q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(q)]

comb = list(itertools.combinations_with_replacement(range(1, m+1), n))
sum_d = 0
for c in comb:
    tmp = 0
    for a in abcd:
        if(c[a[1]-1] - c[a[0]-1] == a[2]):
            tmp += a[3]
    sum_d = max(tmp, sum_d)

print(sum_d)

Measured memory_bytes: 21624
n = int(input())
s = input()
ans_min = s[1:].count('E')
ans = s[1:].count('E')
for i in range(1, len(s)):
    if(s[i] == 'E'):
        ans -= 1   
    if(s[i-1] == 'W'):
        ans += 1
    ans_min = min(ans_min, ans)
print(ans_min)

Measured memory_bytes: 3700
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

//ループ
#define REP(i, n) for(int i = 0; i < n; i++) //普通のループ
#define REPR(i, n) for(int i = n; i >= 0; i--) //逆ループ
#define FOR(i, m, n) for(int i = m; i < n; i++) //最初の数値を指定したループ

//型名省略
typedef long long ll;

//配列要素数
static const int MAX = 200000;

using namespace std;

//#include "./lib/generic/sort.h"

std::tuple<int, int> swap(int num1, int num2){
     return std::forward_as_tuple(num1, num2);
}

void traceArray(int A[], int N){
    for(int i=0; i<N; i++){
        cout << A[i];
        if(i!=N-1){
            cout  << " ";
        }
    }
    cout << endl;
}

void sortBySelection(int A[], int N){
    int min = 0;
    int count = 0;
    for(int i=0; i<N-1; i++){
        min = i;
        for(int j=i+1; j<N; j++){
            if(A[min]>A[j]){
                min = j;
            }
        }
        if(i!=min){
            std::swap(A[i], A[min]);
            count++;
        }
    }
    traceArray(A, N);
    cout << count << endl;
}

int main(){
    int  N;
    cin >> N;
    int  A[N];
    REP(i, N) cin >> A[i];
    //sort::Sort test;
    //traceArray(A, N);
    //test.sortByIntention(A, N);
    //test.sortByBubble(A, N);
    sortBySelection(A, N);
    //traceArray(A, N);

    return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    printf("%d %d\n",a*b,2*a+2*b,1145141111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111);
    return 0;
     
}


Measured memory_bytes: 2724
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007


int main()
{
	int n;
	cin >> n;
	int a[100001];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a + n);
	reverse(a, a + n);
	if(n % 2 == 0){
		long long int ans = 0;
		for(int i = 0; i < n / 2 - 1; i++){
			ans += 2 * a[i];
		}
		ans += a[n / 2 - 1];
		ans -= a[n / 2];
		for(int i = n / 2 + 1; i < n; i++){
			ans -= 2 * a[i];
		}
		cout << ans << endl;
	} else {
		long long int res1 = 0;
		long long int res2 = 0;
		for(int i = 0; i < n / 2 - 1; i++){
			res1 += 2 * a[i];
			res2 += 2 * a[i];
		}
		res1 += 2 * a[n / 2 - 1];
		res1 -= a[n / 2];
		res1 -= a[n / 2 + 1];
		res2 += a[n / 2 - 1];
		res2 += a[n / 2];
		res2 -= 2 * a[n / 2 + 1];
		for(int i = n / 2 + 2; i < n; i++){
			res1 -= 2 * a[i];
			res2 -= 2 * a[i];
		}
		cout << max(res1, res2) << endl;
	}
}



Measured memory_bytes: 640
#include<iostream>
using namespace std;
  
int main(){
  int W,H,x,y,r;

  cin>>W>>H>>x>>y>>r;

  if(x+r>W){cout<<"No";}
  else if(y+r>H){cout<<"No";}
  else if(x-r<0){cout<<"No";}
  else if(y-r<0){cout<<"No";}
  else{cout<<"Yes";}
  cout<<endl;

  return 0;

}
  



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

#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define x first
#define y second
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal

#define ll long long
#define ld long double

const ld EPS = 10e-9;
const int INF = 1e9 + 5;
const long long INFLL = (ll)INF * (ll)INF;
const ll MOD = 1e9 + 7;
const ld PI = 3.14159265358979323846;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "[";
    for (int i = 0; i < (int)v.size(); ++i) {
        os << v[i];
        if (i != (int)v.size() - 1)
            os << ", ";
    }
    os << "]\n";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const set<T>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}\n";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const unordered_set<T>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it.first << " : "
           << it.second;

        if( it != *v.rbegin())
            os  << ", ";
    }

    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const unordered_map<T, S>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it.first << " : "
           << it.second;

        if( it != *v.rbegin())
            os  << ", ";
    }

    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v)
{
    os << "(";
    os << v.first << ", "
       << v.second << ")";
    os << "\n";
    return os;
}

#define DEBUG

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


// __gcd(x, y)

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

    int K, A, B;
    cin >> K;
    cin >> A >> B;

    int p = 1;


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

        cout << "NG";


    return 0;
}



Measured memory_bytes: 3552
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

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

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

	sort(a.begin(), a.end());

	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		if (x >= a.at(i))
		{
			cnt++;
			x -= a.at(i);
		}
		else
		{
			x -= a.at(i);
			break;
		}

	}

	if (x > 0)
	{
		for (int i = 0; i < n; i++)
		{
			cnt--;
			x -= a.at(i);
			if (x <= 0)
			{
				break;
			}
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pown(ll fi,ll se){
  ll ans=1;
  rep(i,se){
    ans*=fi;
  }
  return ans;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/



int main(){
  ll n;
  cin>>n;
  string a;
  cin>>a;
  ll k;
  cin>>k;
  rep(i,a.size()){
    if(a[i]!=a[k-1]){
      a[i]='*';
    }
  }
  cout<<a<<endl;
  return 0;

}

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

N = int(input())
a = list(map(int, input().split()))
assert len(a) == N

# 解説を参照
# https://img.atcoder.jp/arc101/editorial.pdf

def mergesort(S, f, t, T=None):
    """f <= i < j <= t かつ S[i] <= S[j] である(i,j)の個数.
       実行後, S[f:t]は整列済みになる."""
    if t - f <= 1:
        return 0

    # 作業スペース
    if T == None:
        T = [0] * len(S)

    mid = (f + t) // 2
    n1 = mergesort(S, f, mid, T)
    n2 = mergesort(S, mid, t, T)

    # マージ
    n = n1 + n2
    i = f
    j = mid
    k = f
    while i < mid:
        if j >= t or S[i] <= S[j]:
            T[k] = S[i]
            i += 1
            n += t - j
        else:
            T[k] = S[j]
            j += 1
        k += 1
    for i in range(f, k):
        S[i] = T[i]
    return n

def n_median_larger_than_or_equal_to(x):
    """aの部分列の中央値のうちx以上のものの個数"""

    # aの要素を -1, 1 に置換したリスト
    b = [-1 if e < x else 1 for e in a]

    # bの累積和
    S = [0]
    for e in b:
        S.append(S[-1] + e)

    # 和が0以上であるbの部分列の個数
    # == i < j and S[i] <= S[j] である(i,j)の個数
    return mergesort(S, 0, len(S))

# 条件を満たす x の最大値を2分探索で探す
lo = 1
hi = max(a)

ncomb = N * (N + 1) // 2    # 部分列の個数

while lo < hi:
    mid = (lo + hi + 1) // 2
    nm = n_median_larger_than_or_equal_to(mid)
    if nm >= (ncomb + 1) // 2:
        lo = mid
    else:
        hi = mid - 1

print(lo)


Measured memory_bytes: 134348
N = gets.to_i
as, bs = 2.times.map{gets.split(' ').map(&:to_i)}
kills = 0
bs.each_with_index do |b, i|
  if as[i] >= b
    as[i] -= b
    kills += b
  else
    kills += as[i]
    next_a = as[i + 1] - (b - as[i])
    if next_a <= 0
      kills += as[i + 1]
      as[i], as[i + 1] = 0, 0
    else
      kills += (b - as[i])
      as[i], as[i + 1] = 0, as[i + 1] - (b - as[i])
    end
  end
end
p kills

Measured memory_bytes: 20768
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

using ll = long long int;
using namespace std;

int main(){

  ll K, N, tmp;
  vector<ll> A;

  cin >> K >> N;
  for(ll i = 0; i < N; i++){
    cin >> tmp;
    A.push_back(tmp);
  }

  ll max_dist = 0;
  for(ll i = 0; i < N-1; i++){
    max_dist = max(max_dist, A[i+1] - A[i]);
  }
  max_dist = max(max_dist, A[0] + K-A[N-1]);

  cerr << "Answer:" << endl;
  cout << K - max_dist << endl;

  return 0;
  
}


Measured memory_bytes: 2420
(* Vicfred
 * https://atcoder.jp/contests/abc147/tasks/abc147_b
 * string manipulation
 * *)
open Scanf

let main =
    let s = read_line() in
    Printf.printf "%d\n" @@
    Array.fold_left (+) 0 @@
    Array.init (String.length s/2) @@ fun i ->
        if s.[i] = s.[String.length s - i - 1] then 0 else 1



Measured memory_bytes: 3628
# input
n = int(input())
inp_ls = input().split(" ")
a_ls = [int(e) for e in inp_ls[:n-1]]

# calc
w_ls = [0 for i in range(n)]
for a in a_ls:
	w_ls[a-1] += 1

# result
for w in w_ls:
	print(w)

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

int main() {
    int N;
    int d[110];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> d[i];

    int num[110] = {0};
    for (int i = 0; i < N; ++i) {
        num[d[i]]++;
    }

    int res = 0;
    for (int i = 1; i <= 100; i++) {
        if (num[i]) {
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

int main()
{
    int K, S;
    cin >> K >> S;
    int ans = 0;
    for (int x = 0; x <= K; x++) {
        for (int y = 0; y <= K; y++) {
            int z = S - (x + y);
            if (z >= 0 && z <= K)
                ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
    unsigned long long int a=0,b=0,k=0;
    scanf("%lld %lld %lld",&a,&b,&k);
    if(k >= a){
        if(b + a >= k){
            printf("0 %lld",b+a-k);
        }
        else{
            printf("0 0");
        }
    }
    if(k < a){
        printf("%lld %lld",a-k,b);
    }
    return 0;
}

Measured memory_bytes: 128
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i
aa = a+10-(a%10)
bb = b+10-(b%10)
cc = c+10-(c%10)
dd = d+10-(d%10)
ee = e+10-(e%10)
am = a%10
bm = b%10
cm = c%10
dm = d%10
em = e%10
array = [am,bm,cm,dm,em]
array.delete(0)
if array == []
  puts a+b+c+d+e
else
puts aa+bb+cc+dd+ee-10+array.min-(10*(5-array.count))
end

Measured memory_bytes: 1788
/*
      author  : nishi5451
      created : 14.08.2020 14:47:11
*/

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


int main(){
    string s;
    cin >> s;
    vector<bool> dp(26,false);
    rep(i,int(s.size())){
        dp[s[i]-'a']=true;
    }
    rep(i,26){
        if(dp[i]==false){
            cout << char('a'+i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;

    return 0;
}

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

const int inf = 1e9+7;
int a[1007];
int n;
long long ans;

int main(){
	
	scanf("%d",&n);
	for(int i = 2;i<=n;i++){
		int x = i;
		for(int j = 2;j<=sqrt(n);j++){
			while(x%j==0){
				a[j]++;
				x/=j;
			}
		}
		if(x>1) a[x]++;
	}
	ans = 1;
	for(int i = 2;i<=n;i++){
		if(a[i]){
			ans*=(a[i]+1)%inf;
			ans%=inf;
		}
	}
	printf("%lld",ans);
} 

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n;
  char s[102];
  scanf("%d %s",&n,s);
  if(n%2!=0){
    printf("No");
  	return 0;
  }else{
    for(int i=0;i<n/2;i++){
    	if(s[i]!=s[i+n/2]){
        	printf("No");
            return 0;
        }
    }
  }
  printf("Yes");
  return 0;
}

Measured memory_bytes: 128
#N = int(input())
#A = list(map(int, input().split()))
#a, b = map(int, input().split())
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

n = int(input())
print(num2alpha(n).lower())

Measured memory_bytes: 9168
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(ll i=(x);i<(y);i++)
#define disp(a) cout << a << endl;
typedef long long ll;
using namespace std;

bool comp(const int& a, const int& b) {
	return a > b;
}

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	cout << C << " " << A << " " << B << endl;
}

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

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

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))
#define INF (1<<28)
#define pb(i) push_back(i)
#define fs first
#define sc second

const char dx[]={0,1,0,-1},dy[]={1,0,-1,0};

bool find(ll source, int n){
	return source & (1ll << n);
}

ll add(ll &source, int n){
	source |= (1ll << n);
	return source;
}

ll erase(ll &source, int n){
	source &= ~(1ll<<n);
	return source;
}

typedef pair<long,long> pll;

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> c(n);
	vector< vector<int> > edge(n);
	vector< vector<ll> > memo(n);
	rep(i,n) cin >> c[i];
	rep(i,m){
		int s,t;
		cin >> s >> t;
		edge[--s].push_back(--t);
		edge[t].push_back(s);
	}
	vector<int> v(n,INF);
	stack<pll> st;//(node,set)
	st.push(pll(0,1));

	while(!st.empty()){
		int node = st.top().fs;
		ll path = st.top().sc;
		st.pop();
		ll tmp = path;
		rep(i,edge[node].size()){
			add(tmp,edge[node][i]);
		}
		bool f = false;
//		cout << node << " : " << memo[node].size() << endl;
//		int hoge = 0;rep(i,n)if(find(tmp,i)){cout<<i<<",";hoge+=c[i];}cout <<"->"<<hoge<<endl;
		rep(i,memo[node].size()){
			if((memo[node][i]&tmp)==memo[node][i]){
				f=true;
				break;
			}
		}
		if(node == n-1) memo[node].push_back(tmp);
		if(f || node == n-1)continue;
		memo[node].push_back(tmp);
		rep(i,edge[node].size()){
			st.push(pll(edge[node][i],tmp));
		}
	}
	int ans = INF;
/*
	rep(i,memo.size()){
		cout << i << endl;
		rep(j,memo[i].size()){
			int tmp = 0;
			rep(k,n)if(find(memo[i][j],k)){
				cout << k << ",";
				tmp += c[k];
			}
			cout << "->" << tmp << endl;
		}
	}
*/
	rep(i,memo[n-1].size()){
		int tmp = 0;
		rep(j,n)if(find(memo[n-1][i],j)){
			tmp += c[j];
//			cout << j << ",";
		}
//		cout << tmp << endl;
		ans = min(tmp,ans);
	}
	cout <<ans<< endl;


	return 0;
}

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

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef double ld;

char other(char x)
{
	if (x == 'S') {
		return 'W';
	} else {
		return 'S';
	}
}

int main()
{

	//ifstream cin("input.txt");
	//freopen("output.txt", "w", stdout);

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;

	string s;
	cin >> s;

	char x[2] = {'S', 'W'};

	for (int p = 0; p < 2; ++p) {
		for (int q = 0; q < 2; ++q) {
			vector<char> ans(n, '?');
			ans[0] = x[p];
			ans[1] = x[q];
			bool ok = true;
			for (int i = 0; i < n; ++i) {
				int prev = (i - 1 + n) % n;
				int next = (i + 1) % n;
				if (ans[prev] == '?') {
					if ((ans[i] == 'S' && s[i] == 'o') || (ans[i] == 'W' && s[i] == 'x')) {
						ans[prev] = ans[next];
					} else {
						ans[prev] = other(ans[next]);
					}
				} else if (ans[next] == '?') {
					if ((ans[i] == 'S' && s[i] == 'o') || (ans[i] == 'W' && s[i] == 'x')) {
						ans[next] = ans[prev];
					} else {
						ans[next] = other(ans[prev]);
					}
				} else {
					if ((ans[i] == 'S' && s[i] == 'o') || (ans[i] == 'W' && s[i] == 'x')) {
						if (ans[next] != ans[prev]) {
							ok = false;
						}
					} else if (ans[next] == ans[prev]) {
						ok = false;
					}
				}
			}
			if (ok) {
				for (int i = 0; i < n; ++i) {
					cout << ans[i];
				}
				cout << "\n";
				return 0;
			}
		}
	}

	cout << "-1\n";

}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;
int a[500050];
int main()
{
     int n,k;
     cin>>n;
     for(int i=0;i<n-1;i++)
     {
         cin>>k;
         a[k]++;
     }
     for(int i=1;i<=n;i++)
     {
         cout<<a[i]<<endl;
     }
    return 0;
}


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

int main(void) {
  string  s;
  int t=0;
  cin >>s;

for (int i=0 ; i<s.size() ; i++)  
{ t+= s[i]-'0';}
if (t%9==0) {cout << "Yes" <<endl;
}
else {cout << "No" << endl;}
return 0 ;}


Measured memory_bytes: 3684
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + 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 dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
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; }
// template end

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

    ll n;
    in >> n;

    ll a_init, a_min, a_i;
    in >> a_i;
    a_min = a_i;
    vector<ll> v = {a_i};

    REP(i, n-1){
        in >> a_i;
        if(a_min >= a_i){
            BIN_INSERT(v, a_i);
            a_min = a_i;
        }else{
            ll idx = lower_bound(ALL(v), a_i) - v.begin();
            DEL(v, idx - 1);
            BIN_INSERT(v, a_i);
            a_min = v[0];
        }
    }
    out << v.size() << endl;
}


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

#define ll long long
#define PB push_back
#define PII pair<int, int>
#define MP make_pair
#define all(x) x.begin(), x.end()
#define REP(x, y, z) for(int x = y; x <= z; x++)
#define REPP(x, y, z) for(int x = y; x >= z; x--)
#define F first
#define S second
#define MSET(x, y) memset(x, y, sizeof(x)) 
#define EB emplace_back
#define maxn 200005

//structure

//declaration

//functions

int main(void)
{
	#ifdef DBG
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
	#endif

    int n;
    int arr[maxn];

    // MSET(dp, 0);

    scanf("%d", &n);

    REP(i, 1, n)
    {
        scanf("%d", &arr[i]);
        // ans[i] = i;
    }

    int ans = 0;
    int k = 1;

    REP(i, 1, n)
    {
        if(arr[i] == k)
        {
            k++;
        }   
        else
        {
            ans++;
        }
    }

    if(ans == n)
        printf("-1\n");
    else
        printf("%d\n", ans);

    // REP(i, 1, n)
    // {
    //     REP(j, 1, n)
    //     {
    //         if(arr[i] == ans[j])
    //             dp[i][j] = dp[i-1][j-1]+1;
    //         else
    //         {
    //             dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    //         }
            
    //     }
    // }

    // printf("%d\n", n-dp[n][n]);

	return 0;
}

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

int main()
{
  
   int A , B , tot = 1, count = 0;
   cin>>A>>B;

   while(tot < B)
   {
     tot += A-1;
     count++;

   } 
  
   cout<<count <<'\n';
   
   return 0;
   }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >>n;
  ll b[n-1];
  rep(i,n-1) cin >> b[i];
  ll ans=0;
  ans+=b[0];
  rep1(i,n-1){
    ans +=min(b[i],b[i-1]);
  }
  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define x first
#define y second

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

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

int main(void){
    for(int w, h; cin >> h >> w, h;){
        vs strs(h);
        rep(y, h){
            cin >> strs[y];
        }

        set<string> s;
        string res = "0";
        rep(y, h){
            rep(x, w){
                rep(i, 8){
                    string cur;
                    pii next = mp(x, y);

                    do{
                        cur.pb(strs[next.y][next.x]);
                        if(1 < cur.size() && !s.insert(cur).second)
                        {
                            if((res.size() < cur.size()) || 
                               (res.size() == cur.size() && cur < res)){
                                res = cur;
                            }
                        }

                        next.x = (next.x + dx[i] + w) % w;
                        next.y = (next.y + dy[i] + h) % h;
                        
                    } while(next != mp(x, y));
                }
            }
        }

        cout << res << endl;
    }

	return 0;
}

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

typedef deque<int> DI;

int main(void){
  int n, qn;
  vector<DI> vs;
  
  cin >> n >> qn;
  vs = vector<DI>(n);
  for (int i=0; i<qn; i++){
    int q, t;
    cin >> q >> t;
    if (q==0){
      int x;
      cin >> x;
      vs[t].push_back(x);
    } else if (q==1){
      if (!vs[t].empty()) cout << vs[t].back() << endl;
    } else { // q==2
      if (!vs[t].empty()) vs[t].pop_back();
    }
  }
  
  return 0;
}



Measured memory_bytes: 4360
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<map>
#define ran(x) (x).begin(),(x).end()
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	for(int i = 1;i<101; ++i) {
		int d=a * i;
		if(d % b == c)
			return cout << "YES" << endl, 0;
	}
	cout << "NO" << endl;
}

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

int main(){

    int n;
    cin >> n;
    for (int i = 1; i < 10;++i){
        for (int j = 1; j < 10;++j){
            if(n==i*j){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define fr first
#define sc second
#define MAX ((ll)(1e18+100))
#define MOD ((ll)(1e9+7))
#define HSM ((ll)(307))
#define ARRS ((ll)(1e6+900))
#define pb push_back
#define mid ((l+r)>>1)
#define PI 3.14159265358979323846
#define MXN 500009

ll a[ARRS];
ll dp[ARRS];
ll s[ARRS];

int main(){
	ll n,A,B;
	cin>>n>>A>>B;
	if(A>B)swap(A,B);
	for(int i=1; i<=n; i++)
		cin>>a[i];
	ll l=0;
	a[0]=-MAX;
	dp[0]=1;
	s[0]=1;
	for(int i=1; i<=n; i++){
		ll r=upper_bound(a,a+n+1,a[i]-B)-a-1;
		if(l<=r)
			dp[i]=(4ll*MOD+s[r]-((l!=0)?s[l-1]:0))%MOD;
		if(abs(a[i]-a[i-1])<A){
			l=i-1;
			if(i!=1&&abs(a[i]-a[i-2])<A){
				cout<<0;
				return 0;
			}
		}

		s[i]=(s[i-1]+dp[i])%MOD;
	}
	ll pas=0;
	for(int i=l; i<=n; i++){
		pas+=dp[i];
	}
	cout<<pas%MOD;
}


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

int main(){
    int k,n;
    cin >> n >> k;
    vector <ll> h(n);
    rep(i,n){
        cin >> h[i];
    }
    sort(h.begin(),h.end());
    ll mi=1001001001001;
    rep(i,n-k+1){
        mi=min(mi,h[i+k-1]-h[i]);
    }

    cout << mi << endl;


    return 0;
}

Measured memory_bytes: 4056
<?php
fscanf(STDIN, "%d %d %d", $A, $B, $C);
if ($A == 7 and $B == 5 and $C == 5){
    echo "YES";
}elseif ($A == 5 and $B == 7 and $C == 5){
    echo "YES";
}elseif ($A == 5 and $B == 5 and $C == 7){
    echo "YES";
}else{
    echo "NO";
}

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

int main(void){
    int h,w;
    bool f = true;

    while(1){    
        cin >> h >> w;
        if((h == 0) && (w == 0)) break;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(f) cout << '#';
                else cout << '.';
                f = !f;
            }
            if(!(w % 2)) f = !f;
            cout << endl;
        }
        f = true;
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3116
#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++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

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

Measured memory_bytes: 3720
#include<stdio.h>

int main(){
  int N,A[100000];
  int i,j,key,swt;
  
  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);
  key=A[N-1];
  i=-1;
  
  for(j=0;j<N-1;j++){
    if(key>=A[j]){
      i++;
      swt=A[i];
      A[i]=A[j];
      A[j]=swt;
    }
  }

  
  
  key=A[i+1];
  A[i+1]=A[N-1];
  A[N-1]=key;

  for(j=0;j<N-1;j++){
    if(j==i+1) printf("[%d] ",A[j]);
    else printf("%d ",A[j]);
  }
  printf("%d\n",A[N-1]);
   
  return 0;
}




Measured memory_bytes: 2176
import java.util.Scanner;

class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        double c;
        
        c = a * b / 3.305785;
        
            System.out.printf("%.6f\n",c);
            
        }

        
    }




Measured memory_bytes: 26468
n = int(input())
a = [int(i) for i in input().split()]
# a : %4 == 0 ->前後に奇数があってもOK
# b : %4 == 2 ->前後も偶数ならOK
# c : %2 == 1 ->前後が4の倍数ならOK
# ex) cacacacac...のように「aの個数」は「cの個数-1」以上になる必要
# 「aの個数」=「cの個数-1」のとき「bの個数」は0つ
# それ以外はcacaca...cabbbbbと出来るのでbはいくつでもよい

table = [0 for i in range(3)]  # [%4==0, %4==2, %2==1]
for i in range(n):
    if a[i] % 4 == 0:
        table[0] += 1
    elif a[i] % 4 == 2:
        table[1] += 1
    else:
        table[2] += 1
if table[0] < table[2] - 1:
    print("No")
elif table[0] == table[2] - 1 and table[1] != 0:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 14252