akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
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; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll a,b;
  cin >> a >> b;
  ll c=a;
  ll d=b;
  while(c!=d){
    if(c>d){
      d+=b;
    }else {
      c+=a;
    }
  }
  pri(c);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a,b,c;
	int oishii;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(a+b<c){
		oishii=a+b+1+b;
	}else{
		oishii=b+c;
	}
	
	printf("%d",oishii);
	
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string str;
            str = Console.ReadLine ();

            int N = int.Parse (str);

            int ac = 0;
            int wa = 0;
            int tle = 0;
            int re = 0;

            for (int i = 0; i < N; i++)
            {
                string S = Console.ReadLine ();
                switch (S)
                {
                    case "AC":
                        ac += 1;
                        break;
                    case "WA":
                        wa += 1;
                        break;
                    case "TLE":
                        tle += 1;
                        break;
                    case "RE":
                        re += 1;
                        break;
                }
            }

            Console.WriteLine ("AC x " + ac);
            Console.WriteLine ("WA x " + wa);
            Console.WriteLine ("TLE x " + tle);
            Console.WriteLine ("RE x " + re);
        }
    }

    class MyLibrary
    {
        public static int GCD (int a, int b)
        {
            if (a % b == 0) return b;
            return GCD (b, a % b);
        }
    }
}

Measured memory_bytes: 30696
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define endl "\n"
#define all(x) (x).begin(),(x).end()
const int MOD = 1e9+7;
const int mxN = 2e5+3;

void solve(){
	int a,b;
	cin >> a >> b;
	int ans = a * b;
	cout << ans << endl;
}

int32_t main(){
	IO;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif // ONLINE_JUDGE
	int nT = 1;
	//cin >> nT;
	for(int i = 1; i <= nT; ++i)
		solve();
	return 0;
}


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

int main() {



    int n, w1, w2, cnt = 0, ttl = 0, ttl2 = 0, c10 = -1, c5 = -1, c1 = -1, t = 0;
	bool fin = false;

	cin >> n >> ttl;

	if (ttl % 1000 != 0) {
		cout << -1 << ' ' << -1 << ' ' << -1 << endl;
		return 0;
	}

	ttl2 = ttl / 1000;

	for (int i = n;i >= 0;i--) {

		w1 = ttl2 - (i * 10);

		if (w1 < 0) continue;

		for (int k = n - i; k >= 0; k--) {

			w2 = w1 - (k * 5);

			if (w2 < 0) continue;

			t = n - i - k;

			if (w2 == t && (i + k + t) == n) {
				c10 = i;
				c5 = k;
				c1 = n - i - k;

				fin = true;
				break;
			}
		}

		if (fin) break;

	}


	cout << c10 << " " << c5 << " " << c1 << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vv = vector<vector<int>>;
using P = pair<int,int>;


int main(){
  char a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >>f;
  if( a == f && b == e && c == d ){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


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

#define abs(N) (((N)>0)?(N):(-1)*(N))

int main() {
	int N,T,A;
	cin >> N >> T >> A;
	int place=-1;
	double pdiff = 1000000000;

	for (int i = 0; i < N; ++i) {
		int x;
		cin >> x;
		double diff = abs(T - x * 0.006 - A);
		if(pdiff > diff){
			place = i;
			pdiff = diff;
		}
	}
	cout << place+1 << endl;

}


Measured memory_bytes: 256
_ = gets
cities = gets.chomp.split(' ').map(&:to_i)
heros = gets.chomp.split(' ').map(&:to_i)

ans = 0

heros.length.times do |i|
  if heros[i] >= cities[i]
    heros[i] -= cities[i]
    ans += cities[i]
  else
    ans += heros[i]
    heros[i] = 0
  end
  
  next if heros[i].zero?
  next unless cities[i + 1]

  if heros[i] >= cities[i + 1]
    ans += cities[i + 1]
    cities[i + 1] = 0
  else
    ans += heros[i]
    cities[i + 1] -= heros[i]
  end
end

puts ans

Measured memory_bytes: 17548
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const ll INF = 114514810;
const ll MOD = 1000000007;
const double EPS = 1e-8;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///


int main()
{
	int w, h;
	while (cin >> w >> h, w)
	{
		int fld[100][100] = {};
		int sx, sy, gx, gy, n;
		cin >> sy >> sx >> gy >> gx >> n;
		sy--; sx--; gy--; gx--;
		while (n--)
		{
			int c, d, x, y;
			cin >> c >> d >> y >> x;
			y--; x--;
			if (d)
			{
				REP(i, 4)REP(j, 2) fld[x + i][y + j] = c;
			}
			else
			{
				REP(i, 2)REP(j, 4) fld[x + i][y + j] = c;
			}
		}
		/*
		REP(i, h)
		{
			REP(j, w) cout << fld[i][j];
			cout << endl;
		}
		*/
		queue<P> que;
		que.push(P(sx, sy));
		bool f = false;
		int color = fld[sx][sy];
		while (que.size())
		{
			if (color == 0) break;
			int tx = que.front().first, ty = que.front().second;
			fld[tx][ty] = 0;
			que.pop();
			if (tx == gx&&ty == gy)
			{
				f = true;
				break;
			}
			REP(i, 4)
			{
				int nx = tx + dx[i], ny = ty + dy[i];
				if (valid(nx, ny, h, w) && fld[nx][ny] == color) que.push(P(nx, ny));
			}
		}
		puts(f ? "OK" : "NG");
	}
	return 0;
}

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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<(x)<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{   


    li n;

    cin>>n;

    li a[n];

    li cnt=0;

    f(i,0,n-1)
    {
        cin>>a[i];

        if(a[i]==0)
            cnt++;
    }

    if(cnt>0)
    {
        cout<<0;
        return;
    }

    li ans=1,flag=0,tp=1e18;

    f(i,0,n-1)
    {
        if(a[i]>(tp/ans))
        {
            flag=1;
            break;
        }
        else
            ans*=a[i];
    }

    if(flag)
        cout<<-1;
    else
        cout<<ans;
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}


Measured memory_bytes: 4436
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] d = new int[N];
		for (int i = 0; i < N; i++)
			d[i] = sc.nextInt();
		Arrays.sort(d);
		int count = 0;
		for (int i = 0; i < N - 1; i++) {
			if (d[i] != d[i + 1])
				count++;
		}
		System.out.println(count+1);

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 21332
def bubble_sort(data, n):
    """ ??°???data??????????????????????????????????????§???????????????????????????n?????°????????????
    ?????????????????????????????°??¨????????????????????????????????????
    """
    swap_count = 0
    flag = True
    i = 0
    while flag is True:
        flag = False
        for j in range(n-1, i, -1):
            if data[j] < data[j-1]:
                temp = data[j]
                data[j] = data[j-1]
                data[j-1] = temp
                swap_count += 1
                flag = True
        i == 1
    return swap_count, data


if __name__ == '__main__':
    # ??????????????\???
    num = int(input())
    data = [int(x) for x in input().split(' ')]
    # data = [5, 3, 2, 4, 1]

    # ???????????????????????????
    count, data = bubble_sort(data, num)

    # ???????????????
    print('{0}\n{1}'.format(' '.join(map(str, data)), count))

Measured memory_bytes: 7744
#include <bits/stdc++.h>
using namespace std;
int main(){
  int64_t x,y;
  cin>>x>>y;
  if(x<y&&x*y>=0){
    cout<<max(x,y)-min(x,y);
  }
   if(x>y&&x*y>0){
    cout<<2+max(x,y)-min(x,y);
  }
     if(x>y&&x*y==0){
    cout<<1+max(x,y)-min(x,y);
  }
  if(x*y<0) {
    int a=max(x,y);
    int b=min(x,y);
    int B=abs(b);
    int c=max(a,B);
    int d=min(a,B);
    int e=c-d;
    cout<<e+1;
  }
}


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

using namespace std;

int main()
{
  int color[4] = {};
  
  int N;
  cin >> N;
  
  string c;
  for(int i = 0; i < N; i++) {
    cin >> c;
    if(c == "P") color[0]++;
    else if(c == "W") color[1]++;
    else if(c == "G") color[2]++;
    else if(c == "Y") color[3]++;
  }
  
  int res = 0;
  for(int i = 0; i < 4; i++) {
    if(color[i] > 0) res++;
  }
  
  if(res == 3) cout << "Three" << endl;
  else cout << "Four" << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int x = scan.nextInt();
        int y = scan.nextInt();     

        while (x != 0 ||y!= 0) {
            if (x > y) {
                System.out.println(y + " " + x);
            }
            if (x < y) {
                System.out.println(x+ " "+y);
            }
            if (x == y) {
                System.out.println(x + " " + y);
            }
            x = scan.nextInt();
            y = scan.nextInt();
        }
    }
}



Measured memory_bytes: 35820
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  int X, div, nre;
  cin >> X;
  div = X / 100;
  nre = X % 100;
  if (nre > 5 * div) {
    printf("0\n");
  }
  else if (nre <= 5 * div) {
    printf("1\n");
  }
  return 0;
}

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

int max(const std::vector<int> &_vals)
{
    int max = _vals[0];
    for(int x : _vals) {
        if(max < x) { max = x; }
    }
    return max;
}

int min(const std::vector<int> &_vals)
{
    int min = _vals[0];
    for(int x : _vals) {
        if(min > x) { min = x; }
    }
    return min;
}

long sum(const std::vector<int> &_vals)
{
    long sum = 0;
    for(int x : _vals) {
        sum += x;
    }
    return sum;
}

int main(void)
{
    int num;
    std::cin >> num;
    std::vector<int> vals(num);
    for(int i = 0; i < num; i++) {
        std::cin >> vals[i];
    }
    int max_ = max(vals);
    int min_ = min(vals);
    long sum_ = sum(vals);
    std::cout << min_ << " " << max_ << " " << sum_ << std::endl;
    return 0;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  int d[k];
  for(int i=0; i<k; i++){
    cin >> d[i];
  }
  int ans = n;
  while(true){
    int tmp = ans;
    bool like=true;
    while(tmp>0){
      int a = tmp%10;
      tmp /= 10;
      for(int i=0; i<k; i++){
        if(a==d[i]) like = false;
      }
    }
    if(like) break;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define S second
#define F first
#define ll long long
#define ld long double

using namespace std;

const int N = 1e6 + 5, mod = 1e9 + 7;

// ll pw(ll x, ll y)
// {
//     ll ret = 1;
//     while(y)
//     {
//         if(y&1) ret = (ret * x) % mod;
//         y>>=1;
//         x = (x*x) % mod;
//     }
//     return ret;
// }

int main()
{
    ld ans = 0;
    int n, x;
    cin>>n;
    for(int i = 0 ; i < n ; i++)
    {
        cin>>x;
        ans += (1.0 / (1.0L*x));
    }
    cout<<fixed<<setprecision(6)<<(1 / ans)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a[51],maxn=-1000005,minn=1000005,pn,px;
int main (){
	int i;
	scanf ("%d",&n);
	for (i=1;i<=n;i++)
	{scanf ("%d",&a[i]);
	if (a[i]>maxn) {maxn=a[i];px=i;}
	if (a[i]<minn) {minn=a[i];pn=i;}
	}
printf ("%d\n",2*n-2);
	if (maxn>-minn)
	{for (i=1;i<=n;i++)if(i!=px)printf ("%d %d\n",px,i);
	for (i=1;i<n;i++)printf("%d %d\n",i,i+1);
	}
	else
	{for (i=1;i<=n;i++)if(i!=pn)printf ("%d %d\n",pn,i);
	for (i=n-1;i>=1;i--)printf ("%d %d\n",i+1,i);
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    
    vector<double> x(n);
    vector<string> u(n);
    rep(i, n){
        cin >> x.at(i) >> u.at(i);
    }
    
    double ans = 0;
    rep(i, n){
        if(u.at(i) == "JPY") ans += x.at(i);
        else ans += x.at(i)*380000;
    }
    
    printf("%.6lf\n", ans);
    return 0;
}

Measured memory_bytes: 256
use proconio::{input, fastout};
#[fastout]
fn main() {
    input!{
        n: usize,
        mut a: [usize;n],
    }

    let mut ans = 0;
    for i in 1..n {
        if a[i-1] > a[i] {
            ans += a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }

    println!("{}", ans);
    
}


Measured memory_bytes: 5584
#include <iostream>
#include <algorithm>
#include <string>
#include <unordered_map>

using namespace std;

unordered_map<string, int> um;

string strs[200005];

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	
	for (int i = 0; i < n; i++)
	{
		cin >> strs[i];
		if (um.find(strs[i]) != um.end()) // found
		{
			um[strs[i]]++;
		}
		else
		{
			um[strs[i]] = 1;
		}
	}
	sort(strs, strs + n, [](const string& s1, const string& s2)
		{
			if (um[s1] != um[s2])
			{
				return um[s1] > um[s2];
			}
			return s1 < s2;
		});
	auto new_end = unique(strs, strs + n) - strs;
	int max_val = um[strs[0]];
	for (int i = 0; i < new_end && um[strs[i]] == max_val; i++)
	{
		cout << strs[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 24264
using System;
namespace aoj {
	public class Program {
		public static char Check(char[,] map) {
			if (map[1, 0] == map[1, 1] && map[1, 1] == map[1, 2] && map[1, 0] != 's') return map[1, 0];
			if (map[0, 1] == map[1, 1] && map[1, 1] == map[2, 1] && map[0, 1] != 's') return map[0, 1];
			if (map[0, 0] == map[1, 1] && map[1, 1] == map[2, 2] && map[0, 0] != 's') return map[0, 0];
			if (map[0, 2] == map[1, 1] && map[1, 1] == map[2, 0] && map[0, 2] != 's') return map[0, 2];
			if (map[0, 0] == map[0, 1] && map[0, 1] == map[0, 2] && map[0, 0] != 's') return map[0, 0];
			if (map[0, 0] == map[1, 0] && map[1, 0] == map[2, 0] && map[0, 0] != 's') return map[0, 0];
			if (map[2, 2] == map[2, 1] && map[2, 1] == map[2, 0] && map[2, 2] != 's') return map[2, 2];
			if (map[2, 2] == map[1, 2] && map[1, 2] == map[0, 2] && map[2, 2] != 's') return map[2, 2];
			return 'd';
		}
		public static void Main() {
			string str;
			while ((str = Console.ReadLine()) != null) {
				char[,] map = { { str[0], str[1], str[2] }, { str[3], str[4], str[5] }, { str[6], str[7], str[8] } };
				Console.WriteLine(Check(map));
			}
		}
	}
}

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

#define HEAP priority_queue
#define rep(i, n) for(int i = 0, _end_ = (n); i < _end_; ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l), _end_ = (r); i <= _end_; ++i)
#define nrof(i, r, l) for(int i = (r), _end_ = (l); i >= _end_; --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;

const int iinf = 1e9 + 7;
const int oo = 0x3f3f3f3f;
const LL linf = 1ll << 60;
const flt dinf = 1e60;

template <typename T> inline void scf(T &x)
{
	bool f = 0;
	x = 0;
	char c = getchar();
	while(c != '-' && (c < '0' || c > '9')) c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	if(f) x = -x;
	return;
}

template <typename T1, typename T2> void scf(T1 &x, T2 &y)
{
	scf(x);
	return scf(y);
}

template <typename T1, typename T2, typename T3> void scf(T1 &x, T2 &y, T3 &z)
{
	scf(x);
	scf(y);
	return scf(z);
}

template <typename T1, typename T2, typename T3, typename T4> void scf(T1 &x, T2 &y, T3 &z, T4 &w)
{
	scf(x);
	scf(y);
	scf(z);
	return scf(w);
}

inline char mygetchar()
{
	char c = getchar();
	while(c == ' ' || c == '\n') c = getchar();
	return c;
}

template <typename T> inline bool chkmax(T &x, const T &y)
{
	return y > x ? x = y, 1 : 0;
}

template <typename T> inline bool chkmin(T &x, const T &y)
{
	return y < x ? x = y, 1 : 0;
}

#ifdef King_George
#define DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

//---------------------------------------------------------head----------------------------------------------------

const int N = 233;

int n, m;
int K, cnt[N * N];
int a[N][N];

int main()
{
	scf(n, m);
	scf(K);
	int x = 1, y = 0, d = 1;
	forn(col, 1, K)
	{
		int z; scf(z);
		while(z--)
		{
			y += d;
			if(y > m) y = m, d = -1, ++x;
			if(y < 1) y = 1, d = 1, ++x;
			a[x][y] = col;
		}
	}
	forn(i, 1, n)
	{
		forn(j, 1, m) printf("%d ", a[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#define IT vector<pair<long long,long long> >::iterator
using namespace std;
const int N=5e5+500;
int n;
pair<long long,long long>tmp1[N],tmp2[N],tmp[N];
vector<pair<long long,long long> >f[N];
struct Edge{int v,w;}ch[N][2];
void dfs(int u,long long lim)
{
    if(!ch[u][0].v){f[u].push_back(make_pair(0,0));return;}
    dfs(ch[u][0].v,lim),dfs(ch[u][1].v,lim);
    int ls=ch[u][0].v,rs=ch[u][1].v;
    for(IT it=f[ls].begin();it!=f[ls].end();it++)it->first+=ch[u][0].w,it->second+=ch[u][0].w;
    for(IT it=f[rs].begin();it!=f[rs].end();it++)it->first+=ch[u][1].w,it->second+=ch[u][1].w;
    int n1=0,n2=0,i=0,j=0;
    for(int i=0;i<f[ls].size();i++)
    {
//        if(f[ls][i].first>lim)break;
        while(j<f[rs].size()&&f[ls][i].second+f[rs][j].first<=lim)++j;
        if(j&&(!n1||tmp1[n1].second>f[rs][j-1].second))tmp1[++n1]=make_pair(f[ls][i].first,f[rs][j-1].second);
    }
    i=j=0;
    for(int j=0;j<f[rs].size();j++)
    {
//        if(f[rs][j].first>lim)break;
        while(i<f[ls].size()&&f[rs][j].second+f[ls][i].first<=lim)++i;
        if(i&&(!n2||tmp2[n2].second>f[ls][i-1].second))tmp2[++n2]=make_pair(f[rs][j].first,f[ls][i-1].second);
    }
    i=1,j=1;int k=0;
    for(;i<=n1&&j<=n2;)
    {
        if(tmp1[i].first<tmp2[j].first)
        {
            tmp[++k]=tmp1[i++];if(k!=1&&tmp[k].second>=tmp[k-1].second)--k;
        }
        else if(tmp1[i].first>tmp2[j].first)
        {
            tmp[++k]=tmp2[j++];if(k!=1&&tmp[k].second>=tmp[k-1].second)--k;
        }
        else 
        {
            tmp[++k]=tmp1[i].second<tmp2[j].second?tmp1[i]:tmp2[j];i++,j++;
            if(k!=1&&tmp[k].second>=tmp[k-1].second)--k;
        }
    }
    while(i<=n1){tmp[++k]=tmp1[i++];if(k!=1&&tmp[k].second>=tmp[k-1].second)--k;}
    while(j<=n2){tmp[++k]=tmp2[j++];if(k!=1&&tmp[k].second>=tmp[k-1].second)--k;}
    for(int i=1;i<=k;i++)f[u].push_back(tmp[i]);
}
int judge(long long lim)
{
    for(int i=1;i<=n;i++)f[i].clear();
    dfs(1,lim);
    return f[1].size();
}
int main()
{
//    freopen("data.txt","r",stdin);
    scanf("%d",&n);
    for(int i=2,fa,w;i<=n;i++)
    {
        scanf("%d%d",&fa,&w);
        if(ch[fa][0].v)ch[fa][1]=(Edge){i,w};
        else ch[fa][0]=(Edge){i,w};
    }
    long long l=0,r=2000000000000ll,mid;
    while(l<r)
    {
        mid=(l+r)>>1;
        if(judge(mid))r=mid;
        else l=mid+1;
//        cout<<l<<" "<<r<<" "<<mid<<endl;
    }
    cout<<l<<endl;
}

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

std::vector<int> langs;
int find(int x){
  if(langs[x] == x)return x;
  return langs[x] = find(langs[x]);
}
void merge(int x,int y){
  langs[find(x)] = find(y);
}

int main(){
  int m,n;
  std::cin >> n >> m;
  langs.resize(m);
  for(int i=0;i<m;i++)langs[i] = i;
  std::vector<std::vector<int> > poyo(n);
  for(int i=0;i<n;i++){
    int k;
    std::cin >> k;
    int l0;
    std::cin >> l0;
    poyo[i].push_back(l0-1);
    for(int j=0;j<k-1;j++){
      int l;
      std::cin >> l;
      poyo[i].push_back(l-1);
      merge(l0-1,l-1);
    }
  }
  int u = find(poyo[0][0]);
  for(int i=1;i<n;i++){
    if(u != find(poyo[i][0])){
      std::cout << "NO" << std::endl;
      return 0;
    }
  }
  std::cout << "YES" << std::endl;
  return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    bool flg = true;
    for (auto i = 0; i < n; i++) {
        int a;
        cin >> a;
        if(a % 2 == 0) {
            if(a % 5 != 0 and a % 3 != 0) flg = false;
        }
    }

    cout << ((flg) ? "APPROVED" : "DENIED") << endl;
    return 0;
}

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

#define ll long long 
 
using namespace std ;
 
ll z , ans , o ;

ll mod = 1e9 + 7 ;
ll N = 1e5 + 7 ;


int main( ){

	int k ;

	int a , b ;

	cin >> k >> a >> b ;

	for( int i = a ; i <= b ; i ++ ){

		if( i % k == 0 ){

			cout << "OK" << endl ;

			return 0 ;

		}

	}

	cout << "NG" << endl ;

	return 0 ;

}	



Measured memory_bytes: 3636
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class BTapDance {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        string s;
        in>>s;
        bool f=true;
        fr(i,s.length()){
            if(i&1){
                if(s[i]=='R') f=false;
            }
            else{
                if(s[i]=='L') f=false;
            }
        }
        out<<(f?"Yes":"No")<<endl;
    }
};

int main() {
    BTapDance solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

#define length_c 10001


void countingSort( int *a, int *b, int n) {
  
  int i, j;
  int *c;

  c = malloc( sizeof(int) * (length_c) );

  for( i=0; i<length_c; i++) {
    c[i] = 0;
  }
  
  for( j=1; j<=n; j++) {
    c[ a[j] ]++;
  }

  for( i=1; i<length_c; i++) {
    c[i] = c[i] + c[i-1];
  }

  for( j=n; j>=1; j--) {
    b[ c[ a[j] ] ] = a[j];
    c[ a[j] ]--;
  }

}


main() {
  
  int i;
  int n;
  int *a, *b;


  scanf("%d", &n);

  a = malloc( sizeof(int) * (n+1) ); //1オリジンの配列
  for( i=1; i<=n; i++) {
    scanf( "%d", &a[i]);
  }

  b = malloc( sizeof(int) * (n+1) ); //ソートした配列aを格納する配列

  countingSort( a, b, n);

  for( i=1; i<n; i++) {
    printf("%d ", b[i]);
  }
  printf("%d\n", b[i]);

  return 0;

}

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

int main(){
  string S;
  cin >> S;
  bool isGood = true;
  for(int i = 0; i < 3; i++){
    if(S.at(i) == S.at(i + 1)) isGood = false;
  }
  if(isGood) cout << "Good" << endl;
  else cout << "Bad" << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
min_size = A[0]
res = 0
for i in range(N):
  if A[i] < min_size:
    d = min_size - A[i]
    res += d
  elif A[i] > min_size:
    min_size = A[i]
print(res)

Measured memory_bytes: 94204
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#define DEBUG(x) std::cout << '>' << #x << ':' << x << '\n';
#define PRINTVEC(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i] << ' '; std::cout << '\n';
#define PRINTPAIR(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i].first << ' ' << x[i].second << '\n'; std::cout << '\n';
#define PRINTSET(x) for (auto it = x.begin(); it != x.end(); it++) { std::cout << *it << ' '; } std::cout << '\n';
#define io std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);   
const int INF = 1<<29;
typedef long long ll;
using namespace std;


int main()
{
	io;
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);  
    #endif

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

    #ifndef ONLINE_JUDGE   
    //std::cout << '\n' << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    #endif
    return 0;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int K, A, B;
  cin >> K >> A >> B;

  int ans;
  ans = B / K - A / K;
  if (A % K == 0 || B % K == 0 || ans != 0)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;

  return 0;
}


Measured memory_bytes: 3588
var
  s:ansistring;
  i,j,n,k,m,t:longint;
begin
  readln(s);
  k:=length(s);
  if k mod 2<>0 then
  begin
    writeln('No');
    halt;
  end;
  for i:=1 to k div 2+1 do
  begin
    t:=abs(ord(s[i])-ord(s[k-i+1]));
    if (t<>1)and(t<>2) then
    begin
      writeln('No');
      halt;
    end;
  end;
  writeln('Yes');
end.


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
const int MOD = 1000000007;
const int N = 2e6+13, M = N;
int main()
{
    IOS;
    lli n;
    cin>>n;
    lli arr[n];
    lli ans=0;
    lli sum=0;
    for(lli i=0;i<n;i++)
    {
        cin>>arr[i];
        ans+=arr[i]*sum%MOD;
        sum+=arr[i];
        sum%=MOD;
    }
    ans %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5212
N,M=gets.split.map(&:to_i)

edges=Array.new(N){Array.new}

in_count=Array.new(N,0)

(N-1+M).times do
    a,b=gets.split.map(&:to_i)
    a-=1
    b-=1
    edges[a] << b
    in_count[b]+=1
end

root=in_count.index(0)
data=Array.new(N){Array.new}
ans=Array.new(N)
queue=[]

data[root] << [0,-1] # dist,parent
queue << root

while !queue.empty?
    v=queue.shift
    dist,parent = data[v].max
    ans[v] = parent
    edges[v].each do |vv|
        data[vv] << [dist+1,v]
        queue << vv if data[vv].size==in_count[vv]
    end
end

ans.each do |i|
    puts i+1
end

Measured memory_bytes: 28412
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;

template<typename T>
inline bool chmin(T& x, T a) {
	if (x >= a) { x = a; return true; }
	return false;
}

template<typename T>
inline bool chmax(T& x, T a) {
	if (x <= a) { x = a; return true; }
	return false;
}

int main() {
	ll x; cin >> x;
	ll n = x / 500;
	ll ans = n * 1000;
	x -= n * 500;
	n = x / 5;
	ans += n * 5;
	cout << ans << endl;
	return 0;
}

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

ll L,R;
ll saisyou = 2019;

int flag1=0;
int flag2=0;

int main(){
	cin>>L>>R;

	for(ll i=L;i<R;i++){
		for(ll j=i+1;j<=R;j++){
			saisyou = min(saisyou,(i*j)%2019);
			if(saisyou == 0)
				break;
		}
		if(saisyou == 0)
			break;
	}

	if(saisyou == 0)
		cout<<0<<endl;
	else
		cout<<saisyou<<endl;
}

Measured memory_bytes: 256
// 17:30~ 22:30
#include <cstdio>
#include <iostream>
#include <cmath>

#define INF 1000000.0

using namespace std;

struct P{
	double x, y;
	P(double X=0.0, double Y=0.0){
		x = X;
		y = Y;
	} 
	P operator+( const P &in ){
		P tmp( x + in.x , y + in.y );
		return tmp;
	}
	P operator-( const P &in ){
		P tmp( x - in.x , y - in.y );
		return tmp;
	}
	P operator*( const double &in ){
		P tmp( x * in , y * in );
		return tmp;
	}
	double dot( const P &in ){
		return x * in.x + y * in.y;
	}
	double cross( const P &in ){
		return x * in.y - y * in.x;
	}
	double length(){
		return sqrt( x*x + y*y );
	}
};


//交差しているか求める(どの3点も同直線上にない)
bool check(P a1, P a2, P b1, P b2){
	P va = a2 - a1, vb = b2 - b1;
	P v1 = b1 - a1, v2 = b2 - a2;

	if( ( va.cross( v1 ) * va.cross( v2 ) ) < 0.0 &&
		( vb.cross( v1 ) * vb.cross( v2 ) ) < 0.0 )
		return true;
	
	return false;
}

//2円の交点を求める(2円の中心の中点cからのベクトルvを返す(交点はc±v) )
void circlecross(P a, double ra, P b, double rb, P *p1, P *p2){

	double c = (a - b).length();
	double r = (ra*ra - rb*rb + c*c ) / ( 2.0 * c*c );
	double d = sqrt( ra*ra - c*c*r*r );
	
	P tmp( d*(a.y - b.y)/c, d*(b.x - a.x)/c);
	P cen = a * (1.0-r) + b * r;
	
	*p1 = cen + tmp;
	*p2 = cen - tmp;
}

int n;

int solve(){
	P c[100], p[101][2];
	double r[100];
	double dist[205][205];
	
	cin >> c[0].x >> c[0].y >> r[0];
	p[0][0] = c[0];
	p[0][1] = c[0];
	for(int i=1; i<n; i++){
		cin >> c[i].x >> c[i].y >> r[i];
		circlecross( c[i-1], r[i-1], c[i], r[i], &p[i][0], &p[i][1]);
	}
	p[n][0] = c[n-1];
	p[n][1] = c[n-1];

	//求める
	fill( dist[0], dist[0]+205*205, INF );
	for(int i=0; i<n*2; i++){
		for(int j=i+1; j<=n*2; j++){
			bool f=true;
			for(int k=i/2+1; k<j/2; k++){
				if( !check( p[i/2][i%2], p[j/2][j%2], p[k][0], p[k][1] ) )
					f = false;
			}
			if( f ){
				double x = p[i/2][i%2].x - p[j/2][j%2].x;
				double y = p[i/2][i%2].y - p[j/2][j%2].y;
				dist[i][j] = sqrt( x*x + y*y );
			}
		}
	}
	//最短経路
	for(int k=1; k<n*2; k++){
		for(int i=0; i<=n*2; i++){
			for(int j=0; j<=n*2; j++){
				dist[i][j] = min( dist[i][j], dist[i][k] + dist[k][j] );
			}
		}
	}

	printf("%0.6f\n", dist[0][n*2] );
	
	return 0;
}

int main(){
	while( cin >> n, n ){
		solve();
	}
	return 0;
}

Measured memory_bytes: 1584
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"--------------------------"<<endl; 
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e18;
#define PI 3.14159265
 
const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n, d;
    cin >> n >> d;
    d = d * d;
    ll ans = 0;
    rep(i,0,n){
    	ll x, y;
    	cin >> x >> y;
    	if(d >= (x*x + y*y)){
    		ans++;
    	}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end() 
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	string pat = "ABC";
	string s;
	int n;
	cin >> n >> s;
	int ans = 0;
	for(int i = 0;i < n - 2; ++i){
		ans += s.substr(i,3) == pat;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
using i64 = int_fast64_t;
using P = pair<int,int>;

i64 div_ceil(i64 x, i64 d){
    i64 res = x / d;
    if(x % d) res++;
    return res;
}

int main(){
    i64 N, K;
    cin >> N >> K;
    vector<i64> A(N),F(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> F[i];

    sort(rall(A));
    sort(all(F));

    i64 ok = 1e18;
    i64 ng = -1;
    i64 ans = 0;
    while(ok - ng > 1){
        i64 mid = (ok + ng) / 2;
        i64 sum_k = 0;
        i64 res = 0;
        for(int i = 0; i < N; i++){
            if(A[i]*F[i] <= mid) continue;
            i64 k = div_ceil(A[i]*F[i] - mid,F[i]);
            if(k > A[i]){
                sum_k = K+1;
                break;
            }
            res = max(res, (A[i]-k)*F[i]);
            sum_k += k;
        }

        ans = min(ans, res);

        if(K >= sum_k) ok = mid;
        else ng = mid;
    }

    cout << ok << endl;
}

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

using namespace std;

#define ll long long int
#define ld long double
#define MAX 100005
#define MOD 1000000007
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358979323846
#define Q ll _; cin >> _; while(_--)
#define endl "\n"
#define flush fflush(stdout);

int main(){

    fast

    ll i,n;
    cin >> n;
    ll x[n+1];
    ll y[n+1];
    for(i=1;i<=n;i++){
        cin >> x[i] >> y[i];
    }
    ll mx = x[1];
    ll my = y[1];
    for(i=1;i<=n;i++){
        mx = min(mx,x[i]);
        my = min(my,y[i]);
    }

    ll maxa = -100000000000;
    ll mina = 100000000000;

    for(i=1;i<=n;i++){
        x[i]+=abs(mx);
        y[i]+=abs(my);
        maxa = max(maxa,y[i]+x[i]);
        mina = min(mina,y[i]+x[i]);
    }

    ll ans = maxa - mina;

    maxa = -100000000000;
    mina = 100000000000;

    for(i=1;i<=n;i++){
        maxa = max(maxa,y[i]-x[i]);
        mina = min(mina,y[i]-x[i]);
    }

    ans = max(ans,maxa-mina);
    cout << ans << endl;
}


//    cout << fixed << setprecision(12);


Measured memory_bytes: 6708
#include<iostream>
using namespace std;
int main(){

  int a,b,c;

  cin >> a >> b >> c;
  int t;
  if (a>b){
    t=a;
    a=b;
    b=t;
  }
  if(b>c){
    t=b;
    b=c;
    c=t;
  }
  if(a>b){
    t=a;
    a=b;
    b=t;
  }
  cout << a <<" "<< b <<" "<< c <<endl;


  return 0;

}

Measured memory_bytes: 3084
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]

seen = []
list_1 = [ x  for x in sc if x  not in seen and not seen.append(x)]

flag = [0]*n
ans = [0]*n
err = False
num = ''
for i in range(len(list_1)):
  if flag[list_1[i][0] - 1] == 0:
    ans[list_1[i][0] - 1] = list_1[i][1]
    flag[list_1[i][0] - 1] += 1
  else:
    err = True
if flag[0] == 0 and n == 1:
  ans[0] = 0
elif flag[0] == 0 and n > 1:
  ans[0] = 1
elif n>1 and ans[0] == 0:
  err = True

if err == False:
  for i in range(n):
    num += str(ans[i])
else:
  num = -1

print(num)

Measured memory_bytes: 3064
n, l = map(int, input().split())
s = []
for i in range(n):
    s.append(input())
for i in range(n - 1):
    for j in range(i + 1, n):
        if len(s[j]) < len(s[i]) and s[i] == s[j]:
            s[i], s[j] = s[j], s[i]
        else:
            for k in range(min(len(s[i]), len(s[j]))):
                if ord(s[i][k]) > ord(s[j][k]):
                    if s[i][:k] == s[j][:k]:
                        s[i], s[j] = s[j], s[i]
print(*s, sep="")


Measured memory_bytes: 40812
// B.

#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	int n, l, r, ans = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> l >> r;
		ans += (r - l) + 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b ? a:b;}
ll min(ll a, ll b) {return a<b ? a:b;}


int main(void) {
    ll N;
    string s;
    cin >> N;
    cin >> s;
    
    ll cnt=0;
    for(ll i=0; i<N; i++) {
        if(s[i]=='R') cnt++;
        else cnt--;
    }
    
    if(cnt>0) pt("Yes");
    else pt("No");
    
    
    
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  long long n,m;
  cin >> n >> m;
  if (n!=1 && m!=1) cout << (n-2)*(m-2) << endl;
  else if (n==1 && m==1) cout << 1 << endl;
  else cout << n*m-2 << endl;
}

Measured memory_bytes: 256
n,q = map(int,input().split())

Q = []

for i in range(n):
    Q.append([])

for i in range(q):

    nq = list(map(int,input().split()))

    if nq[0] == 0:

        Q[nq[1]].append(nq[2])

    elif nq[0] == 1 and len(Q[nq[1]]) > 0:

        print (Q[nq[1]][0])

    elif len(Q[nq[1]]) > 0:

        del Q[nq[1]][0]



Measured memory_bytes: 13692
// ooooo      ooo                     
// `888b.     `8'                     
//  8 `88b.    8   .ooooo.   .oooo.   
//  8   `88b.  8  d88' `88b `P  )88b  
//  8     `88b.8  888   888  .oP"888  
//  8       `888  888   888 d8(  888  
// o8o        `8  `Y8bod8P' `Y888""8o 
// C++ Conpetitive Programming Template 
// Ver 2.0 (codename: Noa)
// Last Modified : 2019-06-07
// Created       : 2019-05-25
// Auther        : shirataki3
#include <bits/stdc++.h>
using namespace std;
// typename alias
template <class T> using vec = vector<T>;
template <class T, class U> using vep = vec<pair<T,U> >;
template <class T> using PQ = priority_queue<T>;
using ll = long long;
using vll = vec<ll>;
using pll = pair<ll, ll>;
using vpll = vec<pll>;
using str = string;
// あくまのちから
//#define int ll

// const
static const long long INF = 1LL<<59;
static const long long MOD = (ll)1e9+7;
static const double PI = 3.14159265358979323846;

// accelerate stdin, stdout
#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
// repeat macro
#define FOR(i, a, b) for(ll (i)=(a);(i)<=(b);i++)
#define rFOR(i, a, b) for(ll (i)=(b);(i)>=(a);i--)
#define REP(i, n) for(ll i=0;i<n;i++)
// vector macro
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort(WHOLE(v))
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse(WHOLE(v))
#define FOLDL(src, dst, lambda) partial_sum(WHOLE(src), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum(WHOLE(src), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate(WHOLE(v), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

// io helper
template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}
template <typename T>istream& operator>>(istream &is, vec<T> &v) {for(auto &a:v) is >> a; return is;}
template <typename T>ostream& operator<<(ostream &os, vec<T> &v) {os << "[";REP(i, v.size() - 1) os << v[i] <<", "; os << v[v.size()-1]<<"]";return os;}
template <typename T, typename U>ostream& operator<<(ostream &os, pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")";return os;}
template <typename T, typename U>ostream& operator<<(ostream &os, map<T, U> &mp) {os << "{ ";for(auto &p:mp) os << p.first << ": " << p.second << ", "; os << "}";return os;}

void solve() {
    ll P, Q, R;
    cin >> P >> Q >> R;
    out(min(P+Q, min(Q+R,P+R)));
}

signed main() {
    fast_io;
    cout << setprecision(20) << fixed;
    solve();
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize,
        mut d: [i64; n],
    }
    d.push(0);
    d.sort();

    for mindiff in (0..=d[1]).rev() {
        let clocks = vec![0; n+1];
        if dfs(clocks, 1, mindiff, &d) {
            println!("{}", mindiff);
            return;
        }
    }
}

fn dfs(mut clocks: Vec<i64>, pos: usize, mindiff: i64, d: &[i64]) -> bool {
    if pos == d.len() {
        return true;
    }

    let mut res = false;
    for &clock in &[d[pos], 24 - d[pos]] {
        if clocks.iter().take(pos).all(|c| diff(*c, clock) >= mindiff) {
            clocks[pos] = clock;
            res = res || dfs(clocks.clone(), pos+1, mindiff, d);
        }
    }
    res
}

fn diff(a: i64, b: i64) -> i64 {
    min((a-b).abs(), 24-(a-b).abs())
}

Measured memory_bytes: 2208
/*********************************************
* 20.05.19 AtCoder Beginner Contest 153
* 
* 
*********************************************/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int (i)=1;(i)<=(n);i++)
#define rez(i,n) for(int (i)=0;(i)<(n);i++)
#define et "\n"

class CRun{
private:
    struct {
    }gv;
public:
    char problem_num;
    
    CRun(){
        problem_num = 'A';
    }; 
    ~CRun(){};
    void build();
    void solve_A(); void solve_B(); void solve_C(); 
    void solve_D(); void solve_E(); void solve_F();
};

void CRun::build(){
    
}

/*********************************************
A - Serval vs Monster
敵の体力H
味方の攻撃1回で体力をA減らせる
勝つための攻撃回数は？
*********************************************/
void CRun::solve_A(){
    int H; cin >> H;
    int A; cin >> A;
    
    int ans = 0;
    //ans += (H % A > 0 ? H / A + 1 : H / A);
    ans += (H - 1) / A + 1;
    cout << ans;
}

/*********************************************

*********************************************/
void CRun::solve_B(){
    
}

/*********************************************

*********************************************/
void CRun::solve_C(){
    
}

/*********************************************

*********************************************/
void CRun::solve_D(){
    
}

/*********************************************

*********************************************/
void CRun::solve_E(){
    
}

/*********************************************

*********************************************/
void CRun::solve_F(){
    
}

int main(){
    CRun run;
    run.build();
    switch (run.problem_num) {
        case 'A' : run.solve_A();
        case 'B' : run.solve_B();
        case 'C' : run.solve_C();
        case 'D' : run.solve_E();
        case 'E' : run.solve_D();
        case 'F' : run.solve_F();
    }
}



Measured memory_bytes: 256