akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
template <typename T, typename U>ostream &operator<<(ostream &out, const pair<T, U> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>void print(const ContainerType<ValueType, Args...> &c){for (const auto &v : c)cout << v << ' ';cout << '\n';} void print(){cout<<'\n';}
template <typename T, typename... Args>void print(T a, Args... args){cout << a << " ";print(args...);}
lli llipower(lli x, lli y, lli p = LLONG_MAX){lli res = 1;x = x % p;while (y > 0){if (y & 1)res = (res * x) % p;y = y >> 1;x = (x * x) % p;}return res;}

//8====================================D
int main(){
    vector<int> a(5);
    fori(5) cin>>a[i];
    fori(5){
        if(a[i]==0){
            cout<<i+1<<endl;
            return 0;
        }
    }

}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        String in = input.nextLine();
        char[] ch = in.toCharArray();
        for(int i = 0; i < in.length(); i ++ ){
            if(ch[i] >= 'A' && ch[i] <= 'Z')
                ch[i] = (char)(ch[i] - 'A' + 'a');
            else if(ch[i] >= 'a' && ch[i] <= 'z')
                ch[i] = (char)(ch[i] - 'a' + 'A');
        }
        System.out.println(in.valueOf(ch));
    }
}


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

int main()
{int N,K;
long sum = 0;
cin >> N >> K;
vector<int> hpofmonster(N);
for(int i = 0;i<N;i++){
  cin >> hpofmonster[i];
}
sort(hpofmonster.begin(),hpofmonster.end());
for(int i = 0;i<N-K;i++){
   sum += hpofmonster[i];
}
cout << sum;
return 0;
}

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

#define ll long long int
#define li long int
#define ar array

#define min2(a,b) a < b ? a : b
#define max2(a,b) a < b ? b : a

#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)

const int nax=1e5+5;
// int adj[nax][nax];
vector<int> adj[nax];
bool visited[nax];
int cnt;
int n;

bool sorter2(const pair<li,li> &a, 
              const pair<li,li> &b) 
{ 
    return (a.second < b.second); 
} 

void explore(int v){
	visited[v]=true;
	for (int u:adj[v]){
		if(!visited[u]){
			explore(u);
		}
	}
}

void dfs(){
	for(int v=1;v<=n;v++){
		if (!visited[v]){
			cnt++;
			explore(v);
		}
	}
}

int main(){
	#ifndef ONLINE_JUDGE		
	    freopen("input.txt", "r", stdin);
	    freopen("output.txt", "w", stdout);
	#endif
	    
	ios::sync_with_stdio(0);

	int m;
	cin >> n >> m;

	for(int i=0;i<m;i++){
		int v,u;
		cin >> v >> u;

		// adj[v][u]=1;
		// adj[u][v]=1;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	cnt=0;
	dfs();

	cout << cnt-1 << endl;
}

Measured memory_bytes: 9712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n,h;
  cin >> n >> h;
  vector<ll> a(n),b(n);
  ll maxi=0,maxi_b;
  rep(i,n){
    cin >> a.at(i) >> b.at(i);
    if(maxi<a.at(i)){
      maxi=a.at(i);
      maxi_b=b.at(i);
    }
  }
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  ll is=0,ans=0;
  for(ll i=0;i<n;i++){
    if(b.at(i)<=maxi){
      break;
    }
    is+=b.at(i);
    ans++;
    if(is>=h){
      cout << ans << endl;
      return 0;
    }
  }
  ans+=(h-is+maxi-1)/maxi;
  cout <<ans;
}
           


Measured memory_bytes: 4776
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<int>a(3);
    for(int i=0;i<3;i++)cin>>a[i];
    if(a[0]+a[1]+a[2]>=22)cout<<"bust"<<endl;
    else{
        cout<<"win"<<endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
  String s = sc.next();
  while(s.contains("B")){
    int idx = s.indexOf("B");
    s = (idx > 0 ? s.substring(0,idx-1) : "") + s.substring(idx+1);
  }
  System.out.println(s);
}}


Measured memory_bytes: 23380
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

a, b, c = Is()
s = set()
s.add(a)
s.add(b)
s.add(c)
print(len(s))

Measured memory_bytes: 63340
//  0206.cpp
//  2012/09/03.

#if 1

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
    int L;
	while(cin >> L && L)
	{
		int ans = 13;
		rep(i, 12)
		{
			int M, N;
			cin >> M >> N;
			
			L -= M - N;
			
			if(L <= 0) chmin(ans, i);
		}
		
		if(ans == 13) cout << "NA" << endl;
		else cout << ans + 1 << endl;
	}
}

#endif

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
using namespace std;struct road{int a,b,l;road(int a_,int b_,int l_):a(a_),b(b_),l(l_){}};typedef pair<int,int> pii;int main(){int n,m,k,a,b,l,s;vector<road> rd;vector<pii> town[3001];int len[3001];priority_queue<pii,vector<pii>,greater<pii> > qu;for(cin>>n>>m>>k;m--;rd.push_back(road(a,b,l))){cin>>a>>b>>l;town[a].push_back(make_pair(b,l));town[b].push_back(make_pair(a,l));}for(;k--;qu.push(make_pair(0,s)))cin>>s;for(fill(len,len+n+1,-1);!qu.empty();){pii pi = qu.top();qu.pop();if( len[pi.second] == -1 ){len[pi.second] = pi.first;for(vector<pii>::iterator it=town[pi.second].begin();it != town[pi.second].end();++it){qu.push(make_pair(pi.first+it->second,it->first));}}}s=0;for(vector<road>::iterator it = rd.begin(); it != rd.end();++it ){s = max(max( s, len[a] ),max( len[b], (len[it->b] + it->l - len[it->a] + 1)/2 + len[it->a] ));}cout << s << endl;}

Measured memory_bytes: 0
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string t, p;
  cin >> t >> p;
  FOR(i,0,t.length()){
    int cnt = 0;
    for(int j = 0; j < p.length() && i+j<t.length(); j++){
      if(t[i+j]==p[j]) cnt++;
    }
    if(cnt==p.length()){
      cout<<i<<endl;
    }
  }
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str1,str2,str3;
    int a,b;
    cin>>str1>>str2>>a>>b>>str3;
    if(str3 == str1) cout<<a-1<<" "<<b<<endl;
    else cout<<a<<" "<<b-1<<endl;
}

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

int N;
int A[20];
int x[20][20];
int y[20][20];

int counter(int x){
  if (!x) return 0;
  return counter(x >> 1) + (x & 1);
}

int main(){
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    for (int j = 0; j < A[i]; j++) {
      cin >> x[i][j] >> y[i][j];
      x[i][j]--;
    }
  }
  
  int ans = 0;
  
  for (int bits = 0; bits < (1 << N); bits++) {
    bool flag = true;
    for (int i = 0; i < N; i++) {
      if (!(bits & (1 << i))) continue;
      for (int j = 0; j < A[i]; j++) {
        if ((bits >> x[i][j]) & 1 ^ y[i][j]) flag = false;
      }
    }
    if (flag) ans = max(ans, counter(bits));
  }
  
  cout << ans;
  return 0;
}

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



int main(){
    int A,B;
    cin >> A >> B;
    string S;
    cin >> S;
    string ans = "Yes";

    for(int i = 0;i<A;i++){
        if(S.at(i) >= '0' && S.at(i) <= '9'){ 
        }
        else{
            ans = "No";
        }
    }

    if(S.at(A) != '-'){
        ans = "No";
    }

    for(int j = A+1;j<A+B;j++){
        if(S.at(j) >= '0' && S.at(j) <= '9'){ 
        }
        else{
            ans = "No";
        }
    }

    cout << ans << endl;
    

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 998244353
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, s; cin >> n >> s;
    vi a(n);
    rep(i, n) cin >> a[i];
    vvi dp(n+1, vi(s+1, 0));
    dp[0][0] = 1;

    for(ll i=1; i<=n; i++){
        for(ll j=0; j<=s; j++){
            dp[i][j] = (dp[i][j]+dp[i-1][j]*2)%MODV;
            if(j+a[i-1] <= s){
                dp[i][j+a[i-1]] = (dp[i][j+a[i-1]]+dp[i-1][j])%MODV;
            }
        }
    }
    cout << dp[n][s] << endl;
}

Measured memory_bytes: 73696
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    VI a(2);
    rep(i,2)cin >> a[i];
    SORT(a);
    if((a[1] - a[0]) % 2 == 0){
        cout << (a[1] - a[0]) / 2 + a[0] <<endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    String ans = "Yes";
    if(((a * b) % 2) == 0) ans = "No";
    System.out.println(ans);
  }
}

Measured memory_bytes: 23636
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, T;
    cin >> n >> T;
    int ans = Inf;
    int count = 0;
    rep(i, n) {
      int c, t;
      cin >> c >> t;
      if (t <= T) {
        ans = min(ans, c);
        ++count;
      }
    }

    if (count != 0) {
      cout << ans << '\n';
    } else {
      cout << "TLE" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())

Info = [[] for T in range(0,N)]
for I in range(0,N):
    Info[I] = [int(T) for T in input().split()]
Info = sorted(Info,reverse=True,key=lambda X:X[2])
for CX in range(0,101):
    for CY in range(0,101):
        Flag  = True
        BaseH = abs(Info[0][0]-CX)+abs(Info[0][1]-CY)+Info[0][2]
        for I in range(1,N):
            if max(BaseH-abs(Info[I][0]-CX)-abs(Info[I][1]-CY),0)!=Info[I][2]:
                Flag = False
                break
        if Flag:
            Ans = [str(CX),str(CY),str(BaseH)]
            break
    if Flag:
        break
print(' '.join(Ans))

Measured memory_bytes: 9232
N=int(input())
L={}
for i in range(N):
    a,b=input().split()
    if a in L.keys():
        L[a].append([int(b),i+1])
    else:
        L[a]=[[int(b),i+1]]
L1= sorted(L.items(), key=lambda x:x[0])
for i in range(len(L1)):
    a=L1[i][1]
    a.sort(key=lambda x:x[0],reverse=True)
    for j in range(len(a)):
        print(a[j][1])

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

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

  int ans = 2 * N;
  for (int i = N; i >= 1; i--) {
    //cout << s.substr(N - i, i) << ":" << t.substr(0, i) << endl;
    if (s.substr(N - i, i) == t.substr(0, i)) {
      ans -= i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(void){
    int n,d;
    scanf("%d%d",&n,&d);
    int X[n][d];
    for(int i = 0;i < n;i++){
        for(int j = 0;j < d;j++){
            scanf("%d",&X[i][j]);
        }
    }
    int count = 0;
    for(int i = 0;i < n;i++){
        for(int j = i;j < n;j++){
            int sum = 0;
            if(i != j){
                for(int k = 0;k < d;k++){
                    sum += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
                }
                double ans = sqrt((double)sum);
                if ((int)ans == ans) {
                    count++;
                }
            }
        }
    }

    printf("%d",count);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

bool is_prime(unsigned int n){
    if(n <= 1) return false;
    if(n == 2) return true;

    if(n%2 == 0) return false;

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

    return true;
}

vector<bool> IsPrime;

void PrimeTable(int N){
    IsPrime = vector<bool>(N+1, true);
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(int i=2; i*i<=N; ++i){
        if(IsPrime[i]){
            for(int j=2; i*j<=N; ++j){
                IsPrime[i*j] = false;
            }
        }
    }
}

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

    PrimeTable(100001);
    vector<int> ans(100001, 0);
    ans[1] = 0;
    REP(i, 100001){
        if(i%2 == 0) ans[i] = 0;
        else{
            if(IsPrime[i] && IsPrime[(i+1)/2]) ans[i]++;
            ans[i] += ans[i-2];
        }
    }

    int Q;
    cin >> Q;
    REP(i, Q){
        int l, r;
        cin >> l >> r;
        cout << ans[r]-ans[l-2] << "\n";
        
    }
    return 0;
}

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

int n, k, ans=0, a[1003];

int main(){
	cin >> n >> k;
	for (int i=0;i<n;i++) cin >> a[i];
	sort(a,a+n);
	for (int i=0;i<k;i++) ans+=a[i];
	cout << ans << "\n";
}

Measured memory_bytes: 3636
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;
 
long long gcd(long long x, long long y){
			if (x==0)return y;
      if(y==0)return x;
      if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }

   
int main(){
int N;
cin >> N;
vector<int> A(N);
vector<int> left(N+1,0);
vector<int> right(N+1,0);
for(int i = 0; i < N; i++){
  cin >> A[i];
}
for(int i = 0; i < N;i++)left[i+1] = gcd(left[i],A[i]);
for(int i = N-1; i >= 0;i--)right[i] = gcd(right[i+1],A[i]);
long long ans = 1;
for(int i = 0; i <= N;i++){
  long long r = right[i+1];
  long long l = left[i];
  ans = max(ans,gcd(l,r));
  
}
cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;


int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int a, b; cin >> a >> b;
  int d = b - a;
  cout << d * (d + 1) / 2 - b << '\n';
  return 0;
}

Measured memory_bytes: 256
n, k, s = gets.split.map(&:to_i)
if s < 10 ** 9
  ans = [s] * k
  ans += [s + 1] * (n - k)
  puts ans * ' '
else
  ans = [10 ** 9] * k
  ans += [1] * (n - k)
  puts ans * ' '
end

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << min(A, B) + min(C, D) << endl;
    return 0;
}


Measured memory_bytes: 3600
use std::cmp;

fn n_digits(n: u64) -> u64 {
  let mut ans = 1;
  let mut tmp = n;
  while tmp >= 10 {
    ans += 1;
    tmp /= 10;
  }
  return ans;
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf);
    let mut s = buf.split_whitespace();
    let n: u64 = s.next().unwrap().parse().unwrap();

    let mut i = 0;
    let mut ans = 20;
    while i*i <= n {
      i += 1;
      
      if n % i != 0 { continue; }

      let j = n / i;
      let cur = cmp::max(n_digits(i), n_digits(j));
      ans = cmp::min(ans, cur);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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

int main(){

    int n;
    cin >> n;
    string s[n];
    int cnt[n][26] = {0};
    for(int i = 0; i < n; i++){
        cin >> s[i];
        for(int j = 0; j < (int)s[i].size(); j++){
            cnt[i][s[i][j] - 'a']++;
        }
    }
    for(int i = 0; i < 26; i++){
        int tmp = 100;
        for(int j = 0; j < n; j++){
            if(cnt[j][i] < tmp) tmp = cnt[j][i];
        }
        for(int k = 0; k < tmp; k++) cout << char('a' + i);
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 3640
import sys
input = sys.stdin.readline

k = int(input())

res = 1
a = 7%k
p = 7

d = set()

while True:
    if a == 0:
        print(res)
        exit()
    p = p*10%k
    a = (a+p)%k
    res += 1
    if a in d:
        print(-1)
        exit()
    d.add(a)
print(-1)

Measured memory_bytes: 156920
/*
swap????????則??????????????則?????属????属??????????????????則??????
*/
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main() {
    int i,j,k;
    int n;
    char buf;
    int A[100];
    
    cin >> n;
    for(k=0; k<n; k++) cin >> A[k];
 
    for(k=0; k<n; k++){
         cout << A[k];
         if(k!=n-1) cout << ' ';
         else cout << endl;
    }
 
    
    for(j=1; j<n; j++){
         for(i=j-1; i>=0; i--){
             if(A[i+1]<A[i]) swap(A[i+1],A[i]);
         }
         for(k=0; k<n; k++){
             cout << A[k];
             if(k!=n-1) cout << ' ';
             else cout << endl;
         }
    }
    
        return 0;
}
 

Measured memory_bytes: 1160
/**
 *    DP
 *    27.04.2020 14:06
**/

#include <bits/stdc++.h>

using namespace std;

const int nx = 305;
long double ev[nx][nx][nx]; // ev[cnt[1]][cnt[2]][cnt[3]]
int cnt[4];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, x;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    cnt[x]++;
  }
  /*
    EV(i, j, k) = expected number of trials to reach state (i, j, k)
    want to find EV(0, 0, 0): when all of 1, 2, 3 sushi plates are 0
    
    EV(0, 0, 0) = EV(success) + EV(1, 0, 0)
    EV(success) = expected number of trials to reach that 1 sushi plate
                  1/p, where p = probability of success
                  p = number of filled sushi plates / n
    EV(1, 0, 0) = expected number of trials to reach 1, 0, 0 from
                  initial E(cnt[1], cnt[2], cnt[3])
    total plates = i + j + k
    EV(i, j, k) = n / total plates +
                  i / total plates * E(i + 1, j, k) +
                  j / total plates * E(i - 1, j + 1, k) +
                  k / total playes * E(i, j - 1, k + 1)
    loop bottom up
  */

  for (int k = 0; k < nx; k++) {
    for (int j = 0; j + k < nx; j++) {
      for (int i = 0; i + j + k < nx; i++) {
        if (i + j + k == 0 || i + j + k > n) continue;
        double total_plates = i + j + k;
        double ev_success = double(n) / total_plates;
        double p_i = double(i) / total_plates;
        double p_j = double(j) / total_plates;
        double p_k = double(k) / total_plates;
        if (i) ev[i][j][k] += p_i * ev[i - 1][j][k];
        if (j) ev[i][j][k] += p_j * ev[i + 1][j - 1][k];
        if (k) ev[i][j][k] += p_k * ev[i][j + 1][k - 1];
        ev[i][j][k] += ev_success;
      }
    }
  }
  cout << fixed << setprecision(16) << ev[cnt[1]][cnt[2]][cnt[3]] << "\n";
  return 0;
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF=1e9+7;
typedef pair<int,int> P;

int main() {
    int N,M;
    cin >> N >> M;
    vector<P> s(N),c(M);
    rep(i,N)
        cin >> s.at(i).first >> s.at(i).second;
    rep(i,M)
        cin >> c.at(i).first >> c.at(i).second;
    
    rep(i,N) {
        int mi, mv=INF;
        rep(j,M) {
            int t = abs(s.at(i).first-c.at(j).first)+abs(s.at(i).second-c.at(j).second);
            if(t < mv) {
                mv = t;
                mi = j+1;
            }
        }
        cout << mi << endl;
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <typeinfo>

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REP1(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREP1(i, x) for (int i = ((int)(x)); i > 0; i--)
/*
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

#define all(x) (x).begin(),(x).end()
*/

using namespace std;

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

    int add = 0;
    for (int i = 0; i < 3;i++){
        if(s[i]=='o')
            add+=100;
    }

    cout << 700 + add;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
void maxHeapify(int H[], int n, int i)
{
	int flag = 1;
	while (2 * i <= n && flag)
	{
		int max = H[i] > H[2 * i] ? i : 2 * i;
		if (2 * i + 1 <= n)
			max = H[max] > H[2 * i + 1] ? max : 2 * i + 1;
		if (H[max] != H[i])
		{
			swap(H[i], H[max]);
			i = max;
		}
		else
			flag = 0;
	}
}
void buildMaxHeap(int H[],int n)
{
	for (int i = n / 2; i >= 1; i--)
		maxHeapify(H, n, i);
}
int main()
{
	int n;
	cin >> n;
	int *H=new int[n];
	for (int i = 1; i <= n; i++)
		cin >> H[i];
	buildMaxHeap(H, n);
	for (int i = 1; i <= n; i++)
			cout <<" "<< H[i];
	cout << endl;
	delete[] H;
}


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

ll mod = 1e9 + 7;

int main() {
    int n; cin >> n;
    int a[100100];
    for(int i=1; i<=100; i++) {
        for(int j=1; j<=100; j++) {
            for(int k=1; k<=100; k++) {
                int num = (i + j) * (i + j) + (j + k) * (j + k) + (k + i) * (k + i);
                num /= 2;
                a[num]++;
            }
        }
    }
    for(int i=1; i<=n; i++) cout << a[i] << endl;
}

Measured memory_bytes: 3800
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
		 static int a_dist[];
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();	
	        int M = sc.nextInt();	
	        long[][] a = new long[M][2];
	        for (int i=0 ; i<M; i++) {
	            a[i][0] = Long.parseLong(sc.next());
	            a[i][1] = Long.parseLong(sc.next());
	        }

	        Arrays.sort(a, (b, c) -> Long.compare(b[1], c[1]));
	        long now=0;
	        long ans=0;
	        for(int i=0;i<M;i++) {
	        	if(a[i][0]>=now) {
	        		now=a[i][1];
	        		ans++;
	        	}
	        }
	        
	        System.out.println(ans);
		 }
		 
	}

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

void lsd_string_radix(vector<string>& arr, int W)
{
	const auto N = arr.size();
	const int R = 26;

	vector<string> temp (N);

	for (auto i = W - 1; i >= 0; i--)
	{
		int count[R+1] = { 0 };

		for (auto j = 0; j < N; j++)
		{
			count[static_cast<int>(arr[j][i]) - 96]++;
		}

		for (auto r = 0; r < R-1; r++)
			count[r+1] += count[r];

		for (auto j = 0; j < N; j++)
			temp[count[static_cast<int>(arr[j][i]) - 97]++] = arr[j];

		for (auto j = 0; j < N; j++)
			arr[j] = temp[j];
	}
}

int main()
{

	//std::ifstream infile("C:\\a.in");
	int N, L; cin  >> N >>L;

	vector<string> a;
	for(auto i=0; i<N; ++i){
		string temp;
		cin>>temp;
		a.push_back(temp);
	}
	
	lsd_string_radix(a, L);
	for (size_t i = 0; i < N; i++)
		cout << a[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  sort(all(a), greater<ll>());
  ll ans = 0;
  rep(i, n) {
    if(i == 0) continue;
    if(i == 1)
      ans += a[0];
    else {
      ans += a[i / 2];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4840
import math

def prime_division(n):
    ans = []
    m = int(n ** 0.5)
    i = 2
    while i <= m:
        if n % i == 0:
            cnt = 0
            while n % i == 0:
                n //= i
                cnt += 1
            ans.append((i, cnt))
            m = int(n ** 0.5)
        i += 1
    if n != 1:
        ans.append((n, 1))
    return ans

#  aabaaba  count+(N-1) C (N-1)

N,M=map(int,input().split())
pms=prime_division(M)
ans = 1
for pm in pms:
    #print(pm)
    ans *= math.factorial(pm[1]+(N-1)) // (math.factorial(pm[1]) * math.factorial(N-1))

print(ans % (10 ** 9 + 7))


Measured memory_bytes: 114396
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			int p, w;
			double h;
			double min = -1;
			double bmi = 0;
			int ans = -1;
			for(int i=0;i<n;i++){
				p = sc.nextInt();
				h = sc.nextInt();
				w = sc.nextInt();
				h /= 100;
				bmi = (double)w/(h*h);
				if(i==0){
					min = Math.abs(22-bmi);
					ans = p;
				}
				else{
					if(Math.abs(22-bmi)<min){
						min = Math.abs(22-bmi);
						ans = p;
					}
				}	
			}
			System.out.println(ans);
		}
	}	
}

Measured memory_bytes: 29696
from collections import Counter

N = int(input())
S = input()

counter = Counter(S)

r = 1
for c in "RGB":
    r *= counter[c]


for i in range(N):
    for j in range(i+1, N):
        k = 2*j-i
        # print(i, j, k)
        if k < N and len({S[i], S[j], S[k]}) == 3:
            r -= 1

print(r)

Measured memory_bytes: 73972
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=200000;

int len;
char s[N+5],t[N+5];
char s1[255],t1[255];

int main()
{
	scanf("%s %s",s+1,t+1);
	len=strlen(s+1);
	for(int i=1;i<=len;i++)
	{
		if( (!s1[s[i]] || s1[s[i]] == t[i]) && (!t1[t[i]] || t1[t[i]] == s[i]))
		{
			s1[s[i]] = t[i];
			t1[t[i]] = s[i];
		}
		else
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

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

int main(void){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];

    if(a[0] + a[1] + a[2] >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
      
    return 0;
}

Measured memory_bytes: 256
<?php
list($n,$k)=explode(" ",trim(fgets(STDIN)));
$ans=array_fill(1,$n,1);
$i=0;
while($i<$k){
  $d=trim(fgets(STDIN));
  $a=explode(" ",trim(fgets(STDIN)));
  while($d>0){
    --$d;
    if($ans[$a[$d]]==1){
      --$ans[$a[$d]];
      --$n;
      if($n==0){
        echo 0;
        exit;
      }
    }
  }
  ++$i;
}
echo $n;

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

int main() 
{
    string s;
    cin >> s;
    int y = stoi(s.substr(0,4));
    int m = stoi(s.substr(5,2));
    int d = stoi(s.substr(8,2));
    if ((y > 2019) ||
        (y == 2019 && m > 4))
        cout << "TBD";
    else 
        cout << "Heisei";
    return 0;
}

Measured memory_bytes: 256
def saiki(n, s, ks, loops):

    count = ks + s
    ans = 0

    if int(count) > int(n):
        return 0
    elif "3" in count and "5" in count and "7" in count:
        ans += 1

    for i in loops:
        ans += saiki(n, i, count, loops)

    return ans

def b755(n):


    loops = ["3", "5", "7"]
    ans = 0

    for i in loops:
        ans += saiki(n, i, "", loops)

    return ans

def main():
    n = str(input())
    print(b755(n))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
n = int(raw_input())
a = map(int, raw_input().split())

temp = 0
cnt = 0
for i in range(n):
	flag = 0
	min = i
	for j in range(i+1,n):
		if a[min] > a[j]:
			min = j
			flag = 1
	temp = a[i]
	a[i] = a[min]
	a[min] = temp
	cnt += flag

for i in range(n):
	if i != n-1:
		print(a[i]),
	else:
		print(a[i])

print cnt

Measured memory_bytes: 6472
import java.io.*;
import java.util.*;

class Node {
    int n;
    Node prev;
    Node next;
    Node(int n) {
        this.n = n;
        this.prev = null;
        this.next = null;
    }
}

public class Main {
    Scanner sc;
    Main() {
        sc = new Scanner(System.in);
    }
    public static void main(String[] args) {
        new Main().run();
    }
    int n, k, m;
    boolean init() {
        n = sc.nextInt();
        k = sc.nextInt();
        m = sc.nextInt();
        if (n == 0 && k == 0 && m == 0) return false;
        m--;
        return true;
    }
    void run() {
        while (init()) {
            Node root = new Node(1);
            Node prev = root;
            for (int i = 2; i <= n; i++) {
                Node node = new Node(i);
                prev.next = node;
                node.prev = prev;
                prev = node;
            }
            prev.next = root;
            root.prev = prev;
            for (int i = 0; i < m; i++) root = root.next;
            while (!(root.next == root)) {
                Node _root = root;
                Node a, b;
                a = _root.prev;
                b = _root.next;
                a.next = b;
                b.prev = a;
                for (int i = 0; i < k; i++) {
                    root = root.next;
                }
            }
            System.out.println(root.n);
        }
    }
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

ll gcd(ll a, ll b){
    ll r,temp;
    if (a < b){
        temp = a;
        a = b;
        b = temp;
    }
    while ( (r = a % b) != 0){
        a = b;
        b = r;
    }
    return b;
}

int main(){
    ll A,B;
    cin >> A >> B;
    cout << A * B / gcd(A,B) << endl;
}


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

    const int MOD = 1000000007;
    const double PI = acos(-1); 

    //long long
    using ll = long long;

    //出力系
    #define print(x) cout << x << endl
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

    //for
    #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

    //最大公約数（ll）
    ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

    //素因数分解
    vector<pair<ll, int>>factorize(ll n){
      vector<pair<ll, int>> res;
      for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
          n /= i;
          res.back().second++;
        }
      }
    if(n != 1) res.emplace_back(n, 1);
    return res;
    }



  // // 二分探索(最小値を出す問題は疑う)
  // bool C(ll x){
  //     ll res = 0;
  //     for(int i = 0; i < N; ++i){
  // 		res += max(0ll, A[i]-x/F[i]);
  //     }
  //     return res <= K;
  // }

  //   ll binary_search(ll ok, ll ng){
  //     while(abs(ok - ng) > 1){
  //       ll mid = (ok + ng) / 2;
  //       if(C(mid)) ok = mid;
  //       else ng = mid;
  //     }
  //     return ok;
  //   }



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

    int x = min(A, B);
    int y = max(0, (A + B) - N);
    cout << x << ' ' << y << endl;
  }

Measured memory_bytes: 256
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──████AJ████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll unsigned long long

int N, K;
vector<int> a;
vector<int> dp(100001, -1);

bool canWin(int w) {
	// cout << w << endl;
	if (w == 0) return false;
	if (dp[w] != -1) return dp[w];
	for (int i = 0; i < a.size(); ++i) {
		if (a[i] <= w && !canWin(w - a[i])) {
			return dp[w] = true;
		}
	}
	return dp[w] = false;
}

int main() {
	cin >> N >> K;
	a = vector<int> (N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	cout << (canWin(K) ? "First" : "Second") << endl;
	return 0;
}

Measured memory_bytes: 8328
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
#define INF 1000000000
#define MAX_V 3000

#define rep(i,a) for(int i=0;i<a;i++)
struct edge{int to, cap, rev;};
vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap) {
    G[from].push_back((edge){to, cap, G[to].size()});
    G[to].push_back((edge){from, 0, G[from].size() - 1});
}

int dfs(int v, int t, int f){
    if(v == t) return f;
    used[v] = true;
    for(int i = 0; i<G[v].size();i++){
        edge &e = G[v][i];
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    for(;;){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if (f == 0) return flow;
        flow += f;
    }
}

int N, K;
bool can[MAX_V][MAX_V];

void solve(){
    int s = N + K, t = s + 1;
    for(int i = 0; i < N; i++){
        add_edge(s, i, 1);
    }
    for(int i = 0; i < K; i++){
        add_edge(N+i, t, 1);
    }

    for(int i = 0; i < N; i++){
        for(int j = 0; j < K; j++){
            if(can[i][j]){
                add_edge(i, N + j, 1);
            }
        }
    }
    cout << max_flow(s, t) << endl;
}

int main(){
    while(cin>>N>>K,N||K){
        rep(i, MAX_V) G[i].clear();
        vector<int> b(N);
        vector<int> r(K);
        rep(i, N) cin >> b[i];
        rep(i, K) cin >> r[i];
        memset(can, 0, sizeof(can));
        rep(i, N){
            rep(j, K){
                if(__gcd(b[i], r[j]) > 1){
                    can[i][j] = true;
                }
            }
        }
        solve();
    }
}

Measured memory_bytes: 16376
package main

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

var (
	sc = bufio.NewReader(os.Stdin)
)

func main() {
	X := abs(scanInt())
	K := scanInt()
	D := scanInt()

	KK := X / D
	if KK > K {
		fmt.Println(abs(X - K*D))
	} else {
		A := abs(X - KK*D)
		K -= KK
		if K%2 == 0 {
			fmt.Println(A)
		} else {
			fmt.Println(abs(A - D))
		}
	}
}

func min(a []int) int {
	sort.Ints(a)
	return a[0]
}
func abs(a int) int         { return int(math.Abs(float64(a))) }
func scan(a ...interface{}) { _, err := fmt.Fscan(sc, a...); pnc(err) }
func scanStr() (s string)   { scan(&s); return }
func scanInt() int          { i, err := strconv.Atoi(scanStr()); pnc(err); return i }
func scanFloat() float64    { f, err := strconv.ParseFloat(scanStr(), 64); pnc(err); return f }
func pnc(err error) {
	if err != nil {
		panic(err)
	}
}


Measured memory_bytes: 1844
#include<stdio.h>
int main()
{
    int n,x,y,s,i;
    scanf("%d",&n);
    s=0;
    for(i=1;i<=n;i++)
    {
        scanf("%d%d",&x,&y);
        s=s+y-x+1;
    }
    printf("%d\n",s);
    return 0;
}


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

using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ldouble = long double;
 
const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;

string res;

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

    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    for (ll i = 1; i <= n - k; i++)
    {
        if (a[i - 1] < a[i + k - 1])
        {
            println("Yes");
        }
        else
        {
            println("No");
        }
        
    }
}


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

int main()
{
    int fact(int x);
    int n; cin >> n;
    double ans = 0;
    vector<int> x(n),y(n);
    for(int i=0;i<n;i++) cin >> x[i] >> y[i];

    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            double disx = pow(x[i]-x[j],2.0);
            double disy = pow(y[i]-y[j],2.0);
            double dis = sqrt(disx+disy);
            ans += dis*2*fact(n-1);
        }
    }
    ans = ans/fact(n);

    cout << setprecision(10) << ans << endl;
    return 0;

}

int fact(int x){
    if(x == 0 || x == 1){
        return 1;
    }
    else{
        return x*fact(x-1);
    }
}

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


using namespace std;
void func143b (){
	int n, d[50] = { 0 };
	cin >> n;
	for (int i = 0; i < n;i++)cin >> d[i];
	int sum = 0;
	for (int i = 0;i < n;i++) {
		for (int j = i + 1; j < n; j++) {
			sum += d[i] * d[j];
		}
	}
	cout << sum;
}

int main()
{
	func143b();
	return 0;	
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define p2(x) (x)*(x)
#define endl "\n"
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < n; i++)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()

typedef long long ll;
typedef vector<int> vi;

const int MAX_N = 110;
int a[MAX_N];
int n;
int sc = 0;

void bubbleSort(int first, int last) {
	for (int i = last - 1 ; i >= first; i--) {
		for (int j = first ; j <= i; j++) {
			if (a[j] > a[j+1]) {
				swap(a[j], a[j+1]);
				sc++;
			}
		}
	}
}

int main(){
	ios::sync_with_stdio(0);
	cin >> n;
	rep(i, n)
		cin >> a[i];
	bubbleSort(0, n-1);
	rep(i, n) {
		if (i!= n-1)
			cout << a[i] << " ";
		else 
			cout << a[i] << endl;
	}
	cout  << sc << endl ;
	return 0;
}

Measured memory_bytes: 3172
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    int n;
    cin >> n;
    ll march[5]={};
    REP(i,n){
        string tmp;
        cin >> tmp;
        if(tmp[0]=='M') ++march[0];
        else if(tmp[0]=='A') ++march[1];
        else if(tmp[0]=='R') ++march[2];
        else if(tmp[0]=='C') ++march[3];
        else if(tmp[0]=='H') ++march[4];
    }
    ll ans = 0;

    for(int i=0; i<3; ++i){
        for(int j=i+1; j<4; ++j){
            for(int k=j+1; k<5; ++k) ans+= march[i]*march[j]*march[k];
        }
    }
    
    cout << ans <<ENT;
    return 0;
}

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


Measured memory_bytes: 256
import std.stdio,std.conv,std.string;

void main(){
    foreach(_;0..readln.chomp.to!int){
        int point,base,_out;
        while(1){
            final switch(readln.chomp){
                case "HIT":
                    if(base==3)++point;
                    else ++base;
                    break;
                case "HOMERUN":
                    point+=base+1;
                    base=0;
                    break;
                case "OUT":
                    ++_out;
                    break;
            }
            if(_out==3)break;
        }
        point.writeln;
    }
}

Measured memory_bytes: 1052