akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<cctype>
using namespace std;

int main(){
    char ch;

    while(1){
        scanf("%c", &ch);

        if (islower(ch)) printf("%c", toupper(ch));
        else if (isupper(ch)) printf("%c", tolower(ch));
        else printf ("%c", ch);

        if (ch == '\n') break;
    }
    return 0;
}


Measured memory_bytes: 3144
#include<string.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
#define lli long long int
#define ULTRA_INSTINCT ios_base::sync_with_stdio(false); cin.tie(0)
#define fo(i,n) for(int i=0;i<(n);i++)
using namespace std;

lli mod = 1e9+7;

void solve(){

    int n;
    cin>>n;
    lli a[n];
    lli sum = 0;
    fo(i,n){
        cin>>a[i];
        sum += a[i];
        sum %= mod;
    }
    lli ans = 0;
    fo(i,n){
        sum =  (sum - a[i] + 10*mod)%mod;
        ans += ((a[i] *sum) %mod);
        ans %= mod;
    }
    cout<<ans<<endl;


}

int main(){
    ULTRA_INSTINCT;
    int t =1;
    // cin>>t;
    while(t--){
        solve();
    }

    return 0;
}

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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int m = fs.nextInt();
		if(n==m)System.out.println("Yes");
		else System.out.println("No");

	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
const int mod=1e9+7;
int a[100005];
void seive()
{
    for(int i=2;i*i<=100000;i++)
    {
        if(!a[i])
        {
            for(int j=i*i;j<=100000;j+=i)
            a[j]=i;
        }
    }
}
int32_t main()
{
  seive();

  int n;
  cin>>n;
   map<int,int> m;
   for(int i=2;i<=n;i++)
   {
       int temp=i;
       while(a[temp]!=0)
       {
            m[a[temp]]++;
            temp=temp/a[temp];
       }
       m[temp]++;
   }
   int ans=1;
   for(auto i:m)
   {
       if(i.first==1)
       continue;
       else
       {
           
           ans=(ans*(i.second+1))%mod;
       }
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 4376
#include<bits/stdc++.h>
using namespace std;
#define int long long
int ans[30]={},tans=0;
signed main(){
  int N;
  int dp[30]={};
  dp[0]=1;
  for(int i=1;i<=30;i++){
    //cout << i << endl;
    if(i==1) dp[i]=dp[i-1];
    else if(i==2) dp[i]=dp[i-1]+dp[i-2];
    /*else{
      int tmp=dp[i-1]+dp[i-2]+dp[i-3];
      dp[i]=tmp%3650;
      tans+=floor(tmp/3650);
      ans[i]=ans[i-1]+tans;
    }*/
    else dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
  }

  while(cin >> N && N!=0){
  cout << ceil((double)dp[N]/3650.0) << endl;
  //cout << dp[N] << endl;
}
  return 0;
}



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

#define ll long long
#define pb push_back
#define ins insert
#define mp make_pair
#define pii pair<int, int>
#define pil pair<int, ll>
#define pib pair<int, bool>
#define SET(a, c) memset(a, c, sizeof(a))
#define MOD 1000000007
#define enld endl
#define endl "\n"
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define found(u, val) u.find(val) != u.end()

#include <string>
#include <vector>
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
//#include <algorithm>
//#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//#include <cmath>
//#include <cstring>
//#include <sstream>
//#include <stack>
//#include <queue>

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

    int n;
    cin >> n;
    int ar[n + 1];
    for (int i = 0; i < n; i++) cin >> ar[i];

    int dp[n + 1];
    dp[n] = 0;
    dp[n - 1] = 0;
    ar[n] = ar[n - 1];
    for (int i = n - 2; i >= 0; i--) {
        dp[i] = min(abs(ar[i] - ar[i + 1]) + dp[i + 1], abs(ar[i] - ar[i + 2]) + dp[i + 2]);
    }

    cout << dp[0];
}

Measured memory_bytes: 4420
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ans = IntArray(n) {0}
    val max = Math.sqrt(n.toDouble()).toInt() + 1
    for (i in 1..max) {
        for (j in 1..max) {
            for (k in 1..max) {
                val l = i*i + j*j + k*k + i*j + j*k + k*i
                if (l <= n) ans[l-1]++
            }
        }
    }
    repeat(n) {
        println(ans[it])
    }
}


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

using namespace std;
typedef long long ll;
typedef double db;
#define inf 0x3f3f3f3f
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
int a[11234];
signed main() {
	int i, j, k, t;
	for (i = 1; i <= 100; ++i) {
		for (j = 1; j <= 100; ++j) {
			for (k = 1; k <= 100; ++k) {
				t = i * i + j * j + k * k + i * j + i * k + j * k;
				if (t <= 10000)++a[t];
			}
		}
	}
	int n;
	cin >> n;
	for (i = 1; i <= n; ++i)cout << a[i] << endl;
	return 0;
}

Measured memory_bytes: 3704
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()
lens = len(s)
ans = False
keyence = "keyence"


for i in range(0,8):
    if s[:i] + s[i+lens-7:] == keyence:
        ans = True
            
print("YES") if ans else print("NO")

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<functional>
#include<limits.h>
#include<string.h>
#include<algorithm>
using namespace std;

int a[100000];
signed main() {
	int ans = INT_MAX;
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n - k + 1; i++) {
		if (a[i + k - 1] < 0)ans = min(ans, abs(a[i]));
		else if (a[i] > 0)ans = min(ans, a[i + k - 1]);
		else ans = min({ ans,(-a[i]) * 2 + a[i + k - 1],-a[i] + 2 * a[i + k - 1] });
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, x;
	cin >> n >> x;
	vi a(n);
	rep(i, n) cin >> a[i];
	vi ret;
	ret.pb(0);
	rep(i, n){
		ret.pb(ret[ret.size() - 1] + a[i]);
	}
	int ans = lower_bound(all(ret), x) - ret.begin();
	if(ret[ans] == x) ans++;
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int const INF = 1001001001;


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

string s , t;
cin >> s >> t;
int a,b;
cin >> a >> b;
string u;
cin >> u;

if(s == u) cout << a-1 << ' ' << b << endl;
else cout << a << ' ' << b-1 << endl;


return 0;
}

Measured memory_bytes: 256
n = gets.to_i

res = []

n.times do |i|
  res[i] = 0
  num = i + 1

  loop do
    break if num % 2 != 0
    res[i] += 1
    num = num / 2
  end
end

max_cnt = res.max
puts res.index(max_cnt) + 1

Measured memory_bytes: 1788
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
void solve(long long N, long long M, std::vector<long long> A){
  ll ans = 0;
  for (int i = 0; i < M; i++) {
    ans += A[i];
  }
  cout << (N-ans >= 0 ? N-ans : -1) << endl;
}

int main(){
    long long N;
	scanf("%lld",&N);
	long long M;
	scanf("%lld",&M);
	std::vector<long long> A(M);
	for(int i = 0 ; i < M ; i++){
		scanf("%lld",&A[i]);
	}
    solve(N, M, std::move(A));
}


Measured memory_bytes: 3744
#include <iostream>

using namespace std;

int same(char a,char b);

int main(){

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

    char c[m][n];
    int p[m][n]={};

    for(int i=0;i<m;i++)
        for(int j=0;j<n;j++)
            cin >> c[i][j];

    p[0][0] = 0;
    if(c[0][0]=='#')
        p[0][0] = 1;

    for(int j=1;j<n;j++)
        p[0][j] = p[0][j-1]+same(c[0][j],c[0][j-1]);
    for(int i=1;i<m;i++)
        p[i][0] = p[i-1][0]+same(c[i][0],c[i-1][0]);

    for(int i=1;i<m;i++)
        for(int j=1;j<n;j++)
            p[i][j] = min(p[i-1][j]+same(c[i][j],c[i-1][j]),p[i][j-1]+same(c[i][j],c[i][j-1]));

    /*for(int i=0;i<m;i++){
        for(int j=0;j<n;j++)
            cout << p[i][j] << " ";
        cout << "\n";
    }*/

    cout << p[m-1][n-1] << "\n";

    return 0;
}

int same(char a,char b){
    if(a=='#' && b=='.')
        return 1;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b;
  while(1){
    cin>>a>>b;
    if(a==0&&b==0) break;
    if(a>b){
      int temp=a;
      a=b;
      b=temp;
    }
    cout<<a<<" "<<b<<endl;
  }
  return(0);
}

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

int main()
{
  int ans=0; 
  for(int i=0;i<9;i++)
  {
     for(int j=0;j<9;j++)
     {
       ans=(i+1)*(j+1);
       cout<<i+1<<"x"<<j+1<<"="<<ans<<endl;
     }
  }
  return 0;
}

Measured memory_bytes: 1116
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

unsigned long long dp[51][51][2501];

int main(int argc, char const *argv[])
{
    int N, A;
    cin>>N>>A;

    vector<int> x(N+1);
    for(int i=0; i<N; i++) {
        cin >> x[i+1];
    }

    dp[0][0][0] = 1;
    int mm = max(*max_element(x.begin()+1, x.end()), A);
    for(int j=1; j<=N; j++) {
        for(int k=0; k<=N; k++) {
            for(int s=0; s<=k*mm; s++) {
                dp[j][k][s] += dp[j-1][k][s];
                if(s >= x[j])
                    dp[j][k][s] += dp[j-1][k-1][s-x[j]];
            }
        }
    }
    unsigned long long ans = 0;
    for(int k=1; k<=N; k++)
        ans += dp[N][k][k*A];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 49280
a = (1,3,5,7,8,10,12)
b = (4,6,9,11)
c = (2,)
abc = [a,b,c]
x,y = map(int,input().split())
for i, checker in enumerate(abc):
    if x in checker:
        checker2 = checker
if y in checker2:
    print("Yes")
else:
    print("No")


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

const ll MOD=1000000007;

int main(){
    ll X;
    cin>>X;
    ll N=100;
    int count=0;
    while(N<X){
        N=N+N/100;
        count=count+1;
    }
    cout<<count<<endl;
}

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

int main() {
  int A;
  int64_t B, N;
  cin >> A >> B >> N;
  int floor, floor1, floor2;
  if (N >= B) {
    floor = A*(B-1) / B;
  } else {
    floor = A*N / B;
  }
  cout << floor << endl;
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

class modint {
  private:
    ll m_val;
    ll m_mod;
  public:
    constexpr modint() : m_val(0), m_mod() { m_mod = MOD; }
    constexpr modint(const ll x) : m_val(0), m_mod(0) { m_mod = MOD; m_val = x % m_mod; }
    constexpr modint(const ll x, const ll mod) : m_val(0), m_mod(0) { m_mod = mod; m_val = x % m_mod; }
    constexpr ll val() const { return m_val; }
    constexpr modint operator+(const modint &rhs) const { return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const { return modint(*this) /= rhs; }
    constexpr modint &operator+=(const modint &rhs) {
      m_val += rhs.m_val;
      if (m_val >= m_mod) m_val -= m_mod;
      return *this;
    }
    constexpr modint &operator-=(const modint &rhs) {
      if (m_val < rhs.m_val) m_val += m_mod;
      m_val -= rhs.m_val;
      return *this;
    }
    constexpr modint &operator*=(const modint &rhs) {
      m_val = m_val * rhs.m_val % m_mod;
      return *this;
    }
    constexpr modint &operator/=(const modint &rhs) {
      *this *= rhs.pow(m_mod - 2);
      return *this;
    }
    constexpr modint pow(ll n) const {
      if (n == 0) return 1;
      modint o = pow(n >> 1);
      o *= o;
      if (n & 1) o *= *this;
      return o;
    }
    friend ostream& operator<<(ostream& os, const modint &a) { os << a.val(); return os; }
};

ll modpow(ll x, ll n) {
  ll res = 1;
  while (n != 0){
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n = n >> 1;
  }
  return res;
}

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

  vector<ll> memo(k+1);
  for (ll i = k; i >= 1; --i) {
    ll a = modpow(k/i, n);
    memo[i] = a;
    for (ll j = 2; i*j <= k; ++j) {
      memo[i] -= memo[i*j];
    }
  }

  modint ans(0);
  for (ll i = 1; i <= k; ++i) {
    ans += (i * memo[i]);
  }
  cout << ans.val() << endl;

  return 0;
}


Measured memory_bytes: 3988
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    int n0 = 0;
    int n1 = 0;

    for (int i = 0; i < s.length(); i++) {
      if (s.charAt(i) == '0') {
        n0++;
      } else {
        n1++;
      }
    }

    System.out.println(2 * Math.min(n0, n1));

  }
}

Measured memory_bytes: 39124
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

int main() {
   Int n, a, b;
   std::cin >> n >> a >> b;
   puts(std::abs(a-b)%2==0?"Alice":"Borys");
}


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

using namespace std;
const int N=2e5+10,inf=1e9;

int main(){
	int N,ans=0;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    for(int i=0;i<N;i++){
        cin >> V[i];
    }
    for(int i=0;i<N;i++){
        cin >> C[i];
    }
    
    for(int i=0;i<N;i++){
        if(V[i] - C[i] > 0) ans+=V[i]-C[i];
    }
	
	cout << ans << endl;
}


Measured memory_bytes: 256
#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; }




int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    const ll mod = 1e9+7;
    string s; cin >> s;
    vvl dp(s.size()+1, vl(13, 0)); dp[0][0] = 1;
    rep(i, s.size()){
        ll c = s[i] == '?' ? -1: s[i]-'0';
        rep(j, 10){
            if(c != -1 && j != c) continue;
            rep(m, 13){
                dp[i+1][(m*10+j)%13] += dp[i][m];
            }
        }
        rep(m, 13) dp[i+1][m] %= mod;
    }
    cout << dp[s.size()][5] << endstr;
    return 0;
}


Measured memory_bytes: 13648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main {
    static BufferedReader br;
    static StringTokenizer tok;
    static char[][] mat;
    static boolean[] rowVisible, colVisible;
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        tok = new StringTokenizer(br.readLine());
        final int h = Integer.parseInt(tok.nextToken());
        final int w = Integer.parseInt(tok.nextToken());
        mat = new char[h][w];
        rowVisible = new boolean[h];
        colVisible = new boolean[w];
        // 読み込み
        for (int i = 0; i < h; i++) {
            String row = br.readLine();
            for (int j = 0; j < w; j++) {
                char c = row.charAt(j);
                mat[i][j] = c;
                if (c == '#') {
                    rowVisible[i] = true;
                    colVisible[j] = true;
                }
            }
        }
        // 表示
        for (int i = 0; i < h; i++) {
            if (!rowVisible[i]) continue;
            for (int j = 0; j < w; j++) {
                if (!colVisible[j]) continue;
                System.out.print(mat[i][j]);
            }
            System.out.print("\n");
        }
    }
}


Measured memory_bytes: 24660
import sys, math, itertools, bisect, copy, re

from collections import Counter, deque, defaultdict
from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
from functools import reduce
from math import ceil, floor, log10, log2, factorial
from pprint import pprint

# 10倍速いらしい
input = sys.stdin.readline

INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

N = int(input())
V = [int(x) for x in input().split()]
V.sort()
ans = V[0]
for i in range(1, N):
    ans = (ans + V[i]) / 2

print(ans)


Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
int b[100005]={0};

int main()
{
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++){
		b[a[i]-1]++;
		b[a[i]]++;
		b[a[i]+1]++;
	}
	int maxn=0;
	for(int i=1;i<100000;i++){
		maxn=max(maxn,b[i]);
	}
	cout << maxn;
}

Measured memory_bytes: 1024
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        long lcm = 1;
        for(var i = 0; i < num; i++)
        {
            lcm=Calculation.LCM(lcm, ToInt64(ReadLine()));
        }
        WriteLine(lcm);
    }
}
public class Calculation
{
  public static long LCM(long num1, long num2)
    {
        return num1 / GCD(num1, num2) * num2;
    }
  public static long GCD(long num1, long num2)
    {
        return num1 < num2 ? GCD(num2, num1) :
            num2 > 0 ? GCD(num2, num1 % num2) : num1;
    }
}

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

int main() {
	int n;
	cin>>n;
	long long suf[n],a[n],s=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	long long sum=0,mod=1e9+7;
	for(int i=n-1;i>=0;i--){
		s+=a[i];
		suf[i]=s%mod;
	}
	
	for(int i=0;i<n-1;i++){
	sum+=(a[i]*(suf[i+1])) % mod;
	}
	cout<<sum%mod;
	return 0;
}

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}

long long arr[51], cur[51];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n; cin >> n;

    long long diff, tot = 0;

    for(int i = 0; i < n; ++i)
        cin >> arr[i];

    for(int i = 0; i < 625000; ++i){
        for(int j = 0; j < n; ++j){
            diff = (arr[j] + tot - cur[j]) - (n - 1);
            diff = diff / n + (diff % n > 0);
            tot += diff;
            cur[j] += diff;
            arr[j] -= n * diff;
            //cout << arr[j] + tot - cur[j] << " ";
        }
        //cout << endl;
    }

    cout << tot << "\n";

    return 0;

}


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

int main() {
  int N;
  cin >> N;
  set<int> s{};
  for (int i = 1; i < 10; i++){
    for (int j = i; j < 10; j++){
      s.insert(i * j);
    }
  }
  if (s.find(N) == s.end())
  cout << "No" << endl;
  else
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
ary = Array.new(10000)
ary[1] = gets.to_i
i = 2
while ary[i-1] != 0
  ary[i] = gets.to_i
  i += 1
end
if i == 2
  puts ""
else
  for j in 1..i-2
    puts "Case #{j}: #{ary[j]}"
  end
end

Measured memory_bytes: 8744
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int k;
  cin >> k;

  if(c > b) swap(b,c);
  if(b > a) swap(a,b);
  if(c > b) swap(b,c);

  // cout << a << b << c;
  REP(i,k){
    a *= 2;
  }

  int ans = a + b + c;
  cout << ans << endl;



  return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
//#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    int res = 1;

    x = x;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);

        y = y>>1;
        x = (x*x);
    }
    return res;
}
bool isprime(int x)
{
      if(x<2)
        return false;
    for(int i=2;i*i<=x;i++)
     {
        if (x%i==0)
            return false;
    }
    return true;
}
vector<int>primeFactors(int n)
{
    vector<int>v;
    int x=0;
    while (n % 2 == 0)
    {
        x++;
        n = n/2;
        v.pb(2);
    }
    //if(x>0)
    //v.pb({2,x});
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        int y=0;
        while (n % i == 0)
        {
            y++;
            n = n/i;
            v.pb(i);
        }
        //if(y>0)
        //v.pb({i,y});
    }
    if (n > 2)
        v.pb(n);
    return v;
}

vector<int>leastPrimeFactor(int n)
{
    vector<int>least_prime(n);
    // Create a vector to store least primes.
    // Initialize all entries as 0.
    // We need to print 1 for 1.
    least_prime[1] = 1;

    for (int i = 2; i <= n; i++)
    {
        // least_prime[i] == 0
        // means it i is prime
        if (least_prime[i] == 0)
        {
            // marking the prime number
            // as its own lpf
            least_prime[i] = i;

            // mark it as a divisor for all its
            // multiples if not already marked
            for (int j = 2*i; j <= n; j += i)
                if (least_prime[j] == 0)
                   least_prime[j] = i;
        }
    }
    return least_prime;
}

void solve()
{
int n;
cin>>n;
int a[n];
map<int,int>m;
int s=0;
for(int i=0;i<n;i++)
{
    cin>>a[i];
    s+=a[i];
    m[a[i]]++;
}
int q;
cin>>q;
while(q--)
{
    int x,y;
    cin>>x>>y;
    int z=m[x];
    s-=z*x;
    s+=z*y;
    m[y]+=z;
    m[x]=0;
    cout<<s<<endl;
}
}
signed main()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
//cin>>t;
t=1;
while(t--)
{
solve();
}
}



Measured memory_bytes: 10228
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Pattern;

public class Main {

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

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      final Pattern delim = Pattern.compile(" ");
      int[] seq = delim.splitAsStream(br.readLine())
        .mapToInt(Integer::parseInt)
        .toArray();

      int q = partition(seq, 0, n-1);
      dispIntArrayPartition(seq, q);
    }
    catch(IOException e) {
      System.out.println("IOException!");
    }
  }

  public int partition(int[] seq, int p, int r) {

    int x = seq[r];
    int i = p-1;
    int t;

    for(int j=p; j<r; j++) {
      if(seq[j] <= x) {
        t = seq[++i]; seq[i] = seq[j]; seq[j] = t;
      }
    }
    t = seq[i+1]; seq[i+1] = seq[r]; seq[r] = t;

    return i+1;
  }

public void dispIntArrayPartition(int[] target, int q) {
  StringBuilder s = new StringBuilder();
  int l=target.length-1;

  for (int i=0; i<q; i++) { s.append(target[i]).append(" "); }
  s.append("[").append(target[q]).append("] ");
  for (int i=q+1; i<l; i++) { s.append(target[i]).append(" "); }
  s.append(target[l]);

  System.out.println(s);
  }
}


Measured memory_bytes: 45976
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>
#include <set>
#include <functional>
#include <list>

#define MOD (1000000000 + 7)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 3000000;

long long fac[MAX], finv[MAX], inv[MAX];

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}
// テーブルを作る前処理
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;
    }
}

// 二項係数計算
long long 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;
}

map<ll,ll> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

//O(√n)
//整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
   for(ll i=2;i<=(ll)(l);i++) { //
        if(n%i==0){
            prime_factorize(i);prime_factorize(ll(n/i));return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[n]++;return;
} 

vector<ll> divisor;
void list_divisor(ll n) {
    divisor.clear();
    for(int i = 1; i*i <= n; i++) {
        if(n % i == 0) {
            divisor.push_back(i);
            if(i*i != n) divisor.push_back(n/i);
        }
    }
    sort(divisor.begin(), divisor.end());
}

int main() {
    string S;
    cin >> S;
    string T;
    cin >> T;

    if(T.length() > S.length()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    
    for(ll i = S.length() - T.length(); i >= 0; i--) {
        bool match = false;
        for(ll j = 0; j < T.length(); j++) {
            if(S[i+j] != '?' && S[i+j] != T[j]) break;
            if(j == T.length() - 1) match = true;
        }

        if(match) {
            string ret = S.substr(0, i) + T + S.substr(i-1+T.length()+1);
            replace(ret.begin(), ret.end(), '?', 'a');
            cout << ret << endl;
            return 0;
        }
    }

    cout << "UNRESTORABLE" << endl;
}



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

int main(){
	string s;
	cin >> s;
	int ans = 1 << 30;
	for(char c = 'a'; c <= 'z'; c++){
		int p = 0, tmp = -(1 << 30);
		for(int i = 0; i < s.size(); i++){
			if(s[i] == c){
				tmp = max(tmp, i - p);
				p = i + 1;
			}
		}
		tmp = max(tmp, int(s.size()) - p);
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 100000000000
#define int long long int

using namespace std;

vector <int> adj[200005];
vector <bool> vis(200005,false);
vector <int> dp(200005,0);

int dfs(int s){
    vis[s]=true;
    dp[s]=1;
    for(int x:adj[s]){
        if(!vis[x])
            dp[s]+=dfs(x);
    }
    return dp[s];
}

void solve(){
    int n;
    cin>>n;
    for(int i=2;i<=n;i++){
        int x;
        cin>>x;
        adj[x].push_back(i);
    }
    for(int i=1;i<n;i++){
        if(!vis[i])
            dfs(i);
    }
    for(int i=1;i<=n;i++)
        cout<<adj[i].size()<<" ";
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 25108
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func isNum(a string) bool {
	if _, err := strconv.Atoi(a); err == nil {
		return true
	} else {
		return false
	}
}

func main() {
	var a, b int
	var s string
	fmt.Scan(&a, &b, &s)

	t := strings.Split(s, "-")
	if len(t[0]) == a && len(t[1]) == b && isNum(t[0]) && isNum(t[1]) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args) {

            var line = Console.ReadLine();
            var data = line.Split(' ');

            var a = int.Parse(data[0] + data[1]);
            var sqrt = Math.Sqrt(a);

            if((int)sqrt == sqrt) {
                Console.WriteLine("Yes");
            }
            else {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
S = input()
T = input()

ans = float("Inf")

len_s = len(S)
len_t = len(T)
for i in range(len_s-len_t+1):
    _ans = 0
    for j in range(len_t):
        if S[i+j] != T[j]:
            _ans += 1
    ans = min(ans, _ans)

print(ans)


Measured memory_bytes: 9044
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x=0,n,mx=0;
	string s;
	cin>>n;
	cin>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='I') x++; 
		if(s[i]=='D') x--;
		if(x>mx) mx=x;
	}
	cout<<mx;
} 

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

using namespace std;

int main() {
	long l;
	cin >> l;
	long r;
	for (r=1;r<=19;++r) {
		if (l < pow(2,r)) {
			break;
		}
	}
	--r;
	vector<vector<long>> ans;
	for (long i=1;i<=r;++i) {
		ans.push_back({i,i+1,0});
		ans.push_back({i,i+1,static_cast<long>(pow(2,i-1))});
	}
	for (long i=r;i>=1;--i) {
		if (l - pow(2,i-1) >= pow(2,r)) {
			ans.push_back({i,r+1,l-static_cast<long>(pow(2,i-1))});
			l -= pow(2,i-1);
		}
	}
	cout << r+1 << ' ' << ans.size() << "\n";
	for (auto each_ans : ans) {
		cout << each_ans[0] << ' ' << each_ans[1] << ' ' << each_ans[2] << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pi pair<int ,int >
#define pl pair<ll ,ll >
#define pb push_back
#define vl vector <long long int >
#define vi vector <int >
#define vp vector <pi>
#define mod 1000000007
#define eps 1e-9
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define _ <<" "<<
#define forn(x,	n) for(int x = 0; x < n ;++ x) 
#define forn1n(x,n) for(int x = 1; x <= n ;++ x)
#define forn1(x,n) for(int x = 1; x < n ;++ x)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#pragma GCC optimize ("Ofast")
void scan(){}
template<typename F, typename... R> void scan(F &f,R&... r){cin>>f;scan(r...);}
int di_; string dnms_, co_ = ",";
void debug_(){cout<<endl;}
template<typename F, typename... R> void debug_(F &f, R&... r){while(dnms_[di_] != ',')cout<<dnms_[di_++];di_++;cout<<": "<<f<<",";debug_(r...);}
#define debug(...) dnms_=#__VA_ARGS__+co_,di_=0,debug_(__VA_ARGS__)

template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}

int main(){
	IOS

	int n;
	cin>>n;
	n--;
	vi b(n);
	cin>>b;

	int sum=b[0],i;
	for(i=0;i<n-1;i++)
	{
		sum += min(b[i],b[i+1]);
	}
	sum += b[n-1];
	cout<<sum;
 
	return 0;	
}

Measured memory_bytes: 256
from collections import Counter
N = raw_input()
A = raw_input().split()

cnt = Counter()
for num in A:
    cnt[str(num)] += 1

answer = 0
for x, y in cnt.items():
    x = int(x)
    if x < y:
        answer += (y-x)
    elif x > y:
        answer += y
print answer

Measured memory_bytes: 22196
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
using ll = long long;

// auto mod int
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint dp[3009][3009][3];

int main(){
  int n,s;
  cin>>n>>s;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  dp[0][0][0]=1;
  rep(i,n){
    rep(j,s+1){
      dp[i+1][j][0]+=dp[i][j][0];
      dp[i+1][j][1]+=dp[i][j][0]+dp[i][j][1];
      dp[i+1][j][2]+=dp[i][j][0]+dp[i][j][1]+dp[i][j][2];
      if(j+a[i]<=s){
        dp[i+1][j+a[i]][1]+=dp[i][j][0]+dp[i][j][1];
        dp[i+1][j+a[i]][2]+=dp[i][j][0]+dp[i][j][1];
      }
    }
  }
  cout<<dp[n][s][2].x<<endl;
  return(0);
}


Measured memory_bytes: 212480
import sys
import numpy as np
input = sys.stdin.readline
N, X = [int(x) for x in input().split()]
x = np.array([int(x) for x in input().split()])
if len(x) == 1:
    print(abs(X-x[0]))
    sys.exit()
x -= X
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
    
x.tolist()
D = gcd(* x)
print(abs(D))

Measured memory_bytes: 23064
#include <iostream>
using namespace std;
int main()
{
	long int a[100001],b[100001];
	long int c = 0;
	int n;
	cin >> n;
	for(int i=0;i<n;i++)
	{
		cin >> a[i] >> b[i];
	}
	for(int i=(n-1);i>=0;i--)
	{
		if(((a[i] + c) % b[i]) != 0)
		{
			c += (b[i] - ((a[i] + c) % b[i]));
		}
	}
	cout << c << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<queue>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

#define NMAX 50

int N;
string L;
int P;
int A;
int B;
int C;
int D;
int E;
int F;
int S;
int M;

typedef pair<double,string> sd;

vector<pair<double,string> > Q; 

int main()
{
    int T;
    int I;
    double r;
    while(cin >> N){
        if(N == 0)break;
        REP(N){
            cin >>L>>P>>A>>B>>C>>D>>E>>F>>S>>M;
            T = A+B+C+M*(D+E);
            I = M*S*F-P;
            T = T;
            r = (double)I/(double)T; 
            Q.push_back(sd(-1.0*r,L));         
        }
        sort(all(Q));
        REP(Q.size()){
            cout << Q[i].second <<endl;
        }
        Q.clear();
        cout << "#" << endl;
    }
    return 0;
}

Measured memory_bytes: 1220
import java.util.Scanner;

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

        int N = scanner.nextInt();

        double answer = 0;

        for (int i = 0 ; i < N ; i++) {
            double A = scanner.nextDouble();
            answer += 1.0 / A;
        }

        answer = 1.0 / answer;

        System.out.println(answer);
    }
}


Measured memory_bytes: 37796
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int N, M;
    cin >> N >> M;
    int a[N], b[N];
    int c[M], d[M];
    rep(i, N) cin >> a[i] >> b[i];
    rep(i, M) cin >> c[i] >> d[i];
    int near[N];
    rep(i, N){
        int min = pow(10, 8) * 4 + 1;
        rep(j, M){
            int len = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if(min > len){
                min = len;
                near[i] = j + 1;
            }
        }
    }
    rep(i, N) cout << near[i] << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

int M[20][20];

void search(bool S[20][20], int H, int W, int i, int j, int count){
	if(i >= 0 && i < H && j >= 0 && j < W && S[i][j]){
		if(M[i][j] > count){
			M[i][j] = count;
			search(S, H, W, i+1, j, count + 1);
			search(S, H, W, i, j+1, count + 1);
			search(S, H, W, i-1, j, count + 1);
			search(S, H, W, i, j-1, count + 1);
		}
	}
}

int main()
{
	int H, W;
	scanf("%d %d", &H, &W);
	bool S[20][20];
	for(int i = 0; i < H; i++){
		char s[256];
		scanf("%s", s);
		for(int j = 0; j < W; j++){
			S[i][j] = s[j] == '.';
		}
	}
	
	int max = 0;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if(S[i][j]){
				for(int ii = 0; ii < H; ii++){
					for(int jj = 0; jj < W; jj++){
						M[ii][jj] = 1000;
					}
				}
				search(S, H, W, i, j, 0);
				
				int tmpMax = 0;
				for(int ii = 0; ii < H; ii++){
					for(int jj = 0; jj < W; jj++){
						if(S[ii][jj] && tmpMax < M[ii][jj]){
							tmpMax = M[ii][jj];
						}
					}
				}
				
				if(max < tmpMax){
					max = tmpMax;
				}
			}
		}
	}
		
	printf("%d\n", max);
	
	return 0;
}

Measured memory_bytes: 128
using System.Linq;
using static System.Console;
using static System.Int32;
using static System.Math;

class Program
{

    static void Main(string[] args)
    {
        label:
        WriteLine(hoge() ? "Yes" : "No");
    }

    static bool hoge()
    {

        var sp = ReadLine().Split();
        int a = Parse(sp[0]);
        var s = ReadLine();
        for (int i = 0; i < s.Length; ++i)
        {
            if (i == a)
            {
                if (s[i] != '-') return false;
            }
            else
            {
                if (s[i] == '-') return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
#include <math.h>
#define _USE_MATH_DEFINES

int main()
{
    int sum=0,N=0,H[100000]={0},M=0,load[100000][2]={0},flag[100000]={0};
    scanf("%d %d",&N,&M);
    for(int i=0;i<N;i++)
	scanf("%d",&H[i]);
    for(int i=0;i<M;i++)
	scanf("%d %d",&load[i][0],&load[i][1]);


    for(int i=0;i<M;i++){
	if(H[load[i][0]-1]<=H[load[i][1]-1])
	    flag[load[i][0]-1]=1;
	if(H[load[i][1]-1]<=H[load[i][0]-1])
	    flag[load[i][1]-1]=1;	
    }

    for(int i=0;i<N;i++){
	if(flag[i]==0)
	    sum++;
    }

    printf("%d\n",sum);
    return 0;
}





Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL;
  typedef pair<ll,char> PLC;
  typedef pair<char,ll> PCL;

int main(void){
  int N;cin >> N;
  if( N < 1000 ) cout << "ABC" << endl;
  else cout << "ABD" << endl;
  return 0;
}


Measured memory_bytes: 256
'use strict'

const main = (input) => {
    input = input.split('\n')
    let temp = input[0].split(' ').map(i => parseInt(i))
    const N = temp[0]
    const T = temp[1]
    temp = input.slice(1, N + 1)
    temp = temp.filter(t => {
        return parseInt(t.split(' ')[1]) <= T
    })

    let minc = 10000
    let mint = 10000
    temp.forEach(t => {
        let temp = t.split(' ').map(i => parseInt(i))
        if(temp[0] < minc){
            minc = temp[0] 
            mint = temp[1] 
        }
    })

    if(minc === 10000){
        console.log('TLE')
    }else{
        console.log(minc)
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7500
#include<stdio.h>
#include<limits.h>
int main(){
  int i,j;
  int n=0,d=0,x=0;
  scanf("%d",&n);
  int a[n];
  int eat[n],ans=0;
  for(i=0;i<n;i++){
    eat[i]=0;
  }
  scanf("%d%d",&d,&x);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    if(a[i] != 0){
      // printf("OK\n");
      eat[i]=(d-1)/a[i]+1;
    }
    else{
      // printf("a\n");
      eat[i]=0;
    }
    // printf("b\n");
    ans+=eat[i];
  }
  ans+=x;
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
#include <vector>
#define LL long long
using namespace std;
int main() {
	int a, b, c, ans;
	scanf("%d%d%d", &a, &b, &c);
	ans = ceil(a * 1.0 / b) * c;
	printf("%d", ans);
	return 0;
}

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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    double constexpr C = 380000.0;
    double ans = 0.0;
    while(n--) {
        double v;
        string type;
        cin >> v >> type;
        if(type == "JPY")
            ans += v;
        else
            ans += v * C;
    }
    cout << setprecision(12) << fixed << ans << '\n';
}

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

int main() {
  int N;
  cin >> N;
  vector<int> B(N);
  for(int i = 0; i < N; i++) cin >> B.at(i);
  int now = 1;
  int count = 0;
  for(int i = 0; i < N + 1; i++){
    now = B.at(now - 1);
    count += 1;
    if(now == 2) break;
  }
  if(count == N + 1){
    cout << -1 << endl;
  }else{
    cout << count << endl;
  }
}

Measured memory_bytes: 640