akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define rep3(i, x, n) for(int i = x; i > n: i--)

 int main(){
     long long N, K;
     cin >> N >> K;
     long long A[N], F[N];
     rep(i, N){
         cin >> A[i];
     }
     rep(i, N){
         cin >> F[i];
     }
     sort(F, F+N);
     sort(A, A+N, greater<long long>());
     long long M = 0;
     rep(i, N){
         if(F[i]*A[i] > M){
             M = F[i]*A[i];
         }
     }
     long long a = M;
     long long b = 0;
     while(a > b){
         long long c = (a+b)/2;
         long long sum = 0;
         rep(i, N){
             if(A[i] > c/F[i]){
                 sum += A[i] - c/F[i];
             }
         }
         if(sum <= K){
             a = c;
         }
         else{
             b = c+1;
         }
     }
     cout << a << endl;
 }

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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> f(n);
    for (int i = 0; i < n; ++i)
        cin >> f[i];
    queue<pair<int, int>> q;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (f[i][j] == '#')
                q.emplace(i, j);
        }
    }
    int count = 0;
    const int dx[4] = {1, -1, 0, 0};
    const int dy[4] = {0, 0, 1, -1};
    bool done = true;
    do {
        done = true;
        queue<pair<int, int>> nq;
        while (!q.empty()) {
            int x, y;
            tie(x, y) = q.front(); q.pop();

            for (int i = 0; i < 4; ++i) {
                int nx = x + dx[i];
                int ny = y + dy[i];
                if (nx < 0 || nx >= n || ny < 0 || ny >= m)
                    continue;
                if (f[nx][ny] == '.') {
                    f[nx][ny] = '#';
                    nq.emplace(nx, ny);
                }
            }
        }
        if (!nq.empty()) {
            ++count;
            done = false;
        }
        swap(q, nq);
    } while (!done);

    cout << count << "\n";
    return 0;
}


Measured memory_bytes: 9488
t=list(input())
if t[-1]=='?':
    t[-1]='D'
indexes = [i for i, x in enumerate(t) if x == '?']
for i in range(len(indexes)-1,0,-1):
    a=indexes[i]
    if t[a-1]=='P':
        t[a]='D'
    else:
        if t[a+1]=='D':
            t[a]='P'
        else:
            t[a]='D'
if '?'in t:
    a=t.index('?')
    if t[a-1]=='P':
        t[a]='D'
    else:
        if t[a+1]=='D':
            t[a]='P'
        else:
            t[a]='D'   
print(''.join(t))


Measured memory_bytes: 87384
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;



int main(){
  int n,k;
  cin >> n >> k;
  char d[k];
  REP(i,k) cin >> d[i];
  while(true){
    str s = to_string(n);
    bool found = false;
    REP(i,k){
      if(s.find(d[i])!=string::npos) found = true;
    }
    if(!found) break;
    n++;
  }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define REP(i,n) for (lint i = 0; i < (n); i++)
#define REP1(i,n) for (lint i = 1; i < (n); i++)

lint H;

int main(void){
    cin >> H;

    lint m = 0;
    while ((H / 2) != 0) {
        ++m;
        H /= 2;
    }

    lint ans = 1;
    REP (i, m+1) {
        ans *= 2;
    }
    cout << ans - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
///----> bismillahir rahmanir rahim <---- -- { ^ _ ^ }
///     { ^_^ }   { ^ _ ^ }
#include<bits/stdc++.h>
#include<bits/stdc++.h>
using namespace std;

//<--------------------------------------------typo section--------------------------------------------->
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;
typedef priority_queue<int>piwi;
typedef queue<int>kiwi;
typedef map<int,int>mi;
typedef map<string,int>mis;
typedef multimap<int,int>muli;
typedef multimap<string,int>muls;
typedef multiset<int>si;

//<----------------------------------------------------Narcos----------------------------------------------->
#define endl "\n"
#define Y cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define sp " "
#define PB push_back
#define F first
#define S second
#define as(a) (a).begin(),(a).end()
#define ras(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()
#define ki 1LL
#define MOD 1000000007
#define over return 0;
#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))
#define test int t;cin>>t;while(t--)


//<-----------------------------------------------------Const--------------------------------------------------->
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;


//<--------------------------------------------------------------------------------------------------->
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

const long long MAX_SIZE = 1000001; vector<long long >isprime(MAX_SIZE , true); vector<long long >prime; vector<long long >SPF(MAX_SIZE); void manipulated_seive(int N) { isprime[0] = isprime[1] = false ; for (long long int i=2; i<N ; i++) { if (isprime[i]) { prime.push_back(i); SPF[i] = i; } for(int j=0;j < (int)prime.size() && i*prime[j] < N && prime[j] <= SPF[i]; j++) { isprime[i*prime[j]]=false; SPF[i*prime[j]] = prime[j] ; } } }
int man_seive(int n){ manipulated_seive(n); for(int i=0;i<prime.size() && prime[i]<=n;i++)
cout<<prime[i]<<endl;
}
ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }

//continue;

//-----------------------------> YOUR JOURNEY STARTS HERE ------------------------------------>>

int main(){
    optimize();
 ll n,m;
 cin>>n>>m;
 if(gcd(n,m)==1) cout<<n*m<<endl;
 else cout<<max(n,m)*(min(n,m)/gcd(n,m))<<endl;
over
}


Measured memory_bytes: 18624
#include <stdio.h>

int main()
{
  int  a, b, c, t;

  scanf("%d%d%d", &a, &b, &c);
  while(t = a%b){
    a = b;
    b = t;
  }
  printf(c%b ? "NO" : "YES");
  return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:102400000,102400000")
#include<iostream>  
#include<cstdio>  
#include<fstream>  
#include<iomanip>
#include<algorithm>  
#include<cmath>  
#include<deque>  
#include<vector>
#include<bitset>
#include<queue>  
#include<string>  
#include<cstring>  
#include<map>  
#include<stack>  
#include<set>
#include<functional>
#define pii pair<int, int>
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define eps 0.00000001
#define mst(a,i) memset(a,i,sizeof(a))
#define all(n) n.begin(),n.end()
#define lson(x) ((x<<1))  
#define rson(x) ((x<<1)|1) 
#define inf 0x3f3f3f3f
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
vector<ll>a, b, c;
map<ll, ll>mb;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int i, j, k, m, n;
	cin >> n;
	a.resize(n); b.resize(n); c.resize(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < n; ++i)
		cin >> b[i];
	for (int i = 0; i < n; ++i)
		cin >> c[i];
	sort(all(a)); sort(all(b)); sort(all(c));
	for (auto it : b)
	{
		ll pos = upper_bound(c.begin(), c.end(), it)-c.begin();
		ll num = (int)b.size() - pos;
		mb[it] += num;
	}
	auto it = mb.end(); it--;
	for (; it != mb.begin();)
	{
		auto pt = it;
		it--;
		it->second += pt->second;
	}
	ll ans = 0;
	for (auto it : a)
	{
		auto pos = mb.upper_bound(it);
		if (pos == mb.end())continue;
		ans += pos->second;
	}
	cout << ans << endl;
	return 0;
}



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

using namespace std;

typedef long long int64;
const int INF = 1 << 30;
const int mod = 1e9 + 7;

struct SegmentTree
{
  vector< int64 > seg, lazy;
  int sz;

  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz - 1, 0);
    lazy.assign(2 * sz - 1, 1);
  }

  void push(int k)
  {
    if(k < sz - 1) {
      (lazy[2 * k + 1] *= lazy[k]) %= mod;
      (lazy[2 * k + 2] *= lazy[k]) %= mod;
    }
    (seg[k] *= lazy[k]) %= mod;
    lazy[k] = 1;
  }

  void mul(int a, int b, int k, int l, int r)
  {
    push(k);
    if(a >= r || b <= l) return;
    if(a <= l && r <= b) {
      (lazy[k] *= 2) %= mod;
      push(k);
      return;
    }
    mul(a, b, 2 * k + 1, l, (l + r) >> 1);
    mul(a, b, 2 * k + 2, (l + r) >> 1, r);
    seg[k] = (seg[2 * k + 1] + seg[2 * k + 2]) % mod;
  }

  void mul(int a, int b)
  {
    mul(a, b, 0, 0, sz);
  }

  void add(int a, int b, int x, int k, int l, int r)
  {
    push(k);
    if(a >= r || b <= l) return;
    if(a <= l && r <= b) {
      (seg[k] += x) %= mod;
      push(k);
      return;
    }
    add(a, b, x, 2 * k + 1, l, (l + r) >> 1);
    add(a, b, x, 2 * k + 2, (l + r) >> 1, r);
    seg[k] = (seg[2 * k + 1] + seg[2 * k + 2]) % mod;
  }

  void add(int a, int x)
  {
    add(a, a + 1, x, 0, 0, sz);
  }

  int query(int a, int b, int k, int l, int r)
  {
    push(k);
    if(a >= r || b <= l) return (0);
    if(a <= l && r <= b) return (seg[k]);
    return ((query(a, b, 2 * k + 1, l, (l + r) >> 1) + query(a, b, 2 * k + 2, (l + r) >> 1, r)) % mod);
  }

  int query(int a, int b)
  {
    return (query(a, b, 0, 0, sz));
  }
};

int main()
{
  int N;
  cin >> N;
  vector< pair< int, int > > D;
  vector< int > nums;
  for(int i = 0; i < N; i++) {
    int X, V;
    cin >> X >> V;
    D.emplace_back(X, V);
    nums.emplace_back(V);
  }
  sort(begin(D), end(D));
  sort(begin(nums), end(nums));
  for(auto &p : D) {
    p.second = lower_bound(begin(nums), end(nums), p.second) - begin(nums);
  }

  vector< pair< int, int > > range;

  vector< int > latte(N), malta(N);
  for(int i = 0; i < N; i++) {
    latte[i] = D[i].second;
    if(i) latte[i] = max(latte[i], latte[i - 1]);
  }
  for(int i = N - 1; i >= 0; i--) {
    malta[i] = D[i].second;
    if(i != N - 1) malta[i] = min(malta[i], malta[i + 1]);
  }

  for(int i = 0; i < N; i++) {
    range.emplace_back(malta[i], latte[i]);
  }

  sort(begin(range), end(range));
  SegmentTree tree(nums.size());

  for(auto &p : range) {
    int aaa = tree.query(p.first - 1, p.second + 1);
    tree.add(p.second, aaa);
    if(p.first == 0) tree.add(p.second, 1);
  }
  cout << tree.query(range.back().second, range.back().second + 1) << endl;
}

Measured memory_bytes: 18160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

int main() {
    string S; cin >> S;
    int X, Y; cin >> X >> Y;

    const int SMAX = 8001;

    vector<int> dx;
    vector<int> dy;
    int cnt = 0;
    int isX = true;
    rep(i, S.size()) {
        if (S.at(i) == 'F') {
            cnt++;
        } else {
            if (isX) dx.push_back(cnt);
            else dy.push_back(cnt);
            cnt = 0;
            isX = !isX;
        }
    }
    if (cnt != 0) {
        if (isX) dx.push_back(cnt);
        else dy.push_back(cnt);
    }

    // rep(i, dx.size()) { cout << "i: " << i << ", dx[i]: " << dx[i] << endl; }
    // rep(i, dy.size()) { cout << "i: " << i << ", dy[i]: " << dy[i] << endl; }

    vector<vb> dpx(dx.size() + 1, vb(SMAX * 2, false));
    dpx[0][8000] = true; 
    rep(i, dx.size()) {
        for (int x = 0; x < (SMAX * 2); x++) {
            if (dpx[i][x]) {
                if (i == 0) {
                    if (x + dx[i] < 2 * SMAX) dpx[i + 1][x + dx[i]] = true;
                } else {
                    if (x - dx[i] >= 0) dpx[i + 1][x -dx[i]] = true;
                    if (x + dx[i] < 2 * SMAX) dpx[i + 1][x + dx[i]] = true;
                }
            }
        }
    }

    vector<vb> dpy(dy.size() + 1, vb(SMAX * 2, false));
    dpy[0][8000] = true;
    rep(i, dy.size()) {
        for (int y = 0; y < (SMAX * 2); y++) {
            if (dpy[i][y]) {
                if (y - dy[i] >= 0) dpy[i + 1][y -dy[i]] = true;
                if (y + dy[i] < 2 * SMAX) dpy[i + 1][y + dy[i]] = true;
            }
        }
    }

    if (dpx[dx.size()][8000 + X] && dpy[dy.size()][8000 + Y]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 19152
import java.util.Scanner;
public class Main {
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        int n, s, ans = 0;

	        for(;;){
	            n = sc.nextInt();
	            s = sc.nextInt();
	            if(n == 0 && s == 0) break;
	            for(int i = 1; i < n; i++){
	                for(int x = i+1; x < n; x++){
	                    for(int y = x+1; y <= n; y++){
	                        if(i+x+y==s) ans+=1;
	                    }
	                }
	            }
	            System.out.println(ans);
	            ans = 0;
	        }
	    }
	}



Measured memory_bytes: 26576
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main(){
  int N, D, X;
  cin >> N >> D >> X;
  vector<int> A(N);
  
  for(int i = 0; i < N; i++) cin >> A[i];
  map<int,int> M;
  for(int i = 0; i < N; i++){
    for(int j = 0; j * A[i] + 1 <= D; j++){
      M[j * A[i] + 1]++;
    }
  }
  int ans = 0;
  for(int i = 1; i <= D; i++) ans += M[i];
  ans += X;
  cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 int a,b;
 cin>>a>>b;
 int c;
 c=a*b;
 
 if(c%2==0){
  cout<<"Even"<<endl;
 }
 else if (c%2!=0){
  cout<<"Odd"<<endl;
 }
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	return (a %= p) >= 0 ? a : a + p;
}

template<class Iterator>
int inversion_number(Iterator l, Iterator r){
	if(r - l <= 1) return 0;
	Iterator i, j, k, h = l + (r - l) / 2;
	int ans = inversion_number(l, h) + inversion_number(h, r);
	auto x = *l;
	vector<decltype(x)> tmp(l, r);
	for(i = l, j = l, k = h; i < r; i++){
		if(k == r || (j < h && tmp[j - l] <= tmp[k - l])){
			*i = tmp[j - l];
			j++;
		}
		else{
			*i = tmp[k - l];
			ans += k - i;
			k++;
		}
	}
	return ans;
}

signed main(){
	int N, K, i, j;
	scanf("%lld%lld", &N, &K);
	vector<int> A(N);
	for(i = 0; i < N; i++){
		scanf("%lld", &A[i]);
	}
	int ans = MOD(MOD(inversion_number(A.begin(), A.end())) * K);
	vector<int> num(2002, 0);
	for(i = 0; i < N; i++){
		num[A[i]]++;
	}
	for(i = 0; i < N; i++){
		int now = 0;
		for(j = 0; j < A[i]; j++){
			now += num[j];
		}
		ans = MOD(ans + now * MOD((K * (K - 1)) / 2));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;
int k;
int gcd_2(int x,int y){return y?gcd_2(y,x%y):x;}
int gcd_3(int x,int y,int z){return gcd_2(gcd_2(x,y),z);}
long long sum=0;
int main(){
    scanf("%d",&k);
    for(int a=1;a<=k;a++)
        for(int b=1;b<=k;b++)
            for(int c=1;c<=k;c++)
                sum+=gcd_3(a,b,c);
    printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 1732
if __name__ == '__main__':

	n,m = list(map(int,input().split()))

	ans = 0
	if n == 1 and m == 1:
		ans = 1
	elif n == 1:
		ans = m - 2
	elif m == 1:
		ans = n - 2
	elif ( n == 2 or m == 2 ):
		ans = 0
	else:
		ans = (n - 2) * (m - 2)

	print(ans)


Measured memory_bytes: 3060
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let w: usize = itr.next().unwrap().parse().unwrap();

    let mut mn = 1 << 30;
    let mut tw = vec![0; n];
    let mut tv = vec![0; n];
    let mut item = vec![Vec::new(); 4];
    for i in 0..n {
        let a: usize = itr.next().unwrap().parse().unwrap();
        let b: usize = itr.next().unwrap().parse().unwrap();
        tw[i] = a;
        tv[i] = b;
        mn = min(mn, a);
    }
    for i in 0..n {
        item[tw[i] - mn].push(tv[i]);
    }
    for i in 0..4 {
        item[i].sort();
        item[i].push(0);
        item[i].reverse();
        for j in 0..item[i].len() - 1 {
            item[i][j + 1] += item[i][j];
        }
    }

    let mut ans = 0;
    for i in 0..item[0].len() {
        for j in 0..item[1].len() {
            for k in 0..item[2].len() {
                for l in 0..item[3].len() {
                    if mn * i + (mn + 1) * j + (mn + 2) * k + (mn + 3) * l <= w {
                        ans = max(ans, item[0][i] + item[1][j] + item[2][k] + item[3][l]);
                    }
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<stdio.h>
#include<stdlib.h>

using namespace std;
#define endl "\n"
#define FILEIO freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define LL long long 
#define mod 1000000007LL
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back
//#define p push
#define I insert
#define bg begin()
#define ed end()
#define sz size()
#define all(v) v.begin(),v.end()
typedef vector<LL> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef map<LL ,LL > mii;
//typedef priority_queue<int> pq;
typedef queue<int>que;
typedef stack<int>stk;
#define Inf 100000005LL
#define f first
#define s second


vi vect_2pow;
void pow_of_2(){
    vect_2pow.assign(32,0);
      for(int i=0;i<=32;i++){
           LL y = 1<<i;
           vect_2pow[i]=y;
      }
}
bool Ispalindrome(string str){
        LL len = str.size();
		bool flag;
		for(int i=0;i<len/2;i++){
				if(str[i]==str[len-i-1])
				     {
						 flag=0;
						 continue;
					 }
					 else 
					    {
							flag=1;
							break;
						}
			}
		if (flag==1)
		  return false;
		else return true;  
		
}
vector<LL> prime_check;
mii get_high_prime;
int high_prime_factor(){
	//cout<<"ecd";
	LL max_prime=0;
	for(int i=2;i<100000;i++)
	{
		LL n=i;
		
		while(n%2==0)
		{
			max_prime=2;
			n>>=1;
		}
		for(int j=3;j<=sqrt(n);j++)
		{
			while(n%j==0){
				max_prime=j;
				n/=j;
			}
		}
		if(n>2)
		  max_prime=n;
		  
		//prime_check.pb(max_prime);
		get_high_prime[i]=max_prime;
	}
	
			
}

LL mod_power(LL a , LL b){
    
	LL ans=1;


	while(b)
	{
		if(b&1)
			ans=(ans*a)%mod;
		b/=2;
		a=(a*a)%mod;
	}
	return ans;
	

}


LL bin_expo(LL x , LL n){
	  
	  if(n==0)
	     return 1;
	  else if(n==1)
	     return x%mod;
		else
		{
			LL temp = bin_expo(x,n/2);
			temp=(temp*temp)%mod;

			if(n%2==0)
			   return temp;
			else
			{
				return ((x%mod)*temp)%mod;
			}
			   
		}
		 	 
}

// std::vector<int> database;
//   std::string text_line;
//   std::getline(std::cin, text_line);
//   std::istringstream input_stream(text_line);
//   int value;
//   while (input_stream >> value)
//   {
//     database.push_back(value);
//   }
// // Edit 1: printing the vector
//   for (auto&& v:database)
//   {
//      std::cout << v << " ";
//   }
//   std::cout << "\n";
//   return EXIT_SUCCESS;

int main(){

	LL x;
	cin>>x;
	LL ans=0;
    LL p=100;
	while(true){
        
        p+=(p/100);
		ans++;
		if(p>=x)
		   break;
	}
	cout<<ans<<endl;
		
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[300][300];
int gcd(int a,int b)
{
    if(dp[a][b]!=-1)
        return dp[a][b];
    if(b==0)
        return a;
    else return gcd(b,a%b);
}
int main()
{

    ll sum=0;
    int i,j,k,n;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n;k++)
            {

                int temp=gcd(j,k);
                dp[j][k]=temp;
                int temp1=gcd(i,temp);
                dp[i][temp]=temp1;
                sum+=temp1;
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}


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

int a,b,c;

int main()
{
	cin>>a>>b>>c;
	int ans;
	int ab=abs(a-b),ac=abs(a-c),bc=abs(b-c);
    ans=min(ab+ac,min(ab+bc,ac+bc));
    cout<<ans<<endl;
 return 0;
 }


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]
def sort_zip(a:list, b:list):
    z = zip(a, b)
    z = sorted(z)
    a, b = zip(*z)
    a = list(a)
    b = list(b)
    return a, b

def main():
    N, M = map(int, input().split())
    s = [0] * M
    c = [0] * M
    for i in range(M):
        s[i], c[i] = map(int, input().split())

    if M == 0:
        if N == 1:
            print(0)
            exit()
        elif N == 2:
            print(10)
            exit()
        elif N == 3:
            print(100)
            exit()

    for i in range(M):
        if s[i] == 1 and c[i] == 0 and N > 1:
            print(-1)
            exit()

    s, c = sort_zip(s, c)

    for i in range(M - 1):
        if s[i] == s[i + 1]:
            if c[i] != c[i + 1]:
                print(-1)
                exit()

    for i in range(1, N + 1):
        if i not in s:
            s.append(i)
            if i == 1:
                c.append(1)
            else:
                c.append(0)

    s, c = sort_zip(s, c)

    k = 1
    ans = ''
    for i in range(len(s)):
        if s[i] == k:
            ans += str(c[i])
            k += 1
    print(ans)


if __name__ == '__main__':
    main()


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


int main(void){
    // Your code here!
    int N,sum=0;
    cin>>N;
    string S;
    cin>>S;
    rep(1,i,N){
        if(S.substr(i,1)!=S.substr(i-1,1))++sum;
    }
    cout<<sum+1<<endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<stdio.h>
#include<algorithm>
using namespace std;

class Dice{
public:
  int face[6];
  int top(){return face[0];}
  int left(int top, int flont);
  int label(int n);
  void setFace(int i, int num);
  void rot(char dir);
};

int Dice::label(int n){
  for(int i=0; i<6; i++){
    if(face[i] == n) return i;
  }
}

void Dice::setFace(int i, int num){
  face[i] = num;
  return;
}

void Dice::rot(char dir){
  if(dir == 'A'){
    int temp = face[1];
    face[1]=face[3]; face[3]=face[4];
    face[4]=face[2]; face[2]=temp;
  }else if(dir == 'B'){
    int temp = face[0];
    face[0]=face[2]; face[2]=face[5];
    face[5]=face[3]; face[3]=temp;
  }else if(dir == 'C'){
    int temp = face[0];
    face[0]=face[1]; face[1]=face[5];
    face[5]=face[4]; face[4]=temp;
  } 
}

int Dice::left(int top, int flont){
  string s = to_string(label(top)) + to_string(label(flont));
  string r = to_string(label(flont)) + to_string(label(top));
  string a = "02530";
  string b = "01540";
  string c = "12431";
  if(a.find(s) != string::npos) return face[4];
  if(a.find(r) != string::npos) return face[1];
  if(b.find(s) != string::npos) return face[2];
  if(b.find(r) != string::npos) return face[3];
  if(c.find(s) != string::npos) return face[0];
  if(c.find(r) != string::npos) return face[5];
}

int isEqual(Dice d1, Dice d2){
  int eq = 1;
  for(int i=0; i<6; i++){
    if(d1.face[i]-d2.face[i] != 0) eq = 0;
  }
  if(eq == 1) return 1;
  return 0;
}

int main(){
  int num, q;
  Dice d1, d2;
  for(int i=0; i<6; i++){
    cin >> num;
    d1.setFace(i, num);
  }
  for(int i=0; i<6; i++){
    cin >> num;
    d2.setFace(i, num);
  }

  int flag=0;
  for(int i=0; i<4; i++){
    for(int j=0; j<4; j++){
      for(int k=0; k<4; k++){
        d1.rot('A');
        flag += isEqual(d1, d2);
      }
      d1.rot('B');
    }
    d1.rot('C');
  }
  
  if(flag!=0) cout << "Yes" << endl;
  else     cout << "No" << endl;

  return 0;
}



Measured memory_bytes: 3136
#include <ctype.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>

int main(void){

    int n, k=2, *hs;
    long *C1;
    scanf("%d ", &n);

    hs = malloc(n * sizeof(int));
    C1 = malloc(n * sizeof(long));

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

        while(isspace(c)) c = getchar();
        int valor = 0;
        for(; c >= '0'; c = getchar()) valor = valor * 10 + c - '0';
        hs[i] = valor;
    }

    C1[0] = 0;
    int lim = k < n ? k : n;
    for(int i = 1; i < lim; ++i){

        int hi = hs[i];
        long minimo = LONG_MAX;

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

            int prueba = C1[j] + abs(hi - hs[j]);
            if(prueba < minimo) minimo = prueba;
        }

        C1[i] = minimo;
    }

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

        int hi = hs[i];
        long minimo = LONG_MAX;

        for(int j = i - k; j < i; ++j){

            int prueba = C1[j] + abs(hi - hs[j]);
            if(prueba < minimo) minimo = prueba;
        }

        C1[i] = minimo;
    }

    printf("%li", C1[n - 1]);
}




Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b,c,d;
  	cin >> a >>b;
  	c=a*b;
  	d=c%2;
  	if(d==0){
    	cout << "Even" << endl;
    }else{
    	cout << "Odd" << endl;
    }
      
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){

    string S;cin>>S;

    int n=S.size();

    if(S[0]==S[S.size()-1])n--;

    if(n%2)cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<tuple>
#include<stdio.h>
#define rep(i, n) for(int i=1;i<=n;i++)
using namespace std;

int main(){
	int n;
	cin>>n;
	int long long a=0;
	rep(i, n){
		rep(j, n){
			rep(k, n){
				for(int l=min(min(i, j), k);l>0;l--){
					if(i%l==0 && j%l==0 && k%l==0){
						a+=l;
						break;
					}
				}
			}
		}
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 3588
N = int(input())
J = [tuple(map(int, input().split())) for _ in range(N)]

J.sort(key=lambda x: (x[1], -x[0]))

t = 0
for a, b in J:
    if t + a > b:
        res = 'No'
        break
    else:
        t += a
else:
    res = 'Yes'

print(res)


Measured memory_bytes: 50756
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main(){
    lli k;
    string s;
    vector<lli> num;
    lli i,j=0;
    cin>>s>>k;
    while(k!=0){
//        cout<<j+1<<"番目の文字について"<<endl;
        if(j!=s.size()-1){
            if(26-(s[j]-'a')<=k){
                if(s[j]!='a'){
                    k-=26-(s[j]-'a');
//                    cout<<s[j]<<"をaに変える"<<endl;
                    s[j]='a';
                }
            }
            j++;
        }
        else{
            if(26-(s[j]-'a')>k){
//                cout<<s[j]<<"を";
                s[j]+=k;
//                cout<<s[j]<<"に変える"<<endl;
            }
            else{
//                cout<<s[j]<<"を";
                k-=26-(s[j]-'a');
                s[j]='a'+k%26;
//                cout<<s[j]<<"に変える"<<endl;
            }
            k=0;
        }
    }
    cout<<s<<endl;
}


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

int fact(int a)
{
	int s=1;
	while(a>1)
	{
		s=s*a;
		a--;
	}
	return s;
}

int main() {
	int n,i,x=0,y=0,j,p,q,r;
	cin>>n;
	vector<int> v1,v2;
	vector<int> :: iterator it;
	int a[n],b[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		v1.push_back(i+1);
	}
	for(i=0;i<n;i++)
	{
		cin>>b[i];
		v2.push_back(i+1);
	}
	for(i=0;i<n;i++)
	{
		p=0;
		for(j=0;j<v1.size();j++)
		{
			if(v1[j]<a[i]) p++;
		}
		x+=p*fact(n-i-1);
		it=lower_bound(v1.begin(),v1.end(),a[i]);
		v1.erase(it);
	}
	for(i=0;i<n;i++)
	{
		p=0;
		for(j=0;j<v2.size();j++)
		{
			if(v2[j]<b[i]) p++;
		}
		y+=p*fact(n-i-1);
		it=lower_bound(v2.begin(),v2.end(),b[i]);
		v2.erase(it);
	}
	cout<<abs(x-y);
	return 0;
}

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

using namespace std;

long modpow(long a, long b, long m) {
    long r = 1;
    while(b) {
        if(b&1) r *= a, r %= m;
        a *= a, a %= m;
        b >>= 1;
    }
    return r;
}

int main(void) {
    int n;
    cin >> n;
    string ss;
    cin >> ss;
    vector<long> s(n);
    for(int i=0; i<n; i++) s[i] = ss[i] - 'a';

    long b[] = {31, 25, 28};
    long m[] = {(long)1e9+7, 128456903, (long)911131313};

    auto f = [&] (long l) {
        long bn[3];
        for(int i=0; i<3; i++) bn[i] = modpow(b[i], l, m[i]);

        unordered_set<long> st[3];

        long h[3] = {};
        deque<long> q[3];

        for(int i=0; i<l-1; i++)
            for(int j=0; j<3; j++)
                q[j].push_back(-3);

        for(int i=0; i<l; i++)
            for(int j=0; j<3; j++)
                h[j] = (s[i] + (b[j] * h[j])) % m[j];

        for(int j=0; j<3; j++)
            q[j].push_back(h[j]);

        for(int i=l; i<n; i++) {
            for(int j=0; j<3; j++) {
                st[j].insert(q[j].front()); q[j].pop_front();
                h[j] = (s[i] + (b[j] * h[j]) - (bn[j] * s[i-l])) % m[j];
                h[j] = (h[j] + m[j]) % m[j];
                q[j].push_back(h[j]);
            }

            for(int j=0; j<3; j++)
                if(!st[j].count(h[j])) goto poe;
            return true;
poe:
            ;
        }
        return false;
    };

    long l = 0, r = n;
    while(r - l > 1) {
        long m = (l+r)/2;
        if(f(m))
            l = m;
        else
            r = m;
    }

    cout << l << endl;
}


Measured memory_bytes: 996
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(){
   int x1,x2,y2,y1,x3,x4,y3,y4,dx,dy;
   scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
   dx=(x1-x2);
   dy=(y2-y1);
   printf("%d %d %d %d",x2-dy,y2-dx,x2-dy+dx,y2-dx-dy);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  long long k;
  cin>>n>>k;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  
  vector<int> s;
  vector<int> ord(n+1,-1);
  int c=1,l=0;
  int v=1;
  while(ord[v]==-1){
    ord[v]=s.size();
    s.push_back(v);
    v=a[v-1];
  }
  c=s.size()-ord[v];
  l=ord[v];
  if(l>=k){
    cout<<s[k]<<endl;
  }else{
    k-=l;
    k%=c;
    cout<<s[l+k]<<endl;
  }
  return 0;
}


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

int c[6], cost[110][1 << 6], m, n, k, d;
struct st {
	int a, b, c;
}v[600];
int num(string s) {
	if (s == "H")return m + n;
	if (s == "D")return m + n + 1;
	if (s[0] == 'C')return s[1] - '1';
	return stoi(s.substr(1)) - 1 + m;
}
int main() {
	while (scanf("%d%d%d%d", &m, &n, &k, &d), m) {
		rep(i, m)scanf("%d", &c[i]);
		rep(i, d) {
			string s, t; int e; cin >> s >> t >> e; e *= k;
			v[i * 2] = { num(s),num(t),e };
			v[i * 2 + 1] = { num(t),num(s),e };
		}
		memset(cost, 0x3f, sizeof(cost));
		cost[m + n][0] = 0;
		bool update = true;
		while (update) {
			update = false;
			rep(j, 2 * d)rep(i, 1 << m) {
				st&e = v[j];
				if (cost[e.a][i] == INF)continue;
				if (e.b < m) {
					if (!(i >> e.b & 1) && cost[e.b][i | 1 << e.b] > cost[e.a][i] + e.c - c[e.b])
						cost[e.b][i | 1 << e.b] = cost[e.a][i] + e.c - c[e.b], update = true;
				}
				else if (cost[e.b][i] > cost[e.a][i] + e.c)
					cost[e.b][i] = cost[e.a][i] + e.c, update = true;
			}
		}
		int Min = INF;
		rep(i, 1 << m)Min = min(Min, cost[m + n + 1][i]);
		printf("%d\n", Min);
	}
}

Measured memory_bytes: 3240
#include <stdio.h>
int main(){
	int X,Y,num=0;
  	scanf("%d %d",&X,&Y);
  	for(int i=0; i<=X; i++){
    	if(2*i+((X-i)*4)==Y){
        		num=1;
          break;
        	}
    	}
  if(num==0) printf("No");
  if(num==1) printf("Yes");
	}



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

typedef long long ll;

using namespace std;

int main() {
    ll n, cnt = 0;
    cin >> n;
    ++n;
    vector<ll> sum(n), a(n);
    for (ll i = 1; i < n; ++i) {
        cin >> sum.at(i);
        a.at(i) = a.at(i - 1) ^ sum.at(i);
        sum.at(i) += sum.at(i - 1);
    }
    for (ll l = 0, r = 1; r < n; ++r) {
        while (sum.at(r) - sum.at(l) != (a.at(r) ^ a.at(l))) ++l;
        cnt += r - l;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3456
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, k := nextInt(), nextInt()
	cnt := make([]int, 100001)
	for i := 0; i < n; i++ {
		a, b := nextInt(), nextInt()
		cnt[a] += b
	}

	for i, sum := 1, 0; sum < k; i++ {
		sum += cnt[i]
		if sum >= k {
			puts(i)
			break
		}
	}
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 3200
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;

ll dp[110000];

int main(){
  string S,T;
  int count=0;
  cin>>S>>T;
  for(int i=0;i<3;i++){
    if(S[i]==T[i]) count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  ll a=n/100;
  ll b=n%100;
  bool aa=false,bb=false;
  if(1<=a && a<=12) aa=true;
  if(1<=b && b<=12) bb=true;
  if(aa && bb) cout<<"AMBIGUOUS"<<endl;
  else if(aa) cout<<"MMYY"<<endl;
  else if(bb) cout<<"YYMM"<<endl;
  else cout<<"NA"<<endl;
  
  
  
}

Measured memory_bytes: 256
N, M = map(int, input().split())
left = [None] * M
right = [None] * M
for i in range(M):
    left[i], right[i] = map(int, input().split())

ans = min(right) - max(left) + 1
if ans < 0:
    print(0)
else:
    print(ans)
 

Measured memory_bytes: 10868
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n;
	P v;
	C[] cs;

	void run(){
		for(;;){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			int x=sc.nextInt();
			int y=sc.nextInt();
			int z=sc.nextInt();
			v=new P(x, y, z);
			cs=new C[n];
			double maxDist=0;
			for(int i=0; i<n; i++){
				x=sc.nextInt();
				y=sc.nextInt();
				z=sc.nextInt();
				int r=sc.nextInt();
				cs[i]=new C(x, y, z, r);
				maxDist=Math.max(maxDist, cs[i].c.abs()+r);
				// debug(cs[i].c.abs()+r+"");
			}
			v=v.div(v.abs());
			double d=0.01, e=0.00001;
			double e2=0.000001;
			P p=new P(0, 0, 0);
			P last=new P(0, 0, 0);
			for(int t=0;;){
				p=p.add(v.mul(d));
				int k=-1;
				for(int i=0; i<n; i++){
					if(cs[i].contains(p)){
						k=i;
					}
				}
				if(k!=-1){
					for(; cs[k].contains(p);){
						p=p.sub(v.mul(e));
					}
					P q=p.add(v.mul(e));
					p=p.add(q).div(2);
					for(; cs[k].contains(p);){
						p=p.sub(v.mul(e2));
					}
					q=p.add(v.mul(e2));
					p=p.add(q).div(2);

					P u=p.sub(cs[k].c);// @ü
					u=u.div(u.abs());// ³K»
					v=v.sub(u.mul(2*v.dot(u)));
					v=v.div(v.abs());
					last=new P(p);
					// debug(p);
					if(++t>=5){
						break;
					}
				}
				// ­U»è
				if(p.abs()>maxDist+10){
					break;
				}
			}
			println(String.format("%.3f %.3f %.3f", last.x, last.y, last.z));
		}
	}

	class C{
		P c;
		double r;

		C(double x, double y, double z, double r){
			c=new P(x, y, z);
			this.r=r;
		}

		boolean contains(P p){
			return p.sub(c).abs()+EPS<r;
		}
	}

	class P{
		double x, y, z;

		P(){
			this(0, 0, 0);
		}

		P(double x, double y, double z){
			this.x=x;
			this.y=y;
			this.z=z;
		}

		P(P p){
			this(p.x, p.y, p.z);
		}

		P add(P p){
			return new P(x+p.x, y+p.y, z+p.z);
		}

		P sub(P p){
			return new P(x-p.x, y-p.y, z-p.z);
		}

		P mul(double m){
			return new P(x*m, y*m, z*m);
		}

		P div(double d){
			return new P(x/d, y/d, z/d);
		}

		double abs(){
			return Math.sqrt(abs2());
		}

		double abs2(){
			return x*x+y*y+z*z;
		}

		// àÏ
		double dot(P p){
			return x*p.x+y*p.y+z*p.z;
		}

		public String toString(){
			return String.format("(%.3f, %.3f, %.3f)", x, y, z);
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 13000
program can_you_solve_this
  implicit none
  integer :: n, m, c, b(20), a(20), i, k
  read(*,*) n, m, c
  a = 0
  b = 0
  read(*,*) b(1:m)
  k = 0
  do i = 1, n
    read(*,*) a(1:m)
    if (sum(a(1:m)*b(1:m))+c.gt.0) k = k + 1
  end do
  write(*,'(i0)') k
end program can_you_solve_this

Measured memory_bytes: 768
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/09/20 20:59:36
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int h,w; cin>>h>>w;
  int dist[10][10];
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cin>>dist[i][j];
    }
  }
  for (int k = 0; k < 10; k++) {
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
      }
    }
  }
  ll ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int a; cin>>a;
      if (a == -1)
        continue;
      ans += dist[a][1];
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
// AOJ Vol3-0381 Red Dragonfly
// 2018.12.22

//#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main()
{
	int x1, x2, d;

	scanf("%d%d", &x1, &x2);
	d = x1 - x2;
	if (d < 0) d = -d;
	printf("%d\n", d);
	return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = true;

struct student{
    ll id;
    ll number;
};

bool stu(const student a, const student b){
    return a.number > b.number;
}

int main(){

    ll N;
    cin >> N;
    vector<student> v(N);
    for(int i = 0; i < N; i++) {
        cin >> v[i].number;
        v[i].id = i + 1;
    }

    sort(rall(v), stu);
    for(int i = 0; i < N - 1; i++) cout << v[i].id << " ";
    cout << v.back().id << endl;


}



Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define f first
#define s second

int main(){
	ll n ;
	cin>> n ;
	ll sum=0;
	vector<ll> arr(n);
	for(ll i=0 ; i< n ; i++){
		cin>> arr[i];
		sum^=arr[i];
	}
	if(sum)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int f(int n)
{
	int x=0;
	int y=n;
	while(y)
	{
		x=x*10+y%10;
		y/=10;
	}
	if(n==x)
	  return 1;
	else 
	  return 0;  
}
int main()
{
	int n,m,i,s=0;
	scanf("%d %d",&n,&m);
	for(i=n;i<=m;i++)
	{
		if(f(i)==1)
		   s++;
	}
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int P=1e9+7;
const int N=5e3+5;
const int M=1e4+5;
const int Gi=(P+1)>>1;
int n,now,v[M],si[N],nex[M],head[N];
void addedges(int x,int y){
	nex[++now]=head[x];
	head[x]=now,v[now]=y;
}
long long g[N],tmp[N],f[N][N];
void dfs(int x,int fa){
	si[x]=1,f[x][1]=1;
	for(int i=head[x];i;i=nex[i])
		if(v[i]!=fa){
			dfs(v[i],x);
			for(int j=si[x];~j;j--)
				for(int k=si[v[i]];~k;k--)
					tmp[j+k]=(tmp[j+k]+f[x][j]*f[v[i]][k])%P;
			si[x]+=si[v[i]];
			for(int j=0;j<=si[x];j++)	f[x][j]=tmp[j],tmp[j]=0;
		}
	for(int i=1;i<=si[x];i++)	f[x][0]=(f[x][0]-f[x][i]*g[i]%P+P)%P;
}
int main(){
	scanf("%d",&n),g[0]=1;
	for(int i=1,x,y;i<n;i++){
		scanf("%d%d",&x,&y);
		addedges(x,y),addedges(y,x);
	}
	for(int i=2;i<=n;i+=2)	g[i]=g[i-2]*(i-1)%P;
	dfs(1,1),printf("%d\n",(P-f[1][0])%P);
	return 0;
}


Measured memory_bytes: 194816
a = gets.split.map(&:to_i)  # スペースで区切られた複数の整数

A = a[0]
B = a[1]
N = a[2]

A.freeze
B.freeze
N.freeze

#ans = 0
ans =[N, B - 1].min
=begin
for num in 1..N do
  wk = ((A * num) / B ) - (A * ( num / B))
  if wk > ans then
    ans = wk
  end  
end

  N.step(1, -1) do |num|
  wk = ((A * num) / B ) - (A * ( num / B))
  if wk > ans then
    ans = wk
  end  
end
=end
#puts ans
puts ((A * ans) / B ) - (A * ( ans / B))

Measured memory_bytes: 14340
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace LogicSummoner
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim();
            //print a b: str ??? a ??????????????? b ??????????????§??????????????????
            //reverse a b: str ??? a ??????????????? b ??????????????§?????????????????????
            //replace a b p: str ??? a ??????????????? b ??????????????§??? p ?????????????????????

            var N = GetNumber();
            for (int i = 0; i < N; i++)
            {
                var cmd = GetStrings();
                var a = int.Parse(cmd[1]);
                var b = int.Parse(cmd[2]);
                if (cmd[0] == "print")
                {
                    System.Console.WriteLine(line.Substring(a, b - a + 1));
                }
                else if (cmd[0] == "reverse")
                {
                    line = new string(line.Take(a).Concat(line.Substring(a, b - a + 1).Reverse()).Concat(line.Skip(b + 1)).ToArray());
                }
                else if (cmd[0] == "replace")
                {
                    line = new string(line.Take(a).ToArray()) + cmd[3] + new string(line.Skip(b + 1).ToArray());
                }
            }
        }

        //static StreamReader Console = new StreamReader("input.txt");

        static int GetNumber()
        {
            return int.Parse(Console.ReadLine().Trim());
        }

        static double GetDounble()
        {
            return double.Parse(Console.ReadLine().Trim());
        }

        static int[] GetNumbersInt(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        static long[] GetNumbersLong(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToArray();
        }

        static double[] GetNumbersDouble(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => double.Parse(x)).ToArray();
        }

        static string[] GetStrings(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).ToArray();
        }
    }
}

Measured memory_bytes: 10400