akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        init();
        int h = nextInt(), w = nextInt(), n = nextInt();
        int painting = Math.max(h, w);

        System.out.println((int) Math.ceil(((double)n)/painting));
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
}


Measured memory_bytes: 21204
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<cmath>
#define pb push_back
#define ll long long
#define inf 0x3f3f3f3f
#define fill(a,b) memset(a,b,sizeof(a))
#define cpy(a,b) memcpy(a,b,sizeof(b))
template<typename T> inline bool MIN(T &a,const T &b) {return a>b? a=b,1:0;}
template<typename T> inline bool MAX(T &a,const T &b) {return a<b? a=b,1:0;}
#define mod 1000000007
inline int plu(int a,int b) {return a+b>=mod? a+b-mod:a+b;}
inline int sub(int a,int b) {return a-b<0? a-b+mod:a-b;}
inline int mul(int a,int b) {return (ll)a*b%mod;}
inline int inc(int &a,int b) {a+=b;if (a>=mod) a-=mod;}
inline int dec(int &a,int b) {a-=b;if (a<0) a+=mod;}
#define mp make_pair
#define SZ(a) ((int)a.size())
#define BK(a) (a[SZ(a)-1])
#define fi first
#define se second
#define N 100010
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;

int n;int A[N];

int main()
{

    scanf("%d",&n);
    for (int i=1;i<=n;++i) {
        scanf("%d",&A[i]);
    }
    //if (A[])
    ll a=2,b=2;
    for (int i=n;i;--i) {

        a=(a+A[i]-1)/A[i]*A[i];
        b=b-b%A[i];
        b+=A[i]-1;



    }

    if (a>b||A[n]!=2) printf("-1\n");
    else printf("%lld %lld\n",a,b);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

vector<int> calc(const vector<int>& a, int start_pos) {
  vector<int> ans;
  set<int> used;

  for (int i = start_pos; i < a.size(); ++i) {
    if (used.count(a[i])) {
      while (ans.back() != a[i]) {
	used.erase(ans.back());
	ans.pop_back();
      }
      used.erase(ans.back());
      ans.pop_back();
    } else {
      ans.push_back(a[i]);
      used.insert(a[i]);
    }
  }

  return ans;
}

int main(){
  ll n, k;
  cin >> n >> k;
  vector<int> a(n);
  map<int, vector<int>> next;
  rep(i,n) {
    cin >> a[i];
    next[a[i]].push_back(i);
  }

  vector<int> init;
  init.push_back(n);
  map<int, int> used;
  used[n] = 0;

  int pos = 0;
  for (int i = 0; i < k; ++i) {
    if (pos == n) {
      init.push_back(pos);
      break;
    }
    while (true) {
      int val = a[pos];
      const vector<int>& vec = next[val];
      size_t idx = lower_bound(all(vec), pos) - vec.begin();
      if (idx + 1 == vec.size()) {
	break;
      } else {
	pos = vec[idx + 1] + 1;
	if (pos == n) {
	  break;
	}
      }
    }
    init.push_back(pos);
    if (used.count(pos)) break;
    used[pos] = i + 1;
    pos = next[a[pos]][0] + 1;
  }

  int start_pos = 0;
  if (init.size() == k + 1) {
    start_pos = init[k];
  } else {
    int start_cycle = used[init.back()];
    int cycle = init.size() - 1 - start_cycle;
    start_pos = init[(k - start_cycle) % cycle + start_cycle];
  }
  vector<int> ans = calc(a, start_pos);
  rep(i, ans.size()) {
    cout << ans[i] << " \n"[i+1 == ans.size()];
  }
}

Measured memory_bytes: 41716
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=100000007;
const ll INF=1000000101001;
int main(){
int n;cin>>n;
string s;cin>>s;
int N=n/2;
bool ok=true;
if(n%2!=0)ok=false;
rep(i,N){
    if(s[i]!=s[i+N])ok=false;
}
if(ok)cout<<"Yes"<<endl;
else cout << "No" << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n,m,a,b,c;
	string str;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>n>>a;
	if(n<a){cout<<0;}
	else{cout<<10;}

	cout<<endl;
} 


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a[i]-=(i+1)
a.sort()
#print(a)
m,now=sum(a)-2*a[0]+2*a[0]-a[0]*n,sum(a)-2*a[0]+2*a[0]-a[0]*n
for i in range(1,n):
    now=now-(2*(i)*a[i-1]-n*a[i-1])+(-2*a[i]+2*(i+1)*a[i]-n*a[i])
    m=min(now,m)
    #print(now)
print(m)

Measured memory_bytes: 26020
#include<iostream>

using namespace std;

int A[110];
int main()
{
    int N;cin >>N;
    for(int i=0;i<N;++i)
    {
        cin >> A[i];
    }

    for(int j=0;j<N;++j)
    {
        if(A[j] % 2 !=0) continue;
        if(A[j] % 3 !=0 && A[j] % 5 !=0)
        {
            cout << "DENIED"<<endl;
            return 0;
        }
    }

    cout << "APPROVED"<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int GetDigit(int num){
    if(num == 0) return 1;
    int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int s_th_digit(int x, int s){
    if(GetDigit(x) == 1){
        return x;
    }
    else if(GetDigit(x) == 2){
        int xx[2];
        for(int i=0; i<2; i++){
            xx[1-i] = x % 10;
            x -= xx[1-i];
            x /= 10;
        }
        return xx[s-1];
    }
    else if(GetDigit(x) == 3){
        int xx[3];
        for(int i=0; i<3; i++){
            xx[2-i] = x % 10;
            x -= xx[2-i];
            x /= 10;
        }
        return xx[s-1];
    }
}

bool is_ok_d(int x, int n){
    if(GetDigit(x) != n) return false;
    return true;
}

bool is_ok(int x, int s, int c){
    if(s_th_digit(x, s) != c) return false;
    return true;
}

int main(void){

    int n, m;
    cin >> n >> m;

    vector<int> s(m), c(m);
    for(int i=0; i<m; i++){
        cin >> s[i] >> c[i];
    }

    int ans = -1;
    for(int x=0; x<=999; x++){
        if(!is_ok_d(x, n)) continue;
        int flag = 0;
        for(int i=0; i<m; i++){
            if(is_ok(x, s[i], c[i])) flag++;
        }
        if(flag == m){
            ans = x;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ii = long long;
const ii mod = 1e9+7;
ii _dp[2][100100];
#define dp _dp[z]
#define pd _dp[!z]
int main()
{
    int n, k, z = 1;
    cin >> n >> k;
    dp[0] = 1;
    for (int i = 1; i <= n; ++i) {
        z = !z;
        for (int j = 0; j <= k; ++j) {
            dp[j] = 0;
        }
        int x;
        cin >> x;
        ii s = 0;
        for (int j = 0; j <= k; ++j) {
            s += pd[j];
            s %= mod;
            dp[j] += s;
            dp[j] %= mod;
            if (j >= x) s -= pd[j - x];
            s = (s + mod) % mod;
        }
    }
    cout << dp[k] << "\n";
}


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

int main() {
  int h, w;
  cin >> h >> w;
  string s[h];
  for ( int i = 0; i < h; i++ ) {
    cin >> s[i];
  }
  int dp[h][w] = {};

  int len;
  for ( int i = 0; i < h; i++ ) {
    len = 0;
    for ( int j = 0; j < w; j++ ) {
      if ( s[i][j] == '#' ) {
        for ( int k = 1; k <= len; k++ ) {
          dp[i][j-k] = len;
        }
        len = 0;
      } else if( j == w-1 ) {
        len++;
        for ( int k = 0; k <= len; k++ ) {
          dp[i][j-k] = len;
        }
      } else {
        len++;
      }
    }
  }
  for ( int j = 0; j < w; j++ ) {
    len = 0;
    for ( int i = 0; i < h; i++ ) {
      if ( s[i][j] == '#' ) {
        for ( int k = 1; k <= len; k++ ) {
          dp[i-k][j] += len;
        }
        len = 0;
      } else if ( i == h-1 ) {
        len++;
        for ( int k = 0; k <= len; k++ ) {
          dp[i-k][j] += len;
        }
      } else {
        len++;
      }
    }
  }

  int max = 0;
  for ( int i = 0; i < h; i++ ) {
    for ( int j = 0; j < w; j++ ) {
      max = ( dp[i][j] > max ) ? dp[i][j] : max;
    }
  }

  cout << max-1 << endl;
  return 0;
}

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

int main()
{
  int n,k;
  cin >> n >> k;
  vector<int> l(n);
  for(int i = 0;i < n;i++) cin >> l[i];
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  int sum = 0;
  for(int i = 0;i < k;i++){
    sum += l[i];
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vl vector<ll>
#define vs vector<string>

#define vc vector<char>
#define C vector<vc>

C c;

vc r90(vc v){
	vc r;
	rep(i,3)for(int j=2;j>=0;j--)r.pb(v[j*3+i]);
	return r;
}

vc l90(vc v){
	vc r;
	for(int i=2;i>=0;i--)rep(j,3)r.pb(v[j*3+i]);
	return r;
}

vc r180(vc v){
	vc r;
	for(int i=2;i>=0;i--)for(int j=2;j>=0;j--)r.pb(v[i*3+j]);
	return r;
}

C rotf(C c){
	C r;
	r.pb(c[5]);
	r.pb(r90(c[1]));
	r.pb(r180(c[4]));
	r.pb(l90(c[3]));
	r.pb(c[0]);
	r.pb(r180(c[2]));
	return r;
}

C rotr(C c){
	C r;
	r.pb(r90(c[0]));
	r.pb(r90(c[4]));
	r.pb(l90(c[2]));
	r.pb(r90(c[5]));
	r.pb(r90(c[3]));
	r.pb(r90(c[1]));
	return r;
}

C rotba(C c){
	C r;
	r.pb(c[4]);
	r.pb(l90(c[1]));
	r.pb(r180(c[5]));
	r.pb(r90(c[3]));
	r.pb(r180(c[2]));
	r.pb(c[0]);
	return r;
}

C rotl(C c){
	C r;
	r.pb(l90(c[0]));
	r.pb(l90(c[5]));
	r.pb(r90(c[2]));
	r.pb(l90(c[4]));
	r.pb(l90(c[1]));
	r.pb(l90(c[3]));
	return r;
}

int main(){
	c.resize(6);
	rep(i,6)c[i].resize(9);
	while(cin>>c[0][0]){
		if(c[0][0]=='#')break;
		rep(i,8)cin>>c[0][i+1];
		rep(i,5)rep(j,9)cin>>c[i+1][j];
		map<C,int> M;
		queue<C> Q;
		M[c]=0;
		Q.push(c);
		while(1){
			C c=Q.front();Q.pop();
			int s=M[c];
			if((c[0][6]=='*'||c[0][7]=='*'||c[0][8]=='*')&&(c[2][6]=='*'||c[2][7]=='*'||c[2][8]=='*')){
				cout<<s<<endl;
				break;
			}
			C c0=rotf(c),c1=rotr(c),c2=rotba(c),c3=rotl(c);
			if(M.find(c0)==M.end())M[c0]=s+1,Q.push(c0);
			if(M.find(c1)==M.end())M[c1]=s+1,Q.push(c1);
			if(M.find(c2)==M.end())M[c2]=s+1,Q.push(c2);
			if(M.find(c3)==M.end())M[c3]=s+1,Q.push(c3);
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 998244353
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
  int res = 1;
  x = x % p;
  while (y > 0)
  {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res % p;
}
 
int32_t main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  int tc;
  tc = 1;
  //cin >> tc;
  while (tc--)
  {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    b = ceil(1.0 * c / b);
    d = ceil(1.0 * a / d);

    if(b<=d){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3756
#!/usr/bin/env python3
import collections
import itertools as it
import math
import numpy as np

def permutations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# A = input()
# A = int(input())
N, M = map(int, input().split())
# A = list(map(int, input().split()))
# A = [int(input()) for i in range(N)]
#
# c = collections.Counter()

cN = 0
cM = 0
if N == 0:
    cN = 0
elif N == 1:
    cN == 1
else:
    cN = permutations_count(N, 2)

if M == 0:
    cM = 0
elif M == 1:
    cM == 1
else:
    cM = permutations_count(M, 2)

print(cN + cM)

Measured memory_bytes: 21156
#include <stdio.h>
#include <math.h>
int main(){
    int a,b;
    while(scanf("%d%d",&a,&b)!=EOF){
        if((a*b)%2==0){
            printf("Even\n");
        }
        else{
            printf("Odd\n");
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    double n;
    cin >>n;

    int p = int(n * (1.0/1.08))+1;

    if (int(p * 1.08) == n)
        cout << p << endl;
    else
        cout << ":(" << endl;

    return 0;
}


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

int main(){
    string s,t,u;
    int a,b;
    cin >> s >> t >> a >> b >> u;
    if (u == s) a--;
    else b--;
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(c-b<=0){
		cout << "delicious" << endl;
	}else if(c-b<=a){
		cout << "safe" << endl;
	}else if(c-b>a){
		cout << "dangerous" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  s = input[0].split("");
  var ans ="Yes";
  for(var i=0;i<s.length;i++){
    if(i%2==0){
      if(s[i]=="L"){
        ans = "No";
      }
    }else if(i%2==1){
      if(s[i]=="R"){
        ans = "No";
      }
    }
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
import collections
import sys

input = sys.stdin.readline

n, q = map(int, input().split())
es = [[] for _ in range(n + 1)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    es[a].append(b)
    es[b].append(a)

ps = [0] * (n + 1)
for _ in range(q):
    p, v = map(int, input().split())
    ps[p] += v

remaining = collections.deque([[0, 1]])
while len(remaining) > 0:
    a, b = remaining.popleft()
    ps[b] += ps[a]
    for c in es[b]:
        if c != a:
            remaining.append([b, c])
print(*ps[1:])

Measured memory_bytes: 63248
#include<bits/stdc++.h>
using namespace std;
long long ans = INT64_MAX;
long long dif(long long a, long long b, long long c) {
    return max(a, max(b, c))-min(a, min(b, c));
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long H, W;
    cin >> H >> W;
    long long A, B, C;
    for (int i = 0; i < 2; i++, swap(H, W)) {
        if (H%3 == 0) ans = 0;
        else {
            ans = min(ans, W);
            if (H%3 == 1) {
                A = (H/3)*W;
                B = (H/3*2+1)*(W/2+W%2);
                C = (H/3*2+1)*(W/2);
                ans = min(ans, dif(A, B, C));
            } else {
                A = (H/3+1)*W;
                B = (H/3*2+1)*(W/2+W%2);
                C = (H/3*2+1)*(W/2);
                ans = min(ans, dif(A, B, C));
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int n,w;
int main()
{
    long long int i,j,k,x,y,z;
    cin>>n>>w;
    vector<pair<long long int ,long long int>> v;
    for(i=0;i<n;i++)
    {
        cin>>x>>y;
        v.push_back(make_pair(x,y));
    }
    vector<long long int>dp(100001,1e15);
    dp[0]=0;
    for(i=0;i<n;i++)
    {
        vector<long long int>newdp(100001,1e15);
        for(j=0;j<=100000;j++)
        {
            newdp[j]=dp[j];
            if(j-v[i].second>=0)
            newdp[j]=min(newdp[j],dp[j-v[i].second]+v[i].first);
        }
        dp=newdp;
    }
    x=0;
    for(i=0;i<100001;i++)
     if(dp[i]<=w)
      x=i;
    cout<<x;
}

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

using namespace std;

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

    if((A&1) == (B&1)){
        cout<<(max(A, B)-min(A, B))/2 + min(A, B)<<endl;
    }else{
        cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T1, class T2>bool chmax(T1& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<class T1, class T2>bool chmin(T1& a, const T2& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(12); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N - 1);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N - 1) cin >> C[i];

    int ans = 0;
    rep(i, N) {
        ans += B[A[i] - 1];
        if (i > 0 && A[i] == A[i - 1] + 1) {
            ans += C[A[i - 1] - 1];
        }
    }

    write(ans);
}

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

signed main() {
  int h,w,a,b;
    scanf("%d%d%d%d",&h,&w,&a,&b);
    	std::string s(a,'0');
    	std::string t(w-a,'1');
        std::string ans=s+t;
  		std::string S(a,'1');
  		std::string T(w-a,'0');
  		std::string Ans=S+T;
  for(int i=0;i<h;++i){
    if(i<b){
    	printf("%s\n",ans.c_str());
    }
    else{
    	printf("%s\n",Ans.c_str());
    }
  }
}

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

int main() {
  int A,B,K;
  cin>>A>>B>>K;
  vector<int> V={0};
  
  for (int i=1;i<=min(A,B);i++) {
    if (A%i==0 && B%i==0) {
      V.push_back(i);
    }
    else continue;
  }
  reverse(V.begin(),V.end());
  
  cout<<V[K-1]<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
//#include<bits/stdc++.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#include<set>
#define  si(a)       scanf("%d",&a)
#define  sl(a)       scanf("%lld",&a)
#define  sii(a,b)    scanf("%d%d",&a,&b)
#define  sll(a,b)    scanf("%lld%lld",&a,&b)
#define  queues      priority_queue
#define mod 998244353
#define mem(a)  memset(a,0,sizeof(a));
#define def(a) ((a)&(-a))
#define fi  first
#define se  second
#define mp  make_pair
#define  pb push_back
#define mem(a,b) memset(a,b,sizeof(a));
typedef long long ll;
//priority_queue<ll,vector<ll >,greater<ll > >q;
const int INF=0x3f3f3f3f;
//const double E=exp(1);
//const double PI=acos(-1);
using namespace std;
//__builtin_popcount
//priority_queue
const ll MAX=100000;
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
ll kc(ll a,ll b)
{
    ll c=1;
    while(b)
    {
        if(b&1)c=(c*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return c;
}
bool cmp(double x,double y)
{
    return x>y;
}
ll F[50003*3];
ll Find(ll a)
{
    return F[a]<0?a:F[a]=Find(F[a]);
}
ll same(ll a,ll b)
{
    if(Find(a)==Find(b))return 1;
    return 0;
}
ll up1(ll a,ll b)
{
    ll x,y;
    x=Find(a);
    y=Find(b);
    if(x!=y)
        F[x]=y;
    return 0;
}
int read() {
    int x=0,f=1;char s=getchar();
    for(;s>'9'||s<'0';s=getchar()) if(s=='-') f=-1;
    for(;s>='0'&&s<='9';s=getchar()) x=x*10+s-'0';
    return x*f;
}

int main()
{
   // ios::sync_with_stdio(false);
   ll a,b;
   cin>>a>>b;
  // if(abs(a-b)%2==0)cout<<abs(a-b)/2;
  if(abs(a+b)%2==0)cout<<(a+b)/2;
   else cout<<"IMPOSSIBLE\n";
}



Measured memory_bytes: 256
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 
 
const int N = 1e6 + 100, OO = 1e16 + 1000, T = 150, M = 1e9 + 7, P = 6151, SQ = 1000, lg = 44;
typedef pair <int, int> pii;

int32_t main() {
	use_fast;	
	int n, m;
	cin >> n >> m;
	if(n == 1 || m == 1)	
		return cout << 1, 0;
	int q = (n * m + 1) / (int)2;
	cout << q << endl;
	return 0;
} 
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/

Measured memory_bytes: 256
#include<stdio.h>
#define SQ(x) ((x)*(x))
#define IN(x,y) ((0<=x&&x<=5000)&&(0<=y&&y<=5000))


typedef struct{
  int x;
  int y;
}point;

char map[5001][5001];
point ps[3000];
int pi;
int st;

int main(){
  int i,j,d,dx,dy,nx,ny;
  int max;
  do{
    scanf("%d",&pi);
    if(pi==0) break;
    st++;
    max=0;
    for(i=0;i<pi;i++){
      scanf("%d %d",&(ps[i].x),&(ps[i].y));
      map[ps[i].y][ps[i].x]=st;
    }
    for(i=0;i<pi-1;i++){
      for(j=i+1;j<pi;j++){
	d=SQ(ps[i].x>ps[j].x?ps[i].x-ps[j].x:ps[j].x-ps[i].x);
	d+=SQ(ps[i].y>ps[j].y?ps[i].y-ps[j].y:ps[j].y-ps[i].y);
	if(d>max){
	  dx=ps[j].x-ps[i].x;
	  dy=ps[j].y-ps[i].y;
	  nx=ps[i].x+dy;
	  ny=ps[i].y-dx;
	  if(IN(nx,ny)&&(map[ny][nx]==st)){
	    nx+=dx;
	    ny+=dy;
	    if(IN(nx,ny)&&(map[ny][nx]==st)){
	      max=d;
	    }
	  }
	  nx=ps[i].x-dy;
	  ny=ps[i].y+dx;
	  if(IN(nx,ny)&&(map[ny][nx]==st)){
	    nx+=dx;
	    ny+=dy;
	    if(IN(nx,ny)&&(map[ny][nx]==st)){
	      max=d;
	    }
	  }
	}
      }
    }
    printf("%d\n",max);
  }while(1);
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5;
const int N=maxn+10;
int n,par[2*N];
int cntx[2*N],cnty[2*N],sz[2*N];
int x,y;
ll ans;
int find(int x)
{
	return par[x]==x?x:par[x]=find(par[x]);
}
void merge(int x,int y)
{
	x=find(x),y=find(y);
	if(x==y)return;
	if(sz[x]<sz[y])swap(x,y);
	sz[x]+=sz[y];
	cntx[x]+=cntx[y];
	cnty[x]+=cnty[y];
	par[y]=x; 
}
int main()
{
	for(int i=1;i<=maxn;++i)
	par[i]=i,sz[i]=1,cntx[i]=1;
	for(int i=maxn+1;i<=2*maxn;++i)
	par[i]=i,sz[i]=1,cnty[i]=1;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d%d",&x,&y);
		y+=maxn;
		merge(x,y);
	}
	for(int i=1;i<=2*maxn;++i)
	{
		x=find(i);
		if(x!=i)continue;
		ans+=1ll*cntx[i]*cnty[i];		
	}
	printf("%lld\n",ans-n);
	return 0;
}

Measured memory_bytes: 2944
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n, W; cin>>n>>W;
    vector<int> v(n), w(n);
    for(int i=0; i<n; i++) cin>>v[i]>>w[i];

    vector<vector<int>> dp(n+1, vector<int>(W+1, 0));

    for(int i=0; i<n; i++){
        for(int j=0; j<=W; j++){
            chmax(dp[i+1][j], dp[i][j]);
            
            if(j + w[i] <= W){
                chmax(dp[i+1][j+w[i]], dp[i][j] + v[i]);
            }
        }
    }

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


Measured memory_bytes: 6844
from math import ceil
N,K =map(int,input().split())
A = list(map(int,input().split()))
X1 = 1
X2 = 10**9
while X1 != X2-1:
    X = ceil((X1 + X2)/2)
    S = 0
    for i in range(N):
        S += ceil(A[i]/X) - 1
    if S <= K:
        X2 = X
    else:
        X1 = X
S1 = 0
for i in range(N):
    S += ceil(A[i]/X2) - 1
if S <= K:
    X2 = X1
print(X2)

Measured memory_bytes: 31160
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

template <class S, class T>
struct Spair{
    S first;
    T second;
    Spair() = default;
    Spair(S aa, T bb){
        if(aa < bb){
            first = aa; second = bb;
        }else{
            first = bb; second = aa;
        }
    }
    operator pair<S, T>() const { return {first, second}; }
    bool operator < (const Spair& s) const { return pair<S, T>(*this) < pair<S, T>(s); }
    bool operator == (const Spair& s) const { return pair<S, T>(*this) == pair<S, T>(s); }
    void setFirst(S a){ first = a; if(first > second){ swap(first, second); } }
    void setSecond(T b){ second = b; if(first > second){ swap(first, second); } }
    ostream& operator >> (ostream& out){ return out << first << ' ' << second; }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<Spair<int, int>> dp(1 << n);
    for(int i = 0; i < (1 << n); i++){
        cin >> dp[i].second;
        dp[i].first = dp[0].second;
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < (1 << n); j++){
            if(j >> i & 1){
                if(dp[j].first < dp[j ^ 1 << i].first){
                    dp[j].setFirst(dp[j ^ 1 << i].first);
                }
                if(dp[j].first < dp[j ^ 1 << i].second){
                    dp[j].setFirst(dp[j ^ 1 << i].second);
                }
            }
        }
        prints(dp);
    }
    int ans = 0;
    for(int i = 1; i < (1 << n); i++){
        ans = max(ans, dp[i].first + dp[i].second);
        cout << ans << '\n';
    }
}


Measured memory_bytes: 5120
///Coder ---->>>> Kael (Joan Marcos Rivera)
///Team ACM : CyberSpace ____ IPVCE FEDERICO ENGELS
///KingOfString
///Copyright

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;

typedef long long ll;
typedef pair < string , int > par;

#define pb push_back
#define s second
#define mp make_pair
#define f first
#define maxn 100010
#define eps 1e-9
#define mod 50010
#define less(n) order_of_key(n)
#define en_pos(n) find_by_order(n) /// --- >> iterador --- >> empieza en 0

vector<int>top,g[maxn],gr[maxn];
int vis[maxn],dp[maxn];

void dfs(int nod){
    vis[nod]=1;
    for(auto u:g[nod]){
        if(!vis[u]){
            dfs(u);
        }
    }
    top.pb(nod);
}
int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n,m;
    cin >> n >> m;
    for(int i=1;i<=m;i++){
        int a,b;
        cin >> a >> b;
        g[a].pb(b);
        gr[b].pb(a);
    }

    for(int i=1;i<=n;i++)
        if(!vis[i])
            dfs(i);

    reverse(top.begin(),top.end());
    int sol=0;
    for(int i=0;i<n;i++){
        for(auto u:gr[top[i]]){
            dp[top[i]]=max(dp[top[i]],dp[u]+1);
            sol=max(sol,dp[top[i]]);
        }
    }

    cout << sol;


}



Measured memory_bytes: 14588
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
int main(){
    int n,a,b;
    cin >> n >> a >> b;
    if(n*a>b){
        cout << b << endl;
    }
    else{
        cout << n*a <<endl;
    }
}

Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check
const ll INF = 1LL << 60;
ll N;

void solve(long long M){
    if(M == 0) {
        cout<< 0 <<endl; return;
    }
    sll R;
    while(M !=0){
        ll resd=M % 4; M = M/4;
        if(resd == 0){ //* this block is all zero
            R.push(0); R.push(0);
            continue;
        }

        if(resd == 2 || resd == 3) {M ++; resd -= 4;}
        else if(resd == -3){M--; resd +=4;}


        if(resd == -1){
            R.push(1); R.push(1);
        }
        else if(resd == -2){
            R.push(0); R.push(1);
        }
        else if(resd == 1){
            R.push(1); R.push(0);
        }
    }
    while(R.top()==0){
        R.pop();
    }
    while(!R.empty()){
        ll x = R.top(); R.pop();
        cout<<x;
    }
    cout<<endl;
}

int main(){
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
// const int INF = 1e9 + 5;

int main(){
	int n,k;
	cin>>n>>k;	
	vector<int> h(n);		//heights vector
	for(int& x : h) {
		scanf("%d",&x);
    // cin>>x;
	}
	vector<int> dp(n,INT_MAX);
	dp[0] = 0;
	for(int i = 0 ; i < n ; ++i) 
	{
	    for(int j = i+1 ; j <= i+k ; ++j)
        {
		    if(j < n)
		    dp[j] = min(dp[j] , dp[i] + abs(h[i] - h[j]));  
		}
	}
// 	for(auto i : dp)
// 	cout<<i<<" ";
// 	cout<<endl;
	cout<<dp[n-1]<<'\n';
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
vector<int> arr;
int main() {
  int n,tot = 0,cnt=0, ans = INT_MAX;
  scanf ("%d",&n);
  arr.resize(n);
  for (auto &a : arr) {
    scanf ("%d",&a);
    tot += a;
  }
  for (int x = 0; x < n; x++) {
    cnt += arr[x];
    ans = min(ans,abs((tot-cnt)-cnt));
  }
  printf ("%d\n",ans);
  return 0;
}


Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

// use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
// use std::convert::TryInto;
use libm::*;
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
use superslice::*;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//abc075-C
#[fastout]
fn main() {
    input![n: usize, m: usize, edge: [(usize, usize); m]];

    // println!("n={}, m={} edges:{:?}", n, m, edge);

    let mut ad_mat = vec![vec![false; n as usize]; n as usize];

    for (from, to) in edge.iter() {
        ad_mat[from - 1][to - 1] = true;
        ad_mat[to - 1][from - 1] = true;
    }

    // println!("{:?}", ad_mat);

    let dfs = |non_use_edge: (usize, usize)| {
        let (non_from, non_to) = non_use_edge;
        let (non_from, non_to) = (non_from - 1, non_to - 1);

        // eprintln!("non_use_edge: {}, {}", non_from, non_to);
        for from_node_idx in 0..n {
            // eprintln!("from_node_idx: {:?}", from_node_idx);
            let mut s = Vec::new();
            let mut is_visits = vec![false; n];
            s.push(from_node_idx);

            let is_all_visits = |is_visits: &Vec<bool>| {
                for is_visit in is_visits.iter() {
                    // eprintln!("is_visit: {}", *is_visit);

                    if *is_visit {
                    } else {
                        return false;
                    }
                }

                return true;
            };

            while !(s.is_empty() || is_all_visits(&is_visits)) {
                let n = s.pop().unwrap();

                if is_visits[n] {
                    continue;
                }

                is_visits[n] = true;
                for (idx, to) in ad_mat[n].iter().enumerate() {
                    if (non_from == n && non_to == idx) || (non_from == idx && non_to == n) {
                        // eprintln!("non_from: {}, non_to == {}", non_from, non_to);

                        continue;
                    }

                    if *to {
                        if !is_visits[idx] {
                            s.push(idx);
                        }
                    }
                }
            }

            // eprintln!(
            //     "is_all_visits: {}, is_visits: {:?}, ",
            //     is_all_visits(&is_visits),
            //     is_visits
            // );

            if !is_all_visits(&is_visits) {
                return false;
            }
        }

        return true;
    };

    let mut ans = 0;
    for non_use_edge in edge.iter() {
        if !dfs(*non_use_edge) {
            ans += 1;
        }
    }

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


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

int Partation(int *,int,int);


int main(){
  int i, j, *A, n, q;
  
  scanf("%d",&n);
  A = malloc(sizeof(int)*n+1);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  
  q = Partation(A, 0, n-1);
  
  for(i=0;i<n;i++){
    if(i==q) printf(" [%d]",A[i]);
    else if(i>0) printf(" %d",A[i]);
    else printf("%d",A[i]);
  }
  printf("\n");
  return 0;
}

int Partation(int *A, int p, int r){
  
  int x = A[r];
  int i,j,k;
  i = p - 1;
  for(j=p;j<=r-1;j++){
    if(A[j]<=x) {
      i = i + 1;
      k = A[i];
      A[i] = A[j];
      A[j] = k;
    }
  }
  
  k = A[i+1];
  A[i+1] = A[r];
  A[r] = k;
  
  return i+1;
}
/*rは配列Aの最後の要素を指す添字で、A[r]を基準として配列を分割することに注意*/


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


int main(){

    
    int s, a, b;


    cin >> s;


    a = s / 100;

    b = s % 100;


    if( 0 < a && a < 13 && 0 < b && b < 13 ){

        cout << "AMBIGUOUS" << endl;

        }

    else if( 0 < a && a < 13 ) cout << "MMYY" << endl;

    else if( 0 < b && b < 13 ) cout << "YYMM" << endl;

    else cout << "NA" << endl;


    return 0;

    }


Measured memory_bytes: 256
/******* all required header files *******/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;

/*****All definitions*******/
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int>
#define vs vector<string>
#define vc vector<char>
#define mp make_pair
#define ll long long int
#define pb push_back
#define F first
#define S second
/***************************/

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

	ios_base::sync_with_stdio(0);
	cin.tie(0);

    string str;
    cin>>str;
    set<char> s;
    for(int i = 0; i < str.size(); i++)
    {
        char a = str[i];
        s.insert(a);
    }
    vector<int> v;
    for(auto itr = s.begin(); itr != s.end(); itr++)
    {
        int a = count(v.begin(), v.end(), *itr);
        v.pb(a);
    }
    
    if(v.size() == 2 && v[0] == v[1])
    {
        cout<<"Yes";
    }
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> weather = new List<string>{"Sunny","Cloudy","Rainy"}; 
            string kyoWeather = Console.ReadLine();
            int indexNum = weather.IndexOf(kyoWeather);
            if(indexNum == 2){
                indexNum = 0;
            }else{
                indexNum += 1;
            }
            Console.WriteLine(weather[indexNum]);
        }
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 17324
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    cout << a[n-1] - a[0] << endl;
}

Measured memory_bytes: 256
use strict;
use warnings;

my $line = <STDIN>;
chomp($line);

my ($N, $K) = split(q{ }, $line);

my $str = <STDIN>;
chomp($str);

my @str_array = split(q{}, $str);
$str_array[$K-1] = lc($str_array[$K-1]);

print join(q{}, @str_array);

Measured memory_bytes: 640
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

S = list(input())
odd = set(['R', 'U', 'D'])
even = set(['L', 'U', 'D'])

leng = len(S)
for i in range(leng):
    if i%2==1:
        if not S[i] in even:
            print('No')
            break
    else:
        if not S[i] in odd:
            print('No')
            break
else:
    print('Yes')

Measured memory_bytes: 62028
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, ll> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int n, a[MAXN];
ll ss[MAXN], sx[MAXN];

bool check(int l, int r) {
    return (ss[r] - ss[l-1]) == (sx[r] ^ sx[l-1]);
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    FOR(i,1,n) {
        ss[i] = ss[i-1] + a[i];
        sx[i] = sx[i-1] ^ a[i];
    }
    ll res = 0;
    FOR(i,1,n) {
        int dau = 1, cuoi = i, mid;
        while (dau <= cuoi) {
            mid = (dau + cuoi) >> 1;
            if (check(mid, i)) cuoi = mid-1;
            else dau = mid+1;
        }
        res += i-cuoi;
    }
    cout << res;
    return 0;
}

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

typedef long long                   ll;
typedef long double                 ld;
typedef pair<ll,ll>                 pll;
typedef pair<ld,ld>                 pld;


#define all(x)          (x).begin(),(x).end()
#define Sort(x)         sort(all(x))
#define sep             ' '
#define endl            '\n'
#define tab             '\t'
#define X               first
#define Y               second
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io         freopen("in.txt" , "r" , stdin) ; freopen("out.txt" , "w" , stdout);
#define set_random      mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll MOD = 1e9 + 7,
         MAXN= 1e3+10,
         INF=1e18;
ll dp[MAXN][MAXN],H,W;
char p[MAXN][MAXN];
int main()
{
    fast_io;
    cin>>H>>W;
    for(ll i=1;i<=H;i++){
        for(ll j=1;j<=W;j++){
            cin>>p[i][j];
        }
    }
    dp[1][1]=1;
    for(ll i=1;i<=H;i++){
        for(ll j=1;j<=W;j++){
            if(p[i][j]=='#')continue;
            dp[i][j]+=dp[i-1][j] + dp[i][j-1];
            dp[i][j]%=MOD;
        }
    }
    cout<<dp[H][W]<<endl;
    return 0;
}


Measured memory_bytes: 9088
N = int(input())
A = list(map(int,input().split()))
c = [0] * 9
for i in A:
    if i < 3200:
        c[i//400]+=1
    else:
        c[8]+=1
cnt = 0
for i in range(8):
    if c[i] != 0:
        cnt += 1
mini = max(1,cnt)
maxi = cnt+c[8]
print(mini,maxi)


Measured memory_bytes: 9024
import java.util.*

fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val n = sc.nextInt()

    (1..9).forEach { x ->
        (1..9).forEach { y ->
            if (x * y == n) {
                println("Yes")
                return
            }
        }
    }
    println("No")
    return
}

Measured memory_bytes: 31392
#pragma GCC optimize("O3")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define ld long double
#define rep(i,a,n) for (int i=(int)(a);i<(int)(n);i++)
#define per(i,a,n) for (int i=(int)(n-1);i>=(int)(a);i--)
#define mp(a, b) make_pair(a, b)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define fi first
#define se second


const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};


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


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp[2];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        ++mp[0][-i - a[i]];
        ++mp[1][i - a[i]];
    }
    ll res = 0;
    for (int i = 0; i < n; ++i) {
        res += mp[0][a[i] - i];
        res += mp[1][a[i] + i];
    }
    cout << res / 2 << '\n';
}


Measured memory_bytes: 38088
#include<iostream>
using namespace std;
#define ll long long
int has[110];
int a[100010];
bool is[100010];
int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		if (a[x] < a[y])is[x] = 1;
		else if (a[x] > a[y])is[y] = 1;
		else is[x] = 1, is[y] = 1;
	}int ans = 0;
	for (int i = 1; i <= n; i++)
		if (!is[i])ans++;
	cout << ans;
}

Measured memory_bytes: 4104