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


	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);

			int n = sc.nextInt();
			int[] h = new int[n+2];
			int maxh = 0;
			int zero1 = 0;
			int zero2 = n;
			int ret = 0;
			
			for(int i=1;i<n+1;i++) {
				h[i] = sc.nextInt();
				maxh = Math.max(maxh, h[i]);
			}
			
			h[0] = 0;
			h[n+1] = 0;
			
			for(int i=1;i<=maxh;i++) {
				zero1 = 0;
				zero2 = n;
				for(int j=0;j<n+2;j++) {
					if(h[j]==0) {
						zero2 = j;
						
						if(zero2-zero1>1) {
							ret++;
						}
						
						zero1=zero2;
					}
				
				}
				for(int k=0;k<n+2;k++) {
					if(h[k]>0) {
						h[k]--;
					}
				}
				
			}
			
			System.out.println(ret);
			
		}
		
		
		
	}


Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main(void){
    int x,a;
    cin >> x;
    a=x%7;
    
    if(a==1)
        cout << "fri" << endl;
    else if(a==2)
        cout << "sat" << endl;
    else if(a==3)
        cout << "sun" << endl;
    else if(a==4)
        cout << "mon" << endl;
    else if(a==5)
        cout << "tue" << endl;
    else if(a==6)
        cout << "wed" << endl;
    else
        cout <<"thu" << endl;


}




Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;


int main() {
  ll n;
  cin >> n;
  vector<set<ll>> E(n);
  for(ll i=0;i<n-1;i++) {
    ll a,b;
    cin >> a >> b;
    a--;
    b--;
    E[a].insert(b);
    E[b].insert(a);
  }
  vector<ll> d1(n,-1);
  vector<ll> d2(n,-1);
  queue<ll> q;
  q.push(0);
  d1[0]=0;
  while(q.size()) {
    ll f=q.front();
    q.pop();
    for(ll t:E[f]) {
      if(d1[t]<0) {
        d1[t]=d1[f]+1;
        q.push(t);
      }
    }
  }
  ll mx=0,mi=0;
  for(ll i=0;i<n;i++) {
    if(d1[i]>mx) {
      mx=d1[i];
      mi=i;
    }
  }
  d2[mi]=0;
  q.push(mi);
  while(q.size()) {
    ll f=q.front();
    q.pop();
    for(ll t:E[f]) {
      if(d2[t]<0) {
        d2[t]=d2[f]+1;
        q.push(t);
      }
    }
  }
  mx=0;
  for(ll i=0;i<n;i++) {
    mx=max(mx,d2[i]);
  }
  if(mx%3==1) {
    cout << "Second" << endl;
  }
  else {
    cout << "First" << endl;
  }
}

Measured memory_bytes: 33152
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n,sum=0;
  cin >> n;
  vector<int>p(n);
  for(int i=0; i<n; i++){
    cin >> p.at(i);
  }
  sort(p.begin(), p.end());
  for(int i=0; i<n-1; i++){
    sum+=p.at(i);
  }
  sum+=p.at(n-1)/2;
  cout << sum << endl;
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.parent = [ -1 for _ in range(n) ]
        self._size = n
    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            if self.parent[y] < self.parent[x]:
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x
            self._size -= 1
    def same(self, x, y):
        return self.root(x) == self.root(y)
    def root(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.parent[x]
    def size(self, x):
        return -self.parent[self.root(x)]

n, m, k = map(int, input().split())
friends = [ [] for _ in range(n) ]
blocks  = [ [] for _ in range(n) ]

tree = UnionFind(n)

for _ in range(m):
    a, b = map(int, input().split())
    a -= 1; b -= 1;
    friends[a].append(b)
    friends[b].append(a)
    tree.unite(a, b)

for _ in range(k):
    a, b = map(int, input().split())
    a -= 1; b -= 1;
    blocks[a].append(b)
    blocks[b].append(a)

for i in range(n):
    ret = tree.size(i)
    s = set()
    for j in friends[i]:
        s.add(j)
    for j in blocks[i]:
        if tree.same(i, j):
            s.add(j)
    ret -= len(s)
    print(ret-1)

Measured memory_bytes: 47080
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

int n;

int main() {
    cin >> n;
    map<string, int> count;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        count[s]++;
    }
    vector<pair<int, string>> v;
    for (auto e : count) {
        v.push_back(make_pair(e.second, e.first));
    }
    sort(v.begin(), v.end());
    int m = v.back().first;
    vector<string> ans;
    for (auto itr = v.rbegin(); itr != v.rend(); itr++) {
        if (itr->first == m) {
            ans.push_back(itr->second);
        } else {
            break;
        }
    }
    sort(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }
}

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

int main(){
	char s[4];
	for(int i=0;i<4;i++) cin >> s[i];
	cout << ((s[0]==s[1] | s[1]==s[2] | s[2]==s[3])? "Bad": "Good") << endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

vector<ll> num(100, -1);

ll luca(int n) {
  if(n == 0) return 2ll;
  if(n == 1) return 1ll;
  if(num[n] != -1) return num[n];
  return num[n] = luca(n-1) + luca(n-2);
}
int main()
{
  int n; cin >> n;
  cout << luca(n) << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << a*b-a*d-b*c+c*d << endl;
    return 0;
}

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

int main() {
//    freopen("10.in", "r", stdin);
//    freopen("10.out", "w", stdout);
//    int _;
//    while(_--) {
    int n;
    cin >> n;
    long long ans = 0;
        for(int i = 1; i <= n; i++) {
            ans += (long long)(i + n / i * i) * (n / i) / 2;
            // cout << ans << endl;
        }
    cout << ans << endl;
//    }

    return 0;
}


Measured memory_bytes: 3600
#include<cstdio>
#include<algorithm>
using namespace std;
inline char tc(void){
	static char fl[10000],*A=fl,*B=fl;
	return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;
}
inline int read(void){
	int a=0;char c;
	while((c=tc())<'0'||c>'9');
	while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();
	return a;
}
int n,pos[200005],res[200005],mx;
int main(void){
	register int i,x;
	n=read();
	for(i=1;i<=n;++i)
		x=read(),pos[x]=i;
	for(i=1;i<=n;++i){
		if(pos[i]>pos[i-1])res[i]=1+res[i-1];
		else res[i]=1;
		mx=max(mx,res[i]);
	}
	printf("%d\n",n-mx);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 998244353;
const ll INF = 1e16;
const double pi = acos(-1);

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

    vvl dp(c+10, vl(d+10));  // dp[i][j] : i行j列のマス目の塗られ方の数
    
    dp[a][b] = 1;
    exrep(i, a, c) {
        exrep(j, b, d) {
            dp[i+1][j] += j*dp[i][j];
            dp[i+1][j] %= mod;
            dp[i][j+1] += i*dp[i][j];
            dp[i][j+1] %= mod;
            dp[i+1][j+1] = (dp[i+1][j+1] + mod - i*j*dp[i][j])%mod;
        }
    }  

    out(dp[c][d]);
    re0;
}

Measured memory_bytes: 74208
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <map>
#include <iomanip>
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int n, m;
vector<int> g[8];
int cnt;

int main(){
	cin >> n >> m;
	
	REP(i,m){
		int a, b;
		cin >> a >> b;
		
		a--;
		b--;
		
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	queue< pair<int, int> > q;
	q.push(make_pair(0,1));
	
	while( !q.empty() ){
		pair<int , int> c = q.front();
		q.pop();
		
		if (c.second == pow(2,n)-1){
			cnt++;
		}
		
		REP(i,g[c.first].size()){
			if (!(c.second >> g[c.first][i] & 1)){
				q.push(make_pair(g[c.first][i], c.second + pow(2,g[c.first][i])));
			}
		}
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 512
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

// 解説を参考
// https://youtu.be/ENSOy8u9K9I?t=1265
// 部分集合を見る場合の手法

func main() {
	N, M, X := nextInt(), nextInt(), nextInt()
	ans := 100000*12 + 5
	Cn := make([]int, N)
	Anm := make([][]int, N)
	impossible := true
	for i := range Anm {
		Anm[i] = make([]int, M)
	}
	for i := 0; i < N; i++ {
		Cn[i] = nextInt()
		for j := 0; j < M; j++ {
			Anm[i][j] = nextInt()
		}
	}
	for i := 0; i < 1<<uint(N); i++ {
		var cost int
		checkUS := make([]int, M)
		for j := 0; j < N; j++ {
			// iのj bit目が1かどうかのチェック
			// https://qiita.com/3x8tacorice/items/0b8341d7fd3ff3779111
			if uint(i)>>uint(j)&1 == 1 {
				cost += Cn[j]
				for k := 0; k < M; k++ {
					checkUS[k] += Anm[j][k]
				}
			}
		}
		ok := true
		for j := 0; j < M; j++ {
			if checkUS[j] < X {
				ok = false
			}
		}
		if ok && ans > cost {
			impossible = false
			ans = cost
		}
	}
	if impossible {
		fmt.Println(-1)
	} else {
		fmt.Println(ans)
	}
}

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


Measured memory_bytes: 2200
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int N = in.nextInt();
        int A = in.nextInt();
        int B = in.nextInt();

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

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}


Measured memory_bytes: 21460
xy = list(map(int,input().split()))

if xy[2] - xy[0] == 0:
    if xy[3] > xy[1]:
        x3 = xy[2] - (xy[3]-xy[1])
        y3 = xy[3] - (xy[2]-xy[0])
        x4 = xy[0] - (xy[3]-xy[1])
        y4 = xy[1] - (xy[2]-xy[0])
    else:
        x3 = xy[2] - (xy[3]-xy[1])
        y3 = xy[3] - (xy[0]-xy[2])
        x4 = xy[0] - (xy[3]-xy[1])
        y4 = xy[1] - (xy[0]-xy[2])
else:
    if xy[2] > xy[0]:
        x3 = xy[2] - (xy[3]-xy[1])
        y3 = xy[3] - (xy[0]-xy[2])
        x4 = xy[0] - (xy[3]-xy[1])
        y4 = xy[1] - (xy[0]-xy[2])
    else:
        x3 = xy[2] - (xy[3]-xy[1])
        y3 = xy[3] - (xy[0]-xy[2])
        x4 = xy[0] - (xy[3]-xy[1])
        y4 = xy[1] - (xy[0]-xy[2])

print(x3,y3,x4,y4)


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

int main()
{
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    for (int i = 0; i < M; i++)
        cin >> B[i];
    vector<vector<int>> A(N, vector<int>(M, 0));
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < M; j++)
            cin >> A[i][j];
    }
    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        int sum = 0;
        for (int j = 0; j < M; j++)
        {
            sum += A[i][j] * B[j];
        }
        if (0 < sum + C)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

int main() {
	lint N;
	cin >> N;
	vector<int>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	vector<lint>B;
	int cnt = 1;
	rep(i, N-1) {
		if (A[i] == A[i + 1]) {
			B.push_back(cnt);
			cnt = 1;
		}
		else {
			cnt++;
		}
	}
	B.push_back(cnt);
	lint BS = B.size();
	
	lint ans = 0;
	if (BS == 1) {
		ans = B[0];
	}
	else if (BS == 2) {
		ans = B[0] + B[1];
	}
	else {
		rep(i, BS - 2) {
			ans = max(ans, B[i] + B[i + 1] + B[i + 2]);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3844
package main

import (
	"fmt"
	"strings"
)

// var sc = bufio.NewScanner(os.Stdin)

// func init() {
// 	sc.Split(bufio.ScanWords)
// }

// func nextInt() int {
// 	sc.Scan()
// 	i, e := strconv.ParseInt(sc.Text(), 10, 64)
// 	if e != nil {
// 		panic(e)
// 	}
// 	return int(i)
// }

func SingleStr() string {
	var s string
	fmt.Scan(&s)
	return s
}

func main() {
	s := SingleStr()
	ss := strings.Split(s, "")
	n := SingleStr()
	nn := strings.Split(n, "")

	var re int

	for index := 0; index < 3; index++ {
		if ss[index] == nn[index] {
			re++
		}
	}
	fmt.Println(re)
}


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

struct qwq{
	int a,b;
	inline bool operator<(const qwq &x)const{
	   return a<x.a;
	}
} x[100005];

priority_queue<int> q;

int main(){
	int n,m,i,j=1,s=0;
	
	scanf("%d%d",&n,&m);
	
	for(i=1;i<=n;++i)
	   scanf("%d%d",&x[i].a,&x[i].b);
	
	sort(x+1,x+n+1);
	
	for(i=1;i<=m;++i){
		for(;x[j].a==i&&j<=n;++j)
		   q.push(x[j].b);
		if(!q.empty()){
		   s += q.top();
		   q.pop();
		}
	}
	
	printf("%d",s);
	return 0;
}



Measured memory_bytes: 1660
MOD = pow(10,9)+7
N = int(input())
dp = [[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(N+1)]
dp[0][3][3][3] = 1 #3333Sとくる場合は制約に何も引っかからない
#dp[i][j][k][l]: i文字目まで見て最後のの三文字がlkjであるような場合の数
#A=0, G=1, C=2, T=3

for i in range(N):
  for j in range(4):
    for k in range(4):
      for l in range(4):
        if dp[i][j][k][l] == 0: #i文字目で条件にあてはまるものがないときは飛ばす。
          continue
        for a in range(4): #ダメな条件を飛ばす
          if a == 2 and j == 1 and k == 0: #AGC
            continue
          if a == 1 and j == 2 and k == 0: #ACG
            continue
          if a == 2 and j == 0 and k == 1: #GAC
            continue
          if a == 2 and j == 1 and l == 0: #A?GC
            continue
          if a == 2 and k == 1 and l == 0: #AG?c
            continue
          dp[i+1][a][j][k] += dp[i][j][k][l]%MOD
ans = 0            
for j in range(4):
  for k in range(4):
    for l in range(4):
      ans += dp[N][j][k][l]
ans = ans%MOD
print(ans)

Measured memory_bytes: 9284
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 200005
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d\n", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 1000000007
#define PI acos(-1.0)
#define eps 1e-9

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

clock_t t_Start;
void Start()
{
    t_Start = clock();
}
void End()
{
    double Time = (double)(clock()-t_Start)/CLOCKS_PER_SEC;
    error(Time);
}

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Start();

    int n;
    cin>>n;
    string s, t;
    cin>>s>>t;
    for(int i = 0; i < n; i++)
        cout<<s[i]<<t[i];
    cout<<endl;

    //End();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  vector<int> ans;
  cin >> s;
  bool last = false;
  for(int i=0;i<(int)s.size();++i){
    if((s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')&&last){
      ++ans.back();
    }else if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
      ans.emplace_back(1);
      last = true;
    }else{
      last = false;
    }
  }
  if(ans.size()==0){
    puts("0");
    return 0;
  }
  cout << *max_element(ans.begin(),ans.end()) << endl;
}

Measured memory_bytes: 256
def gcd(x,y)
  return x if y == 0
  gcd(y, x.modulo(y))
end
def lcm(x,y)
  x * y / gcd(x,y)
end

n = gets.to_i
l = 1
(1..n).each do |i|
  l = lcm l, gets.to_i
end
puts l


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int N;
    vector<int>A1(3),A2(3),A3(3);
    for(int i=0;i<3;i++){
        cin >> A1[i];
    }
    for(int i=0;i<3;i++){
        cin >> A2[i];
    }
    for(int i=0;i<3;i++){
        cin >> A3[i];
    }
    cin>> N;
    vector<int>b(N);
    for(int i=0;i<N;i++){
        cin >> b[i];
    }
    vector<int>a1(3,0),a2(3,0),a3(3,0);
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            if(A1[j]==b[i]){
                a1[j]=1;
            }
        }
        for(int j=0;j<3;j++){
            if(A2[j]==b[i]){
                a2[j]=1;
            }
        }
        for(int j=0;j<3;j++){
            if(A3[j]==b[i]){
                a3[j]=1;
            }
        }
    }
    if(a1[0]+a1[1]+a1[2]==3 || a2[0]+a2[1]+a2[2]==3 || a3[0]+a3[1]+a3[2]==3){
        cout << "Yes";
    }else if(a1[0]+a2[1]+a3[2]==3 || a3[0]+a2[1]+a1[2]==3){
        cout << "Yes";
    }else if(a1[0]+a2[0]+a3[0]==3 || a1[1]+a2[1]+a3[1]==3 || a1[2]+a2[2]+a3[2]==3){
        cout << "Yes";
    }else{
        cout << "No";
    }

}

Measured memory_bytes: 256
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    a, b, c, d = list(map(int, input().rstrip('\n').split()))
    if b < c:
        print(0)
    elif d < a:
        print(0)
    else:
        print(min(b, d) - max(a, c))


if __name__ == '__main__':
    solve()


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

using namespace std;
const int N = 302;
double dp[N][N][N];
int n;
int cnt[4];


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

    for(int k = 0;k <= n;k++){
        for(int j = 0;j <= n;j++){
            for(int i = 0;i <= n;i++){
                if(i == 0 && j == 0 && k == 0)
                    continue;
                dp[i][j][k] = 1;
                if(i)
                    dp[i][j][k] += 1.0 * i / n * dp[i - 1][j][k];
                if(j)
                    dp[i][j][k] += 1.0 * j / n * dp[i + 1][j - 1][k];
                if(k)
                    dp[i][j][k] += 1.0 * k / n * dp[i][j + 1][k - 1];
                dp[i][j][k] /= 1 - 1.0 * (n - i - j - k) / n;            
            }
        }
    }
    printf("%.10f", dp[cnt[1]][cnt[2]][cnt[3]]);
}

Measured memory_bytes: 218232
a, b, c, x = [int(input()) for i in range(4)]
counter = 0

for rep1 in range(a + 1):
    for rep2 in range(b + 1):
        for rep3 in range(c + 1):
            if rep1 * 500 + rep2 * 100 + rep3 * 50 == x:
                counter += 1

print(counter)


Measured memory_bytes: 2940
x,k,d=map(int,input().split())
if x<0:
    x*=-1

if x>=k*d:
    print(x-k*d)
    exit()
else:
    kk=x//d
    kkk=kk+1
    ans=float("inf")
    ans2=float("inf")
    xx=k-kk
    if xx%2==1:
        ans=abs(x-kk*d-d)
    else:
        ans=abs(x-kk*d)
    y=k-kkk
    if y%2==1:
        ans2=abs(x-kkk*d+d)
    else:
        ans2=abs(x-kkk*d)
    print(min(ans,ans2))
    


Measured memory_bytes: 61992
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    string s; cin >> s;
    int one = 0, zero = 0;
    rep(i, s.size()) {
        if (s[i] == '0') zero++;
        else one++;
    }
    cout << min(zero, one) * 2 << endl;
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
#include <random>
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (ll)(4e18) + 9;
const int MOD = (int)(1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { d, r, u, l , dr, ur, dl, ul };
int dx[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiouy"; //and sometimes "aeiouy"

template<typename X, typename Y> bool ckmin(X& a, Y b) { return a > b ? a = b, true : false; }
template<typename X, typename Y> bool ckmax(X& a, Y b) { return a < b ? a = b, true : false; }

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
//convert index from 2D array to 1D array. (Zero-indexed)
int conv_2_1(int r, int c, int nCol) { return (nCol*r) + c + 1; }
//convert index from 1D array to 2D array. (Zero-indexed)
ii conv_1_2(int n, int nCol) {
	int r = n / nCol, c = n % nCol;
	return ii(r, c);
}

void inter(string s) {
	cout << s << endl;
	fflush(stdout);
}

const int NN = 2e6 + 10;
ll fact[NN];

void init() {
	fact[0] = 1;
	for (int i = 1; i < NN; ++i) fact[i] = (fact[i - 1] * 1LL * i) % MOD;
}

ll nCr(ll n, ll r) {
	auto modInverse = [](ll a) { 
		auto power = [](ll base, ll exp) {
			ll ans = 1;
			base %= MOD;
			while (exp > 0) {
				if (exp & 1) ans = (ans * base) % MOD;
				exp >>= 1;
				base = (base * base) % MOD;
			}
			return ans;
		};
		return power(a, MOD - 2); 
	};
	return (fact[n] * modInverse(fact[r] * 1LL * fact[n - r])) % MOD;
}



int main()
{
#ifndef ONLINE_JUDGE

#else
	//freopen("pyramid.in", "r", stdin);
#endif
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s, t;
	cin >> s >> t;
	int ans = 0;
	lop(i, sz(t)) ans += t[i] != s[i];
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 3812
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const int big=1e9+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
int n;
vector<vector<int>>hen;
vector<int>ki;//is kisu
int solve(int ter,int oya,int bgen){
	//解きます
	//cerr<<ter<<endl;
	multiset<int>soi;
	if(ki[ter]){soi.ins(0);}
	for(auto it:hen[ter]){
		if(it==oya){continue;}
		int kae=solve(it,ter,bgen);
		if(kae==-1){return -1;}
		soi.ins(kae);
	}
	//bgen以下を作る貪欲法
	//soiは1あまる
	//setで殴りすぎlogがひどい
	int sta=-1;
	while(soi.size()>1){
		int mae=*prev(soi.end());
		soi.era(prev(soi.end()));
		auto itr=soi.upper_bound(bgen-mae);
		if(itr==soi.begin()){//ないので
			if(sta!=-1){return -1;}
			else{sta=mae;}
		}
		else{soi.era(prev(itr));}
	}
	if(sta>bgen){return -1;}
	if(soi.size()==1){sta=*soi.begin();}
	if(oya!=-1){return sta+1;}
	else{return 0;}
}
int main(void){
	int i;
	cin>>n;hen.res(n);ki.res(n);
	for(i=0;i<n-1;i++){
		int a,b;cin>>a>>b;a--;b--;
		hen[a].pub(b);ki[a]=(!ki[a]);
		hen[b].pub(a);ki[b]=(!ki[b]);
	}
	int A=0,ha=-1;
	for(i=0;i<n;i++){if(ki[i]){A++;}if(hen[i].size()==1){ha=i;}}
	cout<<A/2<<" ";
	int bmax=n,bmin=0;
	while(bmax-bmin>1){
		int bgen=(bmax+bmin)/2;
		if(solve(ha,-1,bgen)!=-1){bmax=bgen;}
		else{bmin=bgen;}
	}
	cout<<bmax<<endl;
	RE;
}

Measured memory_bytes: 15488
n,t=map(int,input().split())
ab=[tuple(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x:x[0])
ab.insert(0,(0,0))
dp=[[0]*t for _ in range(n+1)]
for i in range(1,n+1):
    a,b=ab[i]
    if a<t:
        dp[i][a]=max(dp[i-1][a],b)
    for j in range(t):
        if dp[i-1][j]==0:
            continue
        if j+a<t:
            dp[i][j+a]=max(dp[i][j+a],dp[i-1][j]+b)
        dp[i][j]=max(dp[i-1][j],dp[i][j])
ans=0
p=[j for i,j in ab]
for i in range(1,n):
    ans=max(ans,max(dp[i])+max(p[i+1:]))
ans=max(ans,max(dp[n]))
print(ans)


Measured memory_bytes: 118232
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	string s, t;
	cin >> s >> t;
	vector<char>S;
	vector<char>T;
	for (int i = 0; i < s.size(); ++i) {
		S.push_back(s[i]);
	}
	for (int i = 0; i < t.size(); ++i) {
		T.push_back(t[i]);
	}
	sort(S.begin(),S.end());
	sort(T.begin(), T.end(), greater<char>());
	if (S < T)
		cout << "Yes" << endl;
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

int main(){
    string s,t; cin>>s>>t;
    string sub;
    int count=1000;
    int count2=0;

    for(int i=0;i<=s.size()-t.size();i++){
        int count2=0;
        sub=s.substr(i,t.size());
        for(int j=0;j<t.size();j++){
            if(t[j]!=sub[j])  count2++;
        }
        if(count2<count) count=count2;
    }

    cout<<count<<endl;
}

Measured memory_bytes: 3620
a,b,c,r,K;gcd(n,m){return m?gcd(m,n%m):n;}main(){scanf("%d",&K);for(a=1;a<=K;++a){for(b=1;b<=K;++b){for(c=1;c<=K;++c)r+=gcd(a,gcd(b,c));}}printf("%d",r);}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX=1e5+10;
int N,A[MAX],dp[MAX];
int solve(int idx)
{
    if(idx==N)return 0;
    if(idx>N)return 1e9;
    if(dp[idx]!=-1)return dp[idx];
    return dp[idx]=min(abs(A[idx+1]-A[idx])+solve(idx+1),abs(A[idx+2]-A[idx])+solve(idx+2));
}
int  main ()
{
    memset(dp,-1,sizeof dp);
    cin >> N;
    for(int i=1;i<=N;i++){
        cin >> A[i];
    }
    cout<<solve(1)<<endl;
    return 0;
}


Measured memory_bytes: 2560
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int S = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        list.add(S);
        int num = S;
        while(true) {
            if (num%2 == 0) {
                num = num/2;
                if (list.contains(num))  break;
                list.add(num);
            } else {
                num = num*3+1;
                if (list.contains(num))  break;
                list.add(num);
            }
        }
        System.out.println(list.size()+1);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
using namespace std;
// 素因数分解
typedef pair<long long, long long> P;
vector<P> prime_factorize(long long n)
{
vector<P> res;
for (long long p = 2; p * p <= n; ++p)
{
if (n % p != 0)
continue;
int num = 0;
while (n % p == 0)
{
++num;
n /= p;
}
res.push_back(make_pair(p, num));
}
if (n != 1)
res.push_back(make_pair(n, 1));
return res;
}
// 因数分解
long long gcd(long long x, long long y)
{
  if (y == 0)
  {
    return x;
  }
  else
  {
    return gcd(y, x % y);
  }
}
//素数判定
bool is_prime(long long n){
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
const int MOD = 1000000007;
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
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; }

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<bool> AC(N,false);
    map<ll, ll> WA;
    ll sum_AC = 0;
    ll sum_PE = 0;
    for (ll i = 0; i < M; i++)
    {
        ll p;
        cin >> p;
        string s;
        cin >> s;
        if(s=="AC"&&AC[p]==false){
            AC[p] = true;
            sum_AC++;
            sum_PE += WA[p];
        }
        else if (s == "WA")
        {
            WA[p]++;
        }
    }
    cout << sum_AC << " " << sum_PE << endl;

    return 0;
}

Measured memory_bytes: 9792
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 1005;
const ll N2 = 2000005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

ll n;
ll arr[N][N];
ll n1;
ll get(ll a, ll b) {
  if (a > b)
    swap(a, b);
  return a * n1 + b;
}
vector<ll> adj[N2];

bool visited[N2], visited2[N2]; // set to false
stack<ll> st;
// uncomment if want the cycle elements
// vector<ll> cycleEl;
bool dfs(ll curr) {
  visited2[curr] = true;
  visited[curr] = true;
  st.push(curr);
  for (ll x : adj[curr]) {
    if (!visited[x]) {
      bool val = dfs(x);
      if (val)
        return true;
    } else if (visited2[x]) {
      // uncomment if want the cycle elements
      /*
      while(true)
      {
          ll curr=st.top();
          st.pop();
          cycleEl.push_back(curr);
          if(curr==x)
              break;
      }
      */
      return true;
    }
  }

  st.pop();
  visited2[curr] = false;

  return false;
}

vector<ll> res;
void dfs2(ll curr) {
  visited[curr] = true;
  for (ll x : adj[curr]) {
    if (!visited[x])
      dfs2(x);
  }
  res.push_back(curr);
}

vector<ll> radj[N2];
void topologicalSort(ll n) {
  res.clear();
  memset(visited, false, sizeof(visited));
  for (ll i = 1; i <= n; i++) {
    if (!visited[i])
      dfs2(i);
  }
  reverse(res.begin(), res.end());
}

ll dp[N2];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n;
  n1 = n + 1;

  for (ll i = 1; i <= n; i++) {
    for (ll j = 1; j < n; j++) {
      cin >> arr[i][j];
    }
    for (ll j = 1; j < (n - 1); j++) {
      ll a = i, b = arr[i][j];
      ll a2 = i, b2 = arr[i][j + 1];

      adj[get(a, b)].push_back(get(a2, b2));

      //  cout << get(a, b) << " " << get(a2, b2) << en;

      radj[get(a2, b2)].push_back(get(a, b));
    }
  }

  memset(visited, false, sizeof(visited));

  memset(visited2, false, sizeof(visited2));
  for (ll i = 1; i <= n; i++) {
    for (ll j = i + 1; j <= n; j++) {
      if (!visited[get(i, j)]) {
        if (dfs(get(i, j))) {
          cout << -1 << en;
          return 0;
        }
      }
    }
  }
  //  cout << get(n - 1, n) << en;

  topologicalSort(get(n - 1, n));

  ll ans = 0;
  for (ll x : res) {
    //    cout << x << en;

    ll curr = 0;
    for (ll y : radj[x]) {
      curr = max(curr, dp[y]);
    }
    curr++;
    dp[x] = curr;
    ans = max(ans, curr);
  }

  cout << ans << en;

  return 0;
}

Measured memory_bytes: 154480
h, w = map(int, input().split())

if h == 1 or w == 1:
    c = 1
elif h & 1:
    if w & 1:
        c = ((h + 1) // 2) * ((w + 1) // 2) + (h // 2) * (w // 2)
    else:
        c = (((h + 1) // 2) + (h // 2)) * (w // 2)
else:
    c = (h // 2) * w

print(c)


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

using namespace std;

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string>str(H);
    for(int i=0; i<H; i++) {
        cin >> str[i];
    }
    vector<bool>row(H, false);
    vector<bool>col(W, false);
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            if(str[i][j]=='#') {
                row[i]=true;
                col[j]=true;
            }
        }
    }
    //cout << endl;
    for(int i=0; i<H; i++) {
        if(row[i]) {
            for(int j=0; j<W; j++) {
                if(col[j]) {
                    cout << str[i][j];
                }
            }
            cout << endl;
        }
    }
    return 0;
}


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

int main(){
    int n,k;
    cin>>n>>k;
    int p[n],i;
    for(i=0;i<n;i++)cin>>p[i];
    sort(p,p+n);
    int ans=0;
    for(i=0;i<k;i++) ans+=p[i];
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3644
N, A, B = map(int, input().split())
MOD = 10 ** 9 + 7

factorial = [1, 1]  # 元テーブル
inverse = [1, 1]  # 逆元テーブル
inverse_from = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, 2 * 10 ** 5 + 10):
    factorial.append((factorial[-1] * i) % MOD)
    inverse_from.append((-inverse_from[MOD % i] * (MOD // i)) % MOD)
    inverse.append((inverse[-1] * inverse_from[-1]) % MOD)


def calc(n):
    ret = 1
    for i in range(n):
        ret = ret * (N - i) % MOD
    return ret * inverse[n] % MOD


print(max(0, (pow(2, N, MOD) - ((calc(A) + calc(B)) % MOD) - 1) % MOD))


Measured memory_bytes: 27100
#include <stdio.h>
#define LENGTH 256

int main()
{
    char input[LENGTH];
    int N, i;
    int result;
    fgets(input, LENGTH-1, stdin);
    sscanf(input, "%d %d", &N, &i);
    result = N - i + 1;
    printf("%d\n", result);
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

const long long MOD = 1000000007;

int main(){
  ll n,a;
  ll ans=0;
  cin >> n;
  
  rep(i,n-1){
    ans += n/(i+1);
    if(n%(i+1)==0) ans--;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3612
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if(A % 3 == 0) {
      System.out.println("Possible");
    } else if(B % 3 == 0) {
      System.out.println("Possible");
    } else if((A + B) % 3 == 0) {
      System.out.println("Possible");
    } else {
      System.out.println("Impossible");
    }
  }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


ll calculate_gcd(ll a, ll b){
    if(a<b){swap(a,b);}
    if(b<1){return 0;}
    ll r;
    while((r = a%b) != 0){
        a = b;
        b = r;
    }
    return b;
}

ll calculate_lcm(ll a,ll b){
    return a*b/calculate_gcd(a,b);
}

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    ll maxval = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        maxval = max(maxval, a[i]);
    }
    ll gcd = a[0];
    for(int i = 0; i < n; i++){
        gcd = calculate_gcd(gcd, a[i]);
    }
    vector<ll> b(n);
    for(int i = 0; i < n; i++){
        b[i] = a[i]/gcd;
        if(b[i]%2 == 0){
            cout << 0 << endl;
            return 0;
        }
    }

    ll lcm = 1;
    for(int i = 0; i < n; i++){
        lcm = calculate_lcm(lcm, b[i]);
        if(lcm > m){cout << 0 << endl; return 0;}
    }
    ll base = lcm;
    for(int i = 0; i < n; i++){
        base = calculate_lcm(a[i]/2, base);
    }
    ll tmpans = m/base;
    ll ans = (tmpans+1)/2;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <cmath>

using namespace std;

int main(){

	int q;
	while(cin>>q&&q!=-1){
		double x=(double)q/2;
		while(abs(x*x*x-q)>=0.00001*q){
			x = x - (x*x*x-q)/(3*x*x);
		}
		printf("%.6f\n",x);
	}

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#define Max 45

int F[Max];

int fibonacci(int n){
  if((n == 0) || (n == 1)){
    return F[n] = 1;
  }
  if(F[n] != 0){
    return F[n];
  }
  return F[n] = fibonacci(n-2) + fibonacci(n-1);
}

int main(){
  int n;

  scanf("%44d",&n);
  printf("%d\n",fibonacci(n));

  return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
const int ss=3e5+5;



 
int main()
{

    int t=1;
    // cin>>t;
    while(t--)
    {
        ll n,k;
        cin>>n>>k;
        ll ar[n];
        for(int i=0;i<n;i++)
        {
            cin>>ar[i];
        }
        for(int i=k;i<n;i++)
        {
            if(ar[i]>ar[i-k])
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
        }

    }

    return 0;
}

Measured memory_bytes: 5204
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main()
{
  string s,t;
  cin>>s>>t;
  std::reverse(t.begin(),t.end());
  if(t==s)
  cout<<"YES"<<endl;
  else
  cout<<"NO"<<endl;
}

Measured memory_bytes: 3628
while True:
    H, W = [int(x) for x in input().split()]
    
    if H == W == 0: break
        
    for i in range(H):
        sharp = '#'
        period = '.'
        
        if i % 2 == 0:
            for k in range(W):
                if k % 2 == 0:
                    print(sharp, end='')
                if k % 2 == 1:
                    print(period, end='')
                    
            print()
        
        elif i % 2 == 1:
            for k in range(W):
                if k % 2 == 0:
                    print(period, end='')
                if k % 2 == 1:
                    print(sharp, end='')
        
            print() 
        
    print()


Measured memory_bytes: 7008
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int n,x;
  cin>>n>>x;
  vector<long long int> a(n);
  long long int ans=0;
  for(long long int i=0; i<n; i++){
    cin>>a.at(i);
    if(a.at(i)>x){
      ans+=a.at(i)-x;
      a.at(i)=x;
    }
  }
  for(long long int i=0; i<n-1; i++){
    long long int aida=a.at(i)+a.at(i+1);
    if(aida>x){
      long long int norma=aida-x;
      ans+=norma;
      if(a.at(i+1)>=norma){
        a.at(i+1)-=norma;
      }else{
        a.at(i)-=norma-a.at(i);
        a.at(i)=0;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main(){
	double d,e;
	double x,y;
	double min;	
	double route;

	while(1){
		cin >> d;
		cin >> e;

		if(e == 0 && d == 0){
			break;
		}
		min = -1;

		for(int i = 0;i <= d;i++){
			x = i;
			y = d-i;
			if(e -sqrt(pow(x,2)+pow(y,2)) > 0){
					route = e -sqrt(pow(x,2)+pow(y,2));
			}else{
				        route = sqrt(pow(x,2)+pow(y,2)) -e;
			}

			if(min > route || min == -1){
				min = route;
			}
		}
		
		cout << min << endl;
	}
}

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

int main(){
  long N, A, B;
  cin >> N >> A >> B;
  long r = N/(A+B);
  long k;
  if(N-(A+B)*r>=A){
    k=A;
  }else{
    k=N-(A+B)*r;
  }
  cout << r*A+k << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
vector<ll> enumDivisor(ll x) {
  vector<ll> res;
  for (ll i = 1; i*i <= x; ++i) {
    if (x % i) continue;
    res.push_back(i);
    if (i * i != x) res.push_back(x/i);
  }
  return res;
}
int main () {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  ll n;
  cin >> n;
  int ans = 0;
  for (auto x : enumDivisor(n)) {
    if (x == 1) continue;
    ll tmp = n;
    while (tmp%x == 0) tmp /= x;
    if (tmp%x == 1) ++ans;
  }
  ans += enumDivisor(n-1).size() - 1;
  cout << ans << endl;
}

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

ll gcd(ll a, ll b){
    if(a < b) return gcd(b, a);
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b){
    ll ret = a / gcd(a,b) * b;
    return ret;
}

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll numc = (b / c) - ((a + c - 1) / c) + 1;
    ll numd = (b / d) - ((a + d - 1) / d) + 1;
    ll l = lcm(c, d);
    ll numl = (b / l) - ((a + l - 1) / l) + 1;
    cout << b - a + 1 - numc - numd + numl << endl;
    return 0;
}

Measured memory_bytes: 3608
package main

import (
	"fmt"
)

func main() {
	var n int

	fmt.Scanf("%d", &n)

	sum := 0
	if n >= 10 {
		sum += 9
	} else {
		sum += n % 10
	}
	if n >= 1000 {
		sum += 900
	} else {
		if n >= 100 {
			sum += ((int)(n/100-1) * 100) + n%100 + 1
		}
	}
	if n >= 100000 {
		sum += 90000
	} else {
		if n >= 10000 {
			sum += ((int)(n/10000-1) * 10000) + n%10000 + 1
		}
	}

	fmt.Print(sum)
}


Measured memory_bytes: 512
N = int(input())
lis = [int(i) for i in input().split()]
i = 0
same = 1
ans = 0
while i < N-1:
  if lis[i] == lis[i+1]:
    same += 1
  else:
    ans += same//2
    same = 1
  i += 1
ans += same//2
print(ans)

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

int main() {
    int N;
    cin >> N;
    int sum = 0;
    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
        sum += A[i];
    }
    int mean = sum / N;
    int can1, can2, can3, can4;
    can1 = mean + 1;
    can2 = mean + 2;
    can3 = mean - 1;
    can4 = mean - 2;

    int res, res1, res2, res3, res4;
    res = 0, res1 = 0, res2 = 0, res3 = 0, res4 = 0;
    rep(i, N) { res += pow((A[i] - mean), 2); }

    rep(i, N) { res1 += pow((A[i] - can1), 2); }

    rep(i, N) { res2 += pow((A[i] - can2), 2); }

    rep(i, N) { res3 += pow((A[i] - can3), 2); }

    rep(i, N) { res4 += pow((A[i] - can4), 2); }

    res = min(res, min(res1, min(res2, min(res3, res4))));
    cout << res << endl;
}

Measured memory_bytes: 256