akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int N;
int A[110];
int odd1, odd2;
vector<int> ans;

int main(){
	scanf("%*d %d", &N);
	for (int i=1; i<=N; i++){
        scanf("%d", &A[i]);
        if (A[i]&1){
            if (!odd1) odd1 = A[i];
            else if (!odd2) odd2 = A[i];
            else{
                printf("Impossible\n");
                return 0;
            }
            A[i] = 0;
        }
    }
    if (odd1) {
        printf("%d ", odd1);
        ans.push_back(odd1);
    }
	for (int i=1; i<=N; i++) if (A[i]) {
        printf("%d ", A[i]);
        ans.push_back(A[i]);
	}
	if (odd2) {
        printf("%d ", odd2);
        ans.push_back(odd2);
    }
	printf("\n");
	if (N == 1){
        if (ans[0] == 1) printf("1\n1");
        else printf("2\n%d 1", ans[0]-1);
        return 0;
	}
	printf("%d\n", N - ((odd1 == 1) ? 1 : 0));
	ans[0]--, ans[N-1]++;
	for (int i=0; i<N; i++) if (ans[i]) printf("%d ", ans[i]);
	return 0;
}


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

const int MAX_N = 1e5 + 1;
const int INF = 1 << 30;

int A[MAX_N];
int dp[MAX_N];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i];
    for (int i = 0; i < N; ++i) dp[i] = -INF;
    for (int i = 0; i < N; ++i) {
        int l = -1, r = N - 1;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            if (dp[mid] < A[i]) r = mid;
            else l = mid;
        }
        dp[r] = A[i];
    }
    for (int i = N - 1; i >= 0; --i) {
        if (dp[i] == -INF) continue;
        cout << i + 1 << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
int main(){
	int n;
	int m;
	int a[10000];
	long long s=0;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a[i];
		s+=a[i];
	}
	if(n<s){
		cout<<-1<<endl;
	}else{
		cout<<n-s<<endl;
	}
	return 0;
}

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

int main()
{
  int n;
  cin>>n;
  int k;
  set<int> s;
  int t = n;
  while(t--)
  {
    cin>>k;
    s.insert(k);
  }

 	int d = *(--s.end()) - *s.begin();
  cout<<d<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a,b;
cin>>a>>b;
if (a>0 && b>0)
{cout<<"Positive"<<endl;}
else if (a<0 && b>0)
{cout<<"Zero"<<endl;}
else if (a<0 && b<0 && (b-a+1)%2==0)
cout<<"Positive"<<endl;
else if (a<0 && b<0 && (b-a+1)%2==1)
cout<<"Negative"<<endl;
}

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

int main(){
  int N;
  int answer;
  cin>>N;
  int A[N];
  answer=0;
  for(int i=0;i<N;i++){
     cin>>A[i];
  }
  for(int i=0;i<N;i++){
     for(int j=i+1;j<N;j++){
       answer+=A[i]*A[j];
     }
  }
  cout<<answer<<endl;
 return 0;
 }

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<cmath>
#include<iomanip>
#include<string.h>
#include<stdio.h>
#include <algorithm>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int n,k;
	while(cin>>n>>k)
	{
		if(n%k==0)
		cout<<0<<endl;
		else
		cout<<1<<endl;
	} 
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.1415926535897932;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n, m;
ll k;
int x[100000];
int d[100000];
int D[100000];
int to[100000];
int a[100000];
int tmp[100000];
bool saw[100000];

int main() {
    cin >> n;
    rep(i,n) cin >> x[i];
    rep(i,n-1) d[i] = x[i+1]-x[i];
    rep(i,n-1) to[i] = i;
    cin >> m >> k;
    rep(i,m) cin >> a[i];
    rep(i,m) a[i]--;
    rep(j,m) {
        swap(to[a[j]-1], to[a[j]]);
    }
    rep(i,n-1) {
        if (saw[i]) continue;
        int p = i;
        int si = 0;
        saw[p] = true;
        tmp[si++] = p;
        while (!saw[to[p]]) {
            saw[to[p]] = true;
            p = to[p];
            tmp[si++] = p;
        }
        rep(j,si) {
            D[tmp[j]] = d[tmp[(j+k)%si]];
        }
    }

    ll pos = x[0];
    cout << pos << endl;
    rep(i,n-1) {
        pos += D[i];
        cout << pos << endl;
    }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x;
  cin>>x;
  vector<int> a(x);
  int sum=0;
  
  for(int i=0;i<x;i++){
    cin>>a[i];
    sum +=a[i];
  }
  int mini=sum;
  int presum=0;
  
  for(int i=0;i<x;i++){
    cin>>a[i];
    presum += a[i];
    mini = min(mini, abs(presum - (sum - presum))); 
  }
  cout<<mini<<endl;
}


Measured memory_bytes: 256
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


x = LI()
ans = x.index(0) + 1
print(ans)


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

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int[] a = na(n);
		int[] as = a.clone();
		Arrays.sort(as);
		int max = as[n - 1];
		int next = as[n - 2];
		for(int i = 0; i < n; i++) {
			if(a[i] == max) {
				System.out.println(next);
			}else {
				System.out.println(max);
			}
		}
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 52828
#include <stdio.h>

int main(void) {
  int i, j, k, n, temp, minj, flag = 1;
  char a[1000][3];
  char b[1000][3];

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s", a[i]);
  }

  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      b[i][j] = a[i][j];
    }
  }

  for (i = 0; i < n; i++) {
    for (j = n - 1; j > i; j--) {
      if (a[j][1] < a[j-1][1]) {
        temp = a[j][0];
        a[j][0] = a[j-1][0];
        a[j-1][0] = temp;
        temp = a[j][1];
        a[j][1] = a[j-1][1];
        a[j-1][1] = temp;
      }
    }
  }

  for (i = 0; i < n; i++) {
    printf("%s", a[i]);
    if (i < n - 1) {
      printf(" ");
    }
  }
  printf("\nStable\n");

  for (i = 0; i < n; i++) {
    minj = i;
    for (j = i; j < n; j++) {
      if (b[j][1] < b[minj][1]) {
        minj = j;
      }
    }
    temp = b[i][0];
    b[i][0] = b[minj][0];
    b[minj][0] = temp;
    temp = b[i][1];
    b[i][1] = b[minj][1];
    b[minj][1] = temp;
  }

  for (i = 0; i < n; i++) {
    printf("%s", b[i]);
    if (i < n - 1) {
      printf(" ");
    }
  }
  printf("\n");

  for (i = 0; i < n; i++) {
    if (flag == 0) {
      break;
    }
    for (j = 0; j < n; j++) {
      if (b[i][j] != a[i][j]) {
        printf("Not stable\n");
        flag = 0;
        break;
      }
    }
  }

  if (flag == 1) {
    printf("Stable\n");
  }


  return 0;
}



Measured memory_bytes: 2140
{-# OPTIONS_GHC -Wall #-}

import Data.Char

f :: String -> Bool
f s = 'A' == head s

g :: String -> Bool
g s = let n = length s in 1 == (length . filter (=='C') . take (n-3) . drop 2) s

h :: String -> Bool
h s = let n = length s in (n-2) == (length . filter isLower) s

solve :: String -> Bool
solve s = f s && g s && h s

main :: IO ()
main = do
    s <- getLine

    let ans = solve s

    putStrLn $ if ans then "AC" else "WA"


Measured memory_bytes: 380
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	var num = input[0];
  
    array = {
      'SUN': 7,
      'MON': 6,
      'TUE': 5,
      'WED': 4,
      'THU': 3,
      'FRI': 2,
      'SAT': 1,
    }; 	
  
	//出力
	console.log(array[num]);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
#include <list>
#include <set>
using namespace std;

using ll = long long;

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

int main()
{
	ll N;
	cin >> N;
	string S;

	ll i = 1;

	while (true)
	{
		if (abs(N) % (2 * abs(i)) == 0)
		{
			S.push_back('0');
		}
		else
		{
			S.push_back('1');
			N -= i;
		}

		if (N == 0) break;

		i *= -2;
	}

	reverse(S.begin(), S.end());

	cout << S << endl;
	
	return 0;
}

Measured memory_bytes: 3616
N,X=map(int,input().split())
x=list(map(int,input().split()))
ans=0
amari=0
big=0
small=0
for i in range(N):
	x[i] = abs(x[i]-X)
if N==1:
	print(x[0])
else:
	ans=x[0]
	for j in range(1,N,1):
		if x[j]>=ans:
			big=x[j]
			small=ans
		else:
			big=ans
			small=x[j]
		while big%small != 0:
			amari=big%small
			big=small
			small=amari
		ans=small
	print(ans)

Measured memory_bytes: 14224
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  string s,u;
  cin >> s;
  if(s.size()%2) {
    cout << "No" << endl;
    return 0;
  }
  u=s;
  reverse(s.begin(),s.end());
  for(int i=0; i<s.size(); i++) {
    if((s[i]=='p'&&u[i]!='q')||(s[i]!='q'&&u[i]=='p')) {
      cout << "No" << endl;
      return 0;
    }
    if((s[i]=='b'&&u[i]!='d')||(s[i]=='d'&&u[i]!='b')) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 512
n,m=map(int, input().split())
A=[int(i) for i in input().split()]
A.sort()
bc=[]
for i in range(m):
    b,c=map(int, input().split())
    bc.append([b,c])
bc.sort(key = lambda x:x[1], reverse=True)
count=0
for i in bc:
    for j in range(i[0]):
        if A[count]<i[1]:
            A[count]=i[1]
            count+=1
        else:
            break
        if count==n:
            print(sum(A))
            exit()
            break
print(sum(A))


Measured memory_bytes: 25528
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  string s;
  cin >> s;
  int n=s.size();
  if(n==2){
    if(s[0]==s[1]){cout<<1<<" "<<2<<endl; return 0;}
    else{cout << -1 << " " << -1 << endl; return 0;}
  }
  rep(i,n-2){
    if(s[i]==s[i+1]||s[i]==s[i+2]){ cout<<i+1<<" "<<i+3<<endl; return 0;}
  }
  
  cout << -1 << " " << -1 << endl;
  return 0;
}


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

int main() {
	string w;
	cin >> w;
	map<char, int> n;
	for(int i = 0; i < w.size(); i++){
		n[w[i]]++;
	}
	for(int i = 0; i < w.size(); i++){
		if(n[w[i]] % 2 != 0){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
//A.cpp
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main(){
  int A,B;
  string S;
  cin >> A >> B >> S;
  bool Ans = true;
  for(int i = 0; i < A; i++){
    bool flag = false;
    for(int j = 0; j < 10; j++){
      if(S[i]=='0'+j){
        flag = true;
        break;
      }
    }
    if(!flag){
      Ans = false;
      break;
    }
  }

  if(Ans) if(S[A]!='-') Ans = false;

  if(Ans){
    for(int i = A+1; i < A+B+1; i++){
      bool flag = false;
      for(int j = 0; j < 10; j++){
        if(S[i]=='0'+j) flag = true;
      }
      if(!flag){
        Ans = false;
        break;
      }
    }
  }

  if(Ans) printf("Yes\n");
  else printf("No\n");
  return 0;
}


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

#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;

int main(){
  string S;
  cin >> S;
  int sum = 0;
  for(int i =0; i < S.length(); i++){
    if(S[i] == 'x'){
      sum++;
    }
  }
  if(sum >= 8)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  //cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int n,k,i,s,t,j;
cin>>n>>k;
int a[n+2];
a[0]=0;
a[1]=n+1;
for(i=2;i<=n;i++)
{
s=0;
t=0;
s=(i*(i-1))/2;
t=(i-1)*n-((i-2)*(i-1))/2;
//cout<<s<<"  "<<t<<endl;
a[i]=((t-s+1)+(n+1-i))%1000000007;

}
a[n+1]=1;
s=0;
for(i=k;i<=n+1;i++)
{
s=(s+a[i])%1000000007;

}
cout<<s<<endl;


}


Measured memory_bytes: 4412
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class AC>void r(AC &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int x,y,k,sum;
int main(){
	r(x);r(y);r(k);
	int g=max(x,y);
	for(int i=g;i>=1;i--){
		if(x%i==0&&y%i==0)sum++;
		if(sum==k){
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF (1<<28)
inline void cmin(int &a, int b) { if (a > b) a = b; }

int W, H, F, M, O, C[12][12], A[12][12];
int dp[12][12][12][2][64];

int main() {
    for (;;) {
        scanf("%d%d", &W, &H);
        if (W == 0 && H == 0) return 0;
        assert (3 <= W && W <= 10);
        assert (3 <= H && H <= 10);
        scanf("%d%d%d", &F, &M, &O);
        assert (1 <= F && F <= 10000);
        assert (3 <= M && M <= 50);
        rep (i, H) rep (j, W) {
            int c;
            scanf("%d", &c);
            if (c < 0) C[i][j] = -c, A[i][j] = 0;
            if (c >= 0) C[i][j] = 0, A[i][j] = c;
        }
        if (O <= 1) {
            puts("NA");
            continue;
        }
        rep (i, H) rep (j, W) rep (k, W) rep (l, 2) rep (m, M+1) {
            dp[i][j][k][l][m] = INF;
        }
        rep (i, W) dp[0][i][0][0][min(M, O-1+A[0][i])] = C[0][i];
        rep (k, H-1) rep (w, W) rep (i, W-w) rep (si, 2) rep (m, M+1) {
            const int j = i+w;
            if (i > 0) {
                const int d = si ? w+1 : 1;
                if (d < m) cmin(dp[k][i-1][w+1][0][min(M, m-d+A[k][i-1])],
                                dp[k][i][w][si][m] + C[k][i-1]);
            }
            if (j < W-1) {
                const int d = si ? 1 : w+1;
                if (d < m) cmin(dp[k][i][w+1][1][min(M, m-d+A[k][j+1])],
                                dp[k][i][w][si][m] + C[k][j+1]);
            }
            for (int x = i; x <= j; x++) {
                const int d = si ? j-x+1 : x-i+1;
                if (d < m) cmin(dp[k+1][x][0][0][min(M, m-d+A[k+1][x])],
                                dp[k][i][w][si][m] + C[k+1][x]);
            }
        }
        int ans = INF;
        rep (i, W) rep (m, M+1) cmin(ans, dp[H-1][i][0][0][m]);
        if (ans > F) puts("NA");
        else printf("%d\n", ans);
    }
}

Measured memory_bytes: 1640
import sys
from random import randint
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def count_v(last_d, C, S, t, d):
    ret = S[t - 1]
    last_d[t - 1] = d
    for i in range(len(last_d)):
        ret -= C[i] * (d - last_d[i])
    return ret


def count_v_virtual(last_d, C, S, t, d):
    ret = S[t]
    tmp = last_d[t]
    last_d[t] = d
    for i in range(len(last_d)):
        ret -= C[i] * (d - last_d[i])
    last_d[t] = tmp
    return ret


def get_diff_score(T, d, q, C, D, Ss):
    diff = 0
    original_t = T[d - 1]
    last_d_q = 0
    last_d_ori = 0
    for i in range(d):
        if T[i] == q:
            last_d_q = i + 1
        if T[i] == original_t and i < d - 1:
            last_d_ori = i + 1
    # print(d, q, original_t, last_d_q, last_d_ori)
    for i in range(d - 1, D):
        if T[i] == q:
            break
        diff += C[q - 1] * (d - last_d_q)
    # print(diff, C[q - 1])
    T[d - 1] = q
    for i in range(d - 1, D):
        if T[i] == original_t:
            break
        diff -= C[original_t - 1] * (d - last_d_ori)
    # print(C[original_t - 1], diff)
    diff += Ss[d - 1][q - 1] - Ss[d - 1][original_t - 1]
    return diff


def main():
    D = int(input())
    C = inpl()
    Ss = [inpl() for _ in range(D)]
    T = []
    last_d = [-1] * len(C)
    Contest = 26

    for d in range(D):
        tmp_t, tmp_v = -1, -float('inf')
        for i in range(Contest):
            tmp_score = count_v_virtual(last_d, C, Ss[d], i, d)
            if tmp_score > tmp_v:
                tmp_v = tmp_score
                tmp_t = i
        last_d[tmp_t] = d
        T.append(tmp_t + 1)

    Cs = [i + 1 for i, c in enumerate(C)]
    Cs.sort(key=lambda x: C[x - 1])

    for _ in range(30000):
        d, q = randint(1, D), randint(1, Contest)
        ori_q = T[d - 1]
        diff = get_diff_score(T, d, q, C, D, Ss)
        if diff < 0:
            T[d - 1] = ori_q

    for t in T:
        print(t)

    return


if __name__ == '__main__':
    main()


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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int>a(n);
  for(int i=0; i<n; i++)cin >> a[i];
  sort(a.rbegin(), a.rend());
  int s = accumulate(a.begin(), a.end(), 0);
  if(a[m-1]*4*m>=s)cout << "Yes";
  else cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int A;
	scanf("%d", &A);

	int B;
	scanf("%d", &B);

	int count = 0;

	while (1) {
		if ( B == 1 && count == 0)
			break;
		else if ( B >= 1 && count == 0) {
			B = B-A;
			count++;
		} else if ( B >= 1 && count > 0) {
			B = B-A+1;
			count++;
		} else {
			break;
		}
	}

	printf("%d\n", count);

	return 0;
}


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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int x = Integer.parseInt(str[0]);
    int y = Integer.parseInt(str[1]);
    int[] group = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    System.out.println(group[x]==group[y]?"Yes":"No");
  }
}

Measured memory_bytes: 32612
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		
		while(stdIn.hasNext()){
			int a = stdIn.nextInt();
			int b = stdIn.nextInt();
			int c = a;
			int d = b;
			
			if(a<b){
				int tmp = b;
				b = a;
				a = tmp;
			}
			
			while(true){
				if(a%b==0){
					System.out.print(b+" ");
					break;
				}
				int tmp = a%b;
				a = b;
				b = tmp;
			}
			
			func(c,d);
			
		}
	}
	
	static void func(int a,int b){
		int ans = 1;
		int i = 2;
		
		while(a*b!=1){
			int count_a = 0;
			int count_b = 0;
			while(a%i==0){
				count_a++;
				a = a/i;
			}
			while(b%i==0){
				count_b++;
				b = b/i;
			}
			int t = Math.max(count_a, count_b);
			ans = ans*(int)Math.pow(i,Math.max(count_a, count_b));
			i++;
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 18412
#include<iostream>

int table[10][10000], R, C;

int reverse(int S){//S: 縦の裏返すところの集合
	for(int i=0;i<R;i++){
		if(S >> i & 1){
			for(int j=0;j<C;j++){
				table[i][j] = !table[i][j];
			}
		}
	}

	int res = 0;
	for(int i=0;i<C;i++){
		int white = 0, black = 0;
		for(int j=0;j<R;j++){
			white += !table[j][i];
			black += table[j][i];
		}
		res += std::max(white, black);
	}

	for(int i=0;i<R;i++){
		if(S >> i & 1){
			for(int j=0;j<C;j++){
				table[i][j] = !table[i][j];
			}
		}
	}

	return res;
}

int main(){
	while(std::cin >> R >> C, R){
		for(int i=0;i<R;i++){
			for(int j=0;j<C;j++){
				std::cin >> table[i][j];
			}
		}

		int res = 0;
		for(int S=0;S<1<<R;S++){
			res = std::max(res, reverse(S));
		}

		std::cout << res << std::endl;
	}
}

Measured memory_bytes: 1548
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin>>n;
  for(int i=1; i<50000; i++){
    if( i*27/25 == n){
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
bool ans;
ll n, m, x, y, xmax, xmin, ymax, ymin;
const ll INF = 1000000000;
int main(void){
    // Your code here!
    ans = true;
    cin >> n >> m >> x >> y;
    xmin = INF, ymin = INF, xmax = -INF, ymax = -INF;
    for (ll i = 0; i < n; i++){
        ll h;
        cin >> h;
        xmax = max(xmax, h);
        xmin = min(xmin, h);
    }
    for (ll i = 0; i < m; i++){
        ll h;
        cin >> h;
        ymax = max(ymax, h);
        ymin = min(ymin, h);
    }
    if (max(x, xmax) < min(y, ymin)) cout << "No War" << endl;
    else cout << "War" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define INF ( 1 << 30 )

int main(){
  string s;
  while(cin >> s){
    int joi = 0, ioi = 0;
    for(int i = 2 ; i < s.size() ; i++ ){
      if(s.substr(i-2,3) == "JOI") joi++;
      else if(s.substr(i-2,3) == "IOI") ioi++;
    }
    cout << joi << endl << ioi << endl;
  }
}

Measured memory_bytes: 1216
#include <iostream>
using namespace std;
int main(){
	int a,b,c,d; cin>>a>>b>>c>>d;
	int i = (c/b) + (c%b ? 1 : 0);
	int j = (a/d) + (a%d ? 1 : 0);
	cout<<(i<=j ? "Yes\n" : "No\n");
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
 
int arr[100001];
 
int main(){
 
    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
 
    int n, c, k;
    cin >> n >> c >> k;
 
    vector<int> t;
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        t.push_back(a);
    }
 
    sort(t.begin(), t.end());
 
    int cur = 0, lowest = 0, cnt = 0;
 
    for(auto i : t){
        if(lowest == 0)
            lowest = i;
        if(lowest + k >= i && cur < c){
            ++cur;
        } else {
            ++cnt;
            cur = 1;
            lowest = i;
        }
    }
 
    if(cur >= 1)
        ++cnt;
 
    cout << cnt;
 
    return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  string a, b, c;
  cin>>a>>b>>c;
  if(a[a.length()-1]==b[0]&&b[b.length()-1]==c[0]){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

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

int main(){
    string cards, tmp1, tmp2;
    char output[100][1000];
    int count1, count2 = 0, shuffle;

    while(1){
        cin >> cards;
        if(cards == "-") break;
        
        cin >> count1;
        for(int i = 0; i < count1; i++){
            cin >> shuffle;
            tmp1 = cards.substr(0, shuffle);
            tmp2 = cards.substr(shuffle, cards.size());
            cards = tmp2 + tmp1;
            for(int j = 0; cards[j] != '\0'; j++){
                output[count2][j] = cards[j];
            }           
        }
        count2++;
    }
    for(int i = 0; i < count2; i++){
        cout << output[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define NMAX 100005

using namespace std;

vector<int> l[NMAX];
int d[NMAX];
int maxx;

int dfs(int node)
{
    d[node] = 1;
    for(auto i : l[node]){
        if(d[i] == 0){
            d[i] = dfs(i);
        }
        d[node] = max(d[node], d[i] + 1);
    }
    return d[node];
}

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

    for(int i = 0 ; i < m ; i ++){
        cin>>x>>y;
        l[x].push_back(y);
    }

    m = 0;

    for(int i = 1 ; i <= n ; i++){
        if(d[i] == 0){
            d[i] = dfs(i);
        }
    }

    for(int i = 1 ; i <= n ; i++){
        m = max(m, d[i]);
    }

    cout<<m - 1;

    return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll x;
  cin >> x;
  ll ans = x / 11 * 2;
  x %= 11;
  if (x > 6) ans += 2;
  else if (x > 0) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def gcdlist(l):
    a = l[0]
    for i in range(1,len(l)):
        a = gcd(a,l[i])
    return a

N,K = map(int,input().split())
A = list(map(int,input().split()))

g = gcdlist(A)
M = max(A)
if K > M:
    ans = 'IMPOSSIBLE'
elif K%g == 0:
    ans = 'POSSIBLE'
else:
    ans = 'IMPOSSIBLE'

print(ans)


Measured memory_bytes: 14228
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
#define MAX_N 4010
struct BIT{
	ll bit[MAX_N+1];
	void init(){
		memset(bit,0,sizeof(bit));
	}
	void add(int i,ll x){
		i++;
		while(i<=MAX_N){
			bit[i]+=x;
			i+=i&-i;
		}
		return;
	}
	ll sum(int i){
		if(i<0)return 0ll;
		i++;
		ll res=0;
		while(i>0){
			res+=bit[i];
			i-=i&-i;
		}
		return res;
	}
}bit;
int N;
char c[4010];
int  a[4010];
int B[2010],W[2010];
int L[4010];
int dp[2010][2010];
int main(){
	scanf("%d",&N);
	for(int i=0;i<2*N;i++){
		scanf(" %c %d",&c[i],&a[i]);
		if(c[i]=='B')B[a[i]]=i;
		else W[a[i]]=i;
	}
	for(int i=0;i<=N;i++){
		for(int j=0;j<=N;j++){
			if(i+j>0)dp[i][j]=INF;
		}
	}	
	for(int i=0;i<=N;i++){
		bit.init();
		for(int j=i+1;j<=N;j++)bit.add(B[j],1);
		for(int j=1;j<=N;j++)bit.add(W[j],1);
		for(int j=0;j<=N;j++){
			if(j>0)bit.add(W[j],-1);
			chmin(dp[i+1][j],dp[i][j]+(int)bit.sum(B[i+1]-1));
			chmin(dp[i][j+1],dp[i][j]+(int)bit.sum(W[j+1]-1));
			//cout << dp[i][j] << ' ';
		}
		//cout << endl;
	}
	cout << dp[N][N] << endl;
	return 0;
}

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

int main(){
    int a, b, c;
    int ans = 0;
    cin >> a >> b >> c;
    for(int i = a; i < b + 1; i++){
        if(c % i == 0){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define N 3001
using namespace std;
typedef pair<int,int> P;
int W,H,n;
char mp[N+100][N+100];

int compress(int *x1,int w){
  vector <int>xs;
  for(int i=0;i<n;i++)xs.push_back(x1[i]);
  sort(xs.begin(),xs.end());
  xs.erase(unique(xs.begin(),xs.end()),xs.end());

  for(int i=0;i<n;i++)
    x1[i]=find(xs.begin(),xs.end(),x1[i])-xs.begin();
  return xs.size();
}

int dfs(int x,int y,int dir){
  if(x<0||y<0||x>=W||y>=H)return 0;
  int dx[]={0,0,-1,1},dy[]={-1,1,0,0};
  char ch=mp[y][x];
  mp[y][x]=0;

  if(ch=='^')dir=0;
  if(ch=='v')dir=1;
  if(ch=='<')dir=2;
  if(ch=='>')dir=3;
  int res= dfs(x+dx[dir],y+dy[dir],dir)+(ch!=0);
  mp[y][x]=ch;
  return res;
}

int main(){
  cin>>n;
  int x[N],y[N];
  char ch[N];
  for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>ch[i];  
  W=compress(x,1e9);
  H=compress(y,1e9);
  memset(mp,0,sizeof(mp));
  for(int i=0;i<n;i++)mp[y[i]][x[i]]=ch[i];

  int ans=0;
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      if(mp[i][j]!=0)ans=max(ans,dfs(j,i,0));
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 11384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i;
    long long int p,q,r,aa,bb,cc,g1,g2,g3;
    cin>>n;
    int a[n+1],b[n+1],c[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    for(i=n;i>=1;i--)
    {
        if(i==n){p=a[i];q=b[i];r=c[i];}
        else
        {   g1=p;g2=q;g3=r;
            aa=a[i]+g2;
            //if((p+b[i])>aa){aa=p+b[i];}
            //cout<<aa;
            if((a[i]+g3)>aa){aa=a[i]+g3;}
            p=aa;
            //cout<<p;

            bb=b[i]+g1;
            //if((q+b[i])>bb){bb=q+b[i];}
            if((b[i]+g3)>bb){bb=b[i]+g3;}
            q=bb;
            //cout<<q;

            cc=c[i]+g1;
            if((c[i]+g2)>cc){cc=c[i]+g2;}
            //if((r+c[i])>cc){cc=r+c[i];}
            r=cc;

        }
        //if(i==n-1){break;}
        //if(i==n){cout<<p<<q<<r;}
        //if(i==n){cout<<p<<' '<<q<<' '<<r;}
    }
    if(p>q)
    {
        if(p>r){cout<<p;}
        else{cout<<r;}
    }
    else
    {
        if(q>r){cout<<q;}
        else{cout<<r;}
    }
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define qu queue
#define ps(x) push(x)
#define vec vector
#define ft() front()
#define mst(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=(res*x);
        }
        x=(x*x);
        y=y/2;
    }
    return res;
}
 




int main(){
 
 /*#ifndef ONLINE_JUDGE
    
   freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
   #endif*/

ll n,i,x;
sfl(n);
map<ll,ll>mp;
ll ans=0,mx=0;
f(i,0,n){
 sfl(x);
 if(x==1){
mp[1]=1;

 }
 else{
  if(mp[x-1]){
      mp[x]=mp[x-1]+1;
      
  }
 }
 mx=max(mx,mp[x]);

}

  if(mp[1]){
  pf(n-mx);
  }
  else pf(-1LL);



   return 0;
 
    
 }

Measured memory_bytes: 12800
using System;

// 円の面積と演習

public class ITP1_4_B
{
    public static void Main(string[] args)
    {
        //var exStdIn = new System.IO.StreamReader( "input.txt" );
        //System.Console.SetIn( exStdIn );

        double r = double.Parse(Console.ReadLine());

        Console.WriteLine($"{r * r * Math.PI:F5} {2.0 * r * Math.PI:F5}");
    }
}



Measured memory_bytes: 17852
import java.util.Scanner;
public class Main {
public static void main(String[] args) {

Scanner sc = new Scanner(System.in);
while(true){
int n = sc.nextInt();
if(n == 0){ break;}
int[] sum = new int[n];
for(int i = 0; i<n; i++){
  sum[i] = 0;
  sum[i] = sc.nextInt();
}
double heikin = 0;
double a = 0;
for(int i = 0; i<n; i++){
  heikin += sum[i];
}
heikin = heikin/n;
for(int i = 0; i<n; i++){
  a += Math.pow((sum[i]-heikin),2);
}
System.out.println(Math.sqrt(a/n));
}
}
}



Measured memory_bytes: 31128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll x, a, b;
  cin >> x >> a >> b;
  if (max(x - a, a - x) < max(x - b, b - x)) cout << 'A' << endl;
  else cout << 'B' << endl;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            String[] W = new String[N];
            for (int i = 0; i < N; i++) {
                W[i] = in.next();
            }

            HashSet<String> used = new HashSet<>();
            used.add(W[0]);
            for (int i = 1; i < N; i++) {
                if (!used.add(W[i]) || !W[i - 1].substring(W[i - 1].length() - 1, W[i - 1].length()).equals(W[i].substring(0, 1))) {
                    System.out.println("No");
                    return;
                }
            }
            System.out.println("Yes");
        }
    }
}


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

typedef long long ll;

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

    long double N, K;

    cin >> N >> K;

    long double count = 0;

    long double base = 1;

    for(int i = N; i > 0; i--) {
        while(base * i < K) {
            base *= 2;
            count *= 2;
        }
        count += 1;
    }

    cout << fixed << setprecision(30) << count / base / N << endl;
}

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


typedef complex<double> xy_t;

double cross_product(xy_t a,xy_t b){
	return (conj(a)*b).imag();
}
const double eps=1e-11;
double x[4],y[4];
int n;

int main(){
	cin>>n;
	rep(i,0,n){
		rep(j,0,4){
			cin>>x[j]>>y[j];
		}
		xy_t a[2]={xy_t(x[0],y[0])-xy_t(x[1],y[1]),xy_t(x[2],y[2])-xy_t(x[3],y[3])};
		bool p=abs(cross_product(a[0],a[1]))<eps;
		cout<<(p?"YES":"NO")<<endl;
	}
}

Measured memory_bytes: 1228
#include <iostream>

using namespace std;

int main(){
  int N, M, i, j, count[31], ans=0;
  cin >> N >> M;
  int A[N][31], K[N];
  for(i=0; i<N; i++){
    cin >> K[i];
    for(j=0; j<K[i]; j++){
      cin >> A[i][j];
    }
  }
  for(i=0; i<31; i++) count[i]=0;
  for(i=0; i<N; i++){
    for(j=0; j<K[i]; j++){
      count[A[i][j]]++;
    }
  }
  for(i=0; i<31; i++){
    if(count[i] == N) ans++;
  }
  cout << ans <<endl;
  return 0;
}


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

int main() {
    int n;
    long int k;
    int q;
    cin >> n >> k >> q;

    vector<int> v(q);
    for(int i = 0; i < q; i++){
        cin >> v[i];
    }
    vector<long int> player(n, k-q);
    
    for(int i = 0; i < q; i++){
        player[v[i]-1]++;
    }

    for(int i = 0; i < n; i++){
        if(player[i] > 0){
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }

}

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

typedef struct node Node;

struct node{
  int key;
  Node *next;
  Node *prev;
};

Node *data;

Node* ListSearch(int);
void insert(int);
void mk(void);
void ListPrint(void);
void DeleteNode(Node*);
void DeleteKey(int);
void DeleteFirst(void);
void DeleteLast(void);

int main()
{
  int i,key,n;
  int np=0,nd=0,size=0;
  char array[20];
  
  scanf("%d",&n);
  mk();

  for(i=0;i<n;i++){
    scanf("%s%d",array,&key);
    if(array[0]=='i'){
      insert(key);
    }
    else if(array[0]=='d'){
      if(strlen(array)>6){
	if(array[6]=='F') DeleteFirst(); //delete"F"irst
	if(array[6]=='L') DeleteLast(); //delete"L"ast
      }
      else{
	DeleteKey(key);
      }

    }
  }
  
  ListPrint();
      
  return 0;
}

Node* ListSearch(int key)
{
  Node *p;

  p = data->next;
  while(p!=data && p->key!=key)
    p = p->next;
  
  return p;
}

void insert(int key)
{
  Node *p = (Node *)malloc(sizeof(Node));
  
  p->next = data->next;
  p->key = key;
  data->next->prev = p;
  data->next = p;
  p->prev = data; //pをリストに繋げていく
}

void mk()
{
  data = (Node *)malloc(sizeof(Node));
  data->next = data;
  data->prev = data;
}

void ListPrint()
{
  int num=0;
  Node *p;

  p = data->next;
  while(1){
    if(p==data) break;
    if(num>0) printf(" ");
    printf("%d",p->key);
    p = p->next;
    num++;
  }
  printf("\n");
}

void DeleteNode(Node *p)
{
  if(p==data) return;
  p->prev->next = p->next;
  p->next->prev = p->prev; //pに繋いでるものをうつす
  free(p);
}

void DeleteKey(int key)
{
  DeleteNode(ListSearch(key));
}

void DeleteFirst()
{
  DeleteNode(data->next);
}

void DeleteLast()
{
  DeleteNode(data->prev);
}
    



Measured memory_bytes: 33008
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

func main() {
	A := nextInt()
	B := nextInt()
	fmt.Println(A * B)
}

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

func nextFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

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

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 1760
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int N = 0;
    cin >> N;
    double v[N];
    for (int i = 0; i < N; i++)
    {
        cin >> v[i];
    }

    sort(v,v+N);

    for (int i = 0; i < N-1; i++)
    {
        v[0] = (v[0] + v[1])/2;
        v[1] = 10000;
        sort(v,v+N);
    }

    cout << v[0] <<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

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

ll A;
ll B;
ll C;
ll N;

int main(){


    
    cin >> A;
    cin >> B;
    cin >> C;

    cout << C << endl;
    cout << A << endl;
    cout << B << endl;
    

}

Measured memory_bytes: 256
using System;

namespace ITP1_5_C
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var input = Console.ReadLine();
                var values = input.Split(' ');
                int H = int.Parse(values[0]);
                int W = int.Parse(values[1]);
                if (H == 0 && W == 0) 
                {
                    return; 
                }

                for (int i = 1; i <= H; i++)
                {
                    for (int j = 1; j <= W; j++)
                    {
                        if ((i + j) % 2 == 0)
                        {
                            Console.Write("#");
                        }
                        else
                        {
                            Console.Write(".");
                        }
                    }
                    Console.Write("\n");
                }
                    Console.Write("\n");
            }
        }
    }
}

Measured memory_bytes: 5284
n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
ab.sort(key=lambda x:x[1])
cnt = 0
end_time = 0
for a,b in ab:
  if end_time <= a:
    end_time = b
    cnt += 1
print(cnt)

Measured memory_bytes: 29080
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

#define FOR(n) for(int i=0;i<n;i++)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]

int main()
{
	int n;
	cin >> n;
	vector <int> h(n);
	IN(n, h);

	int ans = 0,count = 0;
	for (int i = n - 1; i > 0; i--)
	{
		if (h[i] <= h[i - 1])
		{
			count++;
		}
		else
		{
			if (ans < count)ans = count;
			count = 0;
		}
	}

	if (ans == 0) ans = count;

	cout << ans << endl;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL)
   x=x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right!=NIL)
    x=x->right;
  return x;
}

Node treeSearch(Node u, int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key)u=u->left;
    else u=u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL)
    return treeMinimum(x->right);
  y=x->parent;
  while(y!=NIL&&x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node x;
  Node y;
  if(z->left==NIL||z->right==NIL){
    y=z;
  }
  else{
    y=treeSuccessor(z);
  }
  if(y->left!=NIL){
    x=y->left;
  }
  else{
    x=y->right;
  }
  if(x!=NIL){
    x->parent=y->parent;
  }
  if(y->parent==NIL){
    root=x;
  }
  else{
    if(y==y->parent->left){
      y->parent->left=x;
    }
    else{
      y->parent->right=x;
    }
  }
  if(y!=z){
    z->key=y->key;
}
}

void insert(int k){
  Node x = root;
  Node y = NIL;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else{
    if(z->key < y->key){
      y->left=z;
    }
    else{
      y->right=z;
    }
  }
}

void inorder(Node u){
  if(u==NIL){
    return;
  }
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u==NIL){
    return;
  }
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int i,n,x;
  char com[20];
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='f'){
      scanf("%d",&x);
      Node t = treeSearch(root,x);
      if(t!=NIL)
    printf("yes\n");
      else printf("no\n");
    }
    else if(com[0] ==  'i'){
      scanf("%d",&x);
      insert(x);
    }
    else if(com[0] ==  'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(com[0]=='d'){
      scanf("%d",&x);
      treeDelete(treeSearch(root,x));
    }
  }
  return 0;
}



Measured memory_bytes: 20492
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define li long
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pli pair<li,li>
#define pll pair<ll,ll>
#define pb push_back
#define fori(i,k,n) for(int i = k;i<n; i++)
#define rfori(i,k,n) for(int i = k; i>=n; i--)
#define tc int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define inf INT_MAX
#define ninf INT_MIN
#define W(x) cout<<x<<endl
#define WW(x,y) cout<<x<<' '<<y<<endl;
#define in(x) cin>>x
const ll mod1 = 99844353;
const ll mod2 = 1e9+7;
template <class T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

ll power(ll x,ll y){
    ll res = 1;
    
    while(y>0){
        if(y&1)res = (res*x);
        y>>=1;
        x = (x*x);
    }
    return res;
}

ll power(ll x,ll y,ll p){
    ll res = 1;
    x%=p;
    while(y>0){
        if(y&1)res = (res*x)%p;
        y>>=1;
        x = (x*x)%p;
    }
    return res;
}


int main(){
	fastio();
	string s;
	cin>>s;
	if(s[1] == 'B')s[1] = 'R';
	else s[1] = 'B';
	cout<<s<<endl;
}

Measured memory_bytes: 3608
import itertools

n = int(input())
towns = [tuple(map(int, input().split())) for _ in range(n)]
routes = list(itertools.permutations(towns))


def gen(routes):
    for v in routes:
        for i,  move in enumerate(v):
            if i < n-1:
                d = ((v[i][0] - v[i + 1][0]) ** 2 +
                     (v[i][1] - v[i + 1][1]) ** 2) ** 0.5
                yield d


print(sum(gen(routes)) / len(routes))


Measured memory_bytes: 8052
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

const int Maxd = 4;
const string let = "RYGB";
const int Maxn = 505;

int n, m, d;
char B[Maxn][Maxn];

int main()
{
	scanf("%d %d %d", &n, &m, &d);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int d1 = i + j, d2 = i - j + m;
			int val1 = d1 / d % 2? 1: 0, val2 = d2 / d % 2? 2: 0;
			B[i][j] = let[val1 + val2];
		}
		B[i][m] = '\0';
		printf("%s\n", B[i]);
	}
	return 0;

	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++) {
			set <char> S;
			for (int k = 0; k <= d && k <= i; k++) {
				int l = d - k;
				if (j - l >= 0) S.insert(B[i - k][j - l]);
				if (j + l < m && k > 0) S.insert(B[i - k][j + l]);
			}
			int k = 0;
			while (k < Maxd && S.find(let[k]) != S.end()) k++;
			if (k >= Maxd) { printf("FAIL at %d %d\n", i, j); return 0; }
			else B[i][j] = let[k];
		}
	for (int i = 0; i < n; i++) {
		B[i][m] = '\0';
		printf("%s\n", B[i]);
	}
	return 0;
	int rad = (d + 1) / 2;
	int st = 0;
	for (int j = 0; j < m; j += rad) {
		st = (st + Maxd - 1) % Maxd;
		int cur = st;
		for (int i = 0; i < n; i += rad) {
			cur = (cur + 1) % Maxd;
			for (int l1 = 0; l1 < rad; l1++)
				for (int l2 = 0; l2 < rad; l2++)
					if (i + l1 < n && j + l2 < m)
						B[i + l1][j + l2] = let[cur];
		}
	}
	for (int i = 0; i < n; i++) {
		B[i][m] = '\0';
		printf("%s\n", B[i]);
	}
	return 0;
}

Measured memory_bytes: 768