akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) (((n%m) + m)%m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'

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

char arr[N][N];

int memo[N][N];

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

	int n, m;
	cin >> n >> m;
	rep(i, 0, n)
		rep(j, 0, m)
			cin >> arr[i][j];

	for (int i = m - 1; i >= 0; i--)
	{
		if (arr[n - 1][i] == '#')
			break;
		memo[n - 1][i] = 1;
	}

	for (int i = n - 2; i >= 0; i--)
	{
//		int curr = i & 1, nxt = (i & 1) ^ 1;

		for (int j = m - 1; j >= 0; j--)
		{
			if (arr[i][j] == '#')
				continue;

			if (i + 1 < n && arr[i + 1][j] != '#')
				memo[i][j] = (memo[i][j] + memo[i + 1][j]) % mod;
			if (j + 1 < m && arr[i][j + 1] != '#')
				memo[i][j] = (memo[i][j] + memo[i][j + 1]) % mod;
		}
	}

	cout << memo[0][0] << endl;

	return 0;
}


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


int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];

    sort(a,a+n);
    cout<<a[n/2]-a[n/2-1];
}



Measured memory_bytes: 640
# -*- coding: utf-8 -*-
from collections import deque
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]

graph = [[-1 for _ in range(W)] for _ in range(H)]

que = deque()
x,y = 0,0 #初期値
que.append((x,y))
graph[x][y] = 0
while len(que) > 0:
    # x,y = que.pop()  # 深さ優先探索
    x,y = que.popleft() #幅優先探索
    step = graph[x][y]
    #左
    if y-1 >= 0 and s[x][y-1] == "." and graph[x][y-1] == -1:
        que.append((x,y-1))
        graph[x][y-1] = step + 1
    #右
    if y+1 < W and s[x][y+1] == "." and graph[x][y+1] == -1:
        que.append((x, y+1))
        graph[x][y+1] = step + 1
    #上
    if x-1 >= 0 and s[x-1][y] == "." and graph[x-1][y] == -1:
        que.append((x-1, y))
        graph[x-1][y] = step + 1
    #下
    if x+1 < H and s[x+1][y] == "." and graph[x+1][y] == -1:
        que.append((x+1, y))
        graph[x+1][y] = step + 1

#ゴールから戻って最短ルートにマークする（複数ある場合は一方だけマーク）
que = deque()
x, y = H-1, W-1     #初期値（ゴール）
que.append((x,y))
step = graph[x][y]
graph[x][y] = -2  # 最短ルートにマーク

if step == -1:
    print(-1)
    exit()

while len(que) > 0:
    x, y = que.popleft()  # 幅優先探索
    if x == y == 0:
        break
    #左
    if y-1 >= 0 and graph[x][y-1] == step - 1:
        que.append((x, y-1))
        graph[x][y-1] = -2
        step -= 1
        continue
    #右
    if y+1 < W and graph[x][y+1] == step - 1:
        que.append((x, y+1))
        graph[x][y+1] = -2
        step -= 1
        continue
    #上
    if x-1 >= 0 and graph[x-1][y] == step - 1:
        que.append((x-1, y))
        graph[x-1][y] = -2
        step -= 1
        continue
    #下
    if x+1 < H and graph[x+1][y] == step - 1:
        que.append((x+1, y))
        graph[x+1][y] = -2
        step -= 1
        continue

ans = 0
for h in range(H):
    for w in range(W):
        if s[h][w] == "." and graph[h][w] != -2:
            ans += 1

print(ans)


Measured memory_bytes: 3432
import sys
input = sys.stdin.readline
S = list(map(int, list(input())[: -1]))
N = len(S)
res = 0
for i in range(N):
  x = int(S[i])
  for j in range(1, N - i):
    res += x * pow(10, j - 1) * (1 << (N - j - 1))
  res += x * pow(10, N - i - 1) * (1 << i)
print(res)

Measured memory_bytes: 61724
from bisect import *

n=int(input())
x=list(map(int,input().split()))
x_s=sorted(x)

ans1=x_s[n//2]
ans2=x_s[n//2-1]

for i in range(n):
  inx=bisect_right(x_s,x[i])
  if inx<=n//2:
    print(ans1)
  else:
    print(ans2)

Measured memory_bytes: 25224
// "header" {{{
#pragma GCC optimize("Ofast")

#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define int int64_t
#define double long double
#define Fixed fixed << setprecision(10)
#define moke_pair make_pair

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int64_t mod1 = 1000000007;
constexpr int64_t mod2 = 998244353;

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

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class T,class U> using umap = unordered_map<T,U>;

inline int64_t updiv(int64_t n,int64_t d){ return ((n + d -1) / d); }
inline int square(int a){ return a * a; }
// }}}

signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<int> a(n+2),b(n+2);

    rep(i,n+1){
        cin >> a[i];
    }
    rep(i,n){
        cin >> b[i];
    }

    int res = 0;

    rep(i,n){
        int tmp = min(a[i],b[i]);
        a[i] -= tmp;
        b[i] -= tmp;
        res += tmp;
        tmp = min(b[i],a[i+1]);
        res += tmp;
        a[i+1] -= tmp;
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define SIZE(a) int((a).size())
const int INF=INT_MAX;
const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll n,m;cin>>n>>m;
  vvll g(n,vll(0));
  vb v(n,false);
  vll ans(n,-1);
  rep(i,0,m){
    ll a,b;cin>>a>>b;
    a--;b--;
    g[a].push_back(b);g[b].push_back(a);
  }
  queue<P> q;
  v[0]=true;
  q.push(make_pair(0,0));
  while(!q.empty()){
    P tmp=q.front();
    q.pop();
    ll x=tmp.first,y=tmp.second;
    ans[x]=y+1;
    for(ll i:g[x]){
      if(v[i])continue;
      q.push(make_pair(i,x));
      v[i]=true;
    }
  }
  bool ok=true;
  rep(i,1,n){
    if(ans[i]==-1){ok=false;}
  }
  if(ok){
    cout<<"Yes"<<endl;
    rep(i,1,n){
      cout<<ans[i]<<endl;
    }
  }
  else{cout<<"No"<<endl;}
}

Measured memory_bytes: 13484
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
	cin>>a>>b>>c;
	if(a>=b,a>=c){
		cout<<b*c/2<<endl;
	}
	
	else if(b>=a,b>=c){
		cout<<a*c/2<<endl;
	}
	
	else if(c>=a,c>=b){
		cout<<a*b/2<<endl;
	}
	
    
}


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

#define MAX_N 105
#define MAX_V 1005
long dp[MAX_N + 1][MAX_N * MAX_V + 1];

int main() {
  int N, W;
  cin >> N >> W;
  vector<int> w(N), v(N);
  for (int i = 0; i < N; i++) {
    cin >> w[i] >> v[i];
  }

  for (int i = 0; i < MAX_N + 1; i++)
    for (int j = 0; j < MAX_N * MAX_V + 1; j++)
      dp[i][j] = W+10;

  dp[0][0] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= MAX_N * MAX_V; j++) {
      if (j < v[i]) dp[i+1][j] = dp[i][j];
      else dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]] + w[i]);
    }
  }

  long ans = 0;
  for (int i = 0; i <= MAX_N * MAX_V; i++) {
    if (dp[N][i] <= W) ans = i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 87680
#include<iostream>
using namespace std;
int main()
{
	int a[7],b[7];
	for(int i=0 ; i<7 ; ++i){
		cin >> a[i] >> b[i];
	}
	for(int i=0 ; i<7 ; ++i){
		cout << a[i] - b[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double ld;
typedef pair<int,int> P;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 10*60
#define EPS 1e-9

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

ll mod_pow(ll x,ll n,ll m){
    if(n==0) return 1;
    ll res=mod_pow(x*x%m,n/2,m);
    if(n&1) {
      res=res*x%m;
    }
    return res;
}


signed main(){
  int N,K,a,a_1,ans=0;cin>>N>>K;
  cin>>a_1;
  ans+=max(0LL,a_1-K);
  a_1=min(a_1,K);
  REP(i,1,N){
    cin>>a;
    int tmp;
    if(a_1+a-K>=0){
      ans+=a_1+a-K;
      a_1=K-a_1;
    }else{
      a_1=a;
    }
  }
  print(ans)
  


}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() 
{
	int a,b,c,d,i,ans=0;
  	cin >> a >> b >> c >> d;
 
	for(i=0;i<=100;i++)
		if(a<=i && i<=b && c<=i && i<=d){
		ans++;
	}
	if(ans==0){
		cout << ans << endl;
	}
	else{
		cout << ans-1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, W;
  cin >> N >> W;
  vll v(N), w(N);
  for(int i = 0; i < N; i++){
    cin  >> v.at(i) >> w.at(i);
  }
  ll N1 = N/2;
  ll N2 = N - N1;
  vector<Pll> p1(0), p2(0);
  for(int bit = 0; bit < (1<<N1); bit++){
    ll vv = 0LL, ww = 0LL;
    for(int i = 0; i < N1; i++){
      if((bit>>i)&1){
        vv += v.at(i);
        ww += w.at(i);
      }
    }
    p1.push_back(Pll(ww, vv));
  }
  for(int bit = 0; bit < (1<<N2); bit++){
    ll vv = 0LL, ww = 0LL;
    for(int i = 0; i < N2; i++){
      if((bit>>i)&1){
        vv += v.at(N1+i);
        ww += w.at(N1+i);
      }
    }
    p2.push_back(Pll(ww, vv));
  }
  sort(ALL(p1)); sort(ALL(p2));
  ll tmp = p1.at(0).second;
  for(int i = 1; i < sz(p1); i++){
    if(p1.at(i).second > tmp) tmp = p1.at(i).second;
    else p1.at(i).second = tmp;
  }
  tmp = p2.at(0).second;
  for(int i = 1; i < sz(p2); i++){
    if(p2.at(i).second > tmp) tmp = p2.at(i).second;
    else p2.at(i).second = tmp;
  }
  ll ans = 0LL;
  for(int i = 0; i < sz(p1); i++){
    ll x = p1.at(i).second;
    ll maxi = W - p1.at(i).first;
    auto ite = lower_bound(ALL(p2), Pll(maxi+1, 0));
    if(ite == p2.begin()) continue;
    ite--;
    Pll y = *ite;
    chmax(ans, x + y.second);
  }
  cout << ans << endl;
}



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

int main()
{
    long long n, sum = 0;
    cin >> n;
    long long a[n+1], b[200005];
    for(int i=0; i<n; i++){
		cin >> a[i], sum += a[i], b[a[i]]++;
    }

    int q;
    cin >> q;
    while(q--){
		long long x, y;
		cin >> x >> y;
		sum -= x*b[x];
		sum += y*b[x];
		b[y] += b[x];
		b[x] = 0;
		cout << sum << endl;
    }



    return 0;
}


Measured memory_bytes: 5204
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return sorted 約数list 1 <= x <= n
vector<ll> divv(ll n) {
  vector<ll> v;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.push_back(i);
      if(i*i != n) v.push_back(n/i);
    }
  }
  sort(ALL(v));
  return v;
}

int main() {
    ll n,k;
    cin >> n;
        vector<pair<ll,ll>> v;
    rep(i, n){
        ll a, b;
        cin>>a>>b;
        auto c = mp(b,a);
        v.push_back(c);
    }
    sort(ALL(v));
    ll sum = 0;
    for(auto it:v){
        sum += it.second;
        if(sum > it.first) {
            pr("No");
            return 0;
        }
    }
    pr("Yes");
    return 0;
}


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

using namespace std;

typedef long long ll;

ll absr(ll a, ll b){
    return a > b ? a - b : b - a;
}

int main()
{
    ll n, k;
    cin >> n >> k;
    ll h[n];
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    ll dp[n];
    dp[0] = 0;
    dp[1] = absr(h[0], h[1]);
    for(int i = 2; i < n; i++){
        ll minCost = dp[i - 1] + absr(h[i - 1], h[i]);
        for(ll j = 2; j <= k && j <= i; j++){
            if(minCost > dp[i - j] + absr(h[i - j], h[i])){
                minCost = dp[i - j] + absr(h[i - j], h[i]);
            }
        }
        dp[i] = minCost;
    }
    cout << dp[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	int a,b,N;
	a=2;
	b=2;
	scanf("%d",&N);
	while(a<N){
		a=a*2;
		if(a<=N){
			b=a;
		}
	}
	printf("%d\n",b);
	return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	char c[n];
	int a[n];
	for(int i=0;i<n;i++)
		cin >> c[i];
	int e=0,w=0;
	for(int i=0;i<n;i++){
		a[i]=e;
		if(c[i]=='E')
			e++;
	}
	for(int i=(n-1);i>=0;i--){
		a[i]+=w;
		if(c[i]=='W')
			w++;
	}
	sort(a,a+n,greater<int>());
	cout << n-(a[0]+1);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define pp pair<int,int>
#define Pi acos(-1)
#define pq priority_queue
#define mz 1000000007

using namespace std;

int num[100005];

int main()
{
    int n,x,ans=0;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d",&x);
        num[x]++;
    }
    for(int i=1;i<100000;i++)
        ans=max(ans,num[i-1]+num[i]+num[i+1]);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
    int n,a[10][10],b=0;
    scanf("%d",&n);
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            a[i][j]=i*j;
            if(a[i][j]==n)b+=1;
        }
    }
    if(b==0)printf("No\n");
    else printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
x = input()

cnt = 0
  
if x[0] == "R":
  cnt +=1
  if x[1] == "R":
    cnt +=1
    if x[2] == "R":
      cnt +=1

if x[0] == "S":
  if x[1] == "R":
    cnt +=1
    if x[2] == "R":
      cnt +=1
      
if x[0] == "S":
  if x[1] == "S":
    if x[2] == "R":
      cnt +=1

print(cnt)

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;

int n;

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

    cin >> n;
    cout << (n + 1) / 2 << el;

    return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
#include <algorithm>
using namespace std;

int main(){
	char buf[100000];
	int length;

	while(true){
		fgets(buf,10000,stdin);
		if(buf[0] == 'E' && buf[1] == 'N' && buf[2] == 'D' && buf[3] == ' ' &&
				buf[4] == 'O' && buf[5] == 'F' && buf[6] == ' ' && buf[7] == 'I' &&
				buf[8] == 'N' && buf[9] == 'P' && buf[10] == 'U' && buf[11] == 'T')break;
		length = 0;
		for(int i=0;buf[i] != '\n';i++){
			if(buf[i+1] == '\n'){
				length++;
				printf("%d",length);
			}else if(buf[i] == ' '){
				printf("%d",length);
				length = 0;
			}else{
				length++;
			}
		}
		printf("\n");
	}


    return 0;
}

Measured memory_bytes: 2552
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

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

using namespace std;

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

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp( a, b ) make_pair( a, b )
#define mt( ... ) make_tuple( __VA_ARGS__ )

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()

#define MOD ( 1e9 + 7 )


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

	vector<int> v;

	rreps( i, B )
	{
		if ( ( ( A % i ) == 0 )
			 && ( ( B % i ) == 0 ) )
		{
			v.eb( i );
		}
	}

	cout << v[K - 1] << endl;

	return ( 0 );
}


Measured memory_bytes: 256
/**
*    author:  souzai32
*    created: 13.08.2020 17:19:10
**/

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

int main() {

    int n;
    cin >> n;
    string s;

    int a=0,b=0,ab=0;
    int ans=0;
    rep(i,n){
        cin >> s;
        if(s.at(0)=='B' && s.at(s.size()-1)=='A') ab++;
        else if(s.at(0)=='B') b++;
        else if(s.at(s.size()-1)=='A') a++;
        rep(j,s.size()-1){
            if(s.at(j)=='A' && s.at(j+1)=='B') ans++;
        }
    }

    if(max(a,b)) ans+=min(a,b)+ab;
    else ans+=max(ab,1)-1;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
#define MOD 1000000007
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

void print(auto x) {
    cout << x << endl;
}

ll sum(auto x) {
    return accumulate(x.begin(), x.end(), 0LL);
}

int main() {
    int N, K; cin >> N >> K;
    vector<int> P(N), judge(N);
    set<int> s;
    cin >> P[0];
    for (int i = 1; i < N; i++) {
        cin >> P[i];
        if (P[i-1] > P[i]) judge[i] = 1;
    }
    int ans = 1, v = 0;
    bool p = true;
    s.insert(P[0]);
    for (int i = 1; i < K; i++) {
        s.insert(P[i]);
        if (judge[i]) v++; 
    }
    if (v == 0) p = false;
    int i = 0;
    for (int j = K; j < N; j++) {
        v -= judge[i+1];
        v += judge[j];
        if (v == 0) {
            if (p) {
                ans++;
                p = false;
            }
        }
        else if ((*s.begin() != P[i]) || (*s.rbegin() > P[j])) ans++;
        s.erase(P[i]);
        s.insert(P[j]);
        i++;
    }
    print(ans);
}


Measured memory_bytes: 11136
#include <stdio.h> 
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int i;
	int t=1;
	for(i=1;t<=n/2;i++){
		t=t*2;
	}
	cout<<t;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int n,k;
    while(1){
        cin>>n>>k;
        string S[11];
        if(n==0&&k==0) break;
        for(int i=0; i<n; i++) cin>>S[i];
        sort(S,S+n);
        set<string> SS;
        do{
            string str;
            for(int i=0; i<k; i++) str+=S[i];
            SS.insert(str);
        }while(next_permutation(S, S+n));
        cout<<SS.size()<<endl;
    }
}

Measured memory_bytes: 3332
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

#define ll long long

char X, Y;

int main(){
    cin >> X >> Y;
    
    if(X > Y)
        cout << ">" << endl;
    else if(X < Y)
        cout << "<" << endl;
    else
        cout << "=" << endl;
}


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

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> h(n+1);
    vector<bool> flag(n+1, true);

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

    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        if(h[a] > h[b]){
            flag[b] = false;
        }
        else if(h[a] < h[b]){
            flag[a] = false;
        }
        else if( h[a] == h[b]){
            flag[a] = false;
            flag[b] = false;
        }
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        if(flag[i] == true){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3972
#include<stdio.h>

struct Card{
  char suit;
  char value;
};

void bubble(struct Card A[], int n){
  int i, j;
  struct Card t;
  for ( i = 0; i < n; i++ ){
    for ( j = n-1; j >= i+1; j-- ){
      if ( A[j].value < A[j-1].value ){
	t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(struct Card A[], int n){
  int i, j, mini;
  struct Card t;
  for ( i = 0; i < n; i++ ){
    mini = i;
    for ( j = i; j < n; j++ ){
      if ( A[j].value < A[mini].value ) mini = j;
    }
    t = A[i]; A[i] = A[mini]; A[mini] = t;
  }
}

void print(struct Card A[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i ) printf(" ");
    printf("%c%c", A[i].suit, A[i].value);
  }
  printf("\n");
}

int isStable(struct Card C1[], struct Card C2[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( C1[i].suit != C2[i].suit ) return 0;
  }
  return 1;
}

int main(){
  struct Card C1[101], C2[101];
  int n, i;
  char ch;

  //scanf("%d%c", &n, &ch);
  scanf("%d\n", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%c%c ", &C1[i].suit, &C1[i].value);
    //scanf("%c%c%c", &C1[i].suit, &C1[i].value, &ch);
  }

  for ( i = 0; i < n; i++ ) C2[i] = C1[i];

  bubble(C1, n);
  selection(C2, n);

  print(C1, n);
  printf("Stable\n");
  print(C2, n);
  if ( isStable(C1, C2, n) ){
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
using namespace std;
 
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define drng(i,a,b) for(int i=int(a);i>int(b);i--)
typedef long long LL;

string s, t;
vector< vector<int>> dp(3001, vector<int> (3001, 0));
void func(int i, int j){
    if(i == 0 || j == 0)
        return;
    if(s[i-1] == t[j-1]){
        func(i-1,j-1);
        cout<<s[i-1];
    }
    else if(dp[i-1][j]>dp[i][j-1])
        func(i-1,j);
    else
        func(i,j-1);
}

int main() {
    fastio
    cin>> s >> t;
    int l = s.length();
    int m = t.length();
    
    rng(i,0,l){
        rng(j,0,m){
            if(s[i] == t[j]){
                dp[i+1][j+1] = dp[i][j] + 1;
            }
            else{
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
        }
    }
    func(l,m);
    
    return 0;
}

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

signed main(){
	int i, ans = 0;
	string S, T;
	cin >> S;
	cin >> T;
	for(i = 0; i < S.size(); i++){
		if(S[i] != T[i]){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// // assign avl ncm dijkstra geo2 kruskal graph uf lca BIT
// matrix dinic next_combination topcoder lcm vi st gin
// cusum segtree

//最大公約数
int gcd(int x, int y) { return y ? gcd(y, x%y) : x; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
//最大公約数 複数個
int gcd(const vector<int> &v) {
    int ret = v[0];
    for (int i = 1; i < v.size(); i++)
        ret = gcd(ret, v[i]);
    return ret;
}
//最小公倍数 複数個
int lcm(const vector<int> &v) {
    int ret = v[0];
    for (int i = 1; i < v.size(); i++)
        ret = lcm(ret, v[i]);
    return ret;
}

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

    int2(x, y);

    if (lcm(x, y) == x) {
        cout << -1 << endl;
    } else {
        cout << x * (y - 1) << endl;
    }



    return 0;
}


Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=2e5+5;
ll s[N],sa,sb,res;int a[N],b[N],c[N],n,top;
inline int qr(R ll x){return lower_bound(c+1,c+1+top,x)-c;}
int main(){
	scanf("%d",&n);
	fp(i,1,n){
		scanf("%d%d",&a[i],&b[i]),c[++top]=a[i],c[++top]=b[i];
		sa+=a[i],sb+=b[i];
	}
	sort(c+1,c+1+top),res=min(sa,sb);
	fp(i,1,n)s[i]=s[i-1]+c[i];
	fp(i,1,n){
		R ll x=a[i],y=b[i];if(x>y)swap(x,y);
		R int px=qr(x),py=qr(y);
		cmin(res,py<=n?s[n]:(px<=n-1?s[n-1]+y:s[n-2]+x+y));
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  for(int i = 0; i < S.size(); i++){
    if(i % 2 == 0 && S.at(i) == 'R')continue;
    else if(i % 2 == 1 && S.at(i) == 'L')continue;
    else if(S.at(i) == 'U' || S.at(i) == 'D')continue;
    else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

int main(){
  int N,M,X;
  cin >> N >> M >> X;
  
  vector<int> x(M);
  int i;
  for(i = 0;i < M;i++){
    cin >> x.at(i);
  }
  
  int hidari = 0,right = 0;
  for(int j = 0;j < M;j++){
    if(x.at(j) < X){
      hidari++;
    }
    if(x.at(j) > X){
      right++;
    }
  }
  
  if(hidari <= right){
    cout << hidari << endl;
  }
  else if(right < hidari){
    cout << right << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false


signed main(void){
    int N,K;
    cin >> N >> K;
    
    int Ans = 0;
    
    int M = 0,m=0;
    
    for(int i=1;i<=N;i++){
        M+=N-i+1;
        m+=i-1;
        if(i>=K){
            Ans+=M-m+1;
        }
        //cout << m MM M << endl;
        Ans+=MOD;Ans%=MOD;
    }
    Ans++;
    Ans%=MOD;
    
    cout << Ans << endl;
    
    return 0;
}



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

#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define lg long long
#define db double
#define lb(x) ((x)&-(x))
#define ft first
#define sd second

#define HII cerr<<"HI"<<endl
#define LLLINE cerr<<"@@@@@@@@@@@@@@@@@@@@"<<endl

template <class _T_>
void read(_T_& d){
	d=0;int f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f*=-1;
	for(;c>='0'&&c<='9';c=getchar())d=d*10+c-'0';
	d*=f;
}

/************************************************/
#define MN 500005
int n,m,l;
int a,b;
char S[MN],T[MN];
int main(){
	read(n);read(m);read(l);
	read(a);read(b);
	int na=1,nb=m;
	scanf("%s",S+1);
	scanf("%s",T+1);
	for(int i=l;i;--i){
		if(S[i]=='R'){
			--nb;
		}
		if(S[i]=='L'){
			++na;
		}
		if(na>nb)return puts("NO"),0;
		if(T[i-1]=='L'){
			++nb;
			nb=min(nb,m);
		}
		if(T[i-1]=='R'){
			--na;
			na=max(na,1);
		}
		//cerr<<na<<"???"<<nb<<endl;
	}
	if(na>b||nb<b)return puts("NO"),0;
	na=1,nb=n;
	for(int i=l;i;--i){
		if(S[i]=='D'){
			--nb;
		}
		if(S[i]=='U'){
			++na;
		}
		if(na>nb)return puts("NO"),0;
		if(T[i-1]=='U'){
			++nb;
			nb=min(nb,n);
		}
		if(T[i-1]=='D'){
			--na;
			na=max(na,1);
		}
	}
	if(na>a||nb<a)return puts("NO"),0;
	puts("YES");
	return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int count_days(int y, int m, int d) {
    int max_days;
    int count = 0;
    for (; y<1000; y++) {
        for (; m<=10; m++) {
            if (m%2 == 1 || y%3 == 0) {
                max_days = 20;
            }
            else {
                max_days = 19;
            }
            for (; d<=max_days; d++) {
                count++;
            }
            d = 1;
        }
        m = 1;
    }
    return count;
}

int main() {
    int n, y, m, d, days;
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> y >> m >> d;
        days = count_days(y, m, d);
        cout << days << endl;
    }
}

Measured memory_bytes: 1160
//A - Children and Candies (ABC Edit)

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

int main()
{
    int n,ans;
    cin>>n;
    if(n>1)
    {
       ans = n*(n+1);
       ans/=2;
    }

    else 
	ans = n;


    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
# https://beta.atcoder.jp/contests/abc066/tasks/abc066_b


def solve():
    s = input()
    if len(s) % 2 == 0:
        s = s[:-2]
    else:
        s = s[:-1]

    for _ in range(len(s) // 2):
        middle = len(s)//2
        if s[:middle] == s[middle:]:
            print(len(s))
            exit()
        s = s[:-2]


if __name__ == '__main__':
    solve()


Measured memory_bytes: 2940
#!/usr/bin/env python3
(n, _), *m = [[*map(int, i.split())] for i in open(0)]

a = [0]*(n<2) or [1]+[0] * ~-n

for s, c in m:
    if s==1 and a[s-1] in (1,c):
        a[s-1] = c
    elif a[s - 1] in (0, c):
        a[s - 1] = c
    else:
        print(-1)
        exit()

a = int("".join([*map(str, a)]))
if len(str(a))!=n:
    print(-1)
else:
    print(a)


Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define ll  long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define BS binary_search
#define all(c) (c).begin(),(c).end()
#define deb(a) cout<<#a<<" "<<a<<endl
#define WW 100000
#define INF 1000000000000000000 //1e18
#define EPS 0.000000001 //1e-9
//get<a>(t) gives ath element of tuple named t, numbering starts from 0
//max({_,......,_}) can give maximum of any number of elements. Similarly min also.
//don't forget to initialise freq arrays
//reverse(all(v)) would reverse a vector  
//pow(10.0, 2.0) can give exactly 100.0, slightly greater, or slightly less. 
//Therefore use(int)(pow(10.0,zz)+EPS)
int mod=1e9+7;



int32_t main()
{
    IOS;
    int n,k; cin>>n>>k;
    int pre[n+1]={};
    for(int i=1;i<=n;i++)
    {
        pre[i]=(i+pre[i-1] )%mod;
    }
    int sum=0;
    for(int i=k;i<=n;i++)
    {
        int l=pre[i-1], r = pre[n]-pre[n-i];
        //deb(n),deb(n-k);
        //deb(r-l);
        sum+=(r-l+1);
        sum%=mod;
    }
    sum+=1;
    sum%=mod;
    if(sum<0) sum+=mod;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 5180
#pragma GCC optimize("Ofast")
#include  "bits/stdc++.h"
using namespace std;
#define I_AM_SPEED  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define printclock  cerr <<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)
#define anal         '\n'
#define mod 1000000007
#define fst first
#define sec second
//const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long ull;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
   


//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
      
int main(){
I_AM_SPEED;
#ifndef ONLINE_JUDGE  
      freopen("input.in", "r", stdin);
      freopen("output.in", "w", stdout);
#endif 

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
     
     int n;
     cin >> n;
     cout << n + n*n + n*n*n;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//printclock; 
return  0 ;      
}        



   

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    char s[113344];
    Scs(s);

    bool f = false;
    deque<char> d;
    N = strlen(s);
    Rep(i,N){
        d.push_back(s[i]);
    }

    int Q;
    int a,b;
    Scd(Q);
    Rep(i,Q){
        Scd(a);
        if( a == 1 ){
            f = !f;
        }
        else{
            Scd(b);
            Scs(s);
            if( f xor (b==2) ){
                d.push_back(s[0]);
            }else{
                d.push_front(s[0]);
            }
        }
    }

    if( f ){
        while( d.size() ){
            printf ("%c", d.back() );
            d.pop_back();
        }
    }else{
        while( d.size() ){
            printf ("%c", d.front() );
            d.pop_front();
        }
    }

    printf ("\n");

    return 0;
}



Measured memory_bytes: 896
#include <iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
 

 if(a%3==0 || b%3==0 || (a+b)%3==0 )  cout << "Possible" <<endl;
 else cout<<"Impossible"<<endl ;
 
	return 0;
}

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

using namespace std;

const int N = 1e5 + 5;

int n, l, a[N], rmq[N][20], q;

int get (int x, int y) {
    int ans = 0;
    for (int i = 19; i >= 0; i--) {
        if (rmq[x][i] != -1 && rmq[x][i] < y) {
            x = rmq[x][i];
            ans += (1 << i);
        }
    }

    return ++ans;
}

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

    memset(rmq, -1, sizeof(rmq));
    for (int i = 1; i <= n; i++) rmq[i][0] = upper_bound(a + 1, a + n + 1, a[i] + l) - a - 1;
    for (int k = 1; (1 << k) <= n; k++) {
        for (int i = 1; i + (1 << k) - 1 <= n; i++) {
            if (rmq[i][k - 1] != -1) rmq[i][k] = rmq[rmq[i][k - 1]][k - 1];
        }
    }

    scanf("%d", &q);
    while (q--) {
        int l, r;
        scanf("%d %d", &l, &r);
        if (l > r) swap(l, r);
        printf("%d\n", get(l, r));
    }
    return 0;
}


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

int main(void) {
    string S;
    cin >> S;
    string c = "coffee";
    bool flag = false;
    if (S[2] == S[3] && S[4] == S[5]) {
        flag = true;
    }
    if (flag) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

ll N,A,B;

int main(){
    cin>>N>>A>>B;

    ll ans;
    if(!((A&1)^(B&1))){
        ans=(B-A)/2;
    }else{
        ans=min(A+(B-A)/2,(N-B+1)+((N-A)-(N-B+1))/2);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define ll long long
#define vpll vector<pair<ll,ll> >
#define vpii vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mem(a,b) memset(a , b , sizeof a );
#define M 1000000007
#define bs(a,b,x) binary_search(a,b,x)
template<typename T>
T fact(T n)
{
    // to find factorial
    return (n==1 || n==0) ? 1: n * fact(n - 1);
}
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
      int x,y;
      cin>>x>>y;
      if( (y-2*x)%2==0 && (4*x-y)%2==0 && (y-2*x)/2>=0 && (4*x-y)/2>=0 ) cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    
    return 0;
}



Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <climits>
#include <iomanip>
#include <string.h>
#include <algorithm>
#include <functional>

using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define sz(a) int((a).size())
#define pb push_back

typedef unsigned long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

const int N = (int)2e5+77;
const int mod = (int)1e9+7;

ll n,m,k,x,y;
ll arr[111];

int main() {
    fast;
    cin >> n;
    forn(i, n) cin >> arr[i];
    ll ans = arr[0];
    for (int i = 1; i < n; i++) {
        ans = (((ans)) / (gcd(arr[i], ans)));
        ans = (ans * arr[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N=101;
char a[N][N];
int row[N][N],col[N][N],f[N][N][N][N];
int n,m,x,y;

inline void chk(int &a,int b){a=max(a,b);}

int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%s",a[i]+1);
	for(int i=1;i<=n;++i) 
		for(int j=1;j<=m;++j)
		{
			row[i][j]=row[i][j-1]+(a[i][j]=='o');
			col[i][j]=col[i-1][j]+(a[i][j]=='o');
			if(a[i][j]=='E') x=i,y=j;
		};
	int ans=0;
	for(int l=0;l<=y-1;++l)
		for(int r=0;r<=m-y;++r)
			for(int u=0;u<=x-1;++u)
				for(int d=0;d<=n-x;++d)
				{
					ans=max(ans,f[l][r][u][d]);
					int ub=max(x-u,1+d),db=min(x+d,n-u),lb=max(y-l,1+r),rb=min(y+r,m-l);
					int nx,ny;
					ny=y-l-1;
					if(1+r<=ny&&ny<=m-l) chk(f[l+1][r][u][d],f[l][r][u][d]+(db>=ub?(col[db][ny]-col[ub-1][ny]):0));
					ny=y+r+1;
					if(1+r<=ny&&ny<=m-l) chk(f[l][r+1][u][d],f[l][r][u][d]+(db>=ub?(col[db][ny]-col[ub-1][ny]):0));
					nx=x-u-1;
					if(1+d<=nx&&nx<=n-u) chk(f[l][r][u+1][d],f[l][r][u][d]+(rb>=lb?(row[nx][rb]-row[nx][lb-1]):0));
					nx=x+d+1;
					if(1+d<=nx&&nx<=n-u) chk(f[l][r][u][d+1],f[l][r][u][d]+(rb>=lb?(row[nx][rb]-row[nx][lb-1]):0));			
				};
	printf("%d\n",ans);
 	return 0;
}

Measured memory_bytes: 240768
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    string s;cin >> s;
    ll r = 0,b = 0;
    rep(i,s.size()){
        if(s[i] == '0')b++;
        else r++;
    }
    cout << min(b,r)*2 << endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>

#define msn(x) (memset((x),0,sizeof((x))))
#define msi(x) (memset((x),-1,sizeof((x))))
#define msx(x) (memset((x),0x7f,sizeof((x))))
#define fuck(x) cerr << #x << " <- " << x << endl
#define acer cout<<"sb"<<endl
typedef long long ll;
using namespace std;
const int maxn=107;
const int maxm=1e4+7;
struct node
{
    int o,u,v;
}q[maxm];
vector<node>cmp;
int n,m;
bool dp[maxn][maxn];
bool emp[maxn][maxn];
vector<int>a,b;
bool check(int x)
{
    //queue< pair<int ,int> >q;
    cmp.clear();
    msn(dp);
    msn(emp);
    for(int i=1;i<=n;i++)dp[i][i]=1;
    for(int i=0;i<x;i++)
    {
        node &now=q[i];
        if(now.o==1)
        {
            dp[now.u][now.v]=1;
        }
        else if(now.o==2)
        {
            dp[now.u][now.v]=dp[now.v][now.u]=1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
                dp[j][k]|=(dp[j][i]&&dp[i][k]);
        }
    }

    for(int i=0;i<x;i++)
    {
         node &now=q[i];
        if(now.o==4)cmp.push_back(now);
    }
    random_shuffle(cmp.begin(),cmp.end());
    for(int z=0;z<cmp.size();z++)
    {
         node &now=cmp[z];
        if(emp[now.u][now.v])continue;
            a.clear(),b.clear();
            for(int i=1;i<=n;i++)if(dp[i][now.u])a.push_back(i);
            for(int i=1;i<=n;i++)if(dp[i][now.v])b.push_back(i);
             for(int i=0;i<a.size();i++)
            {
                for(int j=0;j<b.size();j++)
                emp[b[j]][a[i]]=emp[a[i]][b[j]]=1;
            }
    }
    for(int i=0;i<x;i++)
    {
         node &now=q[i];
        if(now.o==5)
        {
            if(emp[now.u][now.v]||emp[now.u][now.u]||emp[now.v][now.v])return 0;
        }
    }
    for(int i=0;i<x;i++)
    {
         node &now=q[i];
         if(now.o==3)
         {
             if(emp[now.u][now.u]==1&&emp[now.v][now.v]==1)return 0;
             if(dp[now.u][now.v]==1&&dp[now.v][now.u]==1)return 0;
         }
    }
    return 1;
}
int main()
{
    while(scanf("%d %d",&n,&m))
    {
        if(n==0&&m==0)break;
        for(int i=0;i<m;i++)
        {
            scanf("%d%d%d",&q[i].o,&q[i].u,&q[i].v);
        }
    int l=0,r=m;
        while(l<r)
        {
            int mid=(l+r)/2+1;
            if(check(mid))l=mid;
            else r=mid-1;
        }
       printf("%d\n",l);
    }
    return 0;
}

Measured memory_bytes: 1556
fun main(args: Array<String>) {
    val s = readLine()!!.toCharArray()
    val t = readLine()!!.toCharArray()
    val dp = Array(s.size + 1) { LongArray(t.size + 1) { 0L } }
    for (i in 0 until s.size) {
        for (j in 0 until t.size) {
            if (s[i] == t[j])
                dp[i + 1][j + 1] = Math.max(dp[i + 1][j + 1], dp[i][j] + 1)
            dp[i + 1][j + 1] = Math.max(dp[i + 1][j + 1], dp[i][j + 1])
            dp[i + 1][j + 1] = Math.max(dp[i + 1][j + 1], dp[i + 1][j])
        }
    }
    var answer = ""
    var i = s.size
    var j = t.size
    while (i > 0 && j > 0) {
        when {
            dp[i][j] == dp[i - 1][j] -> i--
            dp[i][j] == dp[i][j - 1] -> j--
            else -> {
                answer = s[i - 1] + answer
                i--
                j--
            }
        }
    }
    println(answer)
}


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

int main(){
	int a,b,c,sum=0;
	scanf("%d %d %d",&a,&b,&c);
	sum=max(sum,a+10*b+c);
	sum=max(sum,a*10+b+c);
	sum=max(sum,c*10+a+b);
	printf("%d\n",sum);
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 20
#define Q 200

int search(int,int,int,int *);

int main(){
  int n,q,a[N],m[Q],i;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++) scanf("%d",&m[i]);
  for(i=0;i<q;i++){
    if(search(0,m[i],n,a)) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int search(int i,int m,int n,int a[]){
  int judge;
  if(m==0) return 1;
  if(i>=n) return 0;
  judge=(search(i+1,m,n,a) || search(i+1,m-a[i],n,a));
  return judge;
}



Measured memory_bytes: 2108