akhauriyash/Code-Regression huggingface dataset:
/*
  The Island Was Silent before.
  .....
  And One day again it became Silent.
*/
#include<bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ll  long long
#define modd(a,b) ((a+2*b)%b)
#define debug(a) cout << #a << ": " << (a) << "\n"
#define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define rtt cerr << "Time: " << clock()*1.0 / CLOCKS_PER_SEC << endl;
#define ffe freopen("input.txt","r",stdin), freopen("output.txt","w",stdout);

int main() {
  ioso
  #ifndef ONLINE_JUDGE
  ffe
  #endif
  ll n,k; cin >> n >> k;
  int co[100010];
  for(int i=1;i<=n;i++) {
    cin >> co[i];
  }
  int dp[100010];
  memset(dp,-1,sizeof(dp));
  dp[1]=0;
  dp[0]=0;
  for(int i=1;i<=n;i++) {
    for(int j=1;j<=k;j++) {
      if(i+j<=n) {if(dp[i+j]==-1) {
        dp[i+j] = dp[i]+ (abs(co[i+j]-co[i]));
      }
      else {
        dp[i+j] = min(dp[i+j], dp[i]+abs(co[i+j]-co[i]));
      }
    }
    }
  }

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

Measured memory_bytes: 4408
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int items = sc.nextInt();
        int trucks = sc.nextInt();
        int[] weights = new int[items];
        for (int i = 0; i < items; i++) {
            int t = sc.nextInt();
            weights[i] = t;
        }
        System.out.println(binarySearch(weights, trucks));
    }

    private static int binarySearch(int[] weights, int trucks) {
        int left = 0;
        int right = Integer.MAX_VALUE;
        int mid = -1, count;
        while (left < right - 1) {
            mid = (left + right) / 2;
            count = itemCount(weights, trucks, mid);
            if (count >= weights.length) {
                right = mid;
            } else {
                left = mid;
            }
        }
        return right;
    }

    private static int itemCount(int[] weights, int trucks, int maxWeight) {
        int count = 0;
        for (int i = 0; i < trucks; i++) {
            int tmp = 0;
            while (weights[count] + tmp <= maxWeight) {
                tmp += weights[count];
                count++;
                if (count == weights.length) {
                    return count;
                }
            }
        }
        return count;
    }
}

Measured memory_bytes: 70276
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long A,B,C,K,sum=0;
    cin >> A >> B >> C >> K;
    if (K<=A) {
        sum = K;
    }
    else {
        sum = A;
        K-=A;
        if (K>B)sum-=(K-B);
    }
    cout << sum << "\n";
    return 0;
}


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

#define mod 1000000007
#define ll long long

ll bow(ll x, ll y) {
  ll res = 1;
  for (ll i = 1; i <= y; ++i) {
    res = res * x % mod;
  }
  return res;
}

void solve() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(max(a * c, a * d), max(b * c, b * d)) << endl;
}

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

Measured memory_bytes: 3652
#! env python
# -*- coding: utf-8 -*-

import os
import sys


# ac_py.main
# Date: 2020/06/14
# Filename: main 
# Author: acto_mini

def main():
    A, B, C = map(int, input().split())

    # if A % 2 != C % 2:
    #     print("NO")
    #     exit()

    for i in range(1, B*A+1):
        if ((i * A) % B) == C:
            print("YES")
            break
    else:
        print("NO")

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const int N = 2003;

int res, si[3];
bool moge[3][N];
string s[3];
VI ind;

bool can(const string& a, const string& b, int pos) {
  int n = a.size();
  int m = b.size();
  for (int i = pos; i < min(n, pos+m); ++i)
    if (a[i] != '?' && b[i-pos] != '?' && a[i] != b[i-pos])
      return false;
  return true;
}

void upd() {

}

int main() {
  init_ios();
  for (int i = 0; i < 3; ++i) {
    cin >> s[i];
    ind.PB(i);
  }
  res = 1e9;
  do {
    for (int i = 0; i < N; ++i)
      moge[0][i] = moge[1][i] = moge[2][i] = false;
    for (int i = 0; i < 3; ++i)
      si[i] = s[ind[i]].size();
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j <= si[i]; ++j)
        if (can(s[ind[i]], s[ind[i+1]], j))
          moge[i][j] = true;
    }
    for (int j = 0; j <= si[0]; ++j)
      if (can(s[ind[0]], s[ind[2]], j))
        moge[2][j] = true;
    for (int i = 0; i <= si[0]; ++i) {
      if (moge[0][i]) {
        for (int j = i; j <= max(si[0], i+si[1]); ++j) {
          bool ok = true;
          if (j < si[0])
            ok &= moge[2][j];
          if (j < i+si[1])
            ok &= moge[1][j-i];
          if (ok)
            res = min(res, max(max(si[0], i+si[1]), j+si[2]));
        }
      }
    }
  } while(next_permutation(ind.begin(), ind.end()));
  cout<<res<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fop(i,m,n) for(int i=m; i<n; i++)
#define MOD 998244353
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
 
using namespace std;

const int N = 150000;
vector<int> v[N];
int dp[N] = {0};

int dfs(int s){
    if(dp[s]) return dp[s];
    if(v[s].size() == 0) return 0;
    for(auto i : v[s]){
        int a = dfs(i);
        dp[s] = max(dp[s], a+1);
    }
    return dp[s];
}

int main()
{
    fastIO;
    
    int n, m;
    cin >> n >> m;

    fop(i,0,m){
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
    }
    
    fop(i,1,n+1) if(dp[i] == 0) dfs(i);
    
    int ans = 0;
    fop(i,1,n+1) ans = max(ans, dp[i]);
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 12600
type ary=array[1..100001]of char;
var a,b,i,j  :integer;
    c:char;
    l  :ary;
    
begin
  j:=1; a:=0; b:=0;
  for i:=1 to 100001 do 
    if i mod 2 = 0 then l[i]:='0'
    else l[i]:='1';
  repeat
    read(c);
    if c=l[j] then inc(a)
    else inc(b);
    inc(j)
  until eoln ;
  if a<b then write(a) 
  else write(b)
  end.


Measured memory_bytes: 256
#import <stdio.h>
int f(int x){
  return (x=='+')?1:-1;
}
int main(){
  char a,b,c,d;
  scanf("%c%c%c%c",&a,&b,&c,&d);
  printf("%d", f(a)+f(b)+f(c)+f(d));
  return 0;
}

Measured memory_bytes: 2164
N,*S=map(int,open(0))
S.sort()

ans=sum(S)
i=0
if ans%10==0:
    while i<N:
        if S[i]%10>0:
            ans-=S[i]
            break
        i+=1

if i==N:
    print(0)
else:
    print(ans)

Measured memory_bytes: 3060
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    X = int(input())
    luck = (X // 500) * 1000 + (X % 500) // 5 * 5
    print(luck)

if __name__ == '__main__':
    main()
    

Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.StringTokenizer;


public class Main{
	
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
	
	static class Pair
	{
		int p;
		int q;
		Pair(int p,int q)
		{
			this.p = p;
			this.q = q;
		}
	}
	
	static int gcd(int a,int b)
	{
		if(a == 0) return b;
		if(b == 0) return a;
		
		return gcd(b,a%b);
	}
	
	
	public static void main(String[] args) 
	{
		OutputStream outputStream = System.out;
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(outputStream);
        
        int h = sc.nextInt();
        int n = sc.nextInt();
        
        int a[] = new int[n];
        int s = 0;
        for(int i = 0; i < n; i++)
        {
        	a[i] = sc.nextInt();
        	s += a[i];
        }
        if(s >= h)
        {
        	out.println("Yes");
        }
        else out.println("No");
        
        out.close();
	}

}


Measured memory_bytes: 31592
from collections import deque

h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
S = [list(input()) for _ in range(h)]



def clear_maze(h, w, ch, cw, dh, dw, S):
    visited = [[-1] * w for _ in range(h)]
    visited[ch - 1][cw - 1] = 0
    queue = deque([[ch - 1 , cw - 1]])
    m_queue = deque([])
    while queue or m_queue:
        if queue:
            y, x = queue.popleft()
        else:
            n_y, n_x, y, x = m_queue.popleft()
            if visited[n_y][n_x] != -1:
                continue
            visited[n_y][n_x] = visited[y][x] + 1
            y, x = n_y, n_x
        if [y, x] == [dh - 1, dw - 1]:
            return visited[y][x]
        num = 0
        for i, j in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            n_y = y + i
            n_x = x + j
            if n_y >= 0 and n_y < h and n_x >= 0 and n_x < w and S[n_y][n_x] == '.':
                if visited[n_y][n_x] == -1:
                    visited[n_y][n_x] = visited[y][x]
                    queue.append([n_y, n_x])
                else:
                    if visited[y][x] < visited[n_y][n_x]:
                        queue.append([n_y, n_x])
                    visited[n_y][n_x] = min(visited[n_y][n_x], visited[y][x])
        for i in range(-2, 2 + 1):
            for j in range(-2, 2 + 1):
                if not [i, j] in ([1, 0], [-1, 0], [0, 0], [0, 1], [0, -1]):
                    n_y = y + i
                    n_x = x + j
                    if n_y >= 0 and n_y < h and n_x >= 0 and n_x < w and S[n_y][n_x] == '.':
                        if visited[n_y][n_x] == -1:
                            # visited[n_y][n_x] = visited[y][x] + 1
                            m_queue.append([n_y, n_x, y, x])
                        # else:
                            # if visited[y][x] + 1 < visited[n_y][n_x]:
                            #     queue.append([n_y, n_x])
                            # visited[n_y][n_x] = min(visited[n_y][n_x], visited[y][x] + 1)
    return -1

print(clear_maze(h, w, ch, cw, dh, dw, S))

Measured memory_bytes: 189812
from collections import deque
import numpy as np

N = int(input())
graph = {i:[] for i in range(N)}
for _ in range(N-1):
    a,b = map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

# グラフのうち最も遠い2点の距離(木の直径)を求める
# 1. 適当な点からの最も遠い点uを求める
# 2. uから最も遠い点を求める
# 全探索×2

def bfs(graph,root):
    distance  = [0]*N
    visited = [False]*N
    visited[root] = True
    queue = deque([root])

    while queue:
        vertex = queue.popleft()
        for neighbour in graph[vertex]:
            if not visited[neighbour]:
                distance[neighbour] = distance[vertex] + 1
                visited[neighbour] = True
                queue.append(neighbour)

    farthest_node = np.argmax(distance)
    farthest_dist = distance[farthest_node]
    return farthest_node, farthest_dist

u, _ = bfs(graph, root=0)
_, diamiter = bfs(graph, root=u)

if diamiter%3==1:
    ans = 'Second'
else:
    ans = 'First'
print(ans)

Measured memory_bytes: 76332
use proconio::input;

fn main() {
    input! {
        n: usize,
    };
    let mut c = vec![1_usize; n + 1];
    for i in 2..=n {
        for j in (i..=n).step_by(i) {
            c[j] += 1;
        }
    }
    let ans = (1..=n).fold(0_usize, |acc, i| acc + i * c[i]);
    println!("{}", ans);
}


Measured memory_bytes: 80156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please


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

	
	int N;
	cin >> N;

	map<int, int> MAP;

	rep(i, N) {
		int A;
		cin >> A;
		if (MAP[A]) MAP[A]--;
		else MAP[A]++;
	}
	int kotae = 0;
	for (auto itr : MAP) {
		kotae += itr.second;
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in))).useDelimiter("(,|\n)");
		int d=0,t=0,l=0;
		double x=0.0,y=0.0;
		do{
			l=sc.nextInt();
			t=sc.nextInt();
			x+=(double)Math.cos((double)d*Math.PI/180)*l;
			y+=(double)Math.sin((double)d*Math.PI/180)*l;
			d+=t;
			t=(t<0)?(t+360):((t>360)?t-360:t);
		}while(l!=0||t!=0);
		System.out.println((int)y);
		System.out.println((int)x);

	}
}

Measured memory_bytes: 12000
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


### BIT binary
def init(bit, values):
    for i,v in enumerate(values):
        add(bit,i+1,v)
#a1 ~ aiまでの和 O(logn)
def query(bit,i):
    res = 0
    while i > 0:
        res += bit[i]
        i -= i&(-i)
    return res

#ai += x(logN)
def add(bit,i,x):
    if i==0:
        raise RuntimeError
    while i <= len(bit)-1:
        bit[i] += x
        i += i&(-i)
    return

n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]
from bisect import bisect_left
def press(l):
    # xs[inds[i]]==l[i]となる
    xs = sorted(set(l))
    inds = [None] * len(l)
    for i,item in enumerate(l):
        inds[i] = bisect_left(xs, item)
    return xs, inds
_, indx = press([item[0] for item in xy])
_, indy = press([item[1] for item in xy])
xy = []
for i in range(n):
    xy.append(indy[i]+indx[i]*n)
xy.sort()
M = 998244353
# ans = (pow(2, n, M) * n) % M
pows = [0]*(n+1)
v = 1
for i in range(n+1):
    pows[i] = v-1
    v *= 2
    v %= M
ans = (pows[n]*n) % M
bit = [0]*(n+1)
for i in range(n):
    x,y = divmod(xy[i],n)
    ans -= pows[i] + pows[n-i-1]
    ans += pows[query(bit, y+1)] + pows[i - query(bit, y+1)]
    add(bit, y+1, 1)
    ans %= M
from operator import itemgetter
xy.sort(key=lambda item: item%n)
bit = [0]*(n+1)
for i in range(n):
    x,y = divmod(xy[i],n)
    ans -= pows[i] + pows[n-i-1]
    ans += pows[i - query(bit, x+1)]
    add(bit, x+1, 1)
    ans %= M
bit = [0]*(n+1)
for i in range(n-1, -1, -1):
    x,y = divmod(xy[i], n)
    ans += pows[(n-1-i) - query(bit, x+1)]
    add(bit, x+1, 1)
    ans %= M
print(ans%M)

Measured memory_bytes: 165056
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int left = A + B;
		int right = C + D;
		if (left > right)
			System.out.println("Left");
		else if (left == right)
			System.out.println("Balanced");
		else {
			System.out.println("Right");
		}
		sc.close();
	}
}

Measured memory_bytes: 22096
#include <bits/stdc++.h>
#define R register

const int MN = 1e5 + 5;

char s[MN];

int n, pre;

inline void WA() {
	puts("-1");
	exit(0);
}

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	
	if (s[1] == '0' || s[n] == '1') WA();

	for (R int i = 2; i < n; ++i) 
		if (s[i] != s[n - i]) WA();

	for (R int i = 2; i <= n; ++i)
		if (s[i] == '1') {
			for (R int j = 1; j < i; ++j)
				printf("%d %d\n", j, i);
			pre = i;
			break;
		}

	for (R int i = pre + 1; i < n; ++i)
		if (s[i] == '1') {
			for (; pre < i; ++pre) printf("%d %d\n", pre, i);
			pre = i;
		}
		
	for (; pre < n; ++pre) printf("%d %d\n", pre, n);
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 2007;
int n, m, q;
string a[N];
int pref1[N][N], prefv[N][N], prefh[N][N];

int sum(int x1, int y1, int x2, int y2, int a[N][N]) {
    if (x2 < x1 || y2 < y1)
        return 0;
    return a[x2][y2] - a[x2][y1 - 1] - a[x1 - 1][y2] + a[x1 - 1][y1 - 1];
}   

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n >> m >> q;
    for (int i = 0; i < n; ++i) 
        cin >> a[i];

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            pref1[i + 1][j + 1] = pref1[i + 1][j] + pref1[i][j + 1] - pref1[i][j] + (a[i][j] == '1');
        }   
    }   
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            prefv[i + 1][j + 1] = prefv[i + 1][j] + prefv[i][j + 1] - prefv[i][j] + (a[i][j] == '1' && a[i + 1][j] == '1');
        }   
    }   
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            prefh[i + 1][j + 1] = prefh[i + 1][j] + prefh[i][j + 1] - prefh[i][j] + (a[i][j] == '1' && a[i][j + 1] == '1');
        }   
    }   

    while (q--) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;

        //cout << sum(x1, y1, x2, y2, pref1) << ' ' << sum(x1, y1, x2 - 1, y2, prefv) << ' ' << sum(x1, y1, x2, y2 - 1, prefh) << endl;                

        cout << sum(x1, y1, x2, y2, pref1) - sum(x1, y1, x2 - 1, y2, prefv) - sum(x1, y1, x2, y2 - 1, prefh) << endl;                
    }   
}   

Measured memory_bytes: 100352
n = int(input())
B = list(map(int, input().split()))
ans = [B[0]]
for i in range(len(B)):
    if i != len(B)-1:
        if B[i] > B[i+1]:
            ans.append(B[i+1])
        else:
            ans.append(B[i])
    else:
        ans.append(B[i])
print(sum(ans))

Measured memory_bytes: 9136
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var H = one[0];
	var W = one[1];
	var list = new Array(H);
	for(var i = 0; i < H; i++){
		list[i] = nextCharArray();
	}
	var max = 0;
	var dy = [-1,0,1,0];
	var dx = [0,-1,0,1];
	for(var i = 0; i < H; i++){
		for(var j = 0; j < W; j++){
			if(list[i][j] == "."){
				bfs(i,j);
			}
		}
	}
	
	myout(max);
	
	function bfs(sy, sx){
		var access = new Array(H);
		var count = new Array(H);
		for(var i = 0; i < H; i++){
			access[i] = new Array(W).fill(false);
			count[i] = new Array(W).fill(0);
		}
		var queue = [[sy, sx]];
		access[sy][sx] = true;
		while(queue.length > 0){
			var tmp = queue.shift();
			var ty = tmp[0];
			var tx = tmp[1];
			max = Math.max(count[ty][tx], max);
			for(var i = 0; i < dy.length; i++){
				var nextY = ty + dy[i];
				var nextX = tx + dx[i];
				if(nextY < H && nextY >= 0 && nextX < W && nextX >= 0){
					if(!access[nextY][nextX] && list[nextY][nextX] == "."){
						access[nextY][nextX] = true;
						count[nextY][nextX] = count[ty][tx] + 1;
						queue.push([nextY, nextX]);
					}
				}
			}
		}
	}
}


Measured memory_bytes: 36992
#include<bits/stdc++.h>
using namespace std;
typedef long long int uni;
int main(){
  uni A, V;
  cin >> A >> V;
  uni B, W;
  cin >> B >> W;
  uni T;
  cin >> T;
  uni D = abs(A - B);
  uni D2 = (V - W)*T;
  puts(D<=D2?"YES":"NO");
} 

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
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) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
	int n;
	cin >> n;
    int ans = (n+1)/2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define REP(i, start, end) for (ll i = start, i##Len = (end); i < i##Len; ++i)
#define REPR(i, start, end) for (ll i = start, i##Len = (end); i > i##Len; --i)
using ll = long long;
using namespace std;

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    ll n;
    cin >> n;
    vector<pair<ll, ll>> a;
    ll x, y;
    REP(i, 0, n)
    {
        cin >> x >> y;
        a.emplace_back(x, y);
    }

    vector<ll> pi(4, -1);
    vector<ll> pv(4, -(1ll << 60));
    REP(i, 0, n)
    {
        tie(x, y) = a[i];
        if (pv[0] < x + y)
        {
            pv[0] = x + y;
            pi[0] = i;
        }
        if (pv[1] < x - y)
        {
            pv[1] = x - y;
            pi[1] = i;
        }
        if (pv[2] < -x + y)
        {
            pv[2] = -x + y;
            pi[2] = i;
        }
        if (pv[3] < -x - y)
        {
            pv[3] = -x - y;
            pi[3] = i;
        }
    }

    ll ans = 0;
    REP(i, 0, 4)
    REP(j, i + 1, 4)
    if (pi[i] != pi[j])
    {
        ans = max(ans, abs(a[pi[i]].first - a[pi[j]].first) + abs(a[pi[i]].second - a[pi[j]].second));
    }

    cout << ans << endl;
}

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

#define ll long long

using namespace std;

int main(){
    int n, T, a, _t, t;
    ll s;

    cin >> n >> T;
    cin >> _t;

    s = T;
    for(int i = 0; i < n-1; i++){
        cin >> t;
        a = t - _t;
        _t = t;
        s += (a > T) ? T : a;
    }

    cout << s << endl;
}

Measured memory_bytes: 3640
/*ITS FUCKING O(N) now
GET ACCEPTED FOR FUCK'S SAKE*/
#define _USE_MATH_DEFINES
 
#include <cmath>

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

long long powerexp(long long base, long long exp, int mod) {
   long long res = 1;
   while (exp > 0) {
      if (exp % 2 == 1)
         res= (res * base) % mod;
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}
int gcd(int a, int b)
{
    int c = a % b;
    while(c != 0)
    {
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}
void PrintVector(vector<long long int> v,long long int n)
{
 
    for(int i=v.size()-1;i>=0;i--)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void Takevector(vector<long long int> &v,long long int n)
{
  for(long long int i=0;i <n;i++)
  { long long int number;
    cin>>number;
    v.push_back(number);
  }
}
typedef long long int ll;
typedef vector<long long int> vi;

#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define scl(x)         ll x;       scanf("%lld", &x);
#define scll(x, y)     ll x, y;    scanf("%lld %lld", &x, &y);
#define sclll(x, y, z) ll x, y, z; scanf("%lld %lld %lld", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define rep(i, x, y)   for (__typeof(x) i = x; i <= y; i ++)
#define repi(i, x, y)  for (__typeof(x) i = x; i >= y; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
#define nl cout<<"\n";
int min(int x, int y)  
{  
    return (x < y)? x: y;  
      
}  
  
int main()
{
  int flag=0;
  ll sum=0;
  int flag1=1;
  ll tot=0;
  int ans=0;
  
  vi v;
  set<int>st;
  string s;
   scii(n,ma);
   Takevector(v,n);
   vector<set<int>>m(n);
   while(ma--)
   {
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    m[a].insert(b);
    m[b].insert(a);

   }
   //for(int i=0;i<n;i++){
     // for(auto it=m[i].begin();it!=m[i].end();it++)
   //{//
  //  cout<<*it<<" ";
  // }
  // cout<<endl;
 //}
   
   int cnt=n;
   rep(i,0,n-1)
   {
      int max=v[i];
      if(m[i].size()>0)
      { 
        auto it=m[i].begin();
        for( it=m[i].begin();it!=m[i].end();it++)
        {
          if(v[*it]>=max)
          {
            //cout<<"pos is "<<i+1<<" set max is: "<<v[*it]<<" h is "<<max<<endl;
            cnt--;
            break;
          }
        }
        
      }

      else{

      }
   }
   cout<<cnt;
    return 0;
}

Measured memory_bytes: 18040
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if b - a > k or  c - a > k or  d - a > k or  e - a > k or  c - b > k or  d - b > k or  e - b > k or  d - c > k or  e - c > k or  e - d > k:
    print(":(")
else:
    print("Yay!")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int N, K;
  cin >> N >> K;

  ll ans = K;
  if (N >= 2) {
    for (int i = 0; i < (N - 1); i++) {
      ans = ans * (K - 1);
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;


int main()
{
	
	int n, t;
	cin>>n>>t;
	int c, ti;
	vector<pair<int,int>> ct;
	rep(i ,0, n-1)
	{
		cin>>c>>ti;
		ct.push_back(make_pair(c, ti));
	}
	sort(ct.begin(), ct.end());
	
	for(auto pi : ct)
	{
		if(pi.second <= t)
		{
			cout<<pi.first;
			return 0;
		}

	}
	cout<<"TLE";
	return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <list>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <iomanip>
#include <queue>
#include <map>
int main()
{
 
	int A, B;
 
	std::cin >> A >> B;
  
	if (A+B >= A-B && A+B >= A*B) {
		std::cout << A+B <<std::endl;
	}else if(A-B >= A+B && A-B >= A*B){
		std::cout << A-B <<std::endl;
	}else if(A*B >= A+B && A*B >= A+B){
		std::cout << A*B <<std::endl;
	}
 
 
}

Measured memory_bytes: 256
def solve():
    N, K = map(int, input().split())
    ps = list(map(int, input().split()))
    curSum = sum(ps[:K])
    curMax = curSum
    i = K; j = 0
    while i < N:
        curSum -= ps[j]
        curSum += ps[i]
        curMax = max(curSum, curMax)
        i += 1; j += 1
    print((curMax + K) / 2)
solve()

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

using namespace std;

int main(){
	string s;
	cin>>s;
	int a = 0;
	int z = 0;
	for(int i =0 ;i<(int)s.size();i++){
		if(s[i]=='A'){
			a = i;
			break;
			}
		}
		for(int i = (int)s.size()-1 ; i>=0;i--){
		if(s[i]=='Z'){
			z = i;
			break;
			}
		}
		cout<<z-a+1<<endl;
	return 0;
	}


Measured memory_bytes: 3688
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
typedef string::const_iterator State;

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


int h, w, d;
int a[301][301];
int q;
int l[100001], r[100001];\
int dist[900001];

int main(void) {
	

	cin >> h >> w >> d;

	vector< pair<int, int> > dp(h*w + 1);

	FOR(i, 1, h) {
		FOR(j, 1, w) {
			cin >> a[i][j];
			dp[a[i][j]].first = i;
			dp[a[i][j]].second = j;
		}
	}

	FOR(i, 1, d) {
		dist[i] = 0;
	}

	FOR(i, d + 1, h*w) {
		dist[i]=dist[i-d]+ abs(dp[i].first - dp[i - d].first) + abs(dp[i].second - dp[i - d].second);
	}

	cin >> q;

	FOR(i, 1, q) {
		cin >> l[i] >> r[i];
	}

	FOR(i, 1, q) {
		cout << dist[r[i]]-dist[l[i]] << endl;
	}

	return 0;
}

Measured memory_bytes: 4736
#include<cmath>
    #include<cstdio>
    using namespace std;
    int n,f[100010],g[100010];
    int min(int a,int b)
    {
    	return (a<b?a:b);
    }
    int abs(int x)
    {
    	return (x>0?x:(-x));
    }
    int main()
    {
    	scanf("%d",&n);
    	for(int i=1;i<=n;i++)
    	{
    		scanf("%d",&f[i]);
    	}
    	g[2]=abs(f[2]-f[1]);
    	for(int i=3;i<=n;i++)
    	{
    		g[i]=min((g[i-1]+abs(f[i]-f[i-1])),(g[i-2]+abs(f[i]-f[i-2])));
    	}
    	printf("%d",g[n]);
    } 

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

int main() {
  int K, N;
  cin >> K >> N;
  
  vector<int> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  vector<int> d(N);
  d.at(N - 1) = K + A.at(0) - A.at(N - 1);
  for (int i = 0; i < (N - 1); i++) {
    d.at(i) = A.at(i + 1) - A.at(i);
  }
  
  sort (d.begin(), d.end());
  
  cout << K - d.at(N - 1) << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
   ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
int main(){
  ll a,b,c;cin>>a>>b;
  c=(a-1)*a/2;
  c+=a*b;  
  if(a+b<=0)cout<<c-b-a+1;
  else if(b>0)cout<<c-b;
  else cout<<c;
}



Measured memory_bytes: 27064
def main():
    n = int(input())
    r_data = []
    ans = []
    for i in range(n):
        s,p = input().split()
        array = [x for x in [i+1,s,int(p)]]
        r_data.append(array)
    r_data = sorted(r_data, key=lambda x:x[2], reverse=True)
    r_data = sorted(r_data, key=lambda x:x[1])
    for i in range(n):
        print(r_data[i][0])


if __name__ == '__main__':
    main()


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

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

	if (!(s[0] == s[1] && s[0] == s[2] && s[1] == s[2])) 
	    cout << "Yes" << endl;
	else 
	    cout << "No" << endl;
	return (0);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNext()) {
            int n = in.nextInt();

            int[] a = new int[3];
            a[0] = n / 100;
            a[1] = n % 100;
            a[2] = a[1] % 10;
            a[1] = a[1] / 10;

            int m;
            if (a[0] == a[1] && a[0] == a[2]) {
                System.out.println(n);
            } else {
                if (a[0] < a[1]) {
                    m = a[0] + 1;
                } else if (a[0] > a[1]) {
                    m = a[0];
                } else {
                    if(a[0] > a[2]){
                        m = a[0];
                    }else{
                        m = a[0] + 1;
                    }
                }
                System.out.println(m * 100 + m * 10 + m);
            }
        }
    }
}

Measured memory_bytes: 25172
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

int main()
{
	int n, k;
	cin >> n >> k;

	vector<int> h(n);
	for (int i = 0; i < n; i++)
	{
		cin >> h.at(i);
	}

	vector<int> dp(n, inf);

	dp.at(0) = 0;

	for (int i = 1; i < n; i++)
	{
		for (int j = 1; j <= k; j++)
		{
			if (i - j >= 0)
			{
				dp.at(i) = min(dp.at(i), dp.at(i - j) + abs(h.at(i) - h.at(i - j)));
			}
		}
	}

	cout << dp.back() << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int arr[n];
  priority_queue<int,vector<int>,greater<int>> pq;
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
    pq.push(arr[i]);
  }
  int sum=0;
  while(k--)
  {
      sum+=pq.top();
      pq.pop();
  }
  
  cout<<sum<<"\n";
  
  return 0;
  
  
}

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

int main(){
	int S, h, m, s;
	cin>>S;

	h = S / 3600;
	S %=  3600;
	m = S / 60;
	s = S % 60;
	cout<<h<<":"<<m<<":"<<s<<endl;

	return 0;
}

Measured memory_bytes: 1164
N, M, X = map(int, input().split())
book_lists = [list(map(int, input().split())) for _ in range(N)]
max_cost = 10**5*12+1
min_cost = max_cost

for i in range(1, 2**N):
   score_list = [0 for _ in range(M)]
   cost = 0
   for j in range(N):
       if i >> j & 1:
           cost += book_lists[j][0]
           for k in range(M):
               score_list[k] += book_lists[j][k+1]
   if min(score_list) >= X:
       min_cost = min(cost, min_cost)

print(min_cost if not min_cost == max_cost else -1)



Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = (n-1); i >= 0; i--)
#define rea(i, a, b) for (int i = (a); i < (b); i++)
#define reab(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(),(a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;
/* END OF TEMPLATE */

int main(){
    ll N;
    cin >> N;
    vll C(N), S(N), F(N);
    rep(i, N-1){
        cin >> C[i] >> S[i] >> F[i];
    }
    rep(i, N-1){
        ll ans = 0;
        rea(j, i, N-1){
            ll t = max(ans, S[j]);
            ll k = (t + (F[j] - 1)) / F[j];
            ans = k * F[j];
            ans += C[j];
        }
        cout << ans << endl;
    }
    cout << 0 << endl;
}

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

int main(){
  ll x;
  cin >> x;
  for(int i = -200; i <= 200; i++){
    for(int j = -200; j <= 200; j++){
      if((pow(i,5)-pow(j,5))==x){
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3968
import sys
a='abcdefghijklmnopqrstuvwxyz'
for b in sys.stdin:
 b=b.strip()
 for i in range(26):
  c=''.join(a[ord(e)-97-i]if e in a else e for e in b)
  if any(('the'in c,'this'in c,'that'in c)):print(c)


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

#define INF 1e9
using namespace std;

int main() {

    long long A, B, C, D; cin >> A >> B >> C >> D;

    long long A_C = 0;
    A_C = A / C;
    if (A % C == 0) {
        --A_C;
    }

    long long A_D = 0;
    A_D = A / D;
    if (A % D == 0) {
        --A_D;
    }

    long long B_C = 0;
    B_C = B / C;
//    if (B % C != 0) {
//        ++B_C;
//    }

    long long B_D = 0;
    B_D = B / D;
//    if (B % D != 0) {
//        ++B_D;
//    }

    long long lcm;
    lcm = C * D / __gcd(C, D);

    long long A_lcm = 0;
    A_lcm = A / lcm;
    if (A % lcm == 0) {
        --A_lcm;
    }

    long long B_lcm = 0;
    B_lcm = B / lcm;
//    if (B % lcm != 0) {
//        ++B_lcm;
//    }

    cout << (B - A + 1) - (B_C - A_C) - (B_D - A_D) + (B_lcm - A_lcm) << endl;
}

Measured memory_bytes: 256
N = gets.to_i
S = gets.chomp.chars
Q = gets.to_i
qu = []
Q.times{
  qu << gets.chomp.split(" ")
}
 
s = Hash.new{|h, k| h[k] = []}
(0...N).each{|i|
  s[S[i]] << (i+1)
}
 
qu.each{|f, a, b|
  if f == '1' then
    a_i = a.to_i
    if S[a_i-1] != b then
      idx = s[S[a_i-1]].bsearch_index{|x| x >= a_i}
      s[S[a_i-1]].delete_at(idx)
      S[a_i-1] = b
      idx = s[b].bsearch_index{|x| x >= a_i}
      idx.nil? ? s[b] << a_i : s[b].insert(idx, a_i)
    end
  else
    l, r = [a.to_i, b.to_i]
    ans = 0
    (0..25).each{|i|
      sl = s[(97+i).chr].bsearch{|x| x >= l}
      ans += 1 if (not sl.nil?) && sl <= r
    }
    puts ans
  end
}

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

#define int int64_t


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int x, y;
    
    cin >> x >> y;
    
    if (x < y/4.0 || x>y/2.0) {
        cout << "No";
        return 0;
    }

    if (y%2 == 1) {
        cout << "No";
        return 0;
    }

    cout << "Yes";
    
    
    
//    y/=2;
    

    return 0;
}



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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
   cin >> n;
   if (n % 2 == 0) MSG(n)
   else MSG(n*2)
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef pair<string,int> SP;

struct rest{
  string s;
  int num;
  int arg;
};

bool restcomp(const rest& a, const rest& b){
  return (a.s < b.s) || ((a.s == b.s) && (a.num > b.num));
}

int main(){
  int n;
  cin >> n;
  vector<rest> a(n);
  REP(i,n){
    cin >> a[i].s >> a[i].num;
    a[i].arg = i+1;
  }
  sort(a.begin(),a.end(),restcomp);
  REP(i,n){
    cout << a[i].arg << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <set>

using namespace std;
int main(void){
    string c;
    int a,b;
    cin>>a>>c>>b;
    if (c=="+"){
        cout <<a+b<<endl;
    }else{
        cout <<a-b<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()
 
#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>
 
#define debug(x) {cerr <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}
 
#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue
 
#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
 
 
using namespace std;

const int mod = 1e9 + 7;

const int max_n = 1e5 + 5;

char s[max_n];

bool doIt(int n) {
	if (n == 0) return true;
	if (n < 5) return false;
	if (s[n-1] == 'e') {
		string t = "erase";
		FOR(j,1,6) if (s[n-j] != t[5-j]) return false;
		return doIt(n-5);
	} 
	if (s[n-1] == 'm') {
		string t = "dream";
		FOR(j,1,6) if (s[n-j] != t[5-j]) return false;
		return doIt(n-5);
	}
	if (s[n-3] == 'm') {
		if (n < 7) return false;
		string t = "dreamer";
		FOR(j,1,8) if (s[n-j] != t[7-j]) return false;
		return doIt(n-7);
	}
		if (n < 6) return false;
		string t = "eraser";
		FOR(j,1,7) if (s[n-j] != t[6-j]) return false;
		return doIt(n-6);

}

int main() {
	scanf("%s", s);
	int n = strlen(s);
	if (doIt(n)) puts("YES");
	else puts("NO");
}



Measured memory_bytes: 3072
#include <iostream>
#include <cstring>
#include <cstdio>
#include<string>
#include <algorithm>
#include <cmath>
#include<vector>
#include<stack>
#define INF 0x3f3f3f3f  
#define maxn 100000+10
using namespace std;

int a[105];
int n, m, x;
int main()
{
	cin >> n >> m >> x;
	memset(a, 0, sizeof(a));
	for (int i = 1; i <= m; i++)
	{
		int y;
		cin >> y;
		a[y] = 1;
	}
	int cnt1=0, cnt2=0;
	for (int i = x+1; i < n; i++)
		if(a[i])
		cnt2++;
	for (int i = 1; i < x; i++)
		if(a[i])
		cnt1++;
	int cnt = min(cnt2, cnt1);
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

import itertools

A = list(itertools.permutations(list(range(1, n+1))))
 
a = A.index(tuple(P))
b = A.index(tuple(Q))
print(abs(a-b))

Measured memory_bytes: 44912
#include <bits/stdc++.h> 
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define mc map<char, int>
#define ms map<string, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define mod 1000000007LL
//#define mod 998244353 
using namespace std;
int power(int x, int y) ;
int gcd(int a, int b) ;

signed main() {
    quickie
    int a, b, c ;
    cin >> a >> b >> c ;
    if((a==b && c!=b) || (b==c && a != c) || (a==c && b!=c)) cout << "Yes" << endl ;
    else cout << "No" << endl ;
}
 
int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
 
int gcd(int a,int b){
    if(a==0) return b;
    return gcd(b%a,a);
}

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

int main(){
    int x, i;
    vector<int> in;

    while (cin >> x) {
        in.push_back(x);
    }

    for (i = 0; i < in.size(); ++i) {
        cout << (in[i] * in[i] + in[i] + 2) / 2 << endl;
    }
}



Measured memory_bytes: 3048