akhauriyash/Code-Regression huggingface dataset:
#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 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;


int main()
{
  int N;
  cin >> N;
  long double ans = 0;
  vector<ll> vec;
  REP(i, N) {
    long double x;
    string v;
    cin >> x >> v;
    if (v == "BTC") {
      ans += 380000 * x;
    } else {
      ans += x;
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a=0,t=0,w=0,r=0;
	while(n--)
	{
		string s;
		cin>>s;

		if(s=="AC")
		{
			a++;
		}
		else if(s=="TLE")
		{
			t++;
		}
		else if(s=="WA")
		{
			w++;
		}
		else
		{
			r++;
		}
	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<w<<endl;
	cout<<"TLE x "<<t<<endl;
	cout<<"RE x "<<r<<endl;
	return 0;

}

Measured memory_bytes: 3624
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int targetNumber = scanner.nextInt();
		
		boolean isPrimeNum = false;
		while(!isPrimeNum) {
			int num = targetNumber;
			isPrimeNum = IntStream.range(2, num).allMatch(n -> num % n != 0);
			if (isPrimeNum) {
				System.out.println(num);
			}else {
			 targetNumber++;
			}
		}

	}
	
	}



Measured memory_bytes: 26964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, a[105], sel=0;
double thres, sum=0, m;
int main() {
	cin >> n >> m;
  	for (int i=0; i<n; i++) {
		cin >> a[i];
      	sum+=a[i];
    }
  	thres=sum/(4*m);
  	for (int i=0; i<n; i++) {
		if (a[i]>=thres) sel++;
    }
  	cout << (sel>=m ? "Yes\n" : "No\n");
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back
#define ll long long
#define rep(i,n) for (i = 0; i < n; ++i) 
#define REP(i,k,n) for (i = k; i <= n; ++i) 
#define REPR(i,k,n) for (i = k; i >= n; --i)
using namespace std;
template<class T, class T1> int chkmin(T &x, const T1 &y) { return x > y ? x = y, 1 : 0; }
template<class T, class T1> int chkmax(T &x, const T1 &y) { return x < y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);
ll l[1000000] , h[1000000] , p[1000000],la , lb , lc , ld,ha , hb , hc , hd;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE 
   freopen("input.txt", "r", stdin); 
   //freopen("error.txt", "w", stderr); 
  freopen("output.txt", "w", stdout); 
#endif   
 ll T = 1 ;
// cin>>T;
 for(ll t=1;t<=T;t++)
{
  ll ans = 0 , c = 0;

  string rep;
  cin>>rep;
  for(ll i=0;i<3;i++)
    if(rep[i]=='R')
      c++;
  if(rep[0]=='R'&&rep[1]=='R'&&rep[2]=='R')
    ans = 3;
  else if(rep[1]=='R'&&rep[0]=='R'||rep[1]=='R'&&rep[2]=='R')
    ans = 2;
  else if(c) 
    ans = 1;
  else ans = 0;
  cout<<ans<<endl;
}
}

Measured memory_bytes: 3612
import math

# 入力
N, D = map(int, input().split())
X = [0] * N
Y = [0] * N
for i in range(N):
    X[i], Y[i] = map(int, input().split())

# 計算
cnt = 0
for i in range(N):
    if math.sqrt(X[i]**2 + Y[i]**2) <= D:
        cnt = cnt+1

# 出力
print(cnt)

Measured memory_bytes: 24616
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	string S, T;
	cin >> S >> T;
	bool f = true;
	string ans;
	for (int i = 0; i < S.size() - T.size() + 1; i++) {
		string tmp = S;
		f = true;
		for (int j = 0; j < T.size(); j++) {
			if (S[i + j] == '?' || S[i + j] == T[j]) {
				tmp[i + j] = T[j];
			}
			else {
				f = false;
				break;
			}
		}
		if (f) {
			for (int j = 0; j < tmp.size(); j++) {
				if (tmp[j] == '?') tmp[j] = 'a';
			}
			if (ans.empty() || tmp < ans) {
				ans = tmp;
			}
		}
	}
	if (ans.empty()) {
		cout << "UNRESTORABLE" << endl;
	}
	else {
		cout << ans << endl;
	}
}


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

int main(){
  int n;
  while(cin >> n){
    int n2 = n % 39;
    cout << "3C";
    if(n2 == 0) n2 = 39;
    if(n2 < 10) cout << 0;
    cout << n2 << endl;
  }
  return 0;
}
  

Measured memory_bytes: 0
#include<stdio.h>
int main(){
int N,K,X,Y;
scanf("%d",&N);
scanf("%d",&K);
scanf("%d",&X);
scanf("%d",&Y);
  if(N>K){
    printf("%d\n",X*K+Y*(N-K));
  }else{
    printf("%d\n",X*N);
   }
return 0;
}

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

using namespace std;

vector<vector<string>> boards = {
{}, {}, {}, 
{// 3, 2
"aab",
"c.b",
"cdd"
},
{// 4, 3
"abcc",
"abdd",
"eefg",
"hhfg",
},
{// 5, 3
"abc..",
"abc..",
"deeff",
"d.ghh",
"iigjj"
},
{// 6, 3
"abc...",
"abc...",
"d.eeff",
"dghh..",
".g.ijj",
"kk.ill",
},
{// 7, 3
"abc....",
"abc....",
"def....",
"def....",
"g..hhii",
"g..jjkk",
".llmmnn",
}
};

int n;
char ans[2005][2005];

void print(int x, int y, int d) {
    for (int i = 0; i < d; ++i) {
        for (int j = 0; j < d; ++j) {
            ans[x + i][y + j] = boards[d][i][j];
        }
    }
}

void answer() {
    for (int i = 0; i < n; ++i) {
        puts(ans[i]);
    }
    exit(0);
}


int main() {
    cin >> n;
    if (n == 2) {
        puts("-1");
        return 0;
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            ans[i][j] = '.';
        }
    }
    if (n == 3) {
        print(0, 0, 3);
        answer();
    }
    int x = 0;
    while (1) {
        if (n - x >= 8) {
            print(x, x, 4);
            x += 4;
        }else {
            print(x, x, n - x);
            answer();
        }
    }
    return 0;
}

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

using namespace std;
typedef long long ll;

const int N = 107;
int w[N], v[N];
int n, W;

ll dp[2][100007];

ll infll;

int main() {
    memset(&infll, 0x3f, sizeof infll);
    cin >> n >> W;

    for(int i = 1; i <= n; ++i) {
        cin >> w[i] >> v[i];
    }

    int cur = 0;
    memset(dp, 0x3f, sizeof dp);
    dp[1-cur][0] = 0;
    for(int i = 1; i <= n; ++i) {
        for(int j = 0; j < 100007; ++j) {
            dp[cur][j] = dp[1-cur][j];
            if(j - v[i] >= 0 and dp[1-cur][j - v[i]] < infll) dp[cur][j] = min(dp[cur][j], w[i] + dp[1-cur][j - v[i]]);
        }
        cur = 1 - cur;
    }

    int ans = 0;
    for(int j = 0; j < 100007; ++j) {
        if(dp[1-cur][j] <= W) ans = max(ans, j);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
   int a,b,k,i;

   scanf("%d%d%d",&a,&b,&k);
   for(i=a;i<=b;i++){
      if((i<=a+k-1) || (i>=b-k+1))
         printf("%d\n",i);
   }


   return 0;
}



Measured memory_bytes: 128
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn sm(n: u64) -> u64 {
    if n < 10 {
        return n;
    }

    (n % 10 + sm(n / 10))
}

fn main() {
    input!{
        n: u64,
    }

    let ans: u64 = if n % 10 == 0 { 10 } else { sm(n) };
    println!("{}", ans);
}


Measured memory_bytes: 4352
n = input()
state = 0
for k in range(448):
    if n * 2 == k * (k + 1):
        state = 1
        print "Yes"
        print k + 1
        break
if state == 1:
    arr = [[0 for j in range(k)] for i in range(k + 1)]
    number = 1
    for p in range(k):
        temp = number
        for s in range(p+1):
            # print "p", p, "s", s, "number", number
            arr[s][p] = number
            number += 1
        number = temp
        for t in range(p+1):
            # print "p+1", p+1, "t", t, "number", number
            arr[p+1][t] = number
            number += 1

    for a in arr:
        print len(a),
        for b in a:
            print b,
        print
else:
    print "No"


Measured memory_bytes: 10244
from collections import defaultdict

def main():
    s = input()
    n = len(s)
    ans = 0
    num = 0
    pow10 = 1
    d = defaultdict(int)
    d[0] = 1
    for i in reversed(range(n)):
        # pow10を10 ** (n-1-i)にしてるだけでTLEしていた
        pow10 = pow10 * 10 % 2019
        num += int(s[i]) * pow10
        mod = num % 2019
        ans += d[mod]
        d[mod] += 1
    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
  long int h,w,ans=0,a,b;
  cin >> h >> w;

  if(h == 1 || w == 1){
    cout << 1;
    return 0;
  }

  a = (w+1)/2+w/2;
  b = h/2;
  ans = a*b;

  if(h%2==1)
    ans += (w+1)/2;

  cout << ans;
  return 0;
}

Measured memory_bytes: 256
class Combination:
    def __init__(self):
        self.fact = [0 for _ in range(100001)]
        self.init_fact()
    
    def init_fact(self):
        self.fact[0] = 1
        self.fact[1] = 1
        for i in range(2,100001):
            self.fact[i] = self.fact[i-1] * i
            print(self.fact[i])

    def calc(self,n,k):
        return int(self.fact[n] / (self.fact[k] * self.fact[n-k]))

N = int(input())

A_num = [0 for _ in range(N + 1)]
A = []
ans = 0

for i in input().split(" "):
    A_num[int(i)] += 1
    A.append(int(i))

for i in A_num:
    if i < 2:
         continue
    else:
        ans += i * (i - 1) // 2

for i in A:
    x = A_num[i]
    ans_tmp = ans - (x * (x - 1) // 2 )
    if (A_num[i] - 1) < 2:
        print(int(ans_tmp))
        continue
    else:
        ans_tmp += ((x - 1) * (x - 2) // 2 )
        print(int(ans_tmp))
        continue

    print(int(ans))
    A_num[i] += 1

Measured memory_bytes: 28120
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
	int a,b;
	
	cin >> a >> b;
	
	if(b>=a*2 && b<=a*4 && b%2==0)cout <<"Yes" << endl;
	
	else cout << "No" <<endl;
	
return 0;
}

Measured memory_bytes: 3648
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 2500
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
struct edge{int to,lt;}e[N<<1];
int in[N],cnt,fa[N],dep[N],n,m,d[N];
void add(int x,int y)
{
	e[++cnt].to=y; e[cnt].lt=in[x]; in[x]=cnt; d[x]++;
	e[++cnt].to=x; e[cnt].lt=in[y]; in[y]=cnt; d[y]++;
}
void dfs(int x,int fr)
{
	dep[x]=dep[fr]+1; fa[x]=fr;
	for(int i=in[x];i;i=e[i].lt)
		if(e[i].to!=fr)	dfs(e[i].to,x);
}
int LCA(int x,int y)
{
	if(dep[x]<dep[y])	swap(x,y);
	while(dep[x]>dep[y]) x=fa[x];
	while(x!=y)	x=fa[x],y=fa[y];
	return x;
}
int s[N]; bool vis[N],tag[N];
void calc(int x)
{
	for(int i=in[x];i;i=e[i].lt) if(e[i].to!=fa[x]) calc(e[i].to),s[x]+=s[e[i].to];
}
int a[N],b[N],ta[N],tb[N],p[N];
int main()
{
	n=read(),m=read(); for(int i=1;i<n;i++)	add(read(),read());
	dfs(1,0); for(int i=1;i<=m;i++)
		ta[i]=a[i]=read(),tb[i]=b[i]=read(),
		s[a[i]]++,s[b[i]]++,s[LCA(a[i],b[i])]-=2;
	calc(1); int T=0; for(int i=2;i<=n;i++) T+=min(2,s[i]); printf("%d\n",T);
	for(int t=2;t<=n;t++)
	{
		int x=0;
		for(int j=2;j<=n;j++)	if(d[j]==1&&!vis[j]){x=j; break;} vis[x]=1; 
		int fx=fa[x],i1=0,i2=0; d[fx]--;
		for(int i=1;i<=m;i++)	if((ta[i]==x)^(tb[i]==x))
			if(!i1)	i1=i; else{i2=i; break;}
		if(!i1&&!i2)	continue;
		if(!i2){if(ta[i1]==x) ta[i1]=fx; else tb[i1]=fx; continue;}
		if(ta[i1]==x)
		{
			if(ta[i2]==x) ta[i1]=tb[i2],tag[i2]^=1;
			else ta[i1]=ta[i2];
		}
		else
		{
			if(tb[i2]==x) tb[i1]=ta[i2],tag[i2]^=1;
			else	tb[i1]=tb[i2];
		}
		ta[i2]=tb[i2]; p[i2]=i1;
		for(int i=i2+1;i<=m;i++) if((ta[i]==x)^(tb[i]==x))
			if(ta[i]==x) ta[i]=fx;
			else	tb[i]=fx;
	}
	for(int i=1;i<=m;i++)	if(p[i]) tag[i]^=tag[p[i]];
	for(int i=1;i<=m;i++)
	{
		if(tag[i])	printf("%d %d\n",b[i],a[i]);
		else	printf("%d %d\n",a[i],b[i]);
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    for(int i=1;i<=5;i++){
        int a;
        cin>>a;
        if(a!=i){
            cout<<i<<endl;
        }
    }
}

Measured memory_bytes: 3632
n,m,l= map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
b = [list(map(int,input().split())) for i in range(m)]
for u in range(n):
   for w in range(l):
     c=0 
     for z in range(m):
       c+=a[u][z]*b[z][w]
     if w==l-1:
       print(c)
     else:
       print(c,end=" ")


Measured memory_bytes: 6576
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Rev(a) reverse(a.begin(), a.end())
typedef long long ll;
const ll MOD = 1e9+7;

/*ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b, a%b);
}*/
/*ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}*/

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

/*int dfs(vector<int> &T, vector<int> &C, int i, int sum, int g, int count){
   
}*/

int main(){
  ll n, k, i;
  cin >> n >> k;
  ll m_sum=0, ans=0, M_s=0;
  rep(j, k) m_sum += j;
  for(i=n; i>n-k; i--) M_s += i;
  //cout << m_sum << " " << M_s << endl;
  for(i=k; i<=n+1; i++){
    ans += M_s - m_sum+1;
    m_sum += i;
    if(n-i>=0) M_s += n-i;
    //cout << m_sum << " " << M_s << endl;
    ans %= MOD;
    //cout << ans << endl;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3636
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from math import gcd
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gcd
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().rstrip().split()
def S(): return sys.stdin.readline().rstrip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]




class BIT:
    def __init__(self, size):
        self.bit = [0] * size
        self.size = size
        self.total = 0

    def add(self, i, w):
        x = i + 1
        self.total += w
        while x <= self.size:
            self.bit[x - 1] += w
            x += x & -x
        return

    def sum(self, i):
        res = 0
        x = i + 1
        while x:
            res += self.bit[x - 1]
            x -= x & -x
        return res

    def interval_sum(self, i, j): # i <= x < j の区間
        return self.sum(j - 1) - self.sum(i - 1) if i else self.sum(j - 1)


mod=998244353
n,k=LI()
lr=LIR(k)
bit=BIT(n+1)
bit.add(0,1)
for i in range(n):
    ret=0
    for j in range(k):
        l,r=lr[j]
        if i-l+1>0:
            ret+=bit.interval_sum(max(i-r,0),i-l+1)
    bit.add(i,ret%mod)
    ans=ret%mod

print(ans)






Measured memory_bytes: 80032
#include<stdio.h>
int main (void){
	int a,b;

	scanf("%d%d",&a,&b);

	if(a<b){
		printf("a < b\n");
}
    if(a>b){
		printf("a > b\n");
}
    if(a==b){
		printf("a == b\n");
}

	return 0;
}

Measured memory_bytes: 580
#include <stdio.h>
#include <stdlib.h>

int asc(const void* a, const void* b) {
    return *(int*)b - *(int*)a;
}

int main()
{
    int n, l[2000], i, j, k;
    long int total = 0;

    scanf("%d", &n);
    for (i = 0; i < n; i++)scanf("%d", &l[i]);

    qsort(l, n, sizeof(int), asc);

    for (i = 0; i < n; i++)
    {
        for (j = i + 1; j < n; j++)
        {
            for (k = j + 1; k < n; k++)
            {
                if (l[i] < l[j] + l[k])total++;
              else break;
            }
        }
    }
    printf("%ld", total);
}


Measured memory_bytes: 128
import java.util.Scanner;
     
public class Main {
    	
    private final static Scanner sc = new Scanner(System.in);
    	
    public static void main(String[] arg) {
    	long N  = sc.nextInt();
        long sol = (N)*(N-1)/2;
      	System.out.println(sol);
   	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int N,W;cin>>N>>W;
    int v[N],w[N];
    REP(i,N)cin>>v[i]>>w[i];
    int dp[N+1][W+1];
    REP(i,N+1)memset(dp[i],0,sizeof(dp[i]));
    REP(i,N)REP(j,W+1){
        if(j-w[i]>=0)
            dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
        else
            dp[i+1][j]=dp[i][j];
    }
    cout<<dp[N][W]<<endl;
    return 0;
}



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

/*
    d[i] = costul minim pt. care avem o piesa la pozitia precedenta
        si 0 piesa la pozitia i
    sa zicem ca pozitia precedenta este p0, si acum se cere p1
    sunt 2 cazuri:
        1) mutam piesa de la p0 la p1, in care caz la d[...] += |p0-p1|
        2) mutam piesa de la "ceva pozitie" la p0, in care caz
            d[p1] = "cost nou". Pt. asta d tre sa aiba un arbint cu minim
            pe sume telescopante
*/

using ll = long long;

struct info{
    ll len, val, up_min, down_min;
    info(): len(1), val((ll)1e6 * (ll)1e6), up_min(val), down_min(val){}
    info(const ll x): len(1), val(x), up_min(x), down_min(x){}
    info(const info& a, const info& b):
        len(a.len + b.len),
        val(-1),
        up_min(min({a.up_min, a.len + b.up_min, (ll)1e6 * (ll)(1e6)})),
        down_min(min({a.down_min + b.len, b.down_min, (ll)1e6 * (ll)(1e6)})){} };

struct arbint{
    ll n, big_delta = 0;
    vector<info> buf;
public:
    arbint(const ll N): n(1 << (ll)ceil(log2(N))), buf(2*n){
        for(ll i = n-1; i; --i) buf[i] = info { buf[2*i], buf[2*i+1] }; }
    void update_delta(const ll x){ big_delta += x; }
    void update(ll poz, const ll new_val){
        buf[poz+=n] = info { new_val - big_delta };
        for(poz /= 2; poz; poz /= 2)
            buf[poz] = info { buf[2*poz], buf[2*poz+1] }; }
    info query(ll st, ll dr){
        info rez_st, rez_dr;
        rez_st.len = rez_dr.len = 0;
        for(st += n, dr += n+1; st < dr; st /= 2, dr /= 2){
            if(st%2) rez_st = info { rez_st, buf[st++] };
            if(dr%2) rez_dr = info { buf[--dr], rez_dr }; }
        auto rez = info { rez_st, rez_dr };
        rez.up_min += big_delta;
        rez.down_min += big_delta;
        return rez; }
    ll stupid_small_cost(){
        ll rez = (ll)1e6 * (ll)1e6;
        for(ll i = n; i < 2*n; ++i) rez = min(rez, buf[i].val + big_delta);
        return rez; } };

int main(){
    ll n, q, a, b;
    cin >> n >> q >> a >> b;
    arbint aa(n + 100);
    ll p0 = a;
    aa.update(b, 0);

    for(ll i = 0, x; i < q; ++i){
        cin >> x;
        const ll other_cost = min<ll>(
            aa.query(1, x).down_min,
            aa.query(x, n).up_min);
        const ll prev_cost = max(p0 - x, x - p0);
        
        aa.update_delta(prev_cost);
        aa.update(p0, other_cost);
        p0 = x; }
    cout << aa.stupid_small_cost() << endl;
    return 0; }


Measured memory_bytes: 16640
#include <iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b)
{
	ll c;

	if (a < b) {
		a += b; b = a - b; a -= b;
	}

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

	return a;
}

int main() {

	ll memory = ll(1e9);
	ll n, x;
	cin >> n >> x;
	vector <ll> city(n);
	for (ll i = 0; i < n; i++) {
		cin >> city[i];
		if (i == 0) {
			memory = min(memory, abs(x - city[i]));
			continue;
		}
		memory = min(memory, gcd(abs(x - city[i]),memory));
		/*if (i >= 1) {
			city[i] = gcd(city[i - 1], city[i]);
		}*/
	}

	cout << memory << endl;



}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 100005
const ll MOD = 1000000007;

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

	ll n;
	cin>>n;
	vector<ll> f(n+1,0);

	ll k = sqrt(n);
	for(ll x=1;x<=k;x++){
		for(ll y=1;y<=k;y++){
			for(ll z=1;z<=k;z++){
				ll val = x*x + y*y + z*z + x*y + y*z + z*x;
				if(val <= n)
					++f[val];
			}
		}
	}

	for(int i=1;i<=n;i++)
		cout<<f[i]<<"\n";
}

Measured memory_bytes: 3640
using System;
using static System.Console;

class Program
{
    static bool isEven(int x){ return (x&1) == 0; }
    
    public static void Main()
    {
	string s = ReadLine();
	int n = s.Length;
	int[] result = new int[n];

	int l=0, r=0;
	char mode = 'R';

	s += "X";
	
	while (l < n)
	{
	    if (mode == 'R')
	    {
		while (s[r] == 'R') r++;
		int m = r - l;
		if (isEven(m))
		{
		    result[r] += m/2;
		    result[r-1] += m/2;
		}
		else
		{
		    result[r] += m/2;
		    result[r-1] += m/2 + 1;
		}
		l = r;
		mode = 'L';
	    }
	    else
	    {
		while (s[r] == 'L') r++;
		int m = r - l;
		if (isEven(m))
		{
		    result[l] += m/2;
		    result[l-1] += m/2;
		}
		else
		{
		    result[l] += m/2 + 1;
		    result[l-1] += m/2;
		}
		l = r;
		mode = 'R';
	    }
	}

	for (int i = 0; i < n-1; i++) Write($"{result[i]} ");
	WriteLine(result[n-1]);
    }
}
    


Measured memory_bytes: 18268
d, n = map(int, input().split())

if d == 0:
    if n == 100:
        print(101)
    else:
        print(n)
elif d == 1:
    if n == 100:
        print(100*101)
    else:
        print(100*n)
else:
    if n == 100:
        print(10000*101)
    else:
        print(10000*n)

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

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int M = scan.nextInt();
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < M; i++) {
            int s = scan.nextInt() - 1;
            int c = scan.nextInt();
            if (map.containsKey(s)) {
                if (c != map.get(s)) {
                    System.out.println(-1);
                    return;
                }
                continue;
            }
            map.put(s, c);
        }
        int[] digits = new int[N];
        if (1 < N && map.containsKey(0) && map.get(0) == 0) {
            System.out.println(-1);
            return;
        }
        digits[0] = map.getOrDefault(0, (N == 1 ? 0 : 1));
        for (int i = 1; i < N; i++) {
            int x = map.getOrDefault(i, 0);
            digits[i] = x;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < N; i++) {
            sb.append(digits[i]);
        }
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 23764
#include <stdio.h>

#define KIND 26
#define MAX 365

struct horieyui {
	int mamegu[MAX];
};

int D;
int c[KIND];
int s[MAX][KIND];

int mizuhasu(const struct horieyui* kitaeri) {
	int sumipe = 0;
	int i, j;
	int last[KIND] = {0};
	for (i = 0; i < D; i++) {
		sumipe += s[i][kitaeri->mamegu[i]];
		last[kitaeri->mamegu[i]] = i + 1;
		for (j = 0; j < KIND; j++) {
			sumipe -= c[j] * ((i + 1) - last[j]);
		}
	}
	return sumipe;
}

int main(void) {
	int i, j;
	struct horieyui otehon;
	int M;
	if (scanf("%d", &D) != 1) return 1;
	for (i = 0; i < KIND; i++) {
		if (scanf("%d", &c[i]) != 1) return 1;
	}
	for (i = 0; i < D; i++) {
		for (j = 0; j < KIND; j++) {
			if (scanf("%d", &s[i][j]) != 1) return 1;
		}
	}
	for (i = 0; i < D; i++) {
		if (scanf("%d", &otehon.mamegu[i]) != 1) return 1;
		otehon.mamegu[i]--;
	}
	if (scanf("%d", &M) != 1) return 1;
	for (i = 0; i < M; i++) {
		int d, q;
		if (scanf("%d%d", &d, &q) != 2) return 1;
		otehon.mamegu[d - 1] = q - 1;
		printf("%d\n", mizuhasu(&otehon));
	}
	return 0;
}


Measured memory_bytes: 1740
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    vector<int> X(N, 0);
    rep(i, M){
        int a, b; cin >> a >> b; a--; b--;
        X[a]++; X[b]++;
    }
    rep(i, N) cout << X[i] << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

int a[10000];
signed main(){
	int n, x, ans = 0;
	scanf("%lld%lld", &n, &x);
	rep(i,n)scanf("%lld", &a[i]);
	rep(i,n)x -= a[i];ans += n;
	int mn = INF;
	rep(i,n)chmin(mn, a[i]);
	ans += x/mn;
	printf("%lld\n", ans);
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), 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(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    int N; cin >> N;
    map<int,int> M;
    rep(i, 0, N){
        int a; cin >> a;
        if(M[a] != 0){
            cout << "NO\n";
            return 0;
        }
        M[a]++;
    }
    cout << "YES\n";

    return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include "math.h"
#include "stdio.h"

using namespace std;

class Dice{
public:
    int surface[6];
    
    void roleEast();
    void roleWest();
    void roleNorth();
    void roleSouth();
    void swap(int surface2[]);
};

void Dice::swap(int* surface2){
    for(int i = 0;i < 6;++i){
        surface[i] = surface2[i];
    }
}

void Dice::roleEast(){
    int tmp[6];
    tmp[0] = surface[3];
    tmp[3] = surface[5];
    tmp[5] = surface[2];
    tmp[2] = surface[0];
    tmp[1] = surface[1];
    tmp[4] = surface[4];
    swap(tmp);
}

void Dice::roleWest(){
    int tmp[6];
    tmp[3] = surface[0];
    tmp[5] = surface[3];
    tmp[2] = surface[5];
    tmp[0] = surface[2];
    tmp[1] = surface[1];
    tmp[4] = surface[4];
    swap(tmp);
}

void Dice::roleNorth(){
    int tmp[6];
    tmp[0] = surface[1];
    tmp[1] = surface[5];
    tmp[5] = surface[4];
    tmp[4] = surface[0];
    tmp[2] = surface[2];
    tmp[3] = surface[3];
    swap(tmp);
}

void Dice::roleSouth(){
    int tmp[6];
    tmp[0] = surface[4];
    tmp[4] = surface[5];
    tmp[5] = surface[1];
    tmp[1] = surface[0];
    tmp[2] = surface[2];
    tmp[3] = surface[3];
    swap(tmp);
}

int main(){
    string s;
    Dice dice;
    for(int i = 0;i < 6;++i){
        cin >> dice.surface[i];
    }
    while(getline(cin,s)){
        for(int i = 0;i < s.length();++i){
            switch(s.at(i)){
                case 'E':
                    dice.roleEast();
                    break;
                case 'N':
                    dice.roleNorth();
                    break;
                case 'S':
                    dice.roleSouth();
                    break;
                case 'W':
                    dice.roleWest();
                    break;
            }
        }
    }
    cout << dice.surface[0] << endl;
}



Measured memory_bytes: 3172
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

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

//累乗だってさ
ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll combination(ll n,ll r){
    ll sum=1;
    rrep(i,min(r,n-r)) (sum*=(n-i+1))%=mod;
    return sum;
}

//逆元だってさ
ll modinv(ll a,ll mod1) {
    return modpow(a, mod1 - 2, mod1);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b;
    cin>>a>>b;
    ll num=a;
    ll cou=0;
    while(b>=num){
        num *= 2;
        cou++;
    }
    cout<<cou<<endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(1,n-1):
    if max(p[i-1],p[i],p[i+1])!=p[i] and min(p[i-1],p[i],p[i+1])!=p[i]:
        ans+=1
print(ans)

Measured memory_bytes: 3060
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn tri(n: usize) -> Option<usize> {
    let n = 8 * n + 1;
    let r = (n as f64).sqrt() as usize;
    if r * r != n {
        return None;
    }
    Some((r as usize - 1) / 2)
}

fn main() {
    input! {
        n: usize,
    }

    if let Some(tri) = tri(n) {
        println!("Yes");
        let mut res = vec![vec![]; tri + 1];
        let mut a = 1;
        for i in 1..=tri {
            for j in 0..i {
                res[i].push(a);
                res[j].push(a);
                a += 1;
            }
        }
        println!("{}", tri + 1);
        for res in res {
            print!("{} ", res.len());
            for res in res {
                print!("{} ", res);
            }
            println!("");
        }
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2852
n = gets.to_i
cn = {}
sp = []

n.times do |i|
    s, p = gets.strip.split
    cn[s] = true
    sp << [i + 1, s, p.to_i]
end

sp.sort!{ |a,b| b[2] <=> a[2] }   # sort with p

cn.keys.sort.each do |c|
    sp.each do |i, s, p|
        if s == c then
            puts i
        end
    end
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,id=0,maxi=0;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0; i<n; i++)
    {
        if(s[i]=='I')
            id++;
        else
            id--;
        if(id>maxi)
            maxi=id;
    }
    cout<<maxi<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	char a;
	cin>>a;
	if(a>='a')cout<<'a'<<endl;
	else cout<<"A"<<endl;
	return 0;
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int range = 2000000000;
#define ll long long
#define rep(i,n) for(int i=0 ; (n) >i; i++)

    int main(){
        string str; cin >> str;
        int count = 0;
        if(str[0] == '1') count++;
        if(str[1] == '1') count++;
        if(str[2] == '1') count++;
        
        cout << count << endl;
        
        return 0;
    }




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

#define IOS		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ld 		    long double
#define ll 		    long long int
#define ull 	   	unsigned long long int
#define pb		    push_back
#define mp		    make_pair
#define F		    first
#define S		    second
#define lb		    lower_bound
#define ub		    upper_bound
#define deb(x)      cout<<"#x "<<x<<"\n";
#define trace(x,y)  cout<<"#x "<<x<<" #y "<<y<<"\n";


const int mod = 1e9;
ll p[1001]; 

int main(){
    for(int i = 0; i<= 1000 ; i++){
        ll r = i;
        p[i] = r*r*r*r*r; 
    }
    map<ll, ll > m;
    for(int i = 0;i <= 1000; i++)m[p[i]]=i;
    ll x;
    cin >> x;
    ll a = 1;
    for(a = 0; a <= 1000; a++){
        if(p[a] == x){
            cout<<a<<" "<<0<<"\n";
            break;
        }
        ll bp = abs(x - p[a]);
        
        if(m[bp] > 0){
            if(x-p[a] < 0){
                cout<<a<<" "<<m[bp]<<"\n";
            }
            else cout<<a<<" -"<<m[bp]<<"\n";
            break;
        }
    }
return 0;
}


Measured memory_bytes: 3708
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<functional>

typedef unsigned long long LL;

using namespace std;

int main() {
	string s;
	cin >> s;
	int answer = 100;
	for (char c = 'a'; c < 'z' + 1; c++) {
		int tmpanswer = 0;
		int tmp=0;
		for (int i = 0; i < s.length(); i++) {
			if (s[i] != c) {
				tmp++;
			}
			else {
				tmpanswer = max(tmpanswer, tmp);
				tmp = 0;
			}
		}
		tmpanswer = max(tmpanswer, tmp);
		answer = min(tmpanswer, answer);
	}
	cout << answer << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	float weight;
	
	while(scanf("%f", &weight) != EOF){
		
		if(weight <= 48) printf("light fly\n");
		else if(weight <= 51) printf("fly\n");
		else if(weight <= 54) printf("bantam\n");
		else if(weight <= 57) printf("feather\n");
		else if(weight <= 60) printf("light\n");
		else if(weight <= 64) printf("light welter\n");
		else if(weight <= 69) printf("welter\n");
		else if(weight <= 75) printf("light middle\n");
		else if(weight <= 81) printf("middle\n");
		else if(weight <= 91) printf("light heavy\n");
		else printf("heavy\n");
	}
	
	return(0);
}

Measured memory_bytes: 604
#include <stdio.h>

int main()
{
    int n;
    int k;
    scanf("%d %d",&n,&k);
    int a[100000];
    for(int i=0;i<n;i++) scanf("%d",&a[i]);


    int ans=0;
    n--;
    while(n>0)
    {
        ans++;
        n-=k-1;
    }
    printf("%d\n",ans);
}

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

int main()
{

	while(true){

		int n;
		int c1;
		int ma, sa;
		int mb, sb;
		int mc, sc;
		int md, sd;
		int t = 0;
		int min = 60*60*4;
		int semimin = 60*60*4;
		int max = -1;
		int max2 = -1;
		int minx = 0, semiminx = 0, maxx = 0, max2x = 0;

		cin >> n;

		if(n==0)
			break;

		for(int i=0 ;i<n ;i++){

			cin >> c1 >> ma >> sa >> mb >> sb >> mc >> sc >> md >> sd;

			int a ,b ,c ,d;
			a = ma*60 + sa;
			b = mb*60 + sb;
			c = mc*60 + sc;
			d = md*60 + sd;

			t = a + b + c + d;

			
			if(t < min){
				semimin = min;
				semiminx = minx;
				min = t;
				minx = c1;
			}
			else if(t < semimin){
				
				semimin = t;
				semiminx = c1;
				
			}
			if(t > max){
				max2 = max;
				max2x = maxx;
				max = t;
				maxx = c1;
			
			}
			else if(t > max2){
				max2 = t;
				max2x = c1;
			}

		}
		cout << minx << endl;
		cout << semiminx << endl;
		cout << max2x << endl;
	}

	return 0;
}

Measured memory_bytes: 868
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int n;
  cin >> n;
  cout << 800*n - (n/15)*200 << endl;
  return 0;
}

Measured memory_bytes: 256
l,r = map(int,input().split())

a = l % 2019
b = r % 2019
tmp = 2018

if abs(l-r) >= 2019*2:
    print(0)
elif abs(l-r) >= 2019:
    print(min(a,b))
else:
    tmp = 2018
    for i in range(min(a,b),max(a,b)+1):
        for j in range(i+1,max(a,b)+1):
            tmp = min((i*j)%2019, tmp)
    print(tmp)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n; cin >> n;
	ll ans = 0;
	REP(i,1,n+1){
		if(i%3 != 0 && i%5 != 0) ans += i;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3644
import sys

# import re
# import math
# import collections
# import decimal
# import bisect
# import itertools
# import fractions
# import functools
# import copy
# import heapq
# import decimal
# import statistics
# import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 10
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    n, m, k = ns()

    friend = UnionFind(n)

    myfriend = [0 for _ in range(n)]
    blocks = {}
    for i in range(n):
        blocks[i] = set()

    for _ in range(m):
        ai, bi = ns()
        ai -= 1
        bi -= 1
        friend.union(ai, bi)
        myfriend[ai] += 1
        myfriend[bi] += 1

    for _ in range(k):
        ci, di = ns()
        ci -= 1
        di -= 1

        blocks[ci].add(di)
        blocks[di].add(ci)

    tmp = 0
    for i in range(n):
        tmp_block = 0
        for j in blocks[i]:
            if friend.same(i, j):
                tmp_block += 1

        ans = friend.size(i) - 1 - myfriend[i] - tmp_block
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 49280
def main():
    N = int(input())
    aD = []
    if N % 2 :
        aD = [[i,N-i] for i in range(1,(N+1)//2)]
        aD.append([N])
    else:
        aD = [[i,N+1-i] for i in range(1,(N//2)+1)]
    iD = len(aD)
    dRes = set()
    def strfy(aD):
        return " ".join(str(_) for _ in sorted(aD))
    for i in range(iD):
        for j in range(iD):
            if i == j :
                pass
            else:
                if len(aD[i]) == 1:
                    dRes.add(strfy([aD[i][0],aD[j][0]]))
                    dRes.add(strfy([aD[i][0],aD[j][1]]))
                elif len(aD[j])== 1:
                    dRes.add(strfy([aD[i][0],aD[j][0]]))
                    dRes.add(strfy([aD[i][1],aD[j][0]]))
                else:
                    dRes.add(strfy([aD[i][0],aD[j][0]]))
                    dRes.add(strfy([aD[i][0],aD[j][1]]))
                    dRes.add(strfy([aD[i][1],aD[j][0]]))
                    dRes.add(strfy([aD[i][1],aD[j][1]]))
    print(len(dRes))
    print(*dRes,sep="\n")
main()


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

int main() {
  string s,t,S;
  cin >> s >> t;
  bool f = false;
  S = s+s;
  for ( int i = 0; i < S.length(); i++ ) {
    int cnt = 0;
    for ( int j = 0; j < t.length(); j++ ) {
      if ( S[i+j] == t[j] ) cnt++;
      if ( cnt == t.length() ) {
	f = true;
	break;
      }
    }
    
  }
  if (f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256