akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var A = sc.nextInt();
        var B = sc.nextInt();
        var C = sc.nextInt();
        WriteLine(Max(C - (A - B), 0));
    }
    
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N, K;
vector<int> G[2009];

pii bfs(int s){
    vector<int> d(N,INF);
    queue<int> que; que.push(s);
    d[s]=0;
    int lst;
    while(!que.empty()){
        int u=que.front(); que.pop();
        for(auto& v:G[u]){
            if(d[v]>d[u]+1){
                d[v]=d[u]+1;
                que.push(v);
            }
        }
        lst=u;
    }
    return {lst,d[lst]};
}

int bfs2(int s, int k){
    vector<int> d(N,INF);
    queue<int> que; que.push(s);
    d[s]=0;
    int cnt=0;
    while(!que.empty()){
        int u=que.front(); que.pop();
        for(auto& v:G[u]){
            if(d[v]>d[u]+1){
                d[v]=d[u]+1;
                que.push(v);
                if(d[v]>k) cnt++;
            }
        }
    }
    return cnt;
}

int bfs3(int s1,int s2, int k){
    vector<int> d(N,INF);
    queue<int> que;
    que.push(s1); que.push(s2);
    d[s1]=d[s2]=0;
    int cnt=0;
    while(!que.empty()){
        int u=que.front(); que.pop();
        for(auto& v:G[u]){
            if((u==s1&&v==s2)||(v==s1&&u==s2)) continue;
            if(d[v]>d[u]+1){
                d[v]=d[u]+1;
                que.push(v);
                if(d[v]>k) cnt++;
            }
        }
    }
    return cnt;
}

int is_dm(int s){
    pii p=bfs(s);
    p=bfs(p.first);
    return p.second;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>K;
    rep(i,N-1){
        int a,b;cin>>a>>b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    int dm=is_dm(0);
    if(dm<=K){cout1(0);return 0;}
    
    int mn=INF;
    if(K%2==0){
        rep(i,N) mn=min(mn,bfs2(i,K/2));
    }else{
        rep(u,N){
            for(auto v:G[u]){
                mn=min(mn,bfs3(u,v,K/2));
            }
        }
    }
    cout1(mn)
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int w,h,i,j,t,r,x[2550],y[2550],c,nx,ny,k;
  int X[8]={0,1,1,1,0,-1,-1,-1};
  int Y[8]={1,1,0,-1,-1,-1,0,1};
  while(scanf("%d %d",&w,&h),w||h){
    int m[52][52]={0};
    for(i=c=0;i<h;i++){
      for(j=0;j<w;j++){
	scanf("%d",&m[i+1][j+1]);
      }
    }
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
	if(!m[i][j])continue;
	y[0  ]=i;
	x[t=0]=j;
	m[i][j]=0;
	c++;
	for(r=1;r-t;t++){
	  for(k=0;k<8;k++){
	    nx=x[t]+X[k];
	    ny=y[t]+Y[k];
	    if(!m[ny][nx])continue;
	    y[r  ]=ny;
	    x[r++]=nx;
	    m[ny][nx]=0;
	  }
	}
	/*for(k=0;k<w*h;k++){
	  if(k%w==0)printf("\n");
	  printf("%d ",m[k/w+1][k%w+1]);
	  }printf("\n");//*/
      }
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 636
import std.stdio;
import std.array;
import std.string;
import std.algorithm;

string[char] next;

static this() {
    next = [
       'A': "BD",
       'B': "ACE",
       'C': "BF",
       'D': "AEG",
       'E': "BDFH",
       'F': "CEI",
       'G': "DH",
       'H': "EGI",
       'I': "FH"
    ];
}

bool movable(char c, char t) {
    return !next[c].find(t).empty;
}

void main() {
loop: foreach (_; 0 .. 1000) {
        string s = readln.chomp;
        foreach (i; 1 .. s.length) {
            if (!s[i - 1].movable(s[i])) {
                continue loop;
            }
        }
        s.writeln;
    }
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    ll x;
    cin >> x;
    ll ans = (x / 500) * 1000;
    ans += ((x % 500) / 5) * 5;
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(void)
{
  int N;
  int v_max = -1;
  cin >> N;
  vector<int> v1(100000);
  vector<int> v2(100000);

  for(int i = 0; i < N; i++){
    int tmp = 0;
    cin >> tmp;
    if(i % 2 == 0){
      v1[tmp-1]++;
    }else{
      v2[tmp-1]++;
    }

    if(tmp > v_max){
      v_max = tmp;
    }
  }
  int max[2][2] = {{-1, -1}, {-1, -1}};
  int n_max[2][2];

  for(int i = 0; i < v_max; i++){

    if(v1[i] >= max[0][0]){
      max[0][1] = max[0][0];
      max[0][0] = v1[i];

      n_max[0][1] = n_max[0][0];
      n_max[0][0] = i;
    }
    else if(v1[i] >= max[0][1]){
      max[0][1] = v1[i];

      n_max[0][1] = i;
    }

    if(v2[i] >= max[1][0]){
      max[1][1] = max[1][0];
      max[1][0] = v2[i];

      n_max[1][1] = n_max[1][0];
      n_max[1][0] = i;
    }
    else if(v2[i] >= max[0][1]){
      max[1][1] = v2[i];

      n_max[1][1] = i;
    }
  }

  int cnt = 0;
  if(max[0][1] == -1 && max[1][1] == -1){
    cnt = N / 2;
  }
  else if(n_max[0][0] != n_max[1][0]){
    cnt = N - max[0][0] - max[1][0];
  }
  else{
    int max12 = max[0][0] + max[1][1];
    int max21 = max[1][0] + max[0][1];

    if(max12 > max21){
      cnt = N - max12;
    }else{
      cnt = N - max21;
    }
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)


class SEGMENTS{
private:
    
    struct seg{
        int l,r;
        bool operator < (seg obj)const {
            if(r!=obj.r) return r<obj.r;
            else return l<obj.l;
        }
    };
    
    set<seg> dat;
    
    bool isCross(int l1,int r1,int l2,int r2){ return ( (l1<=l2 && l2<r1) || (l2<=l1 && l1<r2)); }
    bool isInclude(int li, int ri, int L, int R){ return (L<=li && ri<=R); }
    
public:
    
    void erase(int l, int r){
        while(true){
            auto it = dat.upper_bound(seg{(int)INF,l});
            if(it==dat.end() || r<=it->l)break;
            
            int li = it->l;
            int ri = it->r;
            
            if( isInclude(li,ri,l,r) ) dat.erase(it);
            else{
                int tl = li, tr = ri;
                if( isInclude(l,r,li,ri) ){
                    dat.erase(it);
                    if(li!=l) dat.insert(seg{li,l});
                    if(r!=ri) dat.insert(seg{r,ri});
                }else{
                    if(li<=l&&l<ri) tr = l;
                    if(l<=li&&li<r) tl = r;
                    dat.erase(it);
                    if(tl!=tr) dat.insert(seg{tl,tr});
                }
            }
        }
    }
    
    void insert(int l, int r){
        while(true){
            auto it = dat.upper_bound(seg{(int)INF,l});
            if(it==dat.end() || r<it->l)break;
            
            if( isInclude(it->l,it->r,l,r) ) dat.erase(it);
            else{
                l = min(l,it->l);
                r = max(r,it->r);
            }
        }
        
        auto it = dat.lower_bound(seg{(int)-INF,l});
        if( it!=dat.end() && it->r == l ){
            l = it->l;
            dat.erase(it);
        }
        if(l!=r)dat.insert(seg{l,r});
    }
    
    int size(){ return dat.size(); }
    
    void output(){ for(auto e:dat)cout<<e.l<<" "<<e.r<<endl;cout<<endl; }
};

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    
    SEGMENTS st;
    
    for(int i=0;i<n;){
        if(s[i]=='0')i++;
        else{
            int l=i;
            while(i<n && s[i]=='1') i++;
            st.insert(l,i);
        }
    }
    
    int q;
    cin>>q;
    while(q--){
        int l,r,b;
        cin>>l>>r>>b;
        l--;
        
        if(b==0)    st.erase(l,r);
        else        st.insert(l,r);
        
        cout<<st.size()<<endl;
    }
}

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



int main(){
  rep(i, 365){
    ll j=i%26;
    if(j==0)j+=26;
    cout<<j<<endl;
  }
  
}

Measured memory_bytes: 3632
N,M = map(int,input().split())
mapN = [[i for i in map(int,input().split())]for j in range(N)]
mapM = [[i for i in map(int,input().split())]for j in range(M)]

for a,b in mapN:
    ans = 0
    intInf = float('inf')
    i = 1
    for c,d in mapM:
        work = abs(a - c) + abs(b - d)
        if work < intInf:
            intInf = work
            ans = i
        i += 1
    print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

using namespace std;
typedef long long int64;

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n;
  cin>>n;
  for(int i=0;i<50000;i++){
    if(floor(i*(double)1.08)==n){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<":("<<endl;



  return 0;
}

Measured memory_bytes: 256
import sys, math

N = int(input())
A = list(map(int, input().split()))
G = 0
for a in A:
    G = math.gcd(G, a)

if G != 1:
    print("not coprime")
    exit(0)

M = 10 ** 6 + 5
B = dict()
for a in A:
    if a in B:
        B[a] = B[a] + 1
    else:
        B[a] = 1

for i in range(2, M):
    cnt = 0
    for j in range(i, M, i):
        if j in B:
            cnt += B[j]
    if cnt > 1:
        print("setwise coprime")
        exit(0)

print("pairwise coprime")


Measured memory_bytes: 126856
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int w,h,n,s;
	cin>>w>>h>>n;
	int x,y,a,max_x=0,min_x=10000,max_y=0,min_y=10000;
	for(int i=0;i<n;i++){
		cin>>x>>y>>a;
		if(a==1){
			if(max_x<x) max_x=x;
		}
		else if(a==2){
			if(min_x>x) min_x=x; 
		}
		else if(a==3){
			if(max_y<y) max_y=y;
		}
		else if(a==4){
			if(min_y>y) min_y=y;
		}
	}
	
	if(min_x==10000) min_x=w;
	if(min_y==10000) min_y=h;
	
	w=w-(max_x+(w-min_x));
	h=h-(max_y+(h-min_y));
	
	if(w<0||h<0) cout<<0<<endl;
	else cout<<w*h<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    char c[h+2][w+2];
    queue<pair<int,int>> q1;
    for(int i = 0;i<h+2;i++){
        for(int j = 0;j<w+2;j++){
            c[i][j] = 'm';
        }
    }
    for(int i = 0;i<h;i++){
        for(int j = 0;j<w;j++){
            cin >> c[i+1][j+1];
            if(c[i+1][j+1]=='#') q1.push(make_pair(i+1,j+1));
        }
    }
    int ans = 0;
    int dx[4] = {1,0,-1,0};
    int dy[4] = {0,1,0,-1};
    while(!q1.empty()){
        queue<pair<int,int>> q2;
        while(!q1.empty()){
            pair<int,int> pr = q1.front();
            q1.pop();
            for(int i = 0;i<4;i++){
                if(c[pr.first+dx[i]][pr.second+dy[i]]=='.'){
                    c[pr.first+dx[i]][pr.second+dy[i]]='#';
                    q2.push(make_pair(pr.first+dx[i],pr.second+dy[i]));
                }
            }
        }
        ans++;
        q1=q2;
    }
    cout << ans-1 << endl;
}

Measured memory_bytes: 9600
# coding: utf-8

num, choose_num = map(int, input().split())
total = 0
stick_length = input().split(" ")

str_num = [int(n) for n in stick_length]
list.sort(str_num, reverse=True)

for i in range(choose_num):
    total += str_num[i]

print(total)

Measured memory_bytes: 9120
package main

import(
    "fmt"
)



func main() {
    var n,m int
    fmt.Scan(&n,&m)
    mp := make(map[int]int)
    for i:=0; i<n; i++{
        var k int
        fmt.Scan(&k)
        for j:=0; j<k; j++{
            var a int
            fmt.Scan(&a)
            mp[a]++
        }
    }
    ans := 0
    for _,i := range mp{
        if i==n {
            ans++
        }
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
#include<string>
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s1;
	cin >> s1;
	if (s1 == "ABC"){
		cout << "ARC";
	}
	else cout << "ABC";	
	return 0;
}

Measured memory_bytes: 3612
room=[ [ [ 0 for k in range(10) ] for j in range(3) ] for i in range(4)]
n=int(input())
for i in range(n) :
    b,f,r,v=map(int,input().split())
    room[b-1][f-1][r-1]+=v
for i in range(4) :
    for j in range(3) :
        for k in range(10) :
            print(" {}".format(room[i][j][k]),end="")
        print("")
    if i!=3 :
        for l in range(20) :
            print("#",end="")
        print("")



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

using ll = long long;
using P = pair<int, int>;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  int ans = a + b + c + d + e;
  vector<int> amari;
  if (a % 10 != 0) {
    amari.push_back(10 - a % 10);
  }
  if (b % 10 != 0) {
    amari.push_back(10 - b % 10);
  }
  if (c % 10 != 0) {
    amari.push_back(10 - c % 10);
  }
  if (d % 10 != 0) {
    amari.push_back(10 - d % 10);
  }
  if (e % 10 != 0) {
    amari.push_back(10 - e % 10);
  }
  if (amari.size() > 0) {
    sort(amari.begin(), amari.end());
    for (int i = 0; i < amari.size() - 1; i++) {
      ans += amari[i];
    }
  }

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


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    
    int h,m,i,j;
    scanf("%d %d",&h,&m);
    
    char a[h][m+1];
    int x[101]={0},y[101]={0};
    
    for(i=0; i<h; i++){
        scanf("%s",&a[i][0]);
    }

    for(i=0; i<h; i++){
        for(j=0; j<m; j++){
            if(a[i][j]=='#')
                x[i]=1;
        }
    }
    for(j=0; j<m; j++){
        for(i=0; i<h; i++){
            if(a[i][j]=='#')
                y[j]=1;
        }
    }
    for(i=0; i<h; i++){
        for(j=0; j<m; j++){
            if(x[i]==1 && y[j]==1)
                printf("%c",a[i][j]);
        }
        if(x[i]==1)
            printf("\n");
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
//#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


signed main(){
  int a,b,k;cin>>a>>b>>k;
  int cnt = 0;
  for(int i = min(a,b);i >= 0;i--){
    if(a%i==0 && b%i==0)cnt++;
    if(cnt == k){
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
// AtCoder Regular Contest 075
// D - Widespread

#include <cstdio>
#include <algorithm>
#define MAX_N 100000
using namespace std;
typedef long long int ll;


int N;
ll A, B;
ll h[MAX_N];

bool can(ll k) {
    ll remain = k;
    for (int i = 0; i < N && remain >= 0; i++) {
        remain -= max((ll)0, h[i] - k * B + A - B - 1) / (A - B);
    }
    return (remain >= 0);
}

int main() {

    ll l, r, k;

    scanf("%d", &N);
    scanf("%lld%lld", &A, &B);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &h[i]);
    }

    l = 0;
    r = (ll)1e9;
    while (r - l > 1) {
        k = (r + l + 1) / 2;
        if (can(k)) {
            r = k;
        } else {
            l = k;
        }
    }

    printf("%lld\n", (r + l + 1) / 2);

    return 0;

}





Measured memory_bytes: 896
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<ctype.h>
#include<stack>
#include<math.h>
#include <string>
#include<algorithm>
#include<iomanip>
#define _for(i,a,b) for(int i = (a);i < (b);i++)
#define mset(x) memset(x,0,sizeof(x));
using namespace std;

int main() {
	long long int n,ans;
	cin>>n;
	ans = n * n *n;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>
#include <string.h>
typedef struct{
  char name[10];
  int time;
}Process;
void enqueue(Process);
Process dequeue(void);
int n;
int head = 0;
int tail = 0;
Process p[100001];
int main(){
  int i,q,takenTime;
  Process x;

  scanf("%d %d",&n,&q);
  for(i=0;i<n;i++){
    scanf("%s %d",x.name,&x.time);
    enqueue(x);
  }
  takenTime = 0;
  while( head != tail ){
    x = dequeue();
    if( (x.time - q) > 0 ){
      takenTime += q;
      x.time -= q;
      enqueue(x);
    }
    else {
      takenTime += x.time;
      printf("%s %d\n",x.name,takenTime);
    }
  }
  return 0;
}
void enqueue(Process x){
  p[tail] = x;
  if( tail == n){
    tail = 0;
  }
  else {
    tail++;
  }
}
Process dequeue(void){
  Process x;
  x = p[head];
  if( head == n ){
    head = 0;
  }
  else {
    head++;
  }
  return x;
}

Measured memory_bytes: 1380
import java.util.*;

 class Main
 {
   public static void main(String args[])
   { 
    Scanner sc =new Scanner(System.in);
    
    int i  = sc.nextInt();
    
    int j = 1;
    
    while (i != 0)
    {
      System.out.printf("Case %d: %d",j,i);
      
      System.out.println();
      
      j = ++ j;
      
      i = sc.nextInt();
    }
   }
 }
    
    


Measured memory_bytes: 65240
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

char gID[100001];
int gSum_except_asterisk;
bool gAsterisk_line[10];
int gCandidates[10];
int gCandidate_num;

int dfs(const string& x,int depth);
int ComputeNum(int num,int idx);
int ComputeExceptAsterTotal();
void JudgeAsteriskLine();
int fast_pow(int x,int power);
int fact(int x);
bool isValid(const string& line);

int dfs(const string& x,int depth){
  if(depth == 0){
    if(isValid(x)){
      return 1;
    }
    return 0;
  }

  int res = 0;
  for(int i=0;i<gCandidate_num;i++){
    string tmp = x;
    tmp.push_back(gCandidates[i]+'0');
    res += dfs(tmp,depth-1);
  }

  return res;
}

int ComputeNum(int num,int idx){
  if(idx % 2) return num;
  return num*2 >= 10 ? 1 + num*2%10 : num*2;
}

int ComputeExceptAsterTotal(){
  int res = 0;
  for(int i=0;i<strlen(gID);i++){
    if(gID[i] == '*') continue;
    int idx = strlen(gID) - i;
    res += ComputeNum(gID[i]-'0',idx);
  }
  return res;
}

void JudgeAsteriskLine(){
  int res = 0;
  int asterisk_idx = 0;
  for(int i=0;i<strlen(gID);i++){
    int idx = strlen(gID) - i;
    if(gID[i] == '*') gAsterisk_line[asterisk_idx++] = (idx % 2 == 0) ? true : false;
  }
}

int fast_pow(int x,int power){
  int res = 1;

  //2 ^ 4(0100)
  //2 ^ 2 * 2 ^ 2
  while(power){
    if(power & 1) res *= x;
    x *= x;
    power >>= 1;
  }
  return res;
}

int fact(int x){
  return x-1 <= 0 ? x*1 : x*fact(x-1);
}

bool isValid(const string& line){
  int sum = 0;
  for(int i=0;i<line.size();i++){
    //true:even false:odd
    if(gAsterisk_line[i]) sum += ComputeNum(line[i]-'0',2);
    else sum += ComputeNum(line[i]-'0',3);
  }
  if((gSum_except_asterisk + sum) % 10 == 0){
    return true;
  }

  return false;
}

int main(){
  int n;

  while(~scanf("%d",&n)){
    scanf("%s",gID);
    scanf("%d",&gCandidate_num);
    for(int i=0;i<gCandidate_num;i++){
      scanf("%d",gCandidates+i);
    }
    gSum_except_asterisk = ComputeExceptAsterTotal();
    int asterisk_num = count(gID,gID+n,'*');
    JudgeAsteriskLine();
    int res = 0;
    res = dfs("",asterisk_num);
    printf("%d\n",res);
  }
}

Measured memory_bytes: 1320
#include <algorithm>
#include <climits>
#include <functional>
#include <iostream>
#include <vector>

int main(int argc, char *argv[]) {
  long long n;
  std::cin >> n;
  long long m = 1;
  for (int i = 0; i < 18; ++i)
    m *= 10;

  std::vector<long long> a(n);
  long long max, min;
  for (int i = 0; i < n; ++i) {
    std::cin >> a.at(i);
    if (i == 0) {
      min = max = a.at(i);
      continue;
    }
    max = std::max(max, a.at(i));
    min = std::min(min, a.at(i));
  }

  std::sort(a.begin(), a.end(), std::greater<long long>());

  if (min == 0) {
    std::cout << 0 << std::endl;
    return 0;
  }

  if (max == 1) {
    std::cout << 1 << std::endl;
    return 0;
  }

  long long ans = a.at(0);
  long long prev = ans;
  for (int i = 1; i < n; ++i) {
    ans *= a.at(i);
    if (prev > ans || ans > m) {
      std::cout << -1 << std::endl;
      return 0;
    }
    prev = ans;
  }
  if (prev > ans || ans > m) {
    std::cout << -1 << std::endl;
    return 0;
  }

  std::cout << ans << std::endl;
}


Measured memory_bytes: 3676
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

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

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

ll chk(vvP& to, ll pat, ll p, ll u, ll v) {
  if (u == v) return pat;
  for (P ue : to[u]) {
    ll unx, enx;
    tie(unx, enx) = ue;
    if (unx == p) continue;
    ll ret = chk(to, pat | (1LL << enx), u, unx, v);
    if (ret > 0) return ret;
  }
  return 0;
}

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, m;
  cin >> n;

  vvP to(n);
  rep(i, n - 1) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    to[a].emplace_back(b, i);
    to[b].emplace_back(a, i);
  }

  cin >> m;

  vll pats(m, 0);
  rep(i, m) {
    ll u, v;
    cin >> u >> v;
    u--, v--;
    pats[i] = chk(to, 0, -1, u, v);
  }

  ll ans = 0;
  rep(s, 1 << m) {
    if (s == 0) continue;
    ll spat = 0;
    rep(i, m) {
      if ((s >> i) & 1) spat |= pats[i];
    }
    ll tmp = 1LL << (n - 1 - __builtin_popcountll(spat));
    if(__builtin_popcountll(s) & 1){
      ans += tmp;
    } else {
      ans -= tmp;
    }
  }

  ans = (1LL << (n - 1)) - ans;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<int>l, r;
	l = r = vector<int>(q);
	vector<int>ans(n, 0);
	rep(i, q) {
		int tmpl, tmpr;
		cin >> tmpl >> tmpr;
		l[i] = tmpl - 1;
		r[i] = tmpr - 1;
	}
	ans[0] = 0;
	rep(i, n-1) {
		if (s[i] == 'A' && s[i + 1] == 'C') {
			ans[i + 1] = ans[i] + 1;
		}
		else {
			ans[i + 1] = ans[i];
		}
	}
	//rep(i, n) {
	//	println(ans[i]);
	//}
	rep(i, q) {
		println(ans[r[i]] - ans[l[i]]);
	}
}

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

using namespace std;

template <class T> T gcd(T a, T b) {
	if (a < b) swap(a, b);
	while (b) {
		a = a % b;
		swap(a, b);
	}
	return a;
}

vector<int> sieve(int n) {
	vector<int> primes;
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (int i = 2; i <= n; i++) {
		if (!isPrime[i]) continue;
		primes.push_back(i);
		for (int j = i + i; j <= n; j += i) {
			isPrime[j] = false;
		}
	}
	return primes;
}

class Solution {
public:
	void solve() {
		int n;
		cin >> n;
		vector<int> a(n + 1, 0);
		vector<int> ans;
		vector<int> primes = sieve(1000000);
		for (auto& x : a) cin >> x;
		int y = abs(a[0]);
		for (auto x : a)
			if (x != 0) y = gcd(y, abs(x));
		for (auto p : primes) {
			if (!(y % p)) {
				ans.push_back(p);
				while (!(y % p)) y /= p;
			}
			if (y == 1) break;
		}
		if (y != 1) ans.push_back(y);

		for (auto p : primes) {
			if (p > n) break;
			if (abs(a[n]) % p) continue;
			vector<long long> f(p);
			for (int i = 0; i < n; i++) {
				f[i % (p - 1)] += a[i];
			}
			bool ok = true;
			for (int i = 0; i < p; i++) {
				if (f[i] % p) {
					ok = false;
					break;
				}
			}
			if (ok) ans.push_back(p);
		}

		sort(ans.begin(), ans.end());
		ans.erase(unique(ans.begin(), ans.end()), ans.end());
		for (auto x : ans) cout << x << " ";
		cout << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 1148
import Control.Monad                                                                                                                                  
main :: IO ()                                                                                                                                         
main = readLn >>= \n -> sum . map ((\[x,u] -> read x * unit u) . words) <$> replicateM n getLine >>= print                                            
                                                                                                                                                      
unit :: String -> Double                                                                                                                              
unit "JPY" = 1.0                                                                                                                                      
unit "BTC" = 380000.0

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};



int32_t main()
{

ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

#ifndef ONLINE_JUDGE
freopen("input.txt","rt",stdin);
freopen("output.txt","wt",stdout);
#endif 

int n;
cin>>n;
vector<int>v(n);
int x=0;
for(int i=0;i<n;i++)
{
   cin>>v[i];
   x^=v[i];
  
}

for(auto i : v)
cout<<(i^x)<<" ";



}

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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int a = cin.nextInt();
        int b = cin.nextInt();

        if (b >= a)
        {
            Console.WriteLine(a);
            return;
        }
        Console.WriteLine(a - 1);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(x) x.begin(), v.end()
#define rall(x) x.rbegin(), x.rend()
#define PB push_back
#define F first
#define S second

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

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

	string s, t;
	cin >> s >> t;
	int a, b; cin >> a >> b;
	string u; cin >> u;

	if(u == s) a--;
	else if(u == t) b--;

	cout << a << ' ' << b << '\n';

	return 0;
}


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

int main(){
  string s;
  cin >> s;
  if( (s[0]==s[1] && s[1]==s[2]) || (s[1]==s[2] && s[2]==s[3]) )
    cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
from collections import Counter
import sys

def debug(*a):
    print(*a, file=sys.stderr)

def solve(N, A):
    A = sorted(A)
    debug("A =", A)
    assert len(A) == N
    s = []
    if all(a < 0 for a in A):
        x = A[-1]
        for i in range(0, N-1):
            s.append((x, A[i]))
            x -= A[i]
        print(x)
        for x in s:
            print(*x)
        return
    if all(a >= 0 for a in A):
        x = A[0]
        for i in range(2, N):
            s.append((x, A[i]))
            x -= A[i]
        s.append((A[1], x))
        print(A[1] -x)
        for x in s:
            print(*x)
        return 

    pos = 0
    for i in range(N):
        if A[i] >= 0:
            pos =i
            break
    #print("A =", A)
    x = A[pos] # x > 0
    for i in range(pos-1):
        s.append(("+", x, A[i]))
        x -= A[i]
    
    y = A[pos-1] # y < 0
    for i in range(pos+1, N):
        s.append(("-", y, A[i]))
        y -= A[i] # y < 0
    s.append(("=", x, y))
    #print("N =", x-y)
    print(x-y)
    assert(len(s) == N-1)
    for x in s:
        debug(*x)
        print(*x[1:])

def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    solve(N, A)

main()




Measured memory_bytes: 21976
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

grid = []

for _ in range(3):
    grid.append(LIST())

n =INT()

for _ in range(n):
    b = INT()
    for i in range(3):
        for j in range(3):
            if(grid[i][j]==b):
                grid[i][j] = -1
flag = 0
for i in range(3):
    if(sum(grid[i])==-3):
        flag = 1
        break
if(flag==0):
    for i in range(3):
        temp = 0
        for j in range(3):
            temp+=grid[j][i]
        if(temp==-3):
            flag= 1
            break
if(flag==0):
    temp = 0
    for i in range(3):
        temp+=grid[i][i]
    if(temp==-3):
        flag = 1
if(flag==0):
    temp = 0
    for i in range(3):
        temp += grid[i][2-i]
    if (temp == -3):
        flag = 1
if(flag==1):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 70772
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;

int main(){
	int r;cin>>r;
	cout<<r*r<<"\n";
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
bool comp(const int a,const int b)
{
	return a > b;
}
int main()
{
	int n;
	scanf("%d",&n);
	vector<long long> ns(n);
	int t;
	for(t=0;t<n;t++)
		scanf("%lld",&ns[t]);
	sort(ns.begin(),ns.end(),comp);
	long long a=0,b=0;
	for(t=1;t<n;t++)
	{
		if(ns[t] == ns[t-1])
		{
			a = ns[t];
			break;
		}
	}
	t += 2;
	for(;t<n;t++)
	{
		if(ns[t] == ns[t-1])
		{
			b = ns[t];
			break;
		}
	}
	long long s;
	s = a*b;
	printf("%lld\n",s);
	return 0;
}

Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	for i := 0; i < len(s); i++ {
		first := s[0 : len(s)-1-i]
		second := s[len(s)-1-i:]
		tmp := second + first
		if tmp == t {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(){

	int n,d,x;
	int a;
	int ans=0;
	cin>>n>>d>>x;

	for(int i=0;i<n;i++){
	
		cin>>a;
		int j=0;
		int y=1;
		while(y<=d){
		
			j++;
			y=j*a+1;
		}
		ans+=j;
	}

	cout<<ans+x<<'\n';
	return 0;

}


Measured memory_bytes: 3528
N = int(input())
res = 0
cnt = 0
for i in range(N):
    D = input().split()
    if D[0] == D[1]:
        cnt += 1
        if cnt == 3:
            res += 1
            cnt = 0
    else:
        cnt = 0
if res > 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 8992
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a>b)swap(a,b);
	if(b>c)swap(b,c);
	if(a>b)swap(a,b);
	cout<<a<<" "<<b<<" "<<c<<endl;
	return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

bool calc(int n)
{
	bool flg;

	int a = (int)sqrt((double)n);
	if (a * a == n)
	{
		flg = true;
	}
	else
	{
		flg = false;
	}

	/*for (int i = 1; i <= n; i++)
	{
		if ((n/i) == n)
		{
			flg = true;
		}
		
	}*/

	return flg;
}

int main()
{
	int N, D;
	cin >> N >> D;

	int X[N + 1][D + 1];

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

	int count = 0;

	for (int point1 = 1; point1 <= N; point1++)
	{
		for (int point2 = point1 + 1; point2 <= N; point2++)
		{
			int ans = 0;

			for (int k = 1; k <= D; k++)
			{
				ans += pow(X[point1][k] - X[point2][k], 2);
			}

			if (calc(ans) == true)
			{
				count++;
			}
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int flag=1;
	int hash[26]={0};
	for(int i=0;i<s.length();i++)
	{
		hash[s[i]-'a']++;
		if(hash[s[i]-'a']==2)
		{
			hash[s[i]-'a']=0;
		}
	}
	for(int i=0;i<26;i++)
	{
		if(hash[i]==1)
		flag=0;
	}
	if(flag)
	{
		cout << "Yes";
	}
	else
	cout << "No";
	
	return 0;
}

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

using namespace std;

typedef long long ll;

int n, k;
int arr[200002];
int arr2[200002];
int arr3[200002];

int main(){
    scanf("%d %d", &n, &k);
    for(int i=1; i<=n; i++){
        scanf("%d", &arr[i]);
    }

    for(int i=1; i<=500 && i<=k; i++){
        for(int j=1; j<=n; j++){
            arr2[j+1]++;
            arr2[min(j+arr[j], n)+1]--;

            arr3[j-1]++;
            arr3[max(1, j-arr[j])-1]--;
        }
        for(int j=1; j<=n; j++) arr2[j] += arr2[j-1];
        for(int j=n; j>=1; j--) arr3[j] += arr3[j+1];
        for(int j=1; j<=n; j++) arr[j] = arr2[j] + arr3[j] + 1, arr2[j] = arr3[j] = 0;
    }
    for(int i=1; i<=n; i++) printf("%d ", arr[i]);
}


Measured memory_bytes: 6140
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
//
int main(){
  int N;
  int A[100];
  cin>>N;
  FOR(i,0,N){
    cin>>A[i];
  }
  FOR(i,0,N){
    sort(A,A+i+1);
    FOR(j,0,N){
      if(j!=0){
        cout<<" ";
      }
      cout<<A[j];
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 3136
k = int(input())
 
a, b = map(int, input().split())
ngcounter = 0
for i in range(a, b+1):
  if i % k == 0:
    break
  else:
    ngcounter += 1
    
if ngcounter == b - a + 1:
  print("NG")
else :
  print("OK")

Measured memory_bytes: 9004
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int N=cin.ReadInt;
            var F = new int[N][];
            for(int i=0;i<N;i++){
                F[i]= cin.ReadIntArray(10);
            }
            var P = new int[N][];
            for(int i = 0;i<N;i++){
                P[i] = cin.ReadIntArray(11);
            }

            var Result = new List<int>();
            for(int i =1;i<1024;i++){
                int[] TEN = new int[10].Select((value,index)=> i>>index & 1).ToArray();
                Result.Add(Rieki(N,TEN,F,P));
            }
            WriteLine(Result.Max());
        }

        public int Rieki(int N,int[] open, int[][] F,int[][] P){
            int R = 0;
            for(int j=0;j<N;j++){
                int jufuku = F[j].Select((v,index) => v*open[index]).Sum();
                R += P[j][jufuku];
            }
            return R;
        }


    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator =' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 17728
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        List<Integer>A = new ArrayList<Integer>();
        List<Integer>B = new ArrayList<Integer>();
        for(int i = 0; i < N; i++){
            int a = sc.nextInt();
            A.add(a);
        }
        for(int i = 0; i < N; i++){
            int b = sc.nextInt();
            B.add(b);
        }
        int ans = 0;
        for(int i = 0; i < N; i++)if(A.get(i) > B.get(i))ans += A.get(i) - B.get(i);
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
 
using namespace std;
 
#define MD 1000000007
typedef long long int ll;

ll mul(ll a,ll b){
    return ((a%MD)*(b%MD)) % MD;
}

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

Measured memory_bytes: 256
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
s,w=gsmi
puts w>=s ? 'unsafe' : 'safe'

Measured memory_bytes: 14276
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	vector<ll> x(n);
	for (int i = 0; i < n; i++)
		cin >> x[i];
	ll sum = 0;
	for (int i = 1; i < n; i++)
		sum += min(b, a * (x[i] - x[i - 1]));
	cout << sum << endl;
	return 0;
}

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

int main() {
  vector<string> weather={"Sunny","Cloudy","Rainy"};
  string s;
  cin >> s;
  for(int i=0;i<3;i++) {
    if(s==weather.at(i)) {
      cout << weather.at((i+1)%3) << endl;
    }    
  }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
   int r,d;
   int x[11];
   scanf("%d",&r);
   scanf("%d",&d);
   scanf("%d",&x[0]);
   for(int a=1;a<=10;a++){
       x[a]=r*x[a-1]-d;
       printf("%d\n",x[a]);
   }
   return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
int main(){
	char data[6];
	int stack[128];
	int k=0;
	while(scanf("%s",data)!=EOF){
		if(data[0]=='+'){
			k--;
			stack[k-1]=stack[k-1]+stack[k];
		}
		else if(data[0]=='-'){
			k--;
			stack[k-1]=stack[k-1]-stack[k];
		}
		else if(data[0]=='*'){
			k--;
			stack[k-1]=stack[k-1]*stack[k];
		}
		else{
			stack[k]=atoi(data);
			k++;
		}
	}
	printf("%d\n",stack[0]);
	return 0;
}

Measured memory_bytes: 548
//created by missever

#include<bits/stdc++.h>
#define MAX 1000000007
using namespace std;
typedef long long LL;

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    LL s = 1LL * (n - 2) * (b - a) + 1;
    if(s < 1) cout<<0<<endl;
    else cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256