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

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << "(DUMP) " << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> pl;
typedef pair<ll, ll> pll;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A,B,C,D,E;
int dp[NMAX] = {};
std::map<int, ll> mp;
string S;
vec v;

ll ans = 0;

void solve(){
  // main algorithm
  for(auto&& i : mp) {
    if(K <= i.second) {
      cout << i.first << endl;
      return;
    }
    else {
      K -= i.second;
    }
  }
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  // printf("%lld\n", ans);
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  scanf("%lld%lld", &N,&K);
  for (int i = 0; i < N; ++i)
  {
    scanf("%lld%lld", &A, &B);
    mp[A] += B;
  }
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;


int main(){
   IOS;
 //    #ifndef ONLINE_JUDGE
 //        freopen("in.txt",  "r",  stdin);
 //        freopen("out.txt", "w", stdout);
 //    #endif
   long int n;
   cin>>n;

   set<long int> s;
   for(long int i = 0;i < n; i++){
      long int x;
      cin>>x;
      s.insert(x);
   }  

   if(s.size() == n)
      cout<<"YES";
   else
      cout<<"NO";

   return 0;
}

Measured memory_bytes: 9600
#include<cstdio>
#include<iostream>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
    int r,g,b;
    cin>>r>>g>>b;
    int a;
    a = r*100+g*10+b;
    if(a%4==0)
    {
        printf("YES\n");
    }
    else
        printf("NO\n");
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC145 B

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
s = input()
if n % 2 != 0:
    print('No')
    quit()
if s[:n//2] == s[n//2:]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (int i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 

int solve(){
	ll x;
	cin>> x;
	ll  bal = 100;
	int ans = 0;
	while(true){
		if(bal >= x)
			return cout<< ans, 0;
		ans++;
		bal += (bal/100);
	}
	return 0;
}
 
int main()
{
	fast;
	int t = 1;
	//cin>> t;
	while(t--){  
		solve();
	}
	return 0;
}
//upper_bound returns an iterator pointing to the 
//first element in the range [first,last) which has a value greater than ‘val’
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);

Measured memory_bytes: 3656
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	h := getNextInt(scanner)
	w := getNextInt(scanner)
	grid := make([]string, h)

	for i := 0; i < h; i++ {
		grid[i] = getNextString(scanner)
	}

	cnt := h * w
	color := make([]int, cnt)
	for i := 0; i < cnt; i++ {
		color[i] = i
	}

	for y := 0; y < h; y++ {
		for x := 0; x < w; x++ {
			if y > 0 && grid[y][x] != grid[y-1][x] {
				r1 := root(y*w+x, color)
				r2 := root((y-1)*w+x, color)
				if r1 != r2 {
					color[r2] = r1
				}
			}
			if x > 0 && grid[y][x] != grid[y][x-1] {
				r1 := root(y*w+x, color)
				r2 := root(y*w+x-1, color)
				if r1 != r2 {
					color[r2] = r1
				}
			}
		}
	}

	sum := makeInts(cnt, 2)
	ans := 0
	for y := 0; y < h; y++ {
		for x := 0; x < w; x++ {
			r := root(y*w+x, color)
			if grid[y][x] == '#' {
				sum[r][0]++
				continue
			}
			sum[r][1]++
		}
	}

	for i := 0; i < cnt; i++ {
		ans += sum[i][0] * sum[i][1]
	}

	fmt.Fprintln(writer, ans)

	writer.Flush()
}

func makeInts(h, w int) [][]int {
	index := make([][]int, h, h)
	data := make([]int, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

func root(i int, color []int) int {
	if i == color[i] {
		return i
	}
	color[i] = root(color[i], color)
	return color[i]
}


Measured memory_bytes: 8832
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			if(n==0)
				return;
			char map[][]=new char[n][n];
			int w[][]=new int[n][n];
			int ans=0;
			for(int i=0;i<n;i++)
			{
				String s=in.next();
				for(int j=0;j<n;j++)
					map[i][j]=s.charAt(j);
			}
			for(int i=0;i<n;i++)
				for(int j=0;j<n;j++)
					if(map[i][j]=='.')
						w[i][j]=1;

			for(int i=1;i<n;i++)
				for(int j=1;j<n;j++)
				{
					if(map[i][j]=='*')
						w[i][j]=0;
					else
					{
						w[i][j]=Math.min(w[i-1][j], Math.min(w[i][j-1],w[i-1][j-1]))+1;
						ans=Math.max(ans,w[i][j]);
					}
				}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 58540
#include <bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long t,x;
  string n;
  cin >> n;
  int s=0;
  for( int i=0;i<n.size();i++)
  {
      int c=n[i]-'0';
      s=s+c;
  }
  if(s%9==0)
  {
      cout << "Yes" <<endl;
  }
  else
  {
      cout << "No" <<endl;
  }

  return 0;
}


Measured memory_bytes: 3760
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	private static final int M = 1_000_000_007;

	private static class Combination {
		private final int M;
		private long[] fact;
		private long[] ifact;
		private long[] inv;

		public Combination(int n, int M) {
			this.M = M;
			fact = new long[n + 1];
			ifact = new long[n + 1];
			inv = new long[n + 1];

			fact[0] = fact[1] = 1;
			ifact[0] = ifact[1] = 1;
			inv[1] = 1;

			for (int i = 2; i <= n; i++) {
				fact[i] = fact[i - 1] * i % M;
				// p = (p / a * a) + (p % a)
				// 0 ≡ (p / a * a) + (p % a)          (mod p)
				// a^(-1) ≡ - (p % a)^(-1) * (p / a)  (mod p)
				inv[i] = M - inv[M % i] * (M / i) % M;
				ifact[i] = ifact[i - 1] * inv[i] % M;
			}
		}

		public long choose(int n, int k) {
			if (n < k) return 0;
			if (n < 0 || k < 0) return 0;
			return fact[n] * (ifact[k] * ifact[n - k] % M) % M;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}

		Arrays.sort(a);
		long answer = 0;
		Combination c = new Combination(n, M);

		for (int i = 0; i < n; i++) {
			if (i >= k - 1) {
				answer += a[i] * c.choose(i, k - 1);
				answer %= M;
			}

			if (n - 1 - i >= k - 1) {
				answer -= a[i] * c.choose(n - i - 1, k - 1);
				answer %= M;
			}
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 52732
#include<bits/stdc++.h>
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
//#define pdd pair<double,double>
#define pll pair<LL,LL>
#define pb(x) push_back(x)
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define mii map<int,int>
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi 3.14159265359
//#define INF 0x7fffffff
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
using namespace std;
typedef long long LL;
int main(){
	int n;
	scanf("%d",&n);
	int a[105];
	int sub=1,sum=1;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum*=3;
		if(a[i]%2==0)
		sub*=2;
	}
	printf("%d\n",sum-sub); 
} 





Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


signed main() {
  string s, t;
  cin >> s >> t;

  int N = s.size(), M = t.size();
  vector<int> sum1(N+1), sum2(M+1);
  sum1[0] = 0; sum2[0] = 0;

  FOR(i, 1, N+1){
    if(s[i-1] == 'A') sum1[i] = sum1[i-1]+1;
    else sum1[i] = sum1[i-1]+2;
  }
  FOR(i, 1, M+1){
    if(t[i-1] == 'A') sum2[i] = sum2[i-1]+1;
    else sum2[i] = sum2[i-1]+2;
  }

  int q;
  cin >> q;

  int a, b, c, d;
  REP(i, q){
    cin >> a >> b >> c >> d;
    int x = (sum1[b]-sum1[a-1])%3;
    int y = (sum2[d]-sum2[c-1])%3;
    if(x == y) YES;
    else NO;
  }

  return 0;
}

Measured memory_bytes: 2432
N, K = map(int, input().split())

MOD = 10 ** 9 + 7


def calc(i):
    init = i * (i + 1) // 2
    last = init + (N - i + 1) * i
    return last - init + 1


ans = 0
for i in range(K, N + 2):
    #print(ans, i)
    ans += calc(i)
    ans = ans % MOD
print(ans)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <list>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <vector>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
// const ll MOD = 1000000009;


int main() {
    ll n, m;
    cin >> n >> m;
    vector<string> A(m);
    for (auto & a: A) cin >> a;

    ll matches[10] = {0,2,5,5,4,5,6,3,7,6};

    vector<pair<string,ll>> keys;
    for (auto a : A) {
        keys.push_back(make_pair(a, matches[a[0]-'0']));
    }

    vector<string> dp(n + 1, "NA");
    dp[0] = "";

    for (ll i = 1; i <= n; ++i) {
        for (auto k : keys) {
            ll j = i - k.second;
            if (j >= 0 && dp[j] != "NA") {
                if (dp[i] == "NA") {
                    dp[i] = dp[j] + k.first;
                } else {
                    if (dp[i].length() < dp[j].length() + 1) {
                        dp[i] = dp[j] + k.first;
                    } else if (dp[i].length() == (dp[j].length() + 1)) {
                        auto tmp = dp[j] + k.first;
                        if (dp[i].compare(tmp) < 0) {
                            dp [i] = tmp;
                        }
                        tmp = k.first + dp[j];
                        if (dp[i].compare(tmp) < 0) {
                            dp [i] = tmp;
                        }
                    }
                }
            }
        }
    }
    //for (auto p : dp) {
    //    cerr << p << endl;
    //}

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


Measured memory_bytes: 41856
package main

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

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func sum(n []int) int {
	a := 0
	for _, v := range n {
		a += v
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	n := getInt()
	b := make([]int, n)

	for i := range b {
		b[i] = getInt() - (i + 1)
	}
	sort.Ints(b)
	bt := b[n/2]
	ans := 0
	for i := range b {
		ans += int(math.Abs(float64(b[i] - bt)))
	}
	fmt.Println(ans)
}


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

int main() {
    int n;
    cin>>n;
    float s=(float)n;
    int res=0;
    for(int i=1;i<=n;i++){
        if(i%2==1) res++;
    }
    double f=(res)/(double)n;
    printf("%.10f\n",f);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] a = new int[1000000];



			for(int x=1; x<=100 ; x++) {
				for(int y=1 ; y<=100 ; y++) {
					for(int z=1 ; z<=100 ; z++) {
						a[x*x+y*y+z*z+x*y+y*z+z*x]++;
					}
				}
			}


			for(int i=1 ; i<=n ; i++) {
				System.out.println(a[i]);
			}



		scanner.close();

	}

}

Measured memory_bytes: 42908
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

using namespace std;
typedef pair<int, int> pii;

int main(){
    int N, K;
    cin >> N >> K;
    vector<ll> as(N);
    int max_bit = 45;
    // 10^12 2^42. 45bit?
    rep(i, N){
        cin >> as[i];
    }

    vector<ll> sums(N);
    // sums[i] - sums[j] (j,i]

    rep(i, N){
        // [0, i]
        if(i == 0){
            sums[i] = as[i];
        }else{
            sums[i] = as[i] + sums[i - 1];
        }
    }

    vector<ll> vs;

    for(int i = 0; i < sums.size(); i ++){
        vs.push_back(sums[i]);
        for(int j = i + 1; j < sums.size(); j ++){
            ll tmp = sums[j] - sums[i];
            vs.push_back(tmp);
        }
    }

    ll ans = 0;

    for(int bit = max_bit; bit > 0; bit --){
        ll tmp = ans + (1L << (bit - 1));
        int cnt = 0;
        rep(i, vs.size()){
            if((vs[i] & tmp) == tmp) cnt ++;
            if(cnt >= K){
                ans = tmp;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6388
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
main()
{
    ll n,i,ind,k;
    cin>>n>>k;
    ll ara[n];
    vector<ll>v;
    map<ll,ll>mp,e;
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&ara[i]);
    }
    ll a=1;
    while(1)
    {
        if(mp[ara[a]]==1)
        {
            break;
        }
        v.push_back(ara[a]);
        mp[ara[a]]=1;
        a=ara[a];
    }
    //cout<<v.size()<<endl;
    if(k<=v.size())
    {
        printf("%lld\n",v[k-1]);
        return 0;
    }
    for(i=0;i<v.size();i++)
    {
        if(v[i]==ara[a])
        {
            ind=i;
            break;
        }
    }
    k-=ind;
    ll d=v.size()-ind;
    k=k%d;
    if(k==0)
    {
        k+=d;
    }
    printf("%lld\n",v[ind+k-1]);
}


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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
   char a;
   cin>>a;
   if('a'<=a && a<='z') cout<<'a'<<endl;
   else cout<<'A'<<endl;
   return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<list>
#include<cctype>
#include<utility>
#include<algorithm>
#include<cctype>
using namespace std;

int main()
{
	int n;
	while(cin >>n && n!=0){
		int sum = 0;
		vector<int>s(n);
		for(int i=0;i<n;i++){
			cin >> s[i];
			sum += s[i];
		}
		double avg = (double)sum/n;
		double a=0;
		for(int i=0;i<n;i++){
			a += (s[i]-avg)*(s[i]-avg);
		}
		a /= n;
		printf("%.7f\n",sqrt(a));
	}

    return 0;
}

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

#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

string s;
int n, k;

//組み合わせの計算
const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//初期化
void COMinit() {
    fac[0]  = fac[1]  = 1;
    finv[0] = finv[1] = 1;
    inv[1]  = 1;

    for(int i = 2; i < MAX; ++i){
        fac[i]  = fac[i - 1] * i % MOD;
        inv[i]  = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
//nCk
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;

    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll calc(int digit, int keta, bool issmall){
    if(digit == n){
        //０でない数字が０個欲しい場合は１つ存在する
        if(keta == 0)return 1;
        else return 0;
    }
    //０でない数字が０個欲しい場合は１つ存在する
    if(keta == 0)return 1;

    //今ある桁以下で全部１〜９まで使えるなら、nCk*9^k個存在する
    if(issmall)return COM(n-digit, keta) * pow(9, keta);
    else {
        //0の場合は何もしない
        if(s[digit] == '0') return calc(digit+1, keta, false);
        else{
            //今の桁は0、なので必ずsより小さくなる
            ll zero = calc(digit+1, keta, true);
            //今の桁の数を1つ減して０でない数に、これは桁の数−１個ぶんある
            ll reduce = calc(digit+1, keta-1, true) * (s[digit]-'1');
            //今の桁をそのまま使う
            ll stay = calc(digit+1, keta-1, false);

            return zero + reduce + stay;

        }
    }
}

int main(){
    cin >> s >> k;
    n = s.size();

    COMinit();

    ll ans = calc(0, k, false);

    cout << ans << endl;
}

Measured memory_bytes: 12160
# coding: utf-8
# Your code here!
import fractions
from functools import reduce
N=int(input())
L=[]
for i in range(N):
    L.append(int(input()))
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
    
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
print(lcm_list(L))

Measured memory_bytes: 63980
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+15;
int notp[maxn];
int sum[maxn];
void isprime(){
	memset(notp,0,sizeof(notp));
	notp[1]=1;
	notp[0]=1;
	for(int i=2;i<maxn;i++){
		if(!notp[i]){
			for(int j=i+i;j<maxn;j+=i)
			  notp[j]=1;
		}
	}
}
int main(){
	isprime();
	memset(sum,0,sizeof(sum));
	for(int i=1;i<maxn;i++){
		if(i%2){
		if(!notp[i]&&!notp[(i+1)/2])
	      sum[i]=sum[i-1]+1;
	    else
	      sum[i]=sum[i-1];
		}else sum[i]=sum[i-1];
	}
	int n,l,r;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&l,&r);
		printf("%d\n",sum[r]-sum[l-1]);
	}
	return 0;
}

Measured memory_bytes: 1408
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[][] T = new int[2][N];
        for(int i = 0; i < N; i++){
            T[0][i] = sc.nextInt();
            T[1][i] = sc.nextInt();
        }
        sc.close();

        long numT = 1;
        long numA = 1;
        long t, a, min;
        for(int i = 0; i < N; i++){
            if(numT%T[0][i] == 0)
                t = numT/T[0][i];
            else
                t = numT/T[0][i]+1;
            if(numA%T[1][i] == 0)
                a = numA/T[1][i];
            else
                a = numA/T[1][i]+1;
            min = Math.max(t, a);
            numT = min*T[0][i];
            numA = min*T[1][i];
        }

        System.out.println(numT+numA);
    }
}

Measured memory_bytes: 25576
n,l = map(int,input().split())

li = [i+l-1 for i in range(1,n+1)]

s = sum(li)

res = 1000
ans = 0

for i in li:
    t = s-i
    if res > abs(s-t):
        ans = i
        res = abs(s-t)
    
print(sum(li)-ans)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
int main() {
	string S;
	cin >> S;
	int one = 0;
	int zero = 0;
	for (int i = 0; i < S.size(); ++i) {
		if (S[i] == '0') {
			zero++;
		}
		else {
			one++;
		}
	}
	cout << min(one, zero) * 2 << endl;
	return 0;
}



Measured memory_bytes: 512
# -*- coding: utf-8 -*-
N = int(input())

ans = 0
stack = ['7', '5', '3']
while len(stack) != 0:
    nums = stack.pop()
    if int(nums) > N:
        pass

    else:
        if all([nums.count(c) > 0 for c in '753']):
            ans += 1

        for c in '753':
            stack.append(nums + c)



print(ans)




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

int main() {
  int n;
  while (cin >> n) {
    if (n == 0) break;
    int v[n + 1][n + 1];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        cin >> v[i][j];
      }
    }
    // x
    for (int i = 0; i < n; i++) {
      int sum = 0;
      for (int j = 0; j < n; j++) {
        sum += v[i][j];
      }
      v[i][n] = sum;
    }
    // y
    for (int j = 0; j < n; j++) {
      int sum = 0;
      for (int i = 0; i < n; i++) {
        sum += v[i][j];
      }
      v[n][j] = sum;
    }
    int k = 0;
    for (int i = 0; i < n; i++) {
      k += v[n][i];
    }
    v[n][n] = k;

    for (int i = 0; i <= n; i++) {
      for (int j = 0; j <= n; j++) {
        cout << setw(5) << right << v[i][j];
      }
      cout << endl;
    }
  }
}



Measured memory_bytes: 3080
#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

using namespace std;

int my_abs(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

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

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

int main() {
    string S;
    cin >> S;
    if (S.size() == 2) {
        cout << S << endl;
    }
    if (S.size() == 3) {
        char A = S.at(0);
        S.at(0) = S.at(2);
        S.at(2) = A;
        cout << S << endl;
    }
}


Measured memory_bytes: 256
N,X,Y = map(int,input().split())
A=[0 for a in range(N-1)]
for j in range(N):
 for i in range(j):
  S=min(j-i,abs(X-(i+1))+abs(Y-(j+1))+1)
  A[S-1]+=1
for i in range(N-1):
 print(A[i])


Measured memory_bytes: 3444
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }


const ll mod = 1e9+7;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, X; cin >> N >> X;
    vl S(N); rep(i, N) cin >> S[i];
    sort(ALL(S));
    
    vvl dp(N+1, vl(X+1, 0)); rep(x, X+1) dp[0][x]=x;
    rep(i, N){
        rep(x, X+1){
            dp[i+1][x] += (dp[i][x%S[i]] + i*dp[i][x])%mod;
            dp[i+1][x] %= mod;
        }
    }
    cout << dp[N][X] << endstr;
    return 0;
}


Measured memory_bytes: 158592
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;
using namespace chrono;
 
typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

//#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define loop(x,n) for(int x = 0; x < n; ++x)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define resz resize

const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 100001;

string get_str() {
    string temp;
    cin >> temp;
    return temp;
}
int get_int() {
    int temp;
    cin >> temp;
    return temp;
}

ll n, a[200001], s;
bool first = false;


int main() {
    cin >> n;

    loop(i, n) {
        cin >> a[i];
        if(!first) {
            s = a[i];
            first = true;
        }
        else s = s ^ a[i];
    }

    loop(i, n) {
        cout << (s ^ a[i]) << " ";
    }
    cout << endl;

}

Measured memory_bytes: 5112
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
//namespace
using namespace std;
//#define , typedef, const
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)

#define all_range(C) begin(C), end(C)

typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

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

//main.cpp----------------------------

void solve();

int n, k;

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

  solve();

  return 0;
}

void solve() {

  int i = 0;
  ll sum = k;

  while(i<n-1) {
    sum *= (k-1);
    ++i;
  }

  cout << sum << endl;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
class UnionSet
{
public:
	int fa[N];
	int minv[N];
	void init()
	{
		MEM(fa, -1);
		for (int i = 1; i < N; i++) minv[i] = i;
	}
	int getmin(int x)
	{
		int px = Find(x);
		return minv[px];
	}
	int treesize(int x)
	{
		return -fa[Find(x)];
	}
	int Find(int x)
	{
		int root = x;
		while (fa[root] >= 0) root = fa[root];
		while (x != root)
		{
			int tmp = fa[x];
			fa[x] = root;
			x = tmp;
		}
		return root;
	}
	void Union(int x, int y)
	{
		int px = Find(x);
		int py = Find(y);
		int mv = min(minv[px], minv[py]);
		if (fa[px] > fa[py]) swap(px, py);
		int sz = fa[px] + fa[py];
		fa[py] = px;
		fa[px] = sz;
		minv[px] = mv;
	}
} uf;
int a[N];
int pos[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	uf.init();
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		pos[a[i]] = i;
	}
	LL ans = 0;
	for (int i = n; i > 0; i--)
	{
		int p = pos[i];
		LL l, r;
		l = r = 0;
		int lmin, rmin;
		lmin = rmin = 0;
		if (p > 1)
		{
			lmin = uf.getmin(a[p - 1]);
			if (lmin > i) l = uf.treesize(a[p - 1]);
		}
		if (p < n)
		{
			rmin = uf.getmin(a[p + 1]);
			if (rmin > i) r = uf.treesize(a[p + 1]);
		}
		ans += (l*r + 1 + l + r)*i;
		if (lmin > i) uf.Union(lmin, i);
		if (rmin > i) uf.Union(rmin, i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include "stdio.h"
int main(int argc, char const *argv[])
{
	int a[3],b[3],c[3][3];
	for (int i = 0; i < 3; i++){
		for (int j = 0; j < 3; j++) scanf("%d",&a[j]);
		for (int j = 0; j < 3; j++) scanf("%d",&b[j]);
		for (int j = 2; j > -1; j--){
			if(a[j]>b[j]){
				b[j-1]--;
				b[j]+= 60;
			}
			c[i][j] = b[j] - a[j]; 
		}
	}
	for(int i=0;i<3;i++){
		printf("%d",c[i][0]);
		for (int j = 1; j < 3; j++)
		{
			printf(" %d", c[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int A[100005],id[100005],vis[100005];
int cur[100005],id2[100005];ll k;
void sv(int a)
{
	int t = id[a];
	int c = 0;
	cur[++ c] = a;vis[a] = 1; 
	while(t != a)
		cur[++ c] = t,vis[t] = 1,t = id[t];
	int r = k%c;
	for(int i = 1;i <= c;i ++)
		id2[cur[i]] = cur[(i+r-1)%c+1];
}
int main()
{
	int n,m;
	scanf("%d",&n);
	for(int i = 1;i <= n;i ++)
		scanf("%d",&A[i]),id[i] = i;
	scanf("%d%lld",&m,&k);
	for(int i = 1;i <= m;i ++)
	{
		int a;
		scanf("%d",&a);
		swap(id[a],id[a+1]);
	}
	for(int i = 1;i <= n;i ++)
		if(!vis[i])
			sv(i);
	ll t = A[1];printf("%lld.0\n",t); 
	for(int i = 2;i <= n;i ++)
	{
		t += A[id2[i]]-A[id2[i]-1];
		printf("%lld.0\n",t);
	}
	return 0;
}

Measured memory_bytes: 3456
s = int(input())
list = [s]
bool = True
while bool:
    if list[-1]%2 ==0:
        if int(list[-1]/2) in list:
            bool = False
        list.append(int(list[-1]/2))
    else:
        if int(list[-1]*3 + 1) in list:
            bool = False
        list.append(int(list[-1]*3 + 1))
print(len(list))

Measured memory_bytes: 3060
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	ll res = 0;
	map<int, ll> mp;
	rep(i, n)
	{
		int a; cin >> a;
		res += a;
		++mp[a];
	}
	int q; cin >> q;
	while (q--)
	{
		int b, c; cin >> b >> c;
		res += mp[b] * (c - b);
		mp[c] += mp[b];
		mp[b] = 0;
		cout << res << endl;
	}
}

Measured memory_bytes: 9520
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int k = scanner.nextInt();
		int tmp = 0;
		int[] ary = new int[k];
		for(int n=100; n>0; n--) {
			if(a%n==0 && b%n==0) {
				ary[tmp]= n;
				tmp++;
			}
			
			if(tmp==k)break;
		}
		System.out.println(ary[k-1]);
	}

}

Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {

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

        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();

        long a[][] = new long[n][m];
        long b[][] = new long[m][l];

        long c[][] = new long[n][l];

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                a[i][j] = sc.nextLong();
            }
        }
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < l; j++) {
                b[i][j] = sc.nextLong();
            }
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                for (int k = 0; k < l; k++) {
                    c[i][k] += a[i][j]*b[j][k];
                }
            }
        }

        for (int i=0; i<n; i++) {
            for (int j=0; j<l-1; j++) {
                System.out.print(c[i][j]+" ");
            }
            System.out.println(c[i][l-1]);
        }

    }
}

Measured memory_bytes: 53864
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string S, T, U;
	int A, B;
	cin >> S >> T;
	cin >> A >> B;
	cin >> U;
	if (U == S&&S != T)
		cout << A - 1 <<' '<< B << endl;
	else 
		cout << A <<' '<< B - 1 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define M 5005
#define mod 1000000007
int n,D[M];
long long fac[M],inv[M],fac_inv[M],F[M][M][2],ans;
int read(){
    char c=getchar();int ans=0;
    while (c<'0'||c>'9') c=getchar();
    while (c>='0'&&c<='9') ans=ans*10+c-'0',c=getchar();
    return ans;
}
void Write(long long x){
    if (x<10) putchar(x^48);
    else Write(x/10),putchar((x%10)^48);
    return;
}
int main(){
    n=read();bool flag=1;
    fac[0]=fac[1]=inv[1]=fac_inv[0]=fac_inv[1]=1;
    for (register int i=2;i<=n;i++)
        fac[i]=fac[i-1]*i%mod,
        inv[i]=(mod-mod/i)*inv[mod%i]%mod,
        fac_inv[i]=fac_inv[i-1]*inv[i]%mod;
    for (register int i=1;i<=n;i++) D[i]=read(),flag&=(D[i]==2);
    if (flag){Write(fac[n-1]*inv[2]%mod);return 0;}//特判
    F[0][0][0]=1;
    for (register int i=0;i<n;i++)
        for (register int j=0;j<=i;j++)
            for (register int k=0;k<2;k++){
                if (D[i+1]>0)//树点
                    F[i+1][j][k]=(F[i+1][j][k]+F[i][j][k]*fac_inv[D[i+1]-1])%mod;
                if (D[i+1]>1)//普通环点
                    F[i+1][j+1][k]=(F[i+1][j+1][k]+F[i][j][k]*fac_inv[D[i+1]-2])%mod;
                if (D[i+1]>2&&!k)//特殊环点
                    F[i+1][j+1][1]=(F[i+1][j+1][1]+F[i][j][k]*fac_inv[D[i+1]-3])%mod;
            }
    for (register int i=3;i<n;i++)
        ans=(ans+F[n][i][1]*fac[n-i-1]%mod*fac[i-1]%mod*inv[2])%mod;
    Write(ans);
    return 0;
}

Measured memory_bytes: 22912
n,m = map(int,input().split())
lis = list(map(int,input().split()))
path = [1 for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    if lis[a-1] >= lis[b-1]:
        path[b-1] = 0
    if lis[a-1] <= lis[b-1]:
        path[a-1] = 0
print(path.count(1))

Measured memory_bytes: 20096
from collections import deque
 
N, *AB = map(int, open(0).read().split())
B = AB[1::2]
 
E = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
    E[a].append(b)

Q = deque([1])
C = [0] * (N + 1)
while Q:
    v = Q.popleft()
    c = 0
    for u in E[v]:
        c += 1 + (c + 1 == C[v])
        C[u] = c
        Q.append(u)

print(max(C))
for b in B:
    print(C[b])

Measured memory_bytes: 25892
#include<iostream>
#include<functional>
#include<algorithm>
using namespace std;

int main(){
    int num;
    cin>>num;
    int sum=0;
    int test[num];
    for(int i=1;i<=num;i++){
        cin>>test[i];
        sum+=test[i];
    }
    
    for(int j=1;j<=num-1;j++){
        for(int k=j+1;k<=num;k++){
            test[j]=max(test[j],test[k]);

        }
    }
    int all=sum-test[1];
    if(test[1]<all){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, A;
	cin >> N >> A;
	cout << N * N - A << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int A, B, T;
    cin >> A >> B >> T;
    cout << B * (T / A) << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int n;
    cin >> n;
    vector<int> cnt(n + 1);
    for (int i = 1; i <= n - 1; i++)
    {
        int t;
        cin >> t;
        cnt[t]++;
    }
    for (int i = 1; i <= n; i++)
    {
        cout << cnt[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
main()
{
    long long x;
    cin>>x;
    long long init=100;
    int c=0;
    while(init<x)
    {
        long long d=init/100;
        init+=d;
        c++;
    }
    cout<<c<<endl;
    
}

Measured memory_bytes: 3632
# Aizu Problem 0004: Simultaneous Equation
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input2.txt", "rt")


for line in sys.stdin:
    a, b, c, d, e, f = [int(_) for _ in line.split()]
    det = a * e - b * d
    det1 = c * e - b * f
    det2 = a * f - c * d
    #x = str(round(det1 / det, 3))
    #y = str(round(det2 / det, 3))
    x = det1 / det + 0
    y = det2 / det + 0
    #if -.001 < x < 0:
    #    x = 0
    print("%.3f %.3f" % (x, y))

Measured memory_bytes: 7756
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p = sorted(p)[::-1]
q = sorted(q)[::-1]
r += p[:x]
r += q[:y]
ans = sum(sorted(r)[::-1][:x+y])
print(ans)

Measured memory_bytes: 24496
import itertools

N = int(input())
P = [x for x in input().split()]
Q = [x for x in input().split()]

P = int(''.join(P))
Q = int(''.join(Q))

lst = []
for a in list(itertools.permutations(range(1, N + 1))):
    a = [str(b) for b in a]
    a = ''.join(a)
    a = int(a)

    lst.append(a)

lst.sort()
dic = {}
for i, a in enumerate(lst):
    dic[a] = i + 1

ans = abs(dic[P] - dic[Q])
print(ans)



Measured memory_bytes: 9588
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
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;
    }
}




Measured memory_bytes: 3556
import java.util.Scanner;

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

        int dataCount = sc.nextInt();

        while (dataCount != 0) {
            int[] scores = new int[dataCount];

            int sum = 0;
            double ave = 0, div = 0, var = 0, stdiv = 0;

            for (int i = 0; i < dataCount; i++) {
                scores[i] = sc.nextInt();

                sum += scores[i];
            }
            ave = (double) sum / dataCount;

            for (int i = 0; i < dataCount; i++) {
                div = scores[i] - ave;
                var += div * div;
            }
            var /= dataCount;

            stdiv = Math.sqrt(var);

            System.out.println(stdiv);

            dataCount = sc.nextInt();
        }

        sc.close();
    }
}


Measured memory_bytes: 31536