akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
    private static final StringBuilder builder = new StringBuilder();
    public static void main(String[] args) {
        int n = readInt();
        long prev = readLong();
        long step = 0;
        for (int i = 1; i < n; i++) {
            long cur = readLong();
            if (prev > cur) {
                step += prev - cur;
            } else {
                prev = cur;
            }
        }

        System.out.print(step);
    }

    private static void read() {
        builder.setLength(0);
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) {
                    break;
                } else {
                    builder.appendCodePoint(b);
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static int readInt() {
        read();
        return Integer.parseInt(builder.toString());
    }

    private static int readInt(int radix) {
        read();
        return Integer.parseInt(builder.toString(), radix);
    }

    private static long readLong() {
        read();
        return Long.parseLong(builder.toString());
    }

    private static long readLong(int radix) {
        read();
        return Long.parseLong(builder.toString(), radix);
    }

    private static BigInteger readBigInteger() {
        read();
        return new BigInteger(builder.toString());
    }

    private static BigInteger readBigInteger(int radix) {
        read();
        return new BigInteger(builder.toString(), radix);
    }

    private static double readDouble() {
        read();
        return Double.parseDouble(builder.toString());
    }

    private static BigDecimal readBigDecimal() {
        read();
        return new BigDecimal(builder.toString());
    }

    private static float readFloat() {
        read();
        return Float.parseFloat(builder.toString());
    }

    private static void skipLine() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == '\n' || b == -1) {
                    break;
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static void skip() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) break;
            } catch (IOException e) {
                break;
            }
        }
    }

}


Measured memory_bytes: 43560
import java.util.*;

public class Main {
    public static class QueueforLong{
        private int max,front,rear,number;
        private long[] queue;
    
        public class EmptyIntQueueException extends RuntimeException{
          public EmptyIntQueueException(){}
        }
    
        public class OverflowIntQueueException extends RuntimeException{
            public OverflowIntQueueException(){}
        }
    
        public QueueforLong(int capacity){
            max=capacity;
            front=rear=number=0;
            try{
                queue=new long[max];
            }catch(OutOfMemoryError e){
                max=0;
            }
        }
    
        public long enqueue(long A){
            if(number>=max) throw new OverflowIntQueueException();
            queue[rear++]=A;
            number++;
            if(rear>=max) rear=0;
            return A;
        }
    
    public long dequeue(){
      if(number==0) throw new EmptyIntQueueException();
      long tmp=queue[front];
      queue[front]=0;
      if(++front==max) front=0;
      number--;
      return tmp;
    }
    
    public void getString(){
        System.out.print("[ ");
      for(int i=0;i<max;i++){
        System.out.print(queue[i]+" ");
      }
      System.out.println(" ]");
    }

    public long peek(){
      return queue[front];
    }
    
    public int indexOf(long c){
      for(int i=0;i<number;i++){
        if(queue[(front+i)%max]==c){
          return (front+i)%max;
        }
      }
      return -1;
    }
  }
  
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int K=sc.nextInt();
        QueueforLong queue=new QueueforLong(10*K);
        long res=0;
        
        for(int i=1;i<10;i++){
            res=queue.enqueue(i);
        }
        
        for(int i=0;i<K-1;i++){
            long tmp=queue.dequeue();
            if(tmp%10!=0){
                res=queue.enqueue((long)(tmp*10+(tmp%10)-1));
            }
            res=queue.enqueue((long)(tmp*10+(tmp%10)));
            if(tmp%10!=9){
                res=queue.enqueue((long)(tmp*10+(tmp%10)+1));
            }
        }
        
        long ans=queue.dequeue();
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 29524
#include <iostream>
#include <math.h>
#include <vector>
#include <string>
using namespace std;
int main() {
	int N = 0;
	scanf("%d", &N);
	vector<long>v (N+1,0);

	
	for (int x = 1; x <= 100; x++) {
		for (int y = 1; y <= 100; y++) {
			for (int z = 1; z <= 100; z++) {
				if ((x * x + y * y + z * z + x * y + x * z + z * y) != 0 && ((x * x + y * y + z * z + x * y + x * z + z * y) < v.size())) {
					v[(x * x + y * y + z * z + x * y + x * z + z * y) - 1]++;
				}
				
			}
			
		}
		
	}
	for (int i = 0; i < N; i++) {
		string str = to_string(v[i]);
		const char* l = str.c_str();
		printf(l);
		//if (i != N - 1) {
		printf("\n");
	//}
	}
	
	return 0;
}

Measured memory_bytes: 3704
using System;

namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string S=Console.ReadLine();
      int flg=0;
     for(int i=0;i<(S.Length);i++){
       string str =S.Substring(i,1);
       if((i%2)==0){
         if((str!="R")&&(str!="U")&&(str!="D")){
           flg=1;
           break;
         }
       
    }else{
      if((str!="L")&&(str!="U")&&(str!="D")){
       flg=1;
           break;
         }
   }
  
       
       }
         if (flg==1){
       Console.WriteLine("No");
     }else{
       Console.WriteLine("Yes");
     }
    
     }
    }    
}

Measured memory_bytes: 11092
#include<stdio.h>
#define NAMELEN 128
#define NO  0
#define YES 1


int cmp(char S[]){
  int i;
  for(i=0;S[i]!='\0';i++){
    if(i%2==1)
      if(S[i]=='R')
        return NO;
    if(i%2==0)
      if(S[i]=='L')
	return NO;
  }
  return YES;
}

int main(void){
  char S[NAMELEN];
  scanf("%s",S);

  if(cmp(S)==NO)
    printf("No\n");
  else
    printf("Yes\n");

  return 0;
  
}
  


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

int main()
{
	int n;
	cin >> n;
	long long a[10000];
	long long b[10000];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}

	long long suma=0, sumb=0;
	for (int i = 0; i < n; i++) {
		suma += a[i];
		sumb += b[i];
	}
	if (suma > sumb) {
		cout << "No";
	}
	else if (suma == sumb) {
		for (int i = 0;i < n;i++) {
			if (a[i] != b[i]) {
				cout << "No";
				return 0;
			}
		}
		cout << "Yes";
	}
	else {
		long long na = sumb-suma;
		long long nb = na;
		for (int i = 0;i < n;i++) {
			if (a[i] < b[i]) {
				if ((b[i] - a[i]) % 2 == 0) {
					nb -= (b[i] - a[i]) / 2;
					a[i] = b[i];
				}
				else {
					nb -= (b[i] - a[i] + 1) / 2;
					a[i] = b[i] + 1;
				}
			}
			if (a[i] > b[i]) {
				na -= a[i] - b[i];
				b[i] = a[i];
			}
			if (na < 0 || nb < 0) {
				cout << "No";
				return 0;
			}
		}
		cout << "Yes";
	}

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    vector<lint> a(n);
    int odd = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        odd += a[i] % 2 == 1;
    }
    if (odd % 2)
        cout << "NO"
             << "\n";
    else
        cout << "YES"
             << "\n";
    return 0;
}

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

using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define pb(c) push_back(c)

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

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

	int n, a, b;
	cin >> n >> a >> b;
	string ret = "NG";
	for(int i = a; i <= b; i++) {
		if(i%n == 0) {
			ret = "OK";
			break;
		}
	} cout << ret << "\n";
}


Measured memory_bytes: 3652
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


int main() {
    string s;
    cin >> s;
    rep(i,0,s.size()){
        if(!(i%2)){
            cout << s[i];
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lowbit(a) ((a)&-(a))
#define clean(a,b) memset(a,b,sizeof(a))
const int mod = 1e9 + 7;
const int inf=0x3f3f3f3f;
const int maxn = 1e6+9;
const double pi=acos(-1);
int _;

//========================================================================


//========================================================================

int main()
{
    double a,b,h,m;
    scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
    double jh=30*h+m/2,jm=6*m;
    double j=abs(jh-jm);
    if(j>=180) j=360-j;
    double x=sqrt(a*a+b*b-2*a*b*cos(j*pi/180));
    printf("%.16lf\n",x);
    return 0;
}


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


int main(){
    vector<pair<ll, ll>> V; 
    ll ans = 0;
    for(int i = 0; i < 5; i++) {
        ll x; cin >> x;
        if(x % 10 == 0)ans += x;
        else V.push_back(make_pair(x%10, x));
    }
    if(V.size() == 0){
        cout << ans << endl;
        return 0;
    }
    sort(V.begin(), V.end());
    for(int i = V.size()-1; i >= 1; i--){
        ll x = V[i].second;
        if(x % 10 == 0) ans += x;
        else ans += (x/10+1)*10;
    }
    cout << ans + V[0].second << endl;
    



}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String str = br.readLine();
			
			int n = Integer.parseInt(str);
			
			if(n == 0){
				break;
			}
			
			String input = br.readLine();
			
			System.out.println(solve(input));
		}
	}
	
	static String solve(String str){
		int[] vote = new int[26];
		
		String[] strArray = str.split(" ");
		
		for(int i = 0; i < strArray.length; i++){
			vote[(int)(strArray[i].charAt(0) - 'A')]++;
			
			int[] copyVote = Arrays.copyOf(vote, vote.length);
			
			Arrays.sort(copyVote);
			
			//1?????¨2???????????°???????±???????????????????
			if(copyVote[25] == copyVote[24]){
				continue;
			}
			//1?????¨2???????????????????????????????????°???????¢????
			else if(copyVote[25] > copyVote[24] + (strArray.length - i - 1)){
				return (char)(getTop(vote) + 'A')+" "+(i+1);
			}
			
		}
		
		return "TIE";
	}
	
	static int getTop(int[] vote){
		int max = -1;
		int result = -1;
		for(int i = 0; i < vote.length; i++){
			if(max < vote[i]){
				max = vote[i];
				result = i;
			}
		}
		
		return result;
	}

}

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

#define dump(x) cout << (x) << endl
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

typedef struct {
    Int y, x;
} p_t;

Int dp[100001][4];

int main() {
    string s;
    cin >> s;
    dp[0][0] = 1;
    for (Int i = 0; i < (Int)s.size(); i++) {
        for (Int j = 0; j < 4; j++) {
            if (s[i] == '?') {
                dp[i + 1][j] += dp[i][j] * 3;
                dp[i + 1][j] %= mod;
            }
            else {
                dp[i + 1][j] += dp[i][j];
                dp[i + 1][j] %= mod;
            }
        }   
        if (s[i] == '?') {
            for (Int j = 0; j < 3; j++) {
                dp[i + 1][j + 1] += dp[i][j];
                dp[i + 1][j + 1] %= mod;
            }
        }
        else {
            dp[i + 1][s[i] - 'A' + 1] += dp[i][s[i] - 'A'];
            dp[i + 1][s[i] - 'A' + 1] %= mod;
        }
    }
    // for (Int i = 0; i < (Int)s.size() + 1; i++) {
    //     for (Int j = 0; j < 4; j++) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    dump(dp[s.size()][3]);
    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int x; cin >> x;
  int i = 1, sum = 0;
  while(true) {
    sum += i;
    if(sum >= x) {
      cout << i << endl;
      return 0;
    }
    i++;
  }

  return 0;
}


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

int main(){
  long double w,h,x,y;
  cin >> w >> h >> x >> y;
  
  int ret = 0;
  if(x*2 == w && y*2 == h){
    ret = 1;
  }
  cout << w*h/2 << " " << ret << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a,b,i,j;
  while(1){
  scanf("%d%d",&a,&b);
  if(a == 0 && b == 0){
      break;
      
  }

  for(i=1;i<=a;i++)
    {
      for(j=1;j<=b;j++)
 {
   if(i > 1 && i < a && j < b && j > 1)
   printf(".");
   else 
   printf("#");
 }
      printf("\n");
    }
  printf("\n");
    
    }
  return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    ll n; cin >> n;
    Vl s(n);
    rep(i, 0, n) cin >> s[i];

    ll ans = 0;
    rep(i, 0, n) ans += s[i];

    sort(ALL(s));
    if(ans%10 == 0){
        rep(i, 0, n){
            if(s[i]%10 != 0){
            ans -= s[i];
            break;
            }
            if(i == n-1) ans = 0;
        }
    }

    cout << ans << "\n";
}

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

    solve();
    return 0;
}
 


Measured memory_bytes: 256
import math
n,d=map(int,input().split())
x=[[int(x) for x in input().split()]for _ in range(n)]
cnt=0
for i in range(n):
    for j in range(i+1,n):
        sum=0
        for a,b in zip(x[i],x[j]):
            sum+=(a-b)*(a-b)
        if math.sqrt(sum).is_integer():
            cnt+=1
print(cnt)

Measured memory_bytes: 9140
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
	          int D=stdIn.nextInt();
	        
		if(D==25){
			System.out.println("Christmas");
		}
		else if(D==24){
			System.out.println("Christmas Eve"); 
		}
		else if(D==23){
			System.out.println("Christmas Eve Eve");
			
		}
		else if(D==22){
			System.out.println("Christmas Eve Eve Eve");
			
		}
 
	}
 
}

Measured memory_bytes: 21460
import kotlin.math.pow

private fun readLn(): String = readLine()!!
private fun readInt(): Int = readLn().toInt()
private fun readStrs(): List<String> = readLn().split(" ")
private fun readInts(): IntArray = readStrs().map { it.toInt() }.toIntArray()
private fun readChars(): CharArray = readStrs().map { it.single() }.toCharArray()

fun main(args: Array<String>) {
    val (N, K) = readInts()
    val mod = 10.0.pow(9).toLong() + 7

    var sum = 0L
    for (k in K..(N + 1)) {

        val index = k.toLong()
        val min = index * (index - 1) / 2
        val b =  index.toLong() * (2 * N - index + 1)
        val a = b / 2

        val max = b / 2
        sum += (max - min + 1)
    }
    println(sum % mod)
}

Measured memory_bytes: 36472
#include <bits/stdc++.h>
#include <iomanip> 
using namespace std; 
#define rep(i,a,b)		for(long int i=a;i<=b;i++)
#define MOD 1e9+7

long int n,temp,ans=INT_MAX,cnt;
int main() 
{ 
	ios::sync_with_stdio(false);
    cin.tie(NULL);  
    
	cin>>n;
	rep(i,1,n)
	{
		cnt=0;
		cin>>temp;
		while(temp%2==0)
			cnt++,temp/=2;
		ans = min(ans,cnt);
	}
	cout<<ans;
}
	

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

bool Prime(int x){
    if(x == 2){
        return true;
    }
    
    if(x < 2 || x % 2 == 0){
        return false;
    }
    
    for(int i = 3;i <= sqrt(x);i = i + 2){
        if(x % i == 0){
            return false;
        }
    }
    
    return true;
}

int main(){
    int n,a,r = 0;
    
    cin >> n;
    
    for(int i = 0;i < n;i++){
        cin >> a;
        if(Prime(a) == true){
            r++;
        }
    }
    
    cout << r << endl;
    
    return 0;
}

Measured memory_bytes: 3096
def solve():
    N = int(input())
    tournament = [list(map(lambda x:int(x)-1, input().split())) for _ in range(N)]
    map_que_tournament = {i:[] for i in range(N)} # player iがjと戦いたがってる
    competition_num = -1
    que_player = list(range(N))
    
    while que_player:
        day_process_flag = False
        new_queue = []
        # print(que_player)
        for player in que_player:
            if tournament[player]:
                match_player = tournament[player].pop(0)
                # ぶじマッチング相手が見つかったら
                if map_que_tournament[match_player] and player == map_que_tournament[match_player][0]:
                    # print(player, match_player)
                    day_process_flag = True
                    new_queue.append(match_player)
                    new_queue.append(player)
                    map_que_tournament[match_player].pop()
                else:
                    map_que_tournament[player].append(match_player)

        if day_process_flag:
            if competition_num < 0:
                competition_num = 1
            else: competition_num += 1

        que_player = new_queue
        
    # 途中でやめた場合
    for t in tournament:
        if t:
            competition_num = -1
            break

    print(competition_num)
    
solve()

Measured memory_bytes: 35188
#!usr/bin/env python3


import sys


def main():
    n = int(sys.stdin.readline().strip('\n'))
    taro_score = 0
    hanako_score = 0

    for turn in range(n):
        animals = [animal for animal in
                   sys.stdin.readline().strip('\n').split(' ')]
        if animals[0] == animals[1]:
            taro_score += 1
            hanako_score += 1
        elif max(animals[0], animals[1]) == animals[0]:
            taro_score += 3
        elif max(animals[0], animals[1]) == animals[1]:
            hanako_score += 3

    print('%d %d' % (taro_score, hanako_score))


if __name__ == '__main__':
    main()

Measured memory_bytes: 7632
import java.util.Scanner;

class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int A = sc.nextInt();
		int B = sc.nextInt();

		if(A <= B){
			System.out.println(0);
		}else if(A <= 2*B){
			System.out.println(0);
		}else{
			System.out.println(A - 2*B);
		}
    }
}

Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {

	private void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		
		int ans  = 0;
		boolean odd = true;
		int wall = 10;
		while(wall<=N) {
			if(odd) {
				ans += wall - wall/10;
			}
			odd = !odd;
			wall *= 10;
		}
		if(odd) ans += N - wall/10 + 1;
		System.out.println(ans);	
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}



Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();

        System.out.println((H - h) * (W - w));
    }

}


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

long long count = 0;

void insertionSort(int n, int A[], int g)
{
    int i;
    for (i = g; i < n; i++) {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j+g] = A[j];
            j -= g;
            count++;
        }
        A[j+g] = v;
    }
}

void shellSort(int n, int A[])
{
    if (n == 1) { printf("1\n1\n"); return;}
    
    int *G = (int*)malloc(sizeof(int) * n);
    int i, h, m;
    for (i = 0, h = 1; h < n; m = i++, h = 3*h + 1) {
        G[i] = h;
    }
    printf("%d\n", m+1);
    
    while(i-->0) {
        insertionSort(n, A, G[i]);
        if (m != i && i >= 0) printf(" ");
        printf("%d", G[i]);
    }
    puts("");
    free(G);
}

int main()
{
    int i;
    int N;    
    scanf("%d", &N);
    int *A = (int*)malloc(sizeof(int) * N);
    for (i = 0; i < N ;i++) {
        scanf("%d", &A[i]);
    }
    
    shellSort(N, A);    
    printf("%d\n", count);
    for (i = 0; i < N ;i++) {
        printf("%d\n", A[i]);
    }
    free(A);
    
    return 0;
}

Measured memory_bytes: 4516
#include<bits/stdc++.h>
using namespace std;
const int N(211111);
long long x[N], y[N], a[N], rela[N], delta[N], sgn[N], le[N], ri[N];
int getr(int x) {
	int p(x);
	long long coe(1), pls(0);
	while(p != rela[p]) {
		pls += delta[p] * coe;
		coe *= sgn[p];
	//printf("!%d %lld %lld %lld %lld \n", x, pls, coe, delta[p], sgn[p]);
		p = rela[p];
	}
	int p1(p);
	p = x;
	//printf("!%d %lld %lld\n", x, pls, coe);
	while(p != rela[p]) {
		int p2(rela[p]);
		rela[p] = p1;
		long long dp(delta[p]), sp(sgn[p]);
		delta[p] = pls;
		sgn[p] = coe;
		//coe * x + pls - delta[p] = sgn[p] * y
		coe *= sp;
		pls = (pls - dp) * sp;
		p = p2;
	}
	return p1;
}
int main() {
	int r, c, n;
	cin >> r >> c >> n;
	long long a11(0);
	for(int i(0); i < n; i++) {
		cin >> x[i] >> y[i] >> a[i];
	}
	bool invalid(false);
	for(int i(1); i <= r + c; i++) {
		rela[i] = i;
		delta[i] = 0;
		sgn[i] = 1;
	}
	for(int i(0); i < n; i++) {
		int ca(x[i]), cb(r + y[i]);
		int xx(getr(ca)), yy(getr(cb));
		a[i] += a11;
		//(sgn[ca] * v[xx] + delta[ca] + sgn[cb] * v[yy] + delta[cb] = a[i]);
		//printf("%d %d\n", xx, yy);
		if(xx == yy) {
			//(sgn[ca] + sgn[cb]) * v + delta[ca] + delta[cb] - a[i] = 0;
			if(delta[ca] + delta[cb] - a[i] != 0) {
				invalid = true;
				break;
			}
		}else {
			//v[yy] = sgn[cb] * (-sgn[ca] * v[xx] - delta[ca] - delta[cb] + a[i])

			//rela[yy] = xx;
			long long newsgn = sgn[cb] * sgn[ca] * -1;
			long long newdelta = sgn[cb] * (-delta[ca] - delta[cb] + a[i]);
			rela[yy] = xx;
			sgn[yy] = newsgn;
			delta[yy] = newdelta;
		}
	}
	//cout << invalid << endl;
	for(int i(1); i <= r + c; i++) {
		//printf("%lld %lld %lld\n", rela[i], sgn[i], delta[i]);
		if(rela[i] == i) {
			le[i] = 0;
			ri[i] = 1e18;
		}
	}
	for(int i(1); i <= r + c; i++) {
		getr(i);
		//printf("%lld %lld %lld\n", rela[i], sgn[i], delta[i]);
		if(sgn[i] > 0) {
			le[rela[i]] = max(le[rela[i]], -delta[i]);
		}else {
			ri[rela[i]] = min(ri[rela[i]], delta[i]);
		}
	}
	for(int i(1); i <= r + c; i++) {
		if(le[i] > ri[i]) {
			invalid = true;
			break;
		}
	}
	cout << (invalid ? "No" : "Yes") << endl;
}


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

int main()
{
        string s;

        cin >> s;

        int n = s.length();

        for (int i = 0; i < n; i++) {
                if (i % 2 != 0 && s[i] == 'R') {
                        cout << "No" << endl;
                        return 0;
                }
                else if (i % 2 == 0 && s[i] == 'L') {
                        cout << "No" << endl;
                        return 0;
                }
        }

        cout << "Yes" << endl;

        return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var num int
	fmt.Scanf("%d", &num)

	var str string
	fmt.Scanf("%s", &str)

	fmt.Println(calc(num, str))
}

func calc(num int, s string) int {
	ret := strings.Count(s, "R") * strings.Count(s, "G") * strings.Count(s, "B")

	for i := 0; i < num-2; i++ {
		for j := i + 1; j < num-1; j++ {
			var k = j + j - i
			if k < num {
				if s[i] != s[j] && s[j] != s[k] && s[i] != s[k] {
					ret--
				}
			}
		}
	}

	return ret
}


Measured memory_bytes: 1900
#include<stdio.h>

int main(){

int x,y,n;
int X=0,Y=0;


scanf("%d",&n);

for(int i=0;i<n;i++)
{
scanf("%d %d",&x,&y);
if(i==0){Y=y;X=x;}
if(Y==y&&x<X){X=x;Y=y;}
else if(Y<y){X=x;Y=y;}

}

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

Measured memory_bytes: 1028
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define mod (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int gcd(int A,int B) {if(!B)return A;return gcd(B,A%B);}
int main()
{
   int x,y;
   cin>>x>>y;
   if(y&1){cout<<"No";return 0;}
   if(y > 4*x){cout<<"No";return 0;}
   if(2*x > y){cout<<"No";return 0;}
   cout<<"Yes";
}



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

int main() {
    int t;
    char a[105], b[105];
    cin >> t;
    for(int i=0; i<t; i++) {
        cin >> a[i];
    }
    for(int i=0; i<t; i++) {
        cin >> b[i];
    }
    for(int i=0; i<t; i++) {
        cout << a[i] << b[i];
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}


int main() {
    ll N;
    cin >>N;
    
    const auto &res = prime_factorize(N);

    ll ans = 0;
    for (auto p : res) {
        ll e = p.second;
        ll i =1;
        while(1){
            e-=i;
            if(e>=0){
                ans++;
            }else{
                break;
            }
            i++;
        }
    }

    cout<<ans<<endl;
    return 0;
    

}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
enum MapChip{BLANK='.',WALL='*'};
int main()
{
  int n,ans;
  vector<string>field;
  while(cin>>n,n){
    field.resize(n);
    for(int i=0;i<n;i++)cin>>field[i];

    ans=0;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){

	if(field[i][j]==WALL)continue;

	bool ok=true;
	int size=1;
	for(;size<=n;size++){

	  for(int k=i;k<i+size;k++){
	    for(int l=j;l<j+size;l++){
	      if(k>=n || l>=n || field[k][l]==WALL){
		ok=false;
		break;
	      }
	    }
	    if(ok==false)break;
	  }
	  if(ok==false)break;
	}

	ans=max(ans,size-1);
      }

    }

    cout<<ans<<endl;
  }
}

Measured memory_bytes: 0
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

#define int ll

//get vector of prime numbers which is lower than or equal n
vector<int> get_primes(int n)
{
    vector<bool> is_prime(n + 1, true);
    vector<int> res;
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; i++)
    {
        if (is_prime[i])
        {
            res.push_back(i);
            for (int j = 2 * i; j < is_prime.size(); j = j + i)
            {
                is_prime[j] = false;
            }
        }
    }
    return res;
}

vector<pair<int, int>> factorize(int n)
{
    vector<pair<int, int>> res;
    for (int i = 2; i * i <= n; i++)
    {
        int tmp = 0;
        while (n % i == 0)
        {
            tmp++;
            n /= i;
        }
        res.push_back(make_pair(i, tmp));
    }
    if (n != 1)
    {
        res.push_back(make_pair(n, 1));
    }
    return res;
}

int mpow(int x, int n)
{
    int res = 1;
    while (n != 0)
    {
        if (n & 1)
            res = res * x % INF;
        x = x * x % INF;
        n = n >> 1;
    }
    return res;
}

//mod frac
vector<int> mfrac;
void set_mfrac(int n)
{
    if (mfrac.size() == 0)
    {
        mfrac.push_back(1);
    }
    for (int i = mfrac.size(); i <= n; i++)
    {
        mfrac.push_back((i * mfrac[i - 1]) % INF);
    }
}

//get nCm mod INF
int mcomb(int n, int m)
{
    if (mfrac.size() <= n)
    {
        set_mfrac(n);
    }
    int res = mfrac[n];
    res = res * mpow(mfrac[m], INF - 2) % INF;
    res = res * mpow(mfrac[n - m], INF - 2) % INF;
    return res;
}

vector<int> get_gcd(int n)
{
    vector<int> res;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            if (i * i == n)
            {
                res.push_back(i);
            }
            else
            {
                res.push_back(i);
                res.push_back(n / i);
            }
        }
    }
    return res;
}

signed main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> B(S.size() + 1);
    vector<int> W(S.size() + 1);
    B[0] = W[0] = 0;
    for (int i = 1; i < S.size() + 1; i++)
    {
        if (S[i - 1] == '.')
        {
            W[i] = W[i - 1] + 1;
            B[i] = B[i - 1];
        }
        else
        {
            W[i] = W[i - 1];
            B[i] = B[i - 1] + 1;
        }
    }

    int ans = INF;
    for (int i = 0; i <= S.size(); i++)
    {
        int tmp = B[i] - B[0];
        tmp += W[S.size()] - W[i];
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3716
import sys

n,a,b = map(int, input().split())

if n == 0:
	print(0)
	sys.exit()
if n == 1:
	if a == b:
		print(1)
		sys.exit()
	else:
		print(0)
		sys.exit()
if a > b:
	print(0)
	sys.exit()

maximum = (a+b) + b*(n-2)
minimum = (a+b) + a*(n-2)

print(maximum-minimum+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int n; cin >>n;
	vector<long long> a(n);
	cinf(n,a);
	int cnt=0;
	ll m=10000000000;
	ll sum=0;
	for(int i=0;i<n;i++){
		if(a[i]<0)cnt++;
		m=min(m,abs(a[i]));
		sum+=abs(a[i]);
	}
	if(cnt %2 ==0)cout << sum << endl;
	else cout << sum-m*2 << endl;

}


Measured memory_bytes: 1024
N, K = map(int, input().split())
X = list(map(int, input().split()))

dp = [[0] * (N + 1) for _ in range(100)]
dp[0] = [0] + X
for k in range(1, 100):
    for i in range(N + 1):
        dp[k][i] = dp[k - 1][dp[k - 1][i]]

ans = 1
for k in range(100):
    if K >> k & 1:
        ans = dp[k][ans]

print(ans)


Measured memory_bytes: 236756
#include"bits/stdc++.h"

using namespace std;

typedef long long LL;

int main() 
{
	LL max_ans = 0;
	LL ans = 0;
	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int a, b;
		cin >> a >> b;
		if (a >= max_ans)
		{
			ans = (a + b);
			max_ans = a;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
	int a,b,c,d,e,k;
	cin >> a >> b >> c >> d >> e >> k;
  if(e-a<=k){
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }
}

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

typedef long long ll;

struct Ant {
  int p,i;
  bool operator<(Ant o) const { return p<o.p; }
};

int n,m;
ll t;
vector<Ant> l,r,all,after;
int ans[1<<17];

int main() {
  scanf("%d%d%lld",&n,&m,&t);
  for (int i=0;i<n;i++) {
    int p, d;
    scanf("%d %d",&p,&d);
    int diff = (d==2) ? -1 : 1;
    if (diff==-1) l.push_back({ p-1,i });
    else r.push_back({ p-1,i });
    all.push_back({ p-1,i });
    after.push_back({ (p-1+(t%m)*diff+m)%m,i });
  }
  sort(l.begin(),l.end());
  sort(r.begin(),r.end());
  sort(all.begin(),all.end());
  sort(after.begin(),after.end());
  ll num = t/m+2;
  ll left = 0;
  for (Ant a: l) {
    ll cur = (t-a.p-1+m)/m;
    left+=num+cur;
  }
  for (Ant a: r) {
    ll cur = num-(t+a.p)/m;
    left+=cur;
  }
  left%=n;
  for (int i=0;i<n;i++) {
    int j = all[(left+i)%n].i;
    ans[j] = after[i].p+1;
  }
  for (int i=0;i<n;i++) printf("%d\n",ans[i]%m);


  return 0;
}


Measured memory_bytes: 4288
'''
INPUT SHORTCUTS
N, K = map(int,input().split())
N ,A,B = map(int,input().split())
string = str(input())
arr = list(map(int,input().split()))
N = int(input())
'''
N,M = map(int,input().split())
sub = [ -1 for _ in range(N) ]
penalty = 0
score = 0
for _ in range(M):
	p , s = map(str,input().split())
	p = int(p)
	if s=='WA':
		if sub[p-1]==-1:
			sub[p-1]=1
		elif sub[p-1]>=1:
			sub[p-1]+=1
	elif s=='AC':
		if sub[p-1]==-1:
			score+=1
			sub[p-1]=0
		elif sub[p-1]>=1:
			penalty+=sub[p-1]
			score+=1
			sub[p-1]=0
print(score,penalty)

Measured memory_bytes: 51872
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define tri pair<pll, ll>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<pll, ll> > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define all(v)  (v).begin(), (v).end()
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) (ll)v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
// using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll cpow(ll a, ll b, ll M){ll ans = 1;while(b){if(b&1) ans = ans*a%M; b/=2;a=a*a%M;}return ans;}
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}
ll fexp(ll a, ll b) {return cpow(a, b, MOD);}
ll cinv(ll a, ll p){return cpow(a, p-2, p);} 
ll inverse(ll a)    {return cinv(a, MOD);}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
        ll n, m, k;
        cin>>n>>m>>k;
        rep(i, n+1){
            rep(j, m+1){
                if(i*(m-j) + j*(n-i) == k)  {cout<<"Yes";return 0;}
            }
        }
        cout<<"No";
    }
}

Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from itertools import product
    L=input()
    dp=[1,0]
    for d in range(len(L)):
        ndp=[0,0]
        Ld=int(L[d])
        for lt,a,b in product(range(2),repeat=3):
            nlt=lt
            if(a==1 and b==1): continue
            if(lt==0 and (a==1 or b==1) and Ld==0): continue
            if(a==0 and b==0 and Ld==1): nlt=1
            ndp[nlt]+=dp[lt]
            ndp[nlt]%=MOD
        dp=ndp
    print(sum(dp)%MOD)
resolve()

Measured memory_bytes: 43612
#import collections
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    a= list(map(int, input().split()))
    a.sort()
    ans = 0
    flag = [1]*(10**6+1)
    for i in range(n):
        if (flag[a[i]]==0):
            continue
        tmp = a[i]
        while tmp < 10**6+1:
            flag[tmp] = False
            tmp += a[i]
        if i<n-1:
            if (a[i+1]==a[i]):
                continue
        ans += 1
    #x = collections.Counter(a)
    #ans = 0
    #for i in a:
        #if (flag[i]==1):
            #ans += 1
            #flag[i]=0
            #if (x[i]>1):
                #ans -=1
    print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 109072
import sys
while True:
    n=input()
    if n==0:
        break
    magic=[[0 for i in range(n)] for j in range(n)]
    i=n/2
    j=n/2+1
    for number in range(1,n*n+1):
        magic[j][i]=number
        if number==n*n:
            break
        if magic[(j+1)%n][(i+1)%n]==0:
            i,j=(i+1)%n,(j+1)%n
        else:
            i,j=(i+1)%n,(j+1)%n
            while magic[j][i]!=0:
                i,j=(i-1)%n,(j+1)%n
    for i in range(n):
        print "".join(["%4d" %(e) for e in magic[i]])

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

int  main()
{
	char a; cin >> a;
	if (islower(a))
		cout << "a" << endl;
	else 
		cout << "A" << endl;
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int s(int x)
{
	int re=0;
	while(x)
	{
		re+=x%10;
		x/=10;
	}
	return re;
}
int main()
{
	int n;
	cin>>n;
	if(n%s(n)==0)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    int main(){
        int n,ans;
        double t,h,a,curr_min=10000000;
        cin>>n>>t>>a;
        for(int i=1;i<=n;i++){
            cin>>h;
            if(abs(t-0.006*h-a)<curr_min) {ans=i; curr_min=abs(t-0.006*h-a);}
        }
        cout<<ans; 
    }

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, N, A[200002];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(A[i]));
	A[N+1] = 0;
	
	long long ans = 0;
	if (A[1] != 0) ans = -1;
	else {
		for (i = 2; i <= N + 1; i++) {
			if (A[i] >= A[i-1] + 2) {
				ans = -1;
				break;
			} else if (A[i] <= A[i-1]) ans += A[i-1];
		}
	}
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2508
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn = 1010;
int n;
LL x[maxn],y[maxn],u[maxn],v[maxn],bs[35];

void work() {
cin >> n;
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
    LL sum = (x[0] + y[0]) % 2;
    for (int i = 0; i < n; i++) if ((x[i] + y[i] - sum) % 2 != 0) {cout<<"-1"<<endl;return;}

    if (sum == 0) {
        cout << 32 << endl;
        for (int i = 30; i > -1; i--) cout << bs[i] << " ";
        cout << 1 << endl;
        for (int i = 0; i < n; i++) x[i]++;
    } else {
        cout << 31 << endl;
        for (int i = 30; i > -1; i--) cout << bs[i] << " ";
        cout << endl;
    }

    for (int i = 0; i < n; i++) u[i] = x[i] + y[i], v[i] = x[i] - y[i];

    for (int i = 0; i < n; i++) {
        for (int j = 30; j > -1; j--) {
            if (u[i] > 0 && v[i] > 0) {cout << 'R'; u[i] -= bs[j]; v[i] -= bs[j]; }
            else if (u[i] > 0 && v[i] < 0) { cout << 'U'; u[i] -= bs[j]; v[i] += bs[j]; }
            else if (u[i] < 0 && v[i] > 0) { cout << 'D'; u[i] += bs[j]; v[i] -= bs[j]; }
            else { cout << 'L'; u[i] += bs[j]; v[i] += bs[j];}
        }
        if (sum == 0) cout << 'L';
        cout << endl;
    }
}
int main(){
    bs[0] = 1;
    for (int i=1;i<32;i++) bs[i] = bs[i-1] << 1;
    work();
    return 0;
}


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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define X first
#define Y second
#define pb push_back
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define int long long

const LL mod = 1e9 + 7;


template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }

template<class T, class U>
istream& operator >> (istream& in, pair<T, U> & v){ in >> v.X >> v.Y;return in; }

template<class T, class U>
ostream& operator << (ostream& out, pair<T, U> & v){ out << v.X << " " << v.Y;return out; }

void chkmax(int &a, int b) {
    a = max(a, b);
    return;
}

void chkmin(int &a, int b) {
    a = min(a, b);
    return;
}

LL ppow (LL x, LL s) {
    if (!s) return 1;
    if (!(s - 1)) return x % mod;
    if (s % 2) return (x * ppow (x, s - 1)) % mod;
    LL b = ppow (x, s / 2);
    return (b * b) % mod;
}

vector<vector<int> > gr;


main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("ILUXA.in", "r", stdin);
    int n;
    cin >> n;
    gr.resize(n);

    int X, Y;
    cin >> X >> Y;
    X--;Y--;

    for (int i = 0;i < n - 1;i++) {
        int a, b;
        cin >> a >> b;
        gr[--a].pb(--b);
        gr[b].pb(a);
    }

    queue<int> q;

    q.push(X);
    vector<int> dx(n, -1), dy(n, -1);

    dx[X] = 0;

    dy[Y] = 0;

    while (q.size()) {
        auto cur = q.front();
        q.pop();
        for (auto x : gr[cur]) {
            if (dx[x] == -1) {
                dx[x] = dx[cur] + 1;
                q.push(x);
            }
        }
    }

    q.push(Y);

    while (q.size()) {
        auto cur = q.front();
        q.pop();

        for (auto x : gr[cur]) {
            if (dy[x] == -1) {
                dy[x] = dy[cur] + 1;
                q.push(x);
            }
        }
    }

    int ans = 0;

    for (int i = 0;i < n;i++) {
        if (dx[i] < dy[i]) {
            int cur = dx[i];
            int d = dy[i] - dx[i];
            cur += d - 1;
            chkmax(ans, cur);
        }
    }

    cout << ans;



    return 0;
}




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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

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

    vector<ll> seq(n);
    for (auto &i : seq)
        cin >> i;

    ll cnt = 0;
    for (int i = 1; i < n; ++i) {
        ll t = seq[i - 1] + seq[i];
        if (t > x) {
            if(seq[i] >= (t - x)) {
                cnt += t - x;
                seq[i] -= (t - x);
            } else {
                cnt += seq[i];
                t -= seq[i];
                seq[i] = 0;
                cnt += t - x;
                seq[i - 1] -= (t - x);
            }
        }
    }

    cout << cnt << endl;

    return 0;
}

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



int main() {
	string S;
	cin >> S;
	rep(0, S.size()) {
		cout << 'x';
	}
	cout << endl;
}


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

int compare_string1(const void *a, const void *b) {
  return *(char *)a-*(char *)b;
}

int compare_string2(const void *a, const void *b) {
  return *(char *)b-*(char *)a;
}

int main(){
	
	char s[110],t[110];
	
	scanf("%s",s);
	scanf("%s",t);
	
	qsort(s,strlen(s),sizeof(char),compare_string1);
	qsort(t,strlen(t),sizeof(char),compare_string2);
	
	if(strcmp(s,t)<0){
		printf("\nYes\n\n");
	}else {
		printf("\nNo\n\n");
	}
	
	
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6;
const ll mod=1e9+7;
int main()
{
    int n;
    while(cin>>n)
    {
        int minn=1e9+1;
        int maxx=0;
        for(int i=0;i<n;i++)
        {
            int a;
            cin>>a;
            if(i==0)
            {
                minn=a;
                maxx=a;
            }
            minn=min(minn,a);
            maxx=max(maxx,a);
        }
        cout<<maxx-minn<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<pair<pair<string, int>,int>>p(n);
  for (int i=0; i<n; i++){
    cin>>p[i].first.first>>p[i].first.second;
    p[i].first.second *= -1;
    p[i].second = i+1;
  }
  sort(p.begin(), p.end());
  for (int i=0; i<n; i++){
    cout << p[i].second << endl;
  }
}

Measured memory_bytes: 3608