akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
 
int main() {
  char T[1000], P[1000];
  int i, j;
  int a;
 
  scanf("%s", T);
  scanf("%s", P);
 
  for (i = 0; i < strlen(T); i++)
    {
      a = 0;
      if (T[i] == P[0])
	{
	  a = 1;
	  for (j = 0; j < strlen(P); j++)
	    {
	      if (T[i+j] != P[j]) 
		{
		  a = 0;
		  break;
		}
            }
        }
      if (a == 1)
	{
	  printf("%d\n", i);
	}
    }
 
  return 0;
}

Measured memory_bytes: 540
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int a,b;
    cin>>a>>b;
    cout<<max({a+b,a-b,a*b})<<endl;
    return 0;
}

Measured memory_bytes: 256
n,u,v = map(int,input().split())
inf = 10 ** 6
u -= 1
v -= 1
peer = [[] for _ in range(n)]
for _ in range(n-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  peer[a].append(b)
  peer[b].append(a)
seen = [0 for _ in range(n)]
rank = [0 for _ in range(n)]
seen[v] = 1
now = [v]
pst = [[] for _ in range(n)]
pre = [inf for _ in range(n)]
while now:
  last = now
  now = []
  for x in last:
    for y in peer[x]:
      if seen[y] == 0:
        seen[y] = 1
        rank[y] = rank[x] + 1
        pst[x].append(y)
        pre[y] = x
        now.append(y)
#print(rank)
r = rank[u]
if r % 2 == 0:
  m = r//2 + 1
  M = u
  for _ in range(r-m):
    M = pre[M]
  now = [M]
  while now != []:
    last = now
    now = []
    for x in last:
      for y in pst[x]:
        now.append(y)
  ans = rank[last[0]] - m + r - m + 1
  #print(r,m,M,rank[last[0]],last[0])
  #print(0,ans)
else:
  m = r//2 + 1
  M = u
  for _ in range(r-m):
    M = pre[M]
  now = [M]
  while now != []:
    last = now
    now = []
    for x in last:
      for y in pst[x]:
        now.append(y)
  ans = rank[last[0]] - m + r - m
  #print(r,m,M,rank[last[0]],last[0])
  #print(1,ans)
print(ans)

Measured memory_bytes: 75552
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Build Stairs
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

/* global variables */

int hs[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", hs + i);

  for (int i = n - 2; i >= 0; i--)
    if (hs[i] > hs[i + 1]) {
      hs[i]--;
      if (hs[i] > hs[i + 1]) {
	puts("No");
	return 0;
      }
    }

  puts("Yes");
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
  int N,M,val[2000000];
  cin >> N >> M;
  while(N!=0){
    int dif=0,s,e,tmp,cnt=0;
    fill(val,val+2000000,0);
    int h[N+1],w[M+1];
    h[0]=w[0]=0;
    for(int i=0;i<N;i++){
      cin >> h[i+1];
    }
    for(int i=0;i<M;i++){
      cin >> w[i+1];
    }
    for(int i=1;i<=N;i++){
      h[i]+=h[i-1];
    }
    for(int i=1;i<=M;i++){
      w[i]+=w[i-1];
    }
    for(int i=0;i<=N;i++){
      for(int j=i+1;j<=N;j++){
        val[h[j]-h[i]]++;
      }
    }
    for(int i=0;i<=M;i++){
      for(int j=i+1;j<=M;j++){
        cnt+= val[w[j]-w[i]];
      }
    }
    cout << cnt << endl;
    cin >> N >> M;
  }
}



Measured memory_bytes: 10916
#include <stdio.h>
static int r, c;
static int m[101][101]; // matrix
int main(void) {
    int x, y;
    int t;  // temporal
    scanf("%d%d", &r, &c);
    for (y = 0; y < r; ++y)
        for (x = 0; x < c; ++x) {
            scanf("%d", &t);
            m[y][x] = t;
            m[y][c] += t;
            m[r][x] += t;
            m[r][c] += t;
        }
    for (y = 0; y <= r; ++y) {
        for (x = 0; x <= c; ++x) {
            if (x) putchar(' ');
            printf("%d", m[y][x]);
        }
        putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 644
from math import atan, degrees
a, b, x = map(int, input().split())

if 2*x >= a*a*b:
    h = 2*(a*a*b-x)/(a*a)
    print(degrees(atan(h/a)))
else:
    l = 2*(a*a*b-x)/(a*b) - a
    print(degrees(atan(b/(a-l))))


Measured memory_bytes: 3060
s = list(input())

def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f + "=7")
            exit()
    else:
        dfs(i+1, f + "-" + s[i+1], sum - int(s[i+1]))
        dfs(i+1, f + "+" + s[i+1], sum + int(s[i+1]))

dfs(0, s[0], int(s[0]))

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

using namespace std;

typedef long long ll;

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
//#define N 100005
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795



ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}






int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);

ll n;cin>>n;
ll x=n%10;

if(x==2||x==4||x==9||x==5||x==7)cout<<"hon";

else if(x==0||x==1||x==6||x==8)cout<<"pon";
else cout<<"bon";



return 0;

}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N;
  cin>>N;
  
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  
  bool res=false;
  
  int x=0;
  
  int y=0;
  
  for(int i=0;i<N;i++){
    if(A[i]%2==1){
      x++;
    }
    else if(A[i]%4==0){
      y++;
    }
  }
  
  if(N==x+y){
    if(x<=y+1){
      res=true;
    }
  }
  else{
    if(x<=y){
      res=true;
    }
  }
  
  if(res){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3700
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    InputReader cin = new InputReader(System.in);
    PrintWriter cout = new PrintWriter(System.out);

    Task task = new Task();
    task.run(cin, cout);

    cout.close();
  }
}

class Task {
  void run(InputReader cin, PrintWriter cout) {
    int n = cin.nextInt();
    int m = cin.nextInt();

    int[] n_ball = new int[n];
    boolean[] may_good = new boolean[n];

    Arrays.fill(n_ball, 1);
    Arrays.fill(may_good, false);
    may_good[0] = true;

    for (int i = 0; i < m; ++i) {
      int x = cin.nextInt() - 1;
      int y = cin.nextInt() - 1;
      n_ball[x] -= 1;
      n_ball[y] += 1;
      if (may_good[x]) {
        may_good[y] = true;
      }
      if (n_ball[x] == 0) {
        may_good[x] = false;
      }
    }

    int n_good = 0;
    for (int i = 0; i < n; ++i) {
      if (may_good[i]) {
        n_good += 1;
      }
    }

    cout.printf("%d\n", n_good);
  }
}

class InputReader {
  public BufferedReader reader;
  public StringTokenizer tokenizer;

  public InputReader(InputStream stream) {
    reader = new BufferedReader(new InputStreamReader(stream), 32768);
    tokenizer = null;
  }

  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new StringTokenizer(reader.readLine());
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  public int nextInt() {
    return Integer.parseInt(this.next());
  }
}


Measured memory_bytes: 43144
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();
		
		int n = Integer.parseInt(str);
		
		int lowestRank = 0;
		int lowestScore = Integer.MAX_VALUE;
		for(int i = 0; i < n; i++){
			String[] tmpArray = br.readLine().split(" ");
			int rank = Integer.parseInt(tmpArray[0]);
			int score = Integer.parseInt(tmpArray[1]);
			
			if(lowestRank < rank){
				lowestRank = rank;
				lowestScore = score;
			}
		}
		
		int result = lowestRank + lowestScore;
		System.out.println(result);
	}

}


Measured memory_bytes: 45856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const ll MOD = 1000000007LL;

ll ipow(ll base, ll exp)
{
    ll result = 1LL;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

//const long double PI = (acos(-1));
//const long double EPS = 0.0000000001;

int n, k;
vi leftv;
vi rightv;

int leftdp[55][105];
int rightdp[55][105];

int solveleft(int pos, int cnt) {
    if(cnt == 0) return 0;
    if(pos == n) return 0;

    int& ret = leftdp[pos][cnt];
    if(ret != -1) return ret;
    ret = 0;
    ret = max(ret, leftv[pos] + solveleft(pos+1, cnt-1));
    if(cnt >= 2) {
        ret = max(ret, solveleft(pos+1, cnt-2));
    }
    return ret;
}

int solveright(int pos, int cnt) {
    if(cnt == 0) return 0;
    if(pos == n) return 0;

    int& ret = rightdp[pos][cnt];
    if(ret != -1) return ret;
    ret = 0;
    ret = max(ret, rightv[pos] + solveright(pos+1, cnt-1));
    if(cnt >= 2) {
        ret = max(ret, solveright(pos+1, cnt-2));
    }
    return ret;
}

int main(void) {
    ios_base::sync_with_stdio(false); 
    cin.tie(0); 
    cout.tie(0);
    //freopen("in.txt", "r", stdin);
    memset(rightdp, -1, sizeof(rightdp));
    memset(leftdp, -1, sizeof(leftdp));
    cin >> n >> k;
    leftv.resize(n);
    rightv.resize(n);
    rep(i,0,n) {
        cin >> leftv[i];
        rightv[n-1-i] = leftv[i];
    }

    int ret = 0;
    rep(cnt, 0, k+1) {
        ret = max(ret, solveright(0,cnt)+solveleft(0,max(0,min(n-cnt,k-cnt))));
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line1 = reader.readLine();
		int n = Integer.parseInt(line1);
		int s[] = new int[13];
		int h[] = new int[13];
		int c[] = new int[13];
		int d[] = new int[13];
		for(int i = 0; i < 13; i++){
			s[i] = 0;
			h[i] = 0;
			c[i] = 0;
			d[i] = 0;
		}
		for(int j = 0; j < n; j++){
			String line = reader.readLine();
			String[] sarray = line.split(" ", -1);
			if(sarray[0].equals("S")){
				s[(Integer.parseInt(sarray[1]) - 1)]++;
			} else if(sarray[0].equals("H")){
				h[(Integer.parseInt(sarray[1]) - 1)]++;
			} else if(sarray[0].equals("C")){
				c[(Integer.parseInt(sarray[1]) - 1)]++;
			} else if(sarray[0].equals("D")){
				d[(Integer.parseInt(sarray[1]) - 1)]++;
			}
		}
		for(int k = 0; k < 4; k++){
			for(int l = 0; l < 13; l++){
				switch(k){
					case 0:
						if(s[l] == 0){
							System.out.println("S " + (l + 1));
						}
						break;
					case 1:
						if(h[l] == 0){
							System.out.println("H " + (l + 1));
						}
						break;
					case 2:
						if(c[l] == 0){
							System.out.println("C " + (l + 1));
						}
						break;
					default:
						if(d[l] == 0){
							System.out.println("D " + (l + 1));
						}
				}
			}
		}
	}
}

Measured memory_bytes: 24392
n,m = map(int, input().split())
vote_ls = list(map(int, input().split()))

top_vote_ls = []
selectable = (1/(4*m))*sum(vote_ls)

for i in range(0, m):  
  max = 0
  for j in range(len(vote_ls)):      
    if vote_ls[j] > max: 
      max = vote_ls[j]; 
  vote_ls.remove(max); 
  if max >= selectable:
    top_vote_ls.append(max) 

if len(top_vote_ls) >= m: 
  print("Yes")
else:
  print("No")



Measured memory_bytes: 3064
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (h, w) = (v[0], v[1]);
    let mut grid = vec![vec![]; h];
    for y in 0..h {
        grid[y] = read::<String>().chars().collect::<Vec<_>>();
    }
    debug!("a");

    let mut sum_tate = vec![vec![0; w + 1]; h + 1];
    let mut sum_tate_r = vec![vec![0; w + 1]; h + 1];
    for y in 0..h {
        for x in 0..w {
            if grid[y][x] == '#' {
                sum_tate[y][x] = 0;
            } else if x >= 1 && grid[y][x - 1] == '.' {
                sum_tate[y][x] = 1 + sum_tate[y][x - 1];
            }
        }
    }
    debug!("a");
    for y in 0..h {
        for x in (0..w).rev() {
            if grid[y][x] == '#' {
                sum_tate_r[y][x] = 0;
            } else if w >= 2 && x <= w - 2 && grid[y][x + 1] == '.' {
                sum_tate_r[y][x] = 1 + sum_tate_r[y][x + 1];
            }
        }
    }
    debug!("a");

    let mut sum_yoko = vec![vec![0; w]; h];
    let mut sum_yoko_r = vec![vec![0; w]; h];
    for x in 0..w {
        for y in 0..h {
            if grid[y][x] == '#' {
                sum_yoko[y][x] = 0;
            } else if y >= 1 && grid[y - 1][x] == '.' {
                sum_yoko[y][x] = 1 + sum_yoko[y - 1][x];
            }
        }
    }

    for x in 0..w {
        for y in (0..h).rev() {
            if grid[y][x] == '#' {
                sum_yoko_r[y][x] = 0;
            } else if h >= 2 && y <= h - 2 && grid[y + 1][x] == '.' {
                sum_yoko_r[y][x] = 1 + sum_yoko_r[y + 1][x];
            }
        }
    }
    // debug!(sum_yoko_r);

    let mut ans = 0i64;
    for y in 0..h {
        for x in 0..w {
            /*
            debug!(
                y,
                x,
                sum_tate[y][x] + sum_tate_r[y][x] + sum_yoko[y][x] + sum_yoko_r[y][x] + 1,
                sum_tate[y][x],
                sum_tate_r[y][x],
                sum_yoko[y][x],
                sum_yoko_r[y][x]
            );
            */

            ans = max(
                ans,
                sum_tate[y][x] + sum_tate_r[y][x] + sum_yoko[y][x] + sum_yoko_r[y][x] + 1,
            );
        }
    }
    println!("{:?}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 184572
n = int(input())
w = list(map(int, input().split()))
l = []
for i in range(1, n):
    s1 = 0
    s2 = 0
    for j in range(0, i):
        s1 += w[j]
    s2 = sum(w) -s1
    l.append(abs(s1-s2))
print(min(l))

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
  int n;
  cin >> n;
  map<string, int>mp;
  rep(i, 0, n){
    string s;
    cin >> s;
    mp[s]++;
  }
  int ans = 0;
  for(auto i:mp){
    ans = max(ans, i.second);
  }
  for(auto i:mp){
    if(i.second == ans)cout << i.first << endl;
  }
}

Measured memory_bytes: 19244
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>	
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
using namespace std;
int dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
#define INF 2000000000
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define mk make_pair
#define en endl
#define RE return 0
#define int ll
#define P pair<int,int>

int h,w,k;
int dp[105][10];

int saiki(int takasa,int yoko){
	if(takasa==h){
		return yoko==k-1;
	}
	if(dp[takasa][yoko]!=-1) return dp[takasa][yoko];
	
	int cnt=0;
	for(int bit=0; bit<1<<(w-1); bit++){
		bool ok=true;
		for(int k=0; k<w-2; k++){
			if(bit&(1<<k)&&bit&(1<<(k+1))){
				ok=false;
				break;
			}
		}
		if(!ok) continue;
		if(yoko>=1&&bit&(1<<(yoko-1))) cnt+=saiki(takasa+1, yoko-1);
		else if(bit&(1<<(yoko))) cnt+=saiki(takasa+1, yoko+1);
		else cnt+=saiki(takasa+1, yoko);
	}
	return dp[takasa][yoko]=cnt%MOD;
}

signed main(){
	cin>>h>>w>>k;
	memset(dp, -1, sizeof(dp));
	cout<<saiki(0, 0)<<en;
}
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  sort(a.begin(),a.end());
  const Int MOD = 998244353;
  Int ans=a[0]%MOD;
  for(Int i=1;i<n;i++) ans=(ans*__gcd(a[i],i))%MOD;
  cout<<ans<<endl;
  return 0;
}


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


int main(){
  
  while(1){
  int n;
  cin>>n;
  int nd=n;;
  if(n==0){break;}
  int a[100000];
  bool t=false;

  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]==0){nd-=1;}
    if(a[i]>=2){t=true;}
  }

  if(t){cout<<nd+1<<endl;}
  else{cout<<"NA"<<endl;}
  }
  
  return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    if(size(s) > size(t)) {
        cout << "GREATER" << endl;
    }else if(size(s) < size(t)) {
        cout << "LESS" << endl;
    }else {
        for(int i = 0; i < size(s); i++) {
            int a = s[i] - '0';
            int b = t[i] - '0';
            if(a == b) continue;
            if(a > b) {
                cout << "GREATER" << endl;
                return 0;
            }else {
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }
}

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

using namespace std;

const long long INF = 1LL << 60;

template<typename T>
class LazySegTree {
public:
    explicit LazySegTree(int n, T init, T def) : N(calcN_(n)), def(def) {
        mVal.assign(2*N+1, init);
        mLazy.assign(2*N+1, 0);
        mDirty.assign(2*N+1, 0);
    }
    void update(int l, int r, T value){
        updateImpl_(l, r, value, 0, 0, N);
    }
    void setVal(int idx, T value){
        T cur= get(idx, idx+1);
        update(idx, idx+1, value - cur);
    }
    T get(int l, int r){
        return getImpl_(l, r, 0, 0, N);
    }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    void updateImpl_(int l, int r, T value, int idx, int rangeL, int rangeR){
        eval_(idx);
        if(r <= rangeL || rangeR <= l) return;
        if(l <= rangeL && rangeR <= r){
            setLazy_(idx, value);
            eval_(idx);
        } else {
            int rangeM = (rangeL+rangeR)/2;
            updateImpl_(l, r, value, 2*idx+1, rangeL, rangeM);
            updateImpl_(l, r, value, 2*idx+2, rangeM, rangeR);
            mVal[idx] = operate_(mVal[2*idx+1], mVal[2*idx+2]);
        }
    }
    void setLazy_(int idx, T value){
        mLazy[idx] += value;
        mDirty[idx] = 1;
    }
    T getImpl_(int l, int r, int idx, int rangeL, int rangeR){
        if(r <= rangeL || rangeR <= l) return def;
        eval_(idx);
        if(l <= rangeL && rangeR <= r) return mVal[idx];
        int rangeM = (rangeL+rangeR)/2;
        T a = getImpl_(l, r, 2*idx+1, rangeL, rangeM);
        T b = getImpl_(l, r, 2*idx+2, rangeM, rangeR);
        return operate_(a, b);
    }
    void eval_(int idx){
        if(!mDirty[idx]) return;
        mVal[idx] += mLazy[idx];
        if(idx < N-1){
            setLazy_(2*idx+1, mLazy[idx]);
            setLazy_(2*idx+2, mLazy[idx]);
        }
        mLazy[idx] = 0;
        mDirty[idx] = 0;
    }
    T operate_(T a, T b) const { return min(a, b); }
    const int N;
    const T def;
    vector<T> mVal;
    vector<T> mLazy;
    vector<int> mDirty;
};

int main(){
    int N, Q, A, B; cin >> N >> Q >> A >> B;
    vector<int> x(Q);
    for(auto& t : x) cin >> t;
    LazySegTree<long long> minus(N+1, 1LL << 40, INF);
    LazySegTree<long long> plus(N+1, 1LL << 40, INF);
    minus.setVal(A, abs(B-x[0]) - A);
    minus.setVal(B, abs(A-x[0]) - B);
    plus.setVal(A, abs(B-x[0]) + A);
    plus.setVal(B, abs(A-x[0]) + B);
    for(int i=1;i<Q;i++){
        auto v = min(minus.get(0, x[i]) + x[i], plus.get(x[i], N+1) - x[i]);
        minus.update(1, N+1, abs(x[i]-x[i-1]));
        plus.update(1, N+1, abs(x[i]-x[i-1]));
        minus.setVal(x[i-1], v - x[i-1]);
        plus.setVal(x[i-1], v + x[i-1]);
    }
    long long res = INF;
    for(int i=1;i<=N;i++) res = min(res, plus.get(i, i+1) - i);
    cout << res << endl;
}

Measured memory_bytes: 24660
package main

import "fmt"

func dump(m map[int]map[string]int, n int) {
	var cs = []string{"A", "C", "G", "T"}
	for i := 3; i <= n; i++ {
		for _, c1 := range cs {
			for _, c2 := range cs {
				for _, c3 := range cs {
					s := c1 + c2 + c3
					fmt.Println(s, m[i][s])
				}
			}
		}
	}
}

func dp(s string, n int, m map[int]map[string]int) {
	if s != "AGC" && s != "ACG" && s != "GAC" {
		s1 := "A" + s[0:2]
		s2 := "C" + s[0:2]
		s3 := "G" + s[0:2]
		s4 := "T" + s[0:2]
		m[n][s] = m[n-1][s1] + m[n-1][s2] + m[n-1][s3] + m[n-1][s4]
		if (s[0] == 'G' && s[2] == 'C') || (s[1:] == "GC") {
			m[n][s] -= m[n-1][s1]
		}
		m[n][s] %= 1000000007
	} else {
		m[n][s] = 0
	}
}

func main() {
	var n int
	fmt.Scan(&n)
	var cs = []string{"A", "C", "G", "T"}

	memo := make(map[int]map[string]int)
	for i := 3; i <= n; i++ {
		memo[i] = make(map[string]int)
	}

	for _, c1 := range cs {
		for _, c2 := range cs {
			for _, c3 := range cs {
				s := c1 + c2 + c3
				if s != "AGC" && s != "ACG" && s != "GAC" {
					memo[3][s] = 1
				}
			}
		}
	}

	for i := 4; i <= n; i++ {
		for _, c1 := range cs {
			for _, c2 := range cs {
				for _, c3 := range cs {
					s := c1 + c2 + c3
					dp(s, i, memo)
				}
			}
		}
	}

	ans := 0
	for _, v := range memo[n] {
		ans += v
		ans %= 1000000007
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1280
N, Y = map(int, input().split())
for i in range(N + 1):
    for j in range(N + 1 - i):
        if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y:
            print(i, j, N - i - j)
            exit()
print('-1 -1 -1')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N, X; cin >> N >> X;
  vecll MS(N);
  REP(i, N) cin >> MS[i];
  sort(MS.begin(), MS.end());
  ll S_MS = 0;
  ll mm = MS[0];
  for (const auto m: MS) S_MS += m;
  ll res = N;
  X -= S_MS;
  res += X / mm;
  cout << res << endl;
  return 0;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    for(int i = 0; i < (int)(s.length()); i++){
        s[i] = (char)(int)s[i] + n;
        if((int)s[i] > 90){
            s[i] = (char)(((int)s[i]) - 90 + 64);
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 256
let n = Int(readLine()!)!
 
let a = readLine()!.split(separator: " ").map { Int($0)! }
 
var stocks = 0
var money = 1000
 
for i in 1..<n {
  if a[i-1] < a[i] {
    // buy
    stocks += money / a[i-1]
    money = money % a[i-1]
  } else if a[i-1] > a[i] {
    //sell
    money += stocks * a[i - 1]
    stocks = 0
  }
  if i == n - 1 {
     money += stocks * a[i]
     stocks = 0  
  }
}
 
 
print(money)

Measured memory_bytes: 8292
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string disp(bool x){
    return x ? "Yes" : "No";
}

int main(){
    int a,b,c; cin >> a >> b >> c;
    
    a = a-b;
    
    while(a-c >= 0){
        a = a-c;
    }
    cout << a << endl;
}
    
    






Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

d=[]
for i in range(N):
    d.append(a[i]-b[i])

cnt=-sum(d)
p=0
n=0
for j in range(N):
    if d[j]>0:
        p+=d[j]
    if d[j]<0:
        n+=-d[j]-(-d[j])%2
if n>=p*2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 4596
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

ll pw(ll x, ll y, ll mod) {
    if (y == 0) return 1;
    else if (y == 1) return x % mod;
    else if (y % 2 == 0) {
        ll p = pw(x, y / 2, mod);
        return p * p % mod;
    }
    else {
        ll p = pw(x, y / 2, mod);
        return p * p % mod * x % mod;
    }
}

ll dv(ll x, ll y, ll mod) {
    x %= mod;
    y %= mod;
    return x * pw(y, mod - 2, mod) % mod;
}
 

int main() {
    int n, p;
    cin >> n >> p;
    string s;
    cin >> s;

    ll ten[n + 5], va = 1;
    for (int i = 0; i <= n; i++) {
        ten[i] = va;
        va = va * 10 % p;
    }

    if (p == 2) {
        ll rem = 0, ans = 0;
        for (int i = 0; i < n; i++) {
            if (s[i] % 2 == 0) {
                ans += i + 1;
            }
        }
        cout << ans << endl;
        return 0;
    }
    if (p == 5){
        ll rem = 0, ans = 0;
        for (int i = 0; i < n; i++) {
            if ((s[i] - 48) % 5 == 0) {
                ans += i + 1;
            }
        }
        cout << ans << endl;
        return 0;
    }

    ll x[n] = {}, y[n] = {};
    va = 0;
    for (int i = 0; i < n; i++) {
        va = (va + int(s[i] - 48) * ten[n - 1 - i]) % p;
        x[i + 1] = va;
    }
    va = 0;
    y[n] = 0;
    vector<int> v[p];
    v[0].push_back(n);
    for (int i = n - 1; i >= 0; i--) {
        va = (va + int(s[i] - 48) * ten[n - 1 - i]) % p;
        y[i] = va;
        v[va].push_back(i);
    }

    ll ans = 0;

    for (int i = 0; i < p; i++) sort(all(v[i]));
    for (int i = 0; i < n; i++) {
        int k = (x[n] - x[i] + p) % p;
        int l = -1, r = v[k].size();
        while (r - l > 1) {
            int m = (l + r) / 2;
            if (v[k][m] > i) r = m;
            else l = m;
        }
        ans += v[k].size() - r;
        cerr << i _ ans _ r _ k _ v[k].size() << endl;
    }

    cout << ans << endl;
    

}

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

int main(){
  int n;
  cin >> n;
  
  vector<int> v(n);
  vector<int> c(n);
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> v.at(i);
  for(int i = 0; i < n; i++) cin >> c.at(i);
  for(int i = 0; i < n; i++) a.at(i) = v.at(i) - c.at(i);
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(a.at(i) > 0) ans += a.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
Module Module081B
    Sub Main(ByVal args() As String)
        Dim N As Integer
        Dim i As Integer
        Dim result As Integer : result = 0
        Dim Flag As Boolean : Flag = True

        N = Console.ReadLine()

        Dim arr() As String
        Dim arr_I() As Integer

        ReDim arr(N - 1)
        ReDim arr_I(N - 1)

        arr = Split(Console.ReadLine())

        For i = 0 To N - 1
            arr_I(i) = Integer.Parse(arr(i))
        Next

        While True
            For i = 0 To N - 1
                If arr_I(i) Mod 2 <> 0 Then
                    Flag = False
                    Exit For
                End If
                arr_I(i) = arr_I(i) / 2
            Next
            If Flag = False Then
                Exit While
            End If
            result = result + 1
        End While

        Console.Write(result)
    End Sub
End Module


Measured memory_bytes: 13536
#全探索版

if __name__ == '__main__':

	#n:桁数 m:チェック数
	n,m = map(int,input().split())

	B = []
	for i in range(m):
		x,y = map(int,input().split())
		B.append([x,y])

	flg = False
	for j in range(0,1000):
		tmp = str(j).zfill(n)
		#桁数同士の比較
		#桁数が異なるなら次へ
		if len(str(j)) == len(tmp):
			#チェック開始
			flg = False
			for cmd in B:
				#桁数分ループ
				t2 = cmd[0]
				t3 = str(cmd[1])

				if tmp[t2-1] != t3:
					flg = True
					break
			if flg == False:
				print(j)
				break
	if flg == True:
		print("-1")


Measured memory_bytes: 9164
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b>>c;
    if(a+b>=c && a<=c){
        cout <<"YES";
    }else{
        cout <<"NO";
    }
}

Measured memory_bytes: 256
n = gets.to_i
sticks = gets.split.map(&:to_i).sort
sum = 0
(0...n - 2).each do |index_1|
  (index_1 + 1...n - 1).each do |index_2|
    max = sticks[index_1] + sticks[index_2]
    sum += (sticks.bsearch_index { |s| s >= max } || n) - index_2 - 1
  end
end
puts sum


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

vector<long long> COM;

// a^b mod p を返す
long long modpow(long long a, long long b, long long p) {
  if (b == 0) return 1;
  long long res = modpow(a, b / 2, p);
  if (b % 2 == 0) res = (res * res) % p;
  else res = (((res * res) % p) * a) % p;
  return res;
}

// mod p における a の逆元 a^{p-2} mod p を返す
long long inverse(long long a, long long p) {
  return modpow(a, p-2, p);
}

// nCr を計算
// COM[r] := nCr mod p の値
void Combination(long long n, long long r, long long p) {
  COM.resize(r+1);
  long long t = 1;
  COM.at(0) = t;
  for (int i = 1; i <= r; i++) {
    t = t * (n-i+1) % p;
    t = t * inverse(i, p) % p;
    COM.at(i) = t;
  }
}

// val を m で割った余り (>= 0) を返す
long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

int main() {
  int n, a, b; cin >> n >> a >> b;
  const int MOD = 1000000007;
  Combination(n, 200000, MOD);
  long long ans = modpow(2, n, MOD);
  cout << mod(ans - 1 - COM.at(a) - COM.at(b), MOD) << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define forr(i, t, n) for (int i = t; i<n; ++i)
#define rmod(x, y) (((x%y)+y)%y)
#define pb push_back
#define emp emplace_back
#define ppb pop_back
#define len(v) int(v.size())
#define all(v) (v).begin(),(v).end()
#define ri(x) scanf("%d",&(x))
#define rii(x,y) scanf("%d %d",&(x),&(y))
#define riii(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rl(x) scanf("%lld",&(x))
#define rll(x,y) scanf("%lld %lld",&(x),&(y))
#define rlll(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
void fastio(){ios_base::sync_with_stdio(false); cin.tie(0);}

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;
const int maxn = 1e5;

bool visited[maxn];
int n, m, x, y, k, mxc;
vector<int> vs[maxn];
map<pii, int> etoc;
map<int, pii> ntoe;

void dfs(int v, int cp = -1){
	visited[v] = true;
	int col = 0;
	for(auto&e:vs[v]){
		if(not visited[e]){
			if (col == cp) col++;
			etoc[{v, e}] = etoc[{e, v}] = col;
			dfs(e, col);
			col++;
		}
	}
}

int main() {
	ri(n);
	forn(i, n-1){
		rii(x, y);
		vs[--x].pb(--y);
		vs[y].pb(x);
		ntoe[i] = {x, y};
		mxc = max(mxc, max(len(vs[x]), len(vs[y])));
	}
	dfs(0);
	printf("%d\n", mxc);
	forn(i, n-1){
		printf("%d\n", etoc[ntoe[i]]+1);
	}

	
	
	return 0;
}

Measured memory_bytes: 24832
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, m, n) for (int i = m; i < n; i++)
#define repr(i, m, n) for (int i = m; i >= n; i--)
#define db(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 998244353
#define EPS 1e(-9);
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {

    // 絶対行けないなら No 行けるならN-1回で達成できる

    // どちらのBにも入れるAが2つ以上ある場合、それ以外でA<=Bとなるように、N-2回の置換で必ずできるので Yes
    // そのようなA,Bはsortして1つとなりのものを調べれば良い

    // あとは 1対1 対応のA-Bである場合のみ考える

    // A -> 対応するB となる置換σの各pを生成
    // 参考: https://oguemon.com/study/linear-algebra/permutation/

    // 巡回置換であるとき、すなわち v=0から出て、もどったときのct==Nなら No
    // そうでなければ分割できる（すでに対応するA-Bの組であるなど）ので Yes


    int N; cin>>N;

    ll A[N],B[N];

    vector<P> a;
    vector<P> b;

    rep(i,N){
        cin>>A[i];
        a.emplace_back(A[i],i);
    }
    rep(i,N){
        cin>>B[i];
        b.emplace_back(B[i],i);
    }

    SORT(a);
    SORT(b);

    rep(i,N){
        if(b[i].first<a[i].first){
            cout<< "No" <<"\n"; return;
        }
    }

    rep(i,N-1){
        if(a[i+1].first<=b[i].first){
            cout<< "Yes" <<"\n"; return;
        }
    }

    ll p[N];

    rep(i,N){
        p[a[i].second]=b[i].second;
    }

    ll v=0;
    ll ct=0;
    while(true){
        v=p[v];
        ++ct;
        if(v==0) break;
    }

    if(ct<N){
        cout<< "Yes" <<"\n";
    }
    else{
        cout<< "No" <<"\n";
    }

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 7408
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>

using namespace std;

const int maxn=110;
string all[maxn];
bool cmp(string str1,string str2);

int main()
{
    int n,l;
    scanf("%d %d",&n,&l);
    for(int i=0;i<n;i++)
        cin>>all[i];
    sort(all,all+n,cmp);
    string ans;
    for(int i=0;i<n;i++)
        ans+=all[i];
    cout<<ans<<endl;
    return 0;
}

bool cmp(string str1,string str2)
{
    return str1+str2<str2+str1;
}


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

int main(){
  int X;
  cin >> X;
  int happy=0;
  while(X-500>=0){
    X-=500;
    happy+=1000;
  }
  while(X-5>=1){
    X-=5;
    happy+=5;
  }
  cout << happy << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    ll pre = 2, cur = 1;
    rep(i, n-1){
        ll tmp = cur;
        cur += pre;
        pre = tmp;
    }

    cout << cur << endl;

    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::*;

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
#[test]
        fn solve_test() {
            $(
                {
                    let mut out = Vec::<u8>::new();
                    solve($input,&mut out);
                    let out_str =str::from_utf8(&out).unwrap();
                    assert_eq!(&out_str, &$output);
                }
            )*
        }
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
#[allow(unused_mut)]
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr,str) => {
        $iter.next().unwrap()
    };

    ($iter:expr, $t:tt) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

fn main() {
    let mut out = std::io::stdout();

    solve(&stdin!(), &mut out);
}

#[allow(unused_mut)]
fn solve<W: std::io::Write>(src: &str, out: &mut W) {
    #[allow(unused_macros)]
    macro_rules! out {
        ($fmt:expr) => {{
            let _ = out.write_fmt(format_args!($fmt));
        }};
        ($fmt:expr, $($args:tt)*) => {{
            let _ = out.write_fmt(format_args!($fmt, $($args)*));
        }};
    }
    #[allow(unused_macros)]
    macro_rules! outln {
        ($fmt:expr) => {{
            out!(concat!($fmt,"
"));
        }};
        ($fmt:expr, $($args:tt)*) => {{
            out!(concat!($fmt, "
"), $($args)*);
        }};
    }

    input! {
        source = src,
        n:usize,
        x:usize,
        t:usize,
    }
    out!("{}", (n / x + if n % x > 0 { 1 } else { 0 }) * t);
}
test! {}


Measured memory_bytes: 2092
import java.util.*;

class D {
    static final char[] bs = {'.', '#'};

    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        final int N = Integer.parseInt(sc.nextLine());
        final char[] up = new char[N];
        final char[] lo = new char[N];
        int cols = 0;
        loop1:
        for (; cols < N; cols++) {
            for (int i = 0; i < 2; i++)
                for (int j = 0; j < 2; j++) {
                    up[cols] = bs[i];
                    lo[cols] = bs[j];
                    System.out.println(new String(up, 0, cols + 1));
                    System.out.println(new String(lo, 0, cols + 1));
                    switch (sc.nextLine()) {
                        case "end":
                            return;
                        case "T":
                            continue loop1;
                        case "F":
                            break;
                        default:
                            throw null;
                    }
                }
            break;
        }
        for(int i = 1; i <= cols; i++) {
            up[N - i] = up[cols - i];
            lo[N - i] = lo[cols - i];
        }
        loop2:
        for (; cols < N; cols++) {
            for (int i = 0; i < 2; i++)
                for (int j = 0; j < 2; j++) {
                    up[N - cols - 1] = bs[i];
                    lo[N - cols - 1] = bs[j];
                    System.out.println(new String(up, N - cols - 1, cols + 1));
                    System.out.println(new String(lo, N - cols - 1, cols + 1));
                    switch (sc.nextLine()) {
                        case "end":
                            return;
                        case "T":
                            continue loop2;
                        case "F":
                            break;
                        default:
                            throw null;
                    }
                }
            break;
        }
    }
}
public class Main {
    public static void main(String... args) {
        D.main();
    }
}

Measured memory_bytes: 13852
#include<iostream>
#include<string>

using namespace std;
string S;
int j,i;
int main()
{
    while(cin >> S){
        j=0;
        i=0;
        for(int k=0;k<S.size()-2;k++){
            if(S.substr(k,3)=="JOI"){
                j++;
            }
            if(S.substr(k,3)=="IOI"){
                i++;
            }
        }
        cout << j << endl;
        cout << i << endl;
    }
    
    return 0;
}



Measured memory_bytes: 2996
parseInt(x) = parse(BigInt, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	p = 10^9+7
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	k = lcm(a)
	s = 0
	for i in 1:n
		s = (s+k÷a[i])%p
	end
	println(s)
end

main()

Measured memory_bytes: 154504
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll N;
    cin >> N;

    cout << (N & 1 ? N / 2 + 1 : N / 2) << endl;
    return 0;
}


Measured memory_bytes: 256