akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            String[] tokens = in.nextLine().split(" ");
            out.print(tokens[1] + tokens[0]);
        }

    }
}



Measured memory_bytes: 22740
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <complex>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack> 
#include <bitset>
#include <queue>
#include <assert.h>
using namespace std;

int main() {
	char s[111];
	cin >> s;
	cout << s[0] << s[1] << s[2] << endl;
	return 0;
}


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

int main()
{
  int n;
  cin >> n;
  
  int max = 1;
  int min = pow(10, 9);
  rep(i, n)
  {
    int tmp;
    cin >> tmp;
    
    if (max < tmp)
    {
      max = tmp;
    }
    
    if (min > tmp)
    {
      min = tmp;
    }
  }
  
  cout << max - min << endl;
    
  return 0;
}

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

using namespace std;


int main(){
    int a , b, c;
    cin >> a >> b >> c;
    if(a == b && a == c) cout << "No\n";
    else if(a != b && a != c && b != c) cout << "No\n";
    else cout << "Yes\n";
    return 0;
}

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

using namespace std;

#define ll long long


int main(){
  int n;cin >> n;
  vector<int> v(n);
  for(auto&&e:v)cin >> e;
  sort(v.begin(), v.end());
  if(n%2 == 1){cout << 0 << endl; return 0;}

  int idx = n / 2;
  cout << v[idx] - v[idx - 1] << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef pair < int , int > T;

inline void read(int &x) {
    char ch;
    bool flag = false;
    for (ch = getchar(); !isdigit(ch); ch = getchar())if (ch == '-') flag = true;
    for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
    x = flag ? -x : x;
}


inline void read(long long  &x) {
    char ch;
    bool flag = false;
    for (ch = getchar(); !isdigit(ch); ch = getchar())if (ch == '-') flag = true;
    for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
    x = flag ? -x : x;
}

const int maxn = 310000;
char s[maxn];
int a[maxn];
int  n;

int main() {
    scanf("%s",s);
    n=strlen(s);
    for (int i=0;i<n;i++)
        a[ s[i]-'a' ]++;
    long long ans=1ll*n*(n-1)/2ll+1;
    for (int i=0; i<26;i++)
        ans= ans - 1ll*a[i]*(a[i]-1ll)/2ll;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
#define maxsize 1000005
using namespace std;
int a[1000005];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int m, n;
    cin>>m>>n;
    ll sum=0;
    for (int i=1;i<=n;i++){
        cin>>a[i]; sum+=a[i];}
        
    ll x = m - sum;
    if (x < 0) cout<<-1;
    else cout<<x;
}

Measured memory_bytes: 3676
/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <stdio.h>
int h[20]={};
int main()
{
    int N;
    int count = 1;
    int i = 0;\
    int high = 0;
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&h[i]);
    }
    high = h[0];
    for(i=1;i<N;i++){
      if(h[i]<high){
          
      }
      else{
          high = h[i];
          count++;
      }
    }
    printf("%d", count);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 int main (){
     int64_t n,k;
     cin >> n >> k;
   int64_t t=n%k;
   int64_t ans;
   ans =min(t,abs(k-t));
   cout << ans << endl;
   return 0;
 }

Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

vector<int> G[200010];
int P[200010];
bool C[200010];
int T[200010];

int dfs(int n) {
	set<int> M;
	for (int i = 0;i < G[n].size();i++) {
		if (T[G[n][i]] == -1) T[G[n][i]] = dfs(G[n][i]);
		M.insert(T[G[n][i]]);
	}
	for (int i = 0;;i++) {
		if (M.find(i) == M.end()) {
			T[n] = i;
			return i;
		}
	}
	return -1;
}

int main() {
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    for (int i = 0;i < N;i++) {
    	cin >> P[i];
    	P[i]--;
    	G[P[i]].push_back(i);
    }
    // Find circle.
    int r = 0;
    for (int i = 0;i < N;i++) r = P[r];
    memset(C, 0, sizeof(C));
    while (!C[r]) {
    	C[r] = 1;
    	r = P[r];
    }
    for (int i = 0;i < N;i++) T[i] = -1;
    // Assign all nodes not on circle.
    for (int i = 0;i < N;i++) {
    	if (T[i] == -1 && C[i] == 0) T[i] = dfs(i);
    }
    int q = 0;
    for (int i = 0;i < N;i++) {
    	if (C[i] == 1) {
    		q = i;
    		break;
    	}
    }
    set<int> R;
    for (int i = 0;i < G[q].size();i++) {
    	R.insert(T[G[q][i]]);
    }
    int v = 0;
    for (int i = 0;;i++) {
    	if (R.find(i) == R.end()) {
    		v = i;
    		T[q] = v;
    		break;
    	}
    }
    // Try assign crt value.
    int now = P[q];
    int ls;
    while (now != q) {
    	int tmp = dfs(now);
    	ls = now;
    	now = P[now];
    }
    if (T[ls] != T[q]) {
    	cout << "POSSIBLE" << endl;
    	return 0;
    }
    for (int i = 0;i < N;i++) {
    	if (C[i] == 1) T[i] = -1;
    }
    T[q] = v + 1;
    now = P[q];
    while (now != q) {
    	int tmp = dfs(now);
    	ls = now;
    	now = P[now];
    }
    if (T[ls] == v) {
    	cout << "POSSIBLE" << endl;
    	return 0;
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

#define xin() main()
#define ru(a) if(a)
#define ruguo(a) else if(a)
#define baai(a) while(a)
#define sai(j,n) for(sei j=0;j<sei(n);++j)
#define gsai(j,n) for(sei j=sei(n)-1;j>=0;--j)
#define kan(j,m,n) for(sei j=m;j<sei(n);++j)
#define gkan(j,m,n) for(sei j=sei(n)-1;j>=sei(m);--j)
#define ta else
#define datu break
#define zi continue;
#define hen return
#define zen(h) (h).begin(),(h).end()
#define seiri(h) sort(zen(h))
#define yu(h) h.erase(unique(zen(h)), h.end())
#define gyaku(a) reverse(zen(a))
#define katu &&
#define mata ||
#define nyu(a) cin >> a
#define syutu(a) cout << a << endl
#define tuika(a,b) a.push(b)
#define huka(a,b) a.push_back(b)
#define tou(a) a.top()
#define kuu(a) a.empty()
#define xya(a) a.pop()
#define cyou(a) a.size()
#define tyou(a) a.length()
#define sen first
#define go second
#define kouzoutai struct
#define kigou operator
#define sin true
#define gi false
#define tei const
#define mugen 10000000111
#define yo 10000000711
#define kyou 1e-9

using namespace std;

typedef int seisu;
typedef void mu;
typedef long long sei;
typedef long double xyo;
typedef string moji;
typedef pair<sei, sei> so;
typedef pair<xyo, xyo> sox;
typedef vector<sox> hsox;
typedef vector<sei> hs;
typedef vector<hs> hhs;
typedef vector<xyo> hx;
typedef vector<hx> hhx;
typedef vector<moji> hm;
typedef vector<so> hso;
typedef vector<hso> hhso;
typedef bool singi;
typedef vector<singi>  hsi;
typedef vector<hsi> hhsi;
typedef priority_queue<sei> nibungi;

const seisu h1[8] = {1,1,0,-1,-1,-1,0,1};
const seisu h2[8] = {0,1,1,1,0,-1,-1,-1};

sei dai(sei a, sei b){return max(a,b);}
sei syou(sei a, sei b){return min(a,b);}

sei x1, z1, x2, y2, x3, y3, x4, y4;

mu kai(){
    sei ou = x2 - x1;
    sei zyuu = y2 - z1;
    x3 = x2 - zyuu;
    y3 = y2 + ou;
    x4 = x1 - zyuu;
    y4 = z1 + ou;
}

seisu xin(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    nyu(x1);
    nyu(z1);
    nyu(x2);
    nyu(y2);
    kai();
    syutu(x3);
    syutu(y3);
    syutu(x4);
    syutu(y4);
    hen 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N=int(input())
S=input()

list1=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
list2=[]
for i in range(1,N):
    
    count=0
    for j in range(26):
        if S[:i].count(list1[j])>=1 and S[i:].count(list1[j])>=1:
            count=count+1
    list2.append(count)
#print(S[:3])
#print(S[4:])
#print(list2)
print(max(list2))

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()

# dp[日数][今回ABCのどれにしたか] = その時点での最大値
dp = [[0] * 3 for i in range(N)]
dp[0][0], dp[0][1], dp[0][2] = MAP()

for i in range(N-1):
    abc = LIST()
    # 送り元ループ
    for j in range(3):
        # 送り先ループ
        for k in range(3):
            # 今回と同じ所には送れない
            if j != k:
                dp[i+1][k] = max(dp[i][j] + abc[k], dp[i+1][k])
# 最終日にABCどれにしたかの最大を取る
print(max(dp[N-1]))


Measured memory_bytes: 79336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/


int main(){
    int N; cin >> N;
    string s; cin >> s;

    int red = 0, blue = 0;

    for(int i=0; i<N; i++){
        if(s[i] == 'R') red++;
        else blue++;
    }

    if(red > blue) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
	int score;
	int total_a = 0, total_b = 0;
	for(int i=0; i < 4; i++){
		cin >> score;
		total_a += score;
	}
	for(int i=0; i < 4; i++){
		cin >> score;
		total_b += score;
	}
	cout << max(total_a, total_b) << endl;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;

char data[2048][2048];
int danger[2048][2048];
struct Pt{int w, h;};
//int stk[2048];
int biggest[2048];
Pt stk[2048];
static inline void handle(int& top, int& ans, int a, int b, int h)
{
  while (top > 1 && h < stk[top-1].h)
  {
    int w = a - stk[top-2].w;
    int h = stk[top-1].h;
    int s = w * h;
    if (s > ans) ans = s;
    --top;
  }
  stk[top++] = {b, h};
}
int main()
{
  int h, w; scanf("%d %d", &h, &w);
  while (getchar() != '\n');
  for (int i = 0; i < h; ++i) fgets(data[i], 2048, stdin);
  for (int i = 1; i < h; ++i)
    for (int j = 1; j < w; ++j)
    {
      int c = 0;
      c ^= data[i-1][j-1] == '#';
      c ^= data[i-1][j] == '#';
      c ^= data[i][j-1] == '#';
      c ^= data[i][j] == '#';
      danger[i][j] = c;
    }
  int ans = max(h, w);
  for (int i = 1; i < h; ++i)
  {
    for (int j = 1; j < w; ++j)
    if (danger[i][j]) biggest[j] = i;
    int top = 0;
    int total = 0;
    stk[top++] = {0, 0};
    for (int j = 0; j < w;)
    {
      if (biggest[j] > 0) handle(top, ans, j, j, i - biggest[j] + 1);
      int k = j;
      while (k + 1 < w && biggest[k+1] == 0) ++k;
      handle(top, ans, j, k + 1, i + 1);
      j = k + 1;
    }
    while (top > 1)
    {
      --top;
      int s = stk[top].h * (w - stk[top-1].w);
      if (s > ans) ans = s;
    }
  }
  printf("%d\n", ans);
  return 0;
}

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

int main(){
  	string s;
  	int i;
  	cin >> s;
  	i = s.size();
  	if ( s[i-1] == 's'){
      cout << s << "es";
    }
  	else 
      cout << s << "s";
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
using namespace std;

int main()
{
    int x1, x2, y1, y2;
    while(~scanf("%d%d%d%d", &x1, &y1, &x2, &y2))
    {
        int a = x2 - x1, b = y2 - y1;
        int x3 = x2 - b, y3 = y2 + a;
        int x4 = x1 - b, y4 = y1 + a;
        printf("%d %d %d %d\n", x3, y3, x4, y4);
    }
    return 0;
}


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

int main() {
  int A , B ;
  cin >> A >> B ;
  int ans=0;
  for(int i=A; i<=B; i++){
    int a,b,c,d;
    a = i/10000;
    b = i%10;
    c = (i/1000)%10;
    d = (i%100)/10;
    if(a == b && c == d){
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main() {
    int X;
    cin>>X;
    int nokori;
    bool ans = false;
    for(int i=0;i<=X/100;++i){
        nokori = X - 100*i;
        if(nokori==0){
            ans = true;
            break;
        }
        for(int j=0;j<=nokori/101;++j){
            nokori -= 101*j;
            if(nokori==0){
                ans = true;
                break;
            }
            for(int k=0;k<=nokori/102;++k){
                nokori -= 102*k;
                if(nokori==0){
                    ans = true;
                    break;
                }
                for(int l=0;l<=nokori/103;++l){
                    nokori -= 103*l;
                    if(nokori==0){
                        ans = true;
                        break;
                    }
                    for(int m=0;m<=nokori/104;++m){
                        nokori -= 104*m;
                        if(nokori%105==0){
                            ans = true;
                            break;
                        }
                    }
                }
            }
        }
    }
    if(ans)cout<<1<<endl;
    else cout<<0<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define double long double

const double PI = acosl(-1.0l);

double a, b, h, m;

int32_t main()
{
	IOS;
	cin >> a >> b >> h >> m;
	double angle1 = (2 * PI) / 12 * h;
	double angle2 = (2 * PI) / 60 * m;
	angle1 += (2 * PI) / (12 * 60) * m;
 	double diff = angle1 - angle2;
	if(diff < 0)
		diff += 2 * PI;
	if(diff == PI)
		cout << a + b;
	else
	{
		double ans = a * a + b * b - (2 * a * b * cos(diff));
		ans = sqrtl(ans);
		cout << fixed << setprecision(12) << ans;
	}
	return 0;
}

Measured memory_bytes: 4184
import bisect
from collections import Counter
import sys


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


n, m = LI()
a = LI()
a = sorted(a)[::-1]
bc = LIR(m)
bc = sorted(bc, key=lambda x: x[1])[::-1]
all_c = []
for bi, ci in bc:
    all_c += [ci] * bi
    if len(all_c) >= n:
        break
if len(all_c) < n:
    all_c += [0] * (n - len(all_c))

ans = 0
a_i = 0
c_i = 0
for _ in range(n):
    if a[a_i] > all_c[c_i]:
        ans += a[a_i]
        a_i += 1
    else:
        ans += all_c[c_i]
        c_i += 1
print(ans)


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

public class Main {
	static final Reader in = new Reader();
	static final PrintWriter out = new PrintWriter(System.out);
	
	public static void main(String[] args) {
		int n=in.nextInt(), m=in.nextInt();
		long[] a = new long[n];
		for(int i=0; i<n-1; ++i)
			a[i]=in.nextInt();
		long[][] b = new long[n][m];
		for(int i=0; i<n; ++i)
			for(int j=0; j<m; ++j)
				b[i][j]=in.nextInt();
		SegTree st = new SegTree(n);
		long[] ini = new long[n], mx1 = new long[m];
		long ps=0, ans=0;
		for(int i=0; i<n; ++i) {
			for(int j=0; j<m; ++j)
				ini[i]+=mx1[j]=Math.max(b[i][j], mx1[j]);
			ini[i]-=ps;
			ps+=a[i];
		}
		st.build(ini);
		int[][] nxt = new int[n][m];
		for(int i=n-1; i>=0; --i) {
			for(int j=0; j<m; ++j) {
				nxt[i][j]=i+1;
				while(nxt[i][j]<n&&b[nxt[i][j]][j]<b[i][j])
					nxt[i][j]=nxt[nxt[i][j]][j];
			}
		}
		ps=0;
		for(int i=0; i<n; ++i) {
			ans=Math.max(st.get(i, n-1)+ps, ans);
			for(int j=0; j<m; ++j) {
				st.add(i, nxt[i][j]-1, -b[i][j]);
				for(int k=i+1; k<n&&b[k][j]<b[i][j]; k=nxt[k][j])
					st.add(k, nxt[k][j]-1, b[k][j]);
			}
			ps+=a[i];
		}
		out.println(ans);
		out.close();
	}
	
	static class SegTree {
		int n, l1, r1;
		long v;
		long[] a, lazy;
		SegTree(int n) {
			this.n=n;
			a = new long[4*n];
			lazy = new long[4*n];
		}
		void build(long[] b) {
			build2(1, 0, n-1, b);
		}
		private void build2(int i, int l2, int r2, long[] b) {
			if(l2<r2) {
				int mid=(l2+r2)/2;
				build2(2*i, l2, mid, b);
				build2(2*i+1, mid+1, r2, b);
				a[i]=Math.max(a[2*i], a[2*i+1]);
			} else
				a[i]=b[l2];
		}
		void add(int l, int r, long x) {
			l1=l;
			r1=r;
			v=x;
			add2(1, 0, n-1);
		}
		private void add2(int i, int l2, int r2) {
			if(l1<=l2&&r2<=r1) {
				a[i]+=v;
				if(l2<r2) {
					lazy[2*i]+=v;
					lazy[2*i+1]+=v;
				}
			} else {
				int mid=(l2+r2)/2;
				push(i*2, l2, mid);
				push(i*2+1, mid+1, r2);
				if(l1<=mid)
					add2(i*2, l2, mid);
				if(mid<r1)
					add2(i*2+1, mid+1, r2);
				a[i]=Math.max(a[i*2], a[i*2+1]);
			}
		}
		void push(int i, int l, int r) {
			a[i]+=lazy[i];
			if(l<r) {
				lazy[2*i]+=lazy[i];
				lazy[2*i+1]+=lazy[i];
			}
			lazy[i]=0;
		}
		long get(int l, int r) {
			l1=l;
			r1=r;
			return get2(1, 0, n-1);
		}
		private long get2(int i, int l2, int r2) {
			push(i, l2, r2);
			if(l1<=l2&&r2<=r1)
				return a[i];
			else {
				int mid=(l2+r2)/2;
				long res=Long.MIN_VALUE;
				if(l1<=mid)
					res = Math.max(get2(2*i, l2, mid), res);
				if(mid<r1)
					res = Math.max(get2(2*i+1, mid+1, r2), res);
				return res;
			}
		}
	}
	
	static class Reader {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		
		String next() {
			while(st==null||!st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch(Exception e) {}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}

Measured memory_bytes: 69364
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>

using namespace std;

int main() {
	int I, O, T, J, L, S, Z;
	scanf("%d %d %d %d %d %d %d", &I, &O, &T, &J, &L, &S, &Z);
	int delta = min(min(I, J), L);
	long long cur = 0;
	for (int i = delta; i >= 0 && i >= delta - 1; i--) {
		cur = max(cur, (I - i) / 2 * 2 + (J - i) / 2 * 2 + (L - i) / 2 * 2 + i * 3LL);
	}
	cout << cur + O << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())

a = list(map(int,input().split()))
i = 1
j = 1
c = 0
while(j <= n):
    if(a[j-1] == i):
        i += 1
    else:
        c += 1
    j += 1
if(c == n):print(-1)
else:print(c)


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  rep(i, h) rep(j, w) {
    if(i < b && j < a) cout << '0';
    else if (i >= b && j >= a) cout << '0';
    else cout << '1';
    if(j == w - 1) cout << '\n';
  }
  return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
const int maxn=1e5+5;
int a[maxn];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	if(n%2==1){
		puts("0");
		return 0;
	}
	sort(a+1,a+n+1);
	int ans=a[n/2+1]-a[n/2];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
using namespace std;
//using namespace __gnu_pbds;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long 
#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,arr,n) for(int i=arr;i<=n;i++)
#define repd(i,arr,n) for(int i=arr;i>=n;i--)
#define trav(arr,x) for(auto& arr:x)
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(arr) arr.size()
#define pi 3.14159265358979323846
#define MAX (1000*1000*1000+7)
#define vi vector<int>
#define pii pair<int,int>
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int,vi,greater<int> >
//#define endl "\n"
 
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const int mod=1e10+7;
int power(int a,int b)
{
    int ans=1;
    while(b)
    {
        if(b&1)
        {
            ans=(ans*a);
        }
        a=(a*a);
        b>>=1;
    }
    return ans;
}

int32_t main()
{
    fast;

    int a,b,c,k;
    cin>>a>>b>>c>>k;

    int ans=0;
    while(k>0)
    {
        if(a>0)
        {
            ans+=min(a,k);
            k-=min(a,k);
            a=0;
        }
        else if(b>0)
        {
            k-=min(b,k);
            b=0;   
        }
        else if(c>0)
        {
            ans-=min(c,k);
            k-=min(c,k);
            c=0;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
using namespace std;
int N, W, s[200009];
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> N >> W;
	int ret = 0;
	for (int i = W / 2 + 1; i < W; i++) {
		for (int j = 2 * i - W + 1, k = 1; j <= N - W + 1 || k == 1; j += i, k++) {
			int l = j, r = j + W - i;
			if (j == 2 * i - W + 1) l = 1;
			s[l]++, s[r]--;
		}
	}
	for (int i = 1; i <= N - W + 1; i++) {
		if (i >= 2) cout << ' ';
		s[i] += s[i - 1];
		cout << s[i] + W / 2 + min(i, W);
	}
	cout << "\n";
	return 0;
}


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

typedef complex<double> P;

const double eps = 1e-8;

double dot(P a, P b) {
  return a.real()*b.real() + a.imag()*b.imag();
}

double cross(P a, P b) {
  return a.real()*b.imag() - a.imag()*b.real();
}

P getCrossP(P a1, P a2, P b1, P b2) {
  P a = a2 - a1;
  P b = b2 - b1;
  return a1 + a * cross(b, b1 - a1) / cross(b, a);
}

int ccw(P p, P a, P b) {
  a -= p;
  b -= p;
  if (cross(a, b) > eps) return 1;
  if (cross(a, b) < -eps) return -1;
  if (dot(a, b) < -eps) return 2;
  if (norm(b) - norm(a) > eps) return -2;
  return 0;
}

vector<P> convex_cut(vector<P> ps, P p1, P p2, int dir = -1) {
  vector<P> v;
  for (int i = 0; i < ps.size(); ++i) {
    P a = ps[i];
    P b = ps[(i + 1) % ps.size()];
    if (ccw(p1, p2, a) != dir) v.push_back(a);
    if (ccw(p1, p2, a) * ccw(p1, p2, b) == -1)
      v.push_back(getCrossP(a, b, p1, p2));
  }
  return v;
}

int n;
vector<P> ps;

bool ok(double d) {
  vector<P> g = ps;
  for (int i = 0; i < n; ++i) {
    P a = ps[i];
    P b = ps[(i + 1) % ps.size()];
    P base = b - a;
    P nv = base * P(0, 1);
    nv = nv * d / abs(nv);
    g = convex_cut(g, a + nv, b + nv);
  }
  return g.size() >= 1;
}

int main() {
  for (; cin >> n && n; ) {
    ps = vector<P>(n);
    for (int i = 0; i < n; ++i) {
      cin >> ps[i].real() >> ps[i].imag();
    }
    double l = 0, r = 10000000;
    for (int step = 0; step < 100; ++step) {
      double d = (l + r) / 2.0;
      if (ok(d)) {
        l = d;
      } else {
        r = d;
      }
    }
    printf("%.10f\n", l);
  }
  return 0;
}

Measured memory_bytes: 1284
import itertools

def main():
	d, g = list(map(int, input().split()))
	problems = [list(map(int, input().split())) for _ in range(d)]

	ptns = list(itertools.product([0, 1], repeat = d))

	ans = 10 ** 10

	for pt in ptns:
		rest = g - sum([((i + 1) * 100 * problems[i][0] + problems[i][1]) * pt[i] for i in range(d)])
		tmp = sum([problems[i][0] * pt[i] for i in range(d)])
		
		if rest > 0:
			if 0 in pt:
				rest_max_idx = d - pt[::-1].index(0) - 1
				#print(pt, tmp, rest_max_idx, rest)
				for i in range(problems[rest_max_idx][0]):
					rest -= (rest_max_idx + 1) * 100
					tmp += 1
					if rest <= 0:
						break

		if rest <= 0:
			ans = min(ans, tmp)

	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main()
{
    Hello
    ll n, mn = 1e12;
    cin >> n;
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            ll sec = n/i;
            mn = min(mn, i + sec - 2);
        }
    }
    cout << mn;
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<vector>
#include<utility>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<limits>
#include<bitset>      


#define LL long long
#define f first
#define s second
#define pb push_back
#define mp make_pair


using namespace std;



int main() {

    int n, m;
    cin >> n >> m;

    


    vector<int> a(m), v;

    for(int i = 0; i < m ; i++){
         cin >> a[i];
      } 
    
    sort(a.begin(), a.end());

    for(int i = 1; i < m; i++){
         v.pb(a[i]-a[i-1]);
      }
    

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

    LL res = 0;
    int L = v.size() - (n - 1);

    for(int i = 0; i < max(0,L); i++){
         res += v[i];
      }
    

    cout << res;


    
    
    




    
    return 0;
}

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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, val;
  long long sum = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> val;
    sum += (long long)val;
  }
  if (sum > (long long)n) {
    cout << "-1\n";
  }else{
    cout << ((long long)n - sum) << '\n';
  }
  return 0;
}

Measured memory_bytes: 3624
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
using namespace std;

int main(){
  int n,k;
  cin >> n >> k;
  int ans = 0;
  REP(i,n){
    int x;
    cin >> x;
    ans += 2*min(x,k-x);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, char> pi;
#define f first
#define s second
#define pb push_back

ll n, ans, curl;
bool start;
string str;
char pre, cur;
vector <pi> v;

int main() {
	cin >> str;
	n = str.length();
	pre = str[0], curl = 1;
	str += ' ';
	FOR(i, 1, n) {
		cur = str[i];
		if (cur != pre) {
			v.pb(pi(curl, pre));
			curl = 0;
		}
		curl++;
		pre = cur;
	}
	FOR(i, 0, v.size()-1) {
		ans += (v[i].f * (v[i].f+1))/2;
		if (i != v.size()-1 and v[i].s == '<') ans -= min(v[i].f, v[i+1].f);
	}
	cout << ans;
}


Measured memory_bytes: 6648
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, k; cin >> n >> k ;
    vector<int> a(n);
    for(int i=0; i<n; ++i){cin >> a[i];}
    
    int l = 0; int r = 1000100010; 
    while(r-l>1){
        int mid = (r+l)/2;
        int cut = 0;
        for(int i=0; i<n; ++i){
            if(a[i]==mid){continue;}
            cut += (a[i]/mid); 
        }
        if(cut<=k){r = mid;}
        else{l = mid;}
    }
    cout << r << endl;
    return 0;
}

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

const int INF = 1000;
typedef pair<int, int> P;

#define MAX_N 20
#define MAX_M 20

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

char maze[MAX_N][MAX_M];
int N, M;
int sx, sy, gx, gy;

int d[MAX_N][MAX_M];

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

int bfs() {
    queue<P> que;
    for (int i=0; i<N; ++i) {
        for (int j=0; j<M; ++j) {
            d[i][j] = INF;
        }
    }
    que.push(P(sx, sy));
    d[sx][sy] = 0;

    while (que.size()) {
        P p = que.front(); que.pop();
        if (p.first == gx && p.second == gy) break;
        for (int i=0; i<4; ++i) {
            int nx = p.first + dx[i], ny = p.second + dy[i];
            if (0<=nx && nx<N && 0<=ny && ny<M && maze[nx][ny]!='#' && d[nx][ny]==INF) {
                que.push(P(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    return d[gx][gy];
}

int main() {
    cin >> N >> M;
    for (int i=0; i<N; ++i) {
        for (int j=0; j<M; ++j) {
            char a;
            cin >> a;
            // if (a=='S') {
            //     sx = i, sy = j;
            // }
            // if (a=='G') {
            //     gx = i, gy = j;
            // }
            maze[i][j] = a;
        }
    }
    int res = 0;
    for (int i=0; i<N; ++i) {
        for (int j=0; j<M; ++j) {
            for (int k=0; k<N; ++k) {
                for (int l=0; l<M; ++l) {
                    // setting start and goal
                    if (maze[i][j] != '#' && maze[k][l] != '#') {
                        sx = i, sy = j;
                        gx = k, gy = l;
                    } else {
                        continue;
                    }

                    chmax(res, bfs());
                }
            }
            // reset start and goal
        }
    }
    cout << res << endl;
}

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> d(K),x(N,0);
  vector<vector<int>> A(K, vector<int>(N, -1));
  for(int i=0;i<K;i++){
    cin >> d.at(i);
    for(int j=0;j<d.at(i);j++){
      cin >> A.at(i).at(j);
      if(x.at(A.at(i).at(j)-1)==0){
        x.at(A.at(i).at(j)-1)=1;
      }
    }
  }
  int ans=0;
  for(int i=0;i<N;i++){
    if(x.at(i)==0){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;


const int maxV = 300000;
vector<int> G[maxV]; // 頂点情報のみのグラフ

// treeDFS(親, 現在地, 根から現在地までの距離, 根からの最大の距離, 根から最大の距離となる頂点
void treeDFS(int from, int current, int dist, int &maxDist, int &maxVertex) {
    // 距離と終点を更新
    if (dist > maxDist) {
        maxDist = dist;
        maxVertex = current;
    }
    for (auto to : G[current]) {
        // 逆流を防ぐ
        if (to == from) continue;
        treeDFS(current, to, dist + 1, maxDist, maxVertex);
    }
}

int getTreeDiameter() {
    int start = 0, end = 0, maxDist = 0;
    treeDFS(-1, start, 0, maxDist, end);
    start = end, end = 0, maxDist = 0;
    treeDFS(-1, start, 0, maxDist, end);
    //printf("start: %d, end: %d, diameter: %d\n", start, end, maxDist);
    return maxDist;
}

int main(int argc, char const *argv[]) {
  int N, a, b;
  std::cin >> N;
  for(int i=0;i<N-1;i++){
    std::cin >> a >> b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }
  int ans = getTreeDiameter();
  std::cout << (ans%3==1?"Second":"First") << '\n';
  return 0;
}


Measured memory_bytes: 25984
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

int f(int n, int a, int b){
    int t = n/a + (n%a!=0);
    return t*b;
}

signed main(void) {
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    cout << min(f(n,a,b),f(n,c,d)) << endl;

}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  string s, t;
  cin>>s>>t;
  int a, b;
  cin>>a>>b;
  string u;
  cin>>u;
  if(s == u)a--;
  if(t == u)b--;
  cout<<a<<' '<<b<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
/* ちゃんと考えて実装して問題なくACできた時嬉しいよ！！ */
/* 別にできなくても得るものしかないんだわ。挑戦しよう */

int main(void){
    int r;
    cin >> r;
    cout << r*r;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  string str;
  getline(cin , str);
  rep(i,str.size()){
    if(isupper(str[i])){
      str[i] = tolower(str[i]);
    }else if(islower(str[i])){
      str[i] = toupper(str[i]);
    }
  }
cout << str << endl;
  return 0;
}



Measured memory_bytes: 3136
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;
//
typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatrix;
typedef vector< string > SArray;
typedef vector< pii > PArray;
// popcount
inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
Double EPS = 1e-9;
// in range
inline bool in_range(int _v, int _mx, int _mi) { return _mi <= _v && _v < _mx; }
inline bool in_range(Double _v, Double _mi, Double _mx) { return -EPS < _v - _mi && _v - _mx < EPS; }
inline bool in_range(int _x, int _y, int _W, int _H) { return 0 <= _x && _x < _W && 0 <= _y && _y < _H; }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};

int pointW[10], pointK[10];

void solve() {
	sort(pointW, pointW + 10, greater<int>());
	sort(pointK, pointK + 10, greater<int>());
	
	cout << pointW[0] + pointW[1] + pointW[2] << " " << pointK[0] + pointK[1] + pointK[2] << endl;
}

int main() {
	for_(i,0,10) cin >> pointW[i];
	for_(i,0,10) cin >> pointK[i];
	solve();
	return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
int main()
{
	unsigned long long a[87];
	a[0]=2;
	a[1]=1;
	for(int x=2;x<=86;x++)
	a[x]=a[x-1]+a[x-2];
	int n;
	cin>>n;
	cout<<a[n]<<endl;
}

Measured memory_bytes: 256
H,W,D=list(map(int,input().split()))
map_=[[0,0] for _ in range(H*W+1)]
for y in range(H):
    for x,A in enumerate(map(int,input().split())):
        map_[A]=[x+1,y+1]

cost=[0 for _ in range(H*W+1)]
for i in range(D+1,H*W+1):
    cost[i]+=abs(map_[i][0]-map_[i-D][0])+abs(map_[i][1]-map_[i-D][1])+cost[i-D]
Q=int(input())
for i in range(Q):
    L,R=list(map(int,input().split()))
    print(cost[R]-cost[L])

Measured memory_bytes: 17664
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	getline(cin,s);
	for(int i=0;i<s.size();i++){
		if(islower(s[i])) s[i]-=32;
	}
	/*for(int i=0;i<s.size();i++) cout<<s[i];
	cout<<"\n";*/
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3088
/*
 * ２つの整数 x, y を読み込み、それらを値が小さい順に出力するプログラム
 * @author 前島佑介
 * @version 2014/12/2
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

// 3-C ２つの整数 x, y を読み込み、それらを値が小さい順に出力するプログラム
class Main {

	// プログラムのエントリポイント
	public static void main(String[] args) {

		try{
			//キーボードからの入力準備
			BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));

			//入力値を格納する場所を初期化
			String strLine = "";

			//入力値をint型に置き換える場所を0以外で初期化
			int intNum = 1;

			//入力値をint型で保存する場所
			ArrayList<String> strArray = new ArrayList<String>();

			//入力値の取得にループさせる
			while(true) {

				//1行読み込む
				strLine = insBR.readLine();

				//「数字、スペース、数字」となっているStringデータで、２つの数字を昇順にする
				//もし数字が両方０ならnullが返ってくるメソッド
				strLine = NumSort(strLine);

				//入力値が0だったら
				if(strLine == null) {

					//ループから抜ける
					break;
				}

				//入力値を保存
				strArray.add(strLine);
			}

			//ループさせる
			for(int i = 0; i < strArray.size(); i++) {

				//出力
				System.out.println(strArray.get(i));
			}

		//例外処理
		}catch(IOException e) {

			//例外時の出力
			System.out.println(e);
		}catch(NumberFormatException e) {


			//数値以外の入力値で出力
			System.out.println("数値で入力して下さい");
		}
	}

	/**
	 * 「数字、スペース、数字」となっているStringデータで、２つの数字を昇順にする
	 * もし数字が両方０ならnullが返ってくるメソッド
	 * @param strLine
	 * @return strReplacement
	 */
	public static String NumSort(String strLine) {

		//文字列の分割:入力値を" "で分ける
		//分けた文字列はstrLineAry[0]とstrLineAry[1]に分けられる
		String[] strLineAry = strLine.split(" ");


		//returnで返す値を引数で初期化
		String strReplacement = strLine;


		try{
			//大小の比較をするために、int型にキャスト
			int intNum1 = Integer.parseInt(strLineAry[0]);
			int intNum2 = Integer.parseInt(strLineAry[1]);

			//大小の比較で昇順にしたいので、降順なら
			if(intNum2 < intNum1) {

				//入れ替えした数字で文字列を作成
				strReplacement = strLineAry[1] + " " + strLineAry[0];
			}

			if(intNum1 == 0 && intNum2 == 0) {

				strReplacement = null;
			}
		//例外処理
		} catch(NumberFormatException e) {

			//例外時の出力
			System.out.println("数字で入力して下さいNumSort");


		}

		//問題なければ、引数がそのまま入っている。
		//降順だったら、昇順に並び替えられている
		//値が両方０ならnull
		return strReplacement;

	}
}

Measured memory_bytes: 23276
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;
/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
*/

#define MAX 100000
#define SENTINEL 2000000000

struct Card {
    char suit;
    int value;
};

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

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

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

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

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

int main()
{
    struct Card A[MAX], B[MAX];
    int stable = 1;
    int n;
    cin >> n;
    REP(i, n) {
        int v;
        string S;
        cin >> S >> v;
        A[i].suit = B[i].suit = S[0];
        A[i].value = B[i].value = v;
    }
    
    mergeSort(A, n, 0, n);
    quickSort(B, n, 0, n-1);

    REP(i, n) {
        if(A[i].suit != B[i].suit) stable = 0;
    }

    if(stable) cout << "Stable" << endl;
    else cout << "Not stable" << endl;

    REP(i, n) {
        cout << B[i].suit << " " << B[i].value << endl;
    }
    return 0;
}


Measured memory_bytes: 5344
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  x <- (read::String->Int) .concat . words <$> getLine
  putStrLn $ if isSquare x then "Yes" else "No"

isSquare :: Int -> Bool
isSquare n = m * m == n
  where m = intSqrt(n)
intSqrt :: Int -> Int
intSqrt n = floor (sqrt (fromIntegral n))

Measured memory_bytes: 3760
#include <stdio.h>
#include <time.h>
#include <stdlib.h>

int main(void){ 
    char n[10];
    int k=0;
    scanf("%s",n);
    while (n[k] != '\0'){
        if(n[k]!='h' || n[k+1]!='i'){
            printf("No\n");
            return 0;
        }
        k = k + 2;
    }
    printf("Yes\n");
    return 0;
    }
    


Measured memory_bytes: 128
import math
n, d = map(int, input().split())
pos = [list(map(int, input().split())) for i in range(n)]

ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        distance = 0.0
        for k in range(d):
            distance += (pos[i][k] - pos[j][k]) ** 2
        
        distance = math.sqrt(distance)
        if distance.is_integer():
            ans += 1

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,m,s,t;
vector<int>v[300010];
int d[300010];
void bfs(){
	queue<int>q;
	fill(d,d+3*n,INF);
	d[s]=0;
	q.push(s);
	while(!q.empty()){
		int p=q.front();
		q.pop();
		for(int e:v[p]){
			if(d[e]>d[p]+1){
				d[e]=d[p]+1;
				q.push(e);
			}
		}
	}
}
signed main(){
	cin>>n>>m;
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--,b--;
		v[a].pb(b+n);
		v[a+n].pb(b+n+n);
		v[a+n+n].pb(b);
	}
	cin>>s>>t;
	s--,t--;
	bfs();
	cout<<(d[t]==INF?-1:d[t]/3)<<endl;
	return 0;
}


Measured memory_bytes: 19840
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int K = sc.nextInt();

        int sum = 0;
        if (K - A >=0) {
            K -= A;
            sum += A;
        } else {
            System.out.println(K);
            return;
        }

        if (K - B >=0) {
            K -= B;
            sum += B*0;
        } else {
            System.out.println(sum);
            return;
        }

        System.out.println(sum - K);

        return;
    }

}

Measured memory_bytes: 35728