akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	final int WIN = 3, PASS = 1, FAIL = 0, UNKNOWN = 2;
	Scanner scn = new Scanner(System.in);

	int n;

	int den,mon,cab,total;
	byte[] glist;
	int[][] exps;
	boolean[] provedp;

	while(true){
	    den = scn.nextInt();
	    mon = scn.nextInt();
	    cab = scn.nextInt();
	    total = den+mon+cab;

	    if(total == 0)
		break;

	    n = scn.nextInt();

	    glist = new byte[total+1];
	    provedp = new boolean[n];

	    exps = new int[n][4];

	    for(int i=0; i<glist.length; i++)
		glist[i] = UNKNOWN;

	    for(int i=0; i<n; i++) for(int j=0; j<4; j++)
				       exps[i][j] = scn.nextInt();

	    boolean complete = true;

	    while(complete){
		complete = false;
		for(int i=0; i<n; i++)
		    if(provedp[i]){
			continue;
		    }else if(exps[i][WIN] == PASS){
			complete = true;
			for(int j=0; j<3; j++)
			    glist[exps[i][j]] = PASS;
			provedp[i] = true;
		    }else{
			int cnt = 0;
			for(int j=0; j<3; j++)
			    if(glist[exps[i][j]] == PASS)
				cnt++;

			if(cnt == 2){
			    complete = true;
			    for(int j=0; j<3; j++)
				if(glist[exps[i][j]] == UNKNOWN)
				    glist[exps[i][j]] = FAIL;
			    provedp[i] = true;
			}else{
			    for(int j=0; j<3; j++)
				if(exps[i][j] == FAIL){
				    provedp[i] = true;
				    complete = true;
				}
			}
		    }
	    }

	    for(int i=1 ; i<=total; i++){
		System.out.println(glist[i]);
	    }
	}

	
    }
}

Measured memory_bytes: 13000
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 998244353;

using namespace std;

inline ll int max(ll int a,ll int b) { return a>b?a:b; }
inline ll int min(ll int a,ll int b) { return a<b?a:b; }

//const int maxn=

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	for(int i=1,x;i<=5;i++)
	{
		cin>>x;
		
		if(x==0)
			return cout<<i<<endl,0;
	}
	
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,n)  for (int i = 0; i < n; i++)
#define loop(i,a,n)  for (int i = a; i <= n; i++)
#define deb(x) cout << #x << " = " << x <<'\n'
typedef long long ll;

int main(){
    int r;
    cin >> r;
    cout << 2*3.14159265359*r << endl;
}

Measured memory_bytes: 3772
import sys
input = sys.stdin.readline

N, T = map(int, input().split())
t = list(map(int, input().split()))
ans = 0

for i in range(1, N):
    if t[i]>t[i-1]+T:
        ans += T
    else:
        ans += t[i]-t[i-1]

ans += T
print(ans)

Measured memory_bytes: 77648
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val n = in.nextInt
  val k = in.nextLong
  val as = Array.fill(n)(in.nextLong)

  def calcBit(i: Int): Long = {
    val target = 1L << i
    if (as.count(j => (j & target) != 0) > n / 2) 0L else target
  }

  val op = (40 to 0 by -1).foldLeft(0L){(z, i) =>
    (z + calcBit(i)) match {
      case v if v > k => z
      case v => v
    }
  }

  println(as.foldLeft(0L)((z, i) => z + (i ^ op)))
}

Measured memory_bytes: 80532
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		while(true){
			int w = sc.nextInt();
			int h = sc.nextInt();

			if(w == 0 && h == 0){
				break;
			}

			char matrix[][] = new char[h][w];

			for(int i = 0; i < h; i++){
				String input = sc.next();
				for(int j = 0; j < w; j++){
					matrix[i][j] = input.charAt(j);
				}
			}

//			showMatrix(matrix);
			solve(matrix);
		}
	}

	static void solve(char[][] matrix){
		int h = matrix.length;
		int w = matrix[0].length;

		int[][] resultB = new int[h][w];
		int[][] resultW = new int[h][w];

		int black = 0;
		int white = 0;

		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
//				if(matrix[i][j] != '.'){
//					continue;
//				}
				if(matrix[i][j] == 'B'){
					isExNeighbor(matrix, resultB, j, i, 'B');
				}
				if(matrix[i][j] == 'W'){
					isExNeighbor(matrix, resultW, j, i, 'W');
				}
			}
		}

		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(resultB[i][j] == TRUE && resultW[i][j] != TRUE){
					black++;
				}
				else if(resultW[i][j] == TRUE && resultB[i][j] != TRUE){
					white++;
				}
			}
		}


		//debug
//		showMatrix(resultB);
//		showMatrix(resultW);

		System.out.println(black+" "+white);
	}

	static void showMatrix(char[][] matrix){
		for(int i = 0; i < matrix.length; i++){
			for(int j = 0; j < matrix[0].length ; j++){
				System.out.print(matrix[i][j]+" ");
			}
			System.out.println();
		}
		System.out.println();

	}

	static void showMatrix(int[][] matrix){
		for(int i = 0; i < matrix.length; i++){
			for(int j = 0; j < matrix[0].length ; j++){
				System.out.print(matrix[i][j]+" ");
			}
			System.out.println();
		}
		System.out.println();

	}

	static final int TRUE = 2;
	static final int FALSE = 1;
	static final int NOT_VISITED = 0;
	static final int JUDGE = 4;
	static final int DC = 5;
	static void isExNeighbor(char[][] map, int[][] result, int x, int y, char type){
//		System.out.println("x = "+x+" y = "+y);
		int w = map[0].length;
		int h = map.length;

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

//		result[y][x] = JUDGE;
		if(map[y][x] == type){
			result[y][x] = DC;
		}
		else {
			result[y][x] = TRUE;
		}

		for(int i = 0; i < 4; i++){
			int tmpX = x + dx[i];
			int tmpY = y + dy[i];

			if(!inRange(tmpX, tmpY, h, w)){
				continue;
			}

			if(map[tmpY][tmpX] == '.' && result[tmpY][tmpX] == NOT_VISITED){
				isExNeighbor(map, result, tmpX, tmpY, type);
			}
		}
	}

	static boolean inRange(int x, int y, int h, int w){
		if(x >= 0 && x < w && y >= 0 && y < h){
			return true;
		}
		else {
			return false;
		}
	}

}



Measured memory_bytes: 40940
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    X=[int(_) for _ in input().split()]
    sum_x=sum(X)
    ans=0
    if sum_x/n-sum_x//n<0.5:p=sum_x//n
    else:p=sum_x//n+1
    for i in range(n):
        ans+=(X[i]-p)**2
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <limits>
#include <numeric>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
using namespace std;

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

	char field[100][100];
	int Hs[100], Ws[100];
	int H, W;
	int status = 0;

	cin >> H >> W;

	REP(k, H)
	{
		REP(l, W)
		{
			cin >> field[k][l];
		}
	}

	REP(i, H)
	{
		status = 0;
		REP(j, W)
		{
			if (field[i][j] == '#')
			{
				status = 1;
			}
		}
		if (status == 0)
		{
			H = H - 1;
			FOR(k, i, H)
			{
				REP(l, W)
				{
					field[k][l] = field[k + 1][l];
				}
			}
			i--;
		}
	}

	REP(i, W)
	{
		status = 0;
		REP(j, H)
		{
			if (field[j][i] == '#')
			{
				status = 1;
			}
		}
		if (status == 0)
		{
			W = W - 1;
			FOR(k, i, W)
			{
				REP(l, H)
				{
					field[l][k] = field[l][k + 1];
				}
			}
			i--;
		}
	}


	REP(i, H)
	{
		REP(j, W)
		{
			cout << field[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner X = new Scanner(System.in)){
			int oak = X.nextInt();
			System.out.println(calc(oak));
			
		}	
	}
	public static int calc(int oak) {
		if(oak >= 400 && oak <= 599) {
			return 8;
		}else if(oak >= 600 && oak <= 799) {
			return 7;
		}else if(oak >= 800 && oak <= 999) {
			return 6;
		}else if(oak >= 1000 && oak <= 1199) {
			return 5;
		}else if(oak >= 1200 && oak <= 1399) {
			return 4;
		}else if(oak >= 1400 && oak <= 1599) {
			return 3;
		}else if(oak >= 1600 && oak <= 1799) {
			return 2;
		}else if(oak >= 1800 && oak <= 1999) {
			return 1;
		}
		return 0;
	}
}


Measured memory_bytes: 35572
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;

int main(){
    long long int n,ac=0,ans=0;
    cin>>n;
    vector<long long int>a(10000000);
    vector<long long int>b(10000000);
    vector<long long int>c(10000000);
    for(int i=0;i<(n+1)/2;i++){
        cin>>a[i]>>b[i];
        c[2*i]=a[i];
        c[2*i+1]=b[i];
    }
    sort(a.begin(),a.end(),greater<>());
    sort(b.begin(),b.end(),greater<>());
    sort(c.begin(),c.end(),greater<>());
    for(int i=0;i<n;i++){
        if(c[i]==a[ac]){
            if(i%2!=0){
                if(n%2==0){

                }
                else{
                    ans++;
                }
            }
            else{
                if(n%2==0){
                    ans++;
                }
                else{
                }
            }
            ac++;
        }
    }
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 234752
/******************************************
* AUTHOR : SARTHAK GUPTA *
* NICK : SOPHOZAAR *
* INSTITUTION : BIT MESRA *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second

LL dp[N];
LL arr[N];
LL n;
LL func(LL x) {
	//base
	if(x >= n) {
		return INT_MAX;
	}
	if(x == n - 1) {
		return 0;
	}
	if(dp[x] != -1) {
		return dp[x];
	}
	return dp[x] = min(abs(arr[x] - arr[x + 1]) + func(x + 1), abs(arr[x] - arr[x + 2]) + func(x + 2) );
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);


cin >> n;
for(int i = 0; i < n; i++)
	dp[i] = -1;
for(int i = 0; i < n; i++) {
	cin >> arr[i];
}

cout << func(0) << "\n";

return 0;
}

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

int main() {
	int a, b, c, d;
  	cin >> a >> b >> c >> d;
  	int x=(a+d-1)/d;
  	int y=(c+b-1)/b;
  	if (x>=y) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(void)
{
	long long int a, b, k;
	scanf("%lld %lld %lld", &a, &b, &k);

	if (a > k){
		a -= k;
	}

	else{
		k -= a;
		a = 0;
		if (b > k){
			b -= k;
		}
		else{
			b = 0;
		}
	}
	
	printf("%lld %lld\n", a, b);



	return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    vi a(5);
    rep(i, 0, 5) { cin >> a[i]; }

    int k;
    cin >> k;

    if (a[4] - a[0] > k) {
        cout << ":(" << endl;
    }
    else {
        cout << "Yay!" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000000000;
const int mod = 1000000007;
int test[12345678], cost[12345678];
signed main() {
	vector<int> v; map<string, int> mn;
	int n, m, k, a, b, c = 0, d = 0, cnt = 0, ans = 0; string s, t;
	cin >> m; n = 100;
	for (int h = 1; h < 1000000; h++) {
		n = (double)n / 100 * 101;
		if (n >= m) { cout << h << endl; return 0; }
	}
	return 0;
}

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

        Scanner sc =new Scanner(System.in);
        int n=sc.nextInt(),m=sc.nextInt(),x=sc.nextInt();
        int[] a =new int[1000];
        for(int i=0;i<m;i++)a[sc.nextInt()]++;
        long ans1 =0,ans2=0;
        for(int i=x-1;i>0;--i){
            if(a[i]>0)
                ans1++;
        }
        for (int i=x+1;i<n;i++){
            if(a[i]>0)ans2++;
        }
        System.out.println(Math.min(ans1,ans2));
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    int n,m;
    cin >> n >> m;
    vector<pii> data(n+1,pii(1e7,1e7));
    rep(i,n){
        cin >> data.at(i).first >> data.at(i).second;
    }
    sort(all(data));
    priority_queue<int> que;
    int id = 0;
    long ans = 0;
    for(int d=1;d<=m;d++){
        while(data.at(id).first == d){
            que.push(data.at(id).second);
            id++;
        }
        if(que.size()){
            ans += que.top();
            que.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1660
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = input()
ans = ""
score = 0
for i,t in enumerate(T):
    if t == "r":
        if i >= K and "p" == ans[-K]:
            ans += " "
        else:
            ans += "p"
            score += P
    elif t == "s":
        if i >= K and "r" == ans[-K]:
            ans += " "
        else:
            ans += "r"
            score += R
    else:
        if i >= K and "s" == ans[-K]:
            ans += " "
        else:
            ans += "s"
            score += S
print(score)

Measured memory_bytes: 3444
#16D8101014F KurumeRyunosuke 2018/6/20
#import numpy as np
n=int(input())
#ls=np.zeros((n,n))
ls=[[0 for i in range(n)]for j in range(n)]
for i in range(n):
	tmp=input().split()
	for j in range(int(tmp[1])):
		#print("*")
		ls[i][int(tmp[j+2])-1]=1


for i in range(n):
    for j in range(n):
        if(j!=n-1):
            print(int(ls[i][j]), end=' ')
        else:
            print(int(ls[i][j]))



Measured memory_bytes: 6384
#include<algorithm>
#include<iostream>

int main(){
  int N; std::cin >> N;
  int K; std::cin >> K;
  auto s = 0;
  for(auto i=0; i<N; ++i){
    int x; std::cin >> x;
    s += std::min(x, std::abs(K-x));
    s += std::min(x, std::abs(K-x));
  }
  std::cout << s << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
#define int long long

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
/*
#pragma comment(linker, "/STACK: 20000000005")
*/


using namespace std;


const int N = 200005, MOD = 1e9 + 7;


int X, Y;
int A, B, C;
int a[N], b[N], c[N];

int x = 0, y = 0;
int sum;
int ans;

main()
{
    ios_base::sync_with_stdio(0);
    cin >> X >> Y;
    cin >> A >> B >> C;
    for (int i = 1; i <= A; i++)
        cin >> a[i];
    for (int i = 1; i <= B; i++)
        cin >> b[i];
    for (int i = 1; i <= C; i++)
        cin >> c[i];
    sort (a + 1, a + A + 1);
    reverse (a + 1, a + A + 1);
    sort (b + 1, b + B + 1);
    reverse (b + 1, b + B + 1);
    sort (c + 1, c + C + 1);
    reverse (c + 1, c + C + 1);
    x = X;
    y = Y;
    for (int i = 1; i <= x; i++)
        sum += a[i];
    for (int i = 1; i <= y; i++)
        sum += b[i];
    ans = sum;
    for (int i = 1; i <= X + Y && i <= C; i++){
        sum += c[i];
        if (y == 0 || x > 0 && a[x] <= b[y]){
            sum -= a[x];
            x--;
        }
        else {
            sum -= b[y];
            y--;
        }
        ans = max (ans, sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3584
N, M = map(int, input().split())
mod = 10 ** 9 + 7
a = [0] * N
for i in range(M):
    a[i] = int(input())
val = [0,1]
j = 0
for i in range(1, N + 1):
    ans = (val[0] + val[1]) % mod
    val[0] = val[1]
    val[1] = ans
    if len(a) > 0:
        if i == a[j]:
            val[1] = 0
            if len(a) - 1 != j:
                j += 1
print(ans)

Measured memory_bytes: 6900
import java.util.*;
public class Main{
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int c = 0;
        boolean a = false;
        for(int i = 1; i < 10; i++){
            for(int j = 1; j < 10; j++){
                c = i*j;
                if(c == N) {
                    a = true;
                    break;
            }
        }
    }
    if(a == true) System.out.print("Yes");
    else System.out.print("No");

    }
}

Measured memory_bytes: 23124
/*
  AOJ #1531 
  title:Remainder Zero
  @kankichi57301
 */
#include <stdio.h>
long long a[5],b[5],gcd_a,qb[5],gcd_qb;
int f_expt[14];
int m,n,ret;

long long gcd(long long a, long long b)
{
        long long c;

        while (b > 0) {
                c = a % b;
                a = b;
                b = c;
        }

        return a;
}

void factorize(long long num){
  int i,f,f1,fc;
    
    f=1,fc=-1;
    
    for (i = 2; i <= num; i++) // 他の素数で割っていく
    {
	f=1;
        while (num % i == 0)
	{
	    if(f)
	    {
		f=0;fc++;
	    }
	    f_expt[fc]++;
	    num/=i;
	}
	
    }
}

int solve()
{
  int ret,i;
  for(i=0,ret=1;i<14;i++)
    ret *= (1+f_expt[i]);
  return(ret);
}



int main()
{
  int i;
  
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++)
    scanf("%lld",&a[i]);
  for(i=0;i<m;i++)
    scanf("%lld",&b[i]);
  gcd_a=a[0];
  for(i=1;i<n;i++)
     gcd_a = gcd(gcd_a,a[i]);
  
  //printf("gcd[a]=%lld\n",gcd_a);
  
  for(i=0;i<m;i++)
    {
      if((gcd_a % b[i])>0)
	{
	  printf("0\n",ret);
	  return(0);
	}
      qb[i]=gcd_a/b[i];
    }
  gcd_qb=qb[0];
  
  for(i=1;i<m;i++)
    {
      gcd_qb = gcd(gcd_qb,qb[i]);
    }
  
  factorize(gcd_qb);
  
  ret=solve();
  printf("%d\n",ret);
  
  return(0);
}



Measured memory_bytes: 2112
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

const int MOD = 998244353;
int main() {
    int n,k;
    cin >> n >> k;

    vector<pair<int,int>> lr;
    for (int i=0; i<k; i++) {
        int l,r;
        cin >> l >> r;
        lr.emplace_back(l,r);
    }

    vector<int64> csum(n+1, 0);
    csum[0] = 1;
    csum[1] = -1;
    for (int i=0; i<n; i++) {
        csum[i] %= MOD;
        csum[i+1] += csum[i];
        csum[i+1] %= MOD;
        for (int j=0; j<k; j++) {
            auto [l, r] = lr[j];
            if (i+l >= n) continue;
            csum[i+l] += csum[i];
            csum[min(n, i+r+1)] -= csum[i];
        }
    }
    if (csum[n-1] < 0) csum[n-1] += MOD;

    cout << csum[n-1] << endl;
}

Measured memory_bytes: 4352
n=int(input())
*l,=map(int,input().split())
v=0
for i in range(n-1):
  if l[i]==i+1:
    l[i],l[i+1]=l[i+1],l[i]
    v+=1
if l[n-1]==n:
  l[n-2],l[n-1]=l[n-1],l[n-2]
  v+=1
    
print(v)

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

bool verbose = false;
int mp[25][25];
int cnt[25][25];
ll dfs(int i, int j, int h, int w, int t){
    if(i==h){
        // calc and check
        int tt = t % (w*h);
        while(tt != 0){
            REP(i,h)REP(j,w)cnt[i][j] = 0;
            REP(i,h)REP(j,w){
                int ni, nj;
                if(mp[i][j] == 0){
                    ni = i, nj = j;
                }else if(mp[i][j] == 1){
                    ni = (i+tt)%h, nj = j;
                }else{
                    ni = i, nj = (j+tt)%w;
                }
                if(cnt[ni][nj])return 0;
                cnt[ni][nj]++;
            }
            tt += t;
            tt %= w*h;
        }
        if(verbose){
            REP(i,h){
                REP(j,w)putchar(".v>"[mp[i][j]]);
                puts("");
            }
            puts("");
        }
        return 1ll;
    }
    ll ret = 0;
    REP(x,3){
        mp[i][j] = x;
        if(j+1==w){
            ret += dfs(i+1, 0, h,w,t);
        }else{
            ret += dfs(i, j+1, h,w,t);
        }
    }
    return ret;
}
ll naive(int h, int w, int t){
    return dfs(0,0,h,w,t);
}

ll modpow(ll a, ll b){
    ll r = 1;
    while(b){
        if(b&1)r=r*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return r;
}

ll gcd(ll x, ll y){return __gcd(x,y);}
ll lcm(ll x, ll y){return x * y / gcd(x,y);}

ll solve(ll h, ll w, ll t){
    ll ph = lcm(w/gcd(t,w), h/gcd(t,h));
    if(ph == 1){
        // all
        return modpow(3, h*w);
    }
    ll hh = h / gcd(t,h);
    ll ww = w / gcd(t,w);
    ll ans = 0;
    // solve
    (ans += modpow(2, hh)) %= MOD;
    (ans += modpow(2, ww)) %= MOD;
    (ans += MOD-1) %= MOD;
    (ans += modpow(2, gcd(hh,ww)) + MOD - 2) %= MOD;
    ans = modpow(ans, gcd(t,h) * gcd(t,w));
    return ans;
}

int main(){
    // int h=4, w=4, t=1;
    // verbose = true;
    // ll ans = naive(h,w,t);
    // DEBUG(ans);
    // DEBUG(solve(h,w,t));
    // return 0;

    // if(true)FOR(h,1,20){
    //     FOR(w,1,h+1){
    //         FOR(t,1,h+1){
    //             ll ans1 = solve(h,w,t);
    //             ll ans2 = naive(h,w,t);
    //             if(ans1 != ans2){
    //                 DEBUG(h);DEBUG(w);DEBUG(t);
    //                 DEBUG(ans1);DEBUG(ans2);
    //                 return 0;
    //             }
    //         }
    //     }
    // }

    ll h,w,t;
    scanf("%lld%lld%lld",&h,&w,&t);
    printf("%lld\n",solve(h,w,t));
    return 0;
}


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


def complete_binary_tree(tree, n):
    for i in range(1, n + 1):
        node = "node {0}: ".format(i)
        key = "key = {0}, ".format(tree[i-1])
        if i // 2 == 0:
            parent = ""
        else:
            parent = "parent key = {0}, ".format(tree[(i // 2) - 1])

        if n >= (i * 2) + 1:
            left = "left key = {0}, ".format(tree[(i * 2) - 1])
            right = "right key = {0}, ".format(tree[(i * 2)])
        elif n >= (i * 2):
            left = "left key = {0}, ".format(tree[(i * 2) - 1])
            right = ""
        else:
            left = ""
            right = ""

        print(node + key + parent + left + right)


if __name__ == "__main__":
    n = int(input())
    tree = [int(n) for n in input().split()]
    complete_binary_tree(tree, n)

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

bool match(string T, string P) {
    for (int i = 0; i < T.length(); i++) {
        if (T[i] != P[i]) return false;
    }
    return true;
}

int main() {
    string T, P;
    cin >> T >> P;
    int lt, lp;
    lt = T.length();
    lp = P.length();

    for (int i = 0; i < lt - lp + 1; i++) {
        if (match(T.substr(i, lp), P)) cout << i << endl;
    }

    return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);


int main() {
  int a, b, x;
  cin >> a >> b >> x;
  bool ok = true;

  if(a > x) ok = false;
  if(x > a + b) ok = false;

  if(ok) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 3528
s = gets.chomp.split("")
s.size.times do |i|
  if i % 2 == 0
    if s[i] == 'L'
      puts 'No'
      exit
    end
  else
    if s[i] == 'R'
      puts 'No'
      exit
    end
  end
end
puts 'Yes'




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

const int N=100010;
int dis[N],n;
deque<int>q;

int main()
{
    cin >> n;
    fill(dis,dis+1+n,~0u >> 1);
    q.push_back(1);
    dis[1]=0;
    while(!q.empty())
    {
        int x=q.front();
        q.pop_front();
        if(dis[x*10%n]>dis[x])
        {
            dis[x*10%n]=dis[x];
            q.push_front(x*10%n);
        }
        if(dis[(x+1)%n]>dis[x]+1)
        {
            dis[(x+1)%n]=dis[x]+1;
            q.push_back((x+1)%n);
        }
    }
    cout << dis[0]+1;
    return 0;
}


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

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

    int n;
    cin >> n;
    vector<pair<string, int>> list;
    for (int i = 0; i < n; i++) {
        string s;
        int t;
        cin >> s >> t;
        list.emplace_back(s, t);
    }
    string x;
    cin >> x;
    int ans = 0;
    for (int i = n - 1; i >= 0 && list[i].first != x; i--) ans += list[i].second;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  int ans = 0;
  rep(i, n){
    if(i<k){ans += x;}
    else{ans += y;}
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 508
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int N = sc.nextInt();
    int total = 0;
    for (int i = 0; i < N; i++) {
      total += sc.nextInt();
    }
    System.out.println(total >= H ? "Yes" : "No");
  }
}

Measured memory_bytes: 48232
#include <stdio.h>

int main()
{
    int k,n,p,i,j;
    double ave,max = 0,csum[200020];
    scanf("%d %d",&n,&k);

    csum[0] = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%d",&p);
        ave = (1 + p) / 2.0;
        csum[i + 1] = csum[i] + ave;
    }
    for (i = k; i <= n; i++)
    {
        if(max < csum[i] - csum[i - k])max = csum[i] - csum[i - k];
    }
    printf("%lf",max);
}


Measured memory_bytes: 1664
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scanner =new Scanner(System.in);
		int N = scanner.nextInt();

		int ans = N /2 * (1 + N);
		if (N % 2 == 1) {
			ans += (N /2 + 1);
		}

		System.out.println(ans);

		scanner.close();
	}

}


Measured memory_bytes: 27060
#include <stdio.h>

int gcd(a, b){
	if(a == 0)
		return b;
	if(b == 0)
		return a;
	
	if(a >= b)
		return gcd(a%b, b);
	else
		return gcd(b%a, a);
}

int main()
{
	int n;
	int a;
	int i;
	int g;
	
	scanf("%d ", &n);
	
	scanf("%d ", &g);
	for(i = 1; i < n; ++i){
		scanf("%d ", &a);
		g = gcd(a, g);
		if(g == 1)
			break;
	}
	
	printf("%d", g);
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)1e3+11;

void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        
        ll a;
        ld b;
        cin>>a>>b;
        
        ld ans=(ld)(a*b);
        cout<<(ll)ans<<endl;
        
        
      
       
}
int main(){
        FS;
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}

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

using namespace std;

int n,z,w;
int a[2001];
int dp[2001][2];


int rec(int i, int k, int z, int w) {
  if(dp[i][k] >= 0) return dp[i][k];
  if(i == n) return abs(w-z);
  int &ret = dp[i][k];
  if(!k) {
    for(int j = i; j < n; j++) {
      ret = max(ret,rec(j+1,1,a[j],w));
    }
  }

  else {
    ret = 1e9;
    for(int j = i; j < n; j++) {
      ret = min(ret,rec(j+1,0,z,a[j]));
    }
  }
  return ret;
}

int main() {
  cin >> n >> z >> w;

  for(int i = 0; i < n; i++) cin >> a[i];

  for(int i = 0; i <= n; i++) fill(dp[i],dp[i]+2,-1);

  cout << rec(0,0,z,w) << endl;
}


Measured memory_bytes: 384
import math
n=int(input())
l=list(map(int,input().split()))
d={}
for i in l:
    if i in d:
        d[i]+=1 
    else:
        d[i]=1 
count=0
for k in d.keys():
        x=d[k]
        if x<2:
            count+=0
        else:
            count+=x*(x-1)//2

for i in l:
    x=d[i]
    #print(i, x)
    if x>=2:
        val=x*(x-1)//2
        ans=count-val
        if x>=3:
            x-=1
            val1=x*(x-1)//2
        else:
            val1=0
        ans+=val1
    else:
        if x==2:
            ans=count-1 
        else:
            ans=count 
    print(int(ans))
            


Measured memory_bytes: 91468
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define pi 3.14159265358979323846
#define Endl endl
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int a,b;
	cin>>a>>b;
	for(int i=0;i<=100000;i++){
		int aa = i * 108 / 100;
		int bb = i * 110 / 100;
		if( a == aa-i && b == bb-i ){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
#define MINS(a,b) a = min(a,(decltype(a))(b))
#define MAXS(a,b) a = max(a,(decltype(a))(b))


using arr = array<ll, 3>;
int main() {
	auto proc = [](string str) {
		int bra = 0;
		int cket = 0;
		for (char c : str) {
			if (c == '(') {
				++bra;
			}
			else {
				if (bra > 0) --bra;
				else ++cket;
			}
		}
		return arr{cket, bra, bra - cket};
	};
	auto cmp = [](arr a, arr b) {
		if (a[0] == b[0])return a[1] > b[1];
		return a[0] < b[0];
	};
	auto cmp2 = [](arr a, arr b) {
		if (a[1] == b[1])return a[0] > b[0];
		return a[1] > b[1];
	};
	ll N;
	cin >> N;
	vector<arr> plus,minus;
	REP(i, 0, N) {
		string str;
		cin >> str;
		auto a = proc(str);
		if (a[2] >= 0) plus.push_back(a);
		else minus.push_back(a);
	}
	sort(plus.begin(), plus.end(), cmp);
	sort(minus.begin(), minus.end(), cmp2);
	int cur = 0;
	for (auto p : plus) {
		cur -= p[0];
		if (cur < 0) {
			PRIN;
			return 0;
		}
		cur += p[1];
	}
	REP(i, 0, minus.size()) {
		auto p = minus[i];
		cur -= p[0];
		if (cur < 0) {
			PRIN;
			return 0;
		}
		cur += p[1];
	}
	if (cur == 0)PRIY;
	else PRIN;
	return 0;
}

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

using namespace std;

const int N = 2e5 + 5, OO = 0x3f3f3f3f;

int n, k, A[N], mid1, mid2, ans;

int main()
{
	scanf("%d %d", &k, &n);
	for(int i = 0 ; i < n; ++i)	scanf("%d", A + i);
	sort(A, A + n);
	for(int i = 0 ; i < n - 1; ++i)
		ans = max(ans, A[i + 1] - A[i]);
	
	cout << min(k - ans, A[n - 1] - A[0]) << endl;
	return 0;
}

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

using namespace std;

int main() {
    int a, b, k;
    cin >> a >> b >> k;

    set<int> st;
    for (int i = 0; i < k; ++i) {
        if (a + i <= b) st.insert(a + i);
        if (b - i >= a) st.insert(b - i);
    }

    vector<int> vt(st.begin(), st.end());
    sort(vt.begin(), vt.end());
    for (const auto &e : vt) {
        cout << e << endl;
    }
    return 0;
}


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

int main() {
  int n, t, a;
  cin >> n >> t >> a;
  vector<int> X(n);
  for(int i = 0; i < n; i++) cin >> X.at(i);
  double min = fabs (a - (t - X.at(0) * 0.006));
  int answer = 1;
  for (int i = 0; i < n; i++) {
    double check = fabs (a - (t - X.at(i) * 0.006));
    if (check < min) {
      min = check;
      answer = i + 1;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define f first
#define s second
using namespace std;
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
typedef long long ll;
const int INF = 1e9;
const ll INFl = 1e18;
typedef pair<int,int> pii;
typedef vector<int> vi;

void solve() {
	int n, m, k; cin >> n >> m >> k;
	cout << (k + max(n, m) - 1) / max(n, m) << '\n';
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int q = 1;
	//cin >> q;
	while (q--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
import sys
from fractions import gcd
input = sys.stdin.readline
N, M = map(int, input().split())
a = list(map(int, input().split()))
gh = 0
l = 1
dbl = [0] * N
for i in range(N):
  x = a[i]
  t = 0
  while x % 2 == 0:
    x //= 2
    t += 1
  dbl[i] = t
if max(dbl) != min(dbl):
  print(0)
  exit(0)
t = pow(2, dbl[0])
s = set()
for i in range(N):
  if a[i] in s: continue
  s.add(a[i])
  l *= a[i] // t // gcd(l, a[i])
  if l > M:
    print(0)
    exit(0)
l *= t // 2

print(M // l - M // (2 * l))


Measured memory_bytes: 85372
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=1; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
	int A, B;
	cin >> A >> B;
	int cnt = 0;
	if (A > B) {
		cnt += A;
		A--;
	}
	else {
		cnt += B;
		B--;
	}
	cnt += max(A, B);

	cout << cnt << endl;


	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define int ll

int n;
int a[1000000];
int dp[1000000];


signed main(){
  cin>>n;
  rep(i,n){
    cin>>a[i];
  }

  dp[1]=abs(a[0]-a[1]);

  FOR(i,2,n){
    dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
  }

  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define GET_MACRO(a, b, c, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define rep2(i, a) rep3 (i, 0, a)
#define rep3(i, a, b) for (int i = (a); i < (b); i++)
#define repr(...) GET_MACRO(__VA_ARGS__, repr3, repr2)(__VA_ARGS__)
#define repr2(i, a) repr3 (i, 0, a)
#define repr3(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define chmin(a, b) ((b) < a && (a = (b), true))
#define chmax(a, b) (a < (b) && (a = (b), true))
using namespace std;
typedef long long ll;
 
struct Toposort {
    vector<vector<int>> g;
    vector<int> ord, indeg;
    Toposort(int n) : g(n), ord(n), indeg(n) {}
    void add(int u, int v) {
        g[u].push_back(v);
    }
    void build() {
        for (auto &v : g) for (int w : v) indeg[w]++;
        queue<int> q;
        rep (i, g.size()) if (indeg[i] == 0) q.push(i);
        int k = 0;
        while (!q.empty()) {
            int v = q.front(); q.pop();
            ord[k++] = v;
            for (int w : g[v]) {
                indeg[w]--;
                if (indeg[w] == 0) q.push(w);
            }
        }
    }
};
 
template<class T>
ostream &operator <<(ostream &os, const vector<T> &v) {
    rep (i, v.size()) {
        if (i) os << " ";
        os << v[i];
    }
    return os;
}
 
int main() {
    int n, m;
    cin >> n >> m;
    Toposort ts(n);
    rep (i, m) {
        int u, v;
        cin >> u >> v;
        ts.add(u, v);
    }
    ts.build();
    for (auto v : ts.ord) {
        cout << v << endl;
    }
    return 0;
}

Measured memory_bytes: 3564
#include <iostream>

using namespace std;

int main()
{
	string s, t;

    cin >> s >> t;

	auto count = 0;
	const int length  = s.length();

	for (auto i=0; i < length; i++)
	{
		if (s[i] != t[i])
			count++;
	}
	
	cout << count << endl;
	
    return 0;
}


Measured memory_bytes: 3436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
double pi = 3.14159265359;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int n;
    cin >> n;
    ll dp[50];
    dp[0] = 1, dp[1] = 1;
    rep (i, 0, n) { dp[i + 2] = dp[i + 1] + dp[i]; }
    cout << dp[n] << "\n";
}


Measured memory_bytes: 3104
solver::[Int]->Int->Int
solver coords init_pos = let d = (map (\x -> abs (init_pos - x)) coords) in
                         foldl gcd (head d) (tail d)

main::IO()
main=do
  nxc<-getLine
  let n:x:[]= map read (words nxc)::[Int]
  d<-getLine
  let dat = map read (words d) ::[Int]
  print (solver dat x)


Measured memory_bytes: 36220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string S;
    cin >> S;
    S[3] = '8';
    cout << S;
}

Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.Scanner;

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

//    	File file = new File("src/in.txt");

        //コード
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int C1 = 0;
    	int C2 = 0;
    	int C3 = 0;
    	int C4 = 0;
    	for(int i=0;i<N;i++) {
    		String S = sc.next();
    		switch(S) {
    		case "AC":
    			C1++;
    			break;
    		case "WA":
    			C2++;
    			break;
    		case "TLE":
    			C3++;
    			break;
    		case "RE":
    			C4++;
    			break;
    		}
    	}
    	System.out.println("AC x "+C1);
    	System.out.println("WA x "+C2);
    	System.out.println("TLE x "+C3);
    	System.out.println("RE x "+C4);

    }
}

Measured memory_bytes: 58432
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//省略
using vi  = vector<int>;
using vii = vector<vector<int>>;
using vl  = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
    ll D,T,S;
    cin>>D>>T>>S;
    if(T*S>=D){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3632
const main = (input) => {
  const args = input.trim().split("\n");
  const [x, n] = args[0]
    .trim()
    .split(" ")
    .map((n) => parseInt(n, 10));
 
  const excluded = (() => {
    if (n === 0) {
      return [];
    } else {
      return args[1]
        .trim()
        .split(" ")
        .map((n) => parseInt(n, 10));
    }
  })();
 
  const selection = [...Array(101 + 1).keys()].filter(
    (s) => !excluded.includes(s)
  );
 
  const abs = (n) => {
    if (n < 0) return -n;
    else {
      return n;
    }
  };
  const byAsc = (a, b) => a[1] - b[1];
 
  const answer = selection
    .map((s) => [s, (abs((x - s) | 0) | 0)])
    .sort(byAsc)[0][0];
 
  console.log(answer);
};
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int a1, a2, b1, b2, c1, c2, d1, d2, e1, e2;
    while (cin >> a1 >> a2 && a1 && a2 && cin >> b1 >> b2 >> c1 >> c2 >> d1 >> d2 >> e1 >> e2) {
        int a = a1 + a2;
        int b = b1 + b2;
        int c = c1 + c2;
        int d = d1 + d2;
        int e = e1 + e2;
        int maxv = max({ a, b, c, d, e });
        if (maxv == a) cout << "A ";
        if (maxv == b) cout << "B ";
        if (maxv == c) cout << "C ";
        if (maxv == d) cout << "D ";
        if (maxv == e) cout << "E ";
        cout << maxv << endl;
    }
}


Measured memory_bytes: 3068
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    ArrayList<Integer> list = new ArrayList<Integer>();
    int j=0;
    list.add(0);
    for(int i=0;i<a.length();i++){
      char c = a.charAt(i);
      if(c=='A'||c=='G'||c=='C'||c=='T'){
        j++;
        list.add(j);
      }else{
        list.add(j);
        j=0;
      }
    }
    Collections.sort(list, Collections.reverseOrder());
    System.out.println(list.get(0));
  }
}

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

typedef long long ll;
using namespace std;

const ll MOD = 1e9 + 7;

int main() {
    string l;
    cin >> l;
    int n = l.size();
    ll dp[2][n];
    for (int i = 0; i < 2; i++) {
        for (int k = 0; k < n; k++) {
            dp[i][k] = 0;
        }
    }
    dp[0][0] = 1;
    dp[1][0] = 2;
    for (int i = 1; i < n; i++) {
        if (l[i] == '1') {
            dp[0][i] = (dp[0][i - 1] * 3 + dp[1][i - 1]) % MOD;
            dp[1][i] = dp[1][i - 1] * 2 % MOD;
        } else {
            dp[0][i] = dp[0][i - 1] * 3 % MOD;
            dp[1][i] = dp[1][i - 1];
        }
    }
    cout << (dp[0][n - 1] + dp[1][n - 1]) % MOD << endl;
    return 0;
}


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

void outputArray(int A[],int n){
	for(int i=0;i<n-1;i++)
		cout<<A[i]<<" ";
	cout<<A[n-1]<<endl;
}

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

	outputArray(A,N);
	}
}

int main(){
	
	int n;
	cin>>n;
	int A[n];
	for(int i=0;i<n;i++)
		cin>>A[i];
		
	insertionSort(A, n);

//	outputArray(A,n);
	
	return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */

ll n,m;
ll a[100001];

/* add your algorithm here */

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

  ll sum[n+1];
  sum[0] = 0;
  rep(i,n+1) {
    sum[i+1] = (sum[i] + a[i]) % m;
  }

  map<ll, ll> m;
  ll ans = 0;
  for (int i = 1; i < n+1; ++i) {
    ans += m[sum[i]];
    m[sum[i]]++;
  }

  ans += m[0];

  cout << ans << endl;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld double
#define mod 1000000007
#define har ios_base::sync_with_stdio(),cout.tie(NULL),cin.tie(NULL);
const int N = 1e5 + 5;
ll arr[3][N];
ll dp[3][N];
int main()
{
	int n;
	cin >> n;

	for (int j = 0; j < n; j++)
	{
		for (int i = 0; i < 3; i++)
		{
			cin >> arr[i][j];
		}
	}
	dp[0][0] = arr[0][0];
	dp[1][0] = arr[1][0];
	dp[2][0] = arr[2][0];
	for (int i = 1; i < n; i++)
	{
		dp[0][i] = max(dp[1][i - 1] + arr[0][i], dp[2][i - 1] + arr[0][i]);
		dp[1][i] = max(dp[0][i - 1] + arr[1][i], dp[2][i - 1] + arr[1][i]);
		dp[2][i] = max(dp[1][i - 1] + arr[2][i], dp[0][i - 1] + arr[2][i]);
	}


	ll ans = max(max(dp[0][n - 1], dp[1][n - 1]), dp[2][n - 1]);
	cout << ans << "\n";
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[300005];
ll MOD = 1e9 + 7;
ll pow2[64];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  pow2[0] = 1;
  for (int i = 1; i <= 61; i++)
    pow2[i] = pow2[i - 1] * 2 % MOD;
  ll sum = 0;
  for (int i = 0; i <= 61; i++) {
    ll zc = 0, oc = 0;
    ll idsum = 0;
    for (int j = 0; j < n; j++) {
      if (a[j] & 1)
        oc++;
      else
        zc++;
      a[j] /= 2;
    }
    idsum = (oc * zc % MOD * pow2[i]) % MOD;
    sum = (sum + idsum) % MOD;
  }
  cout << sum << endl;
}

Measured memory_bytes: 2560