akhauriyash/Code-Regression huggingface dataset:
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#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>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x, a, b;
  cin >> x >> a >> b;
  x -= a;
  while(true) {
    if(x - b >= 0){
    x -= b;
    continue;
    }
  cout << x << endl;
  return 0;
}
}
//templete by private_yusuke

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#define rep(i,n) for(int i(0);i<n;i++)
using namespace std;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	int t[n], x[n], y[n];
	t[0] = x[0] = y[0] = 0;
	rep(i,n)cin >> t[i+1] >> x[i+1] >> y[i+1];
	
	bool can = true;
	rep(i,n){
		int dt = t[i+1] - t[i];
		int dist=abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
		if(dt<dist) can=false;
		if(dist%2 != dt%2) can=false;
	}

	if(can) cout << "Yes" << endl;
	else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
long long n,tot;
long long w[200],v[200];
long long dp[100010];
int main()
{
	cin>>n>>tot;
	for(int i=1;i<=n;i++){
		cin>>w[i]>>v[i];
		for(int j=tot-w[i];j>=0;j--)
		   dp[j+w[i]]=max(dp[j+w[i]],dp[j]+v[i]);
	}
	cout<<*(max_element(dp,dp+tot+1))<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<math.h>


int main(){

  char N[3];

  scanf("%s",N);

  /*
  int A[N];
  int i;
  for(i=0;i<N;i++){
   scanf("%d",&A[i]);
   }
  */
 if(N[0] == N[1] && N[1] == N[2] && N[0] == N[2]){
   printf("No");
 }
 else{
   printf("Yes");
 }








 return(0);
 }


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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  = 3.141592653589793238463;
const int N = 1010;
const ll INF = 1LL << 60;

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

llt gcd(llt x, llt y)
{
  if(y == 0) return x;
  return gcd(y, x%y);
}
llt lcm(llt x, llt y)
{
  return (x / gcd(x, y)) * y;
}


// Main Code
int main()
{
	int n;
	cin>>n;
	ll ans = 0;
	rep(i, 0, n)
	{
		ll x;
		cin>>x;
		x--;
		ans += x;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
int n,dp[1009][10009];
pair <pair<int,int>,int> v[1009];
bool comp(pair <pair<int,int>,int> a,pair <pair<int,int>,int> b){
	int w1=a.f.f,w2=b.f.f;
	int s1=a.f.s,s2=b.f.s;
	if(s1+w1==s2+w2)
		return s1>s2;
	return (s1+w1>s2+w2);
	// if(s1>=w2 and s2>=w1)return (s1-w2>s2-w1);
	// if(s1<w2 and s2<w1)return (s1>s2);
	// if(s1>=w2 and s2<w1)return 1;
	// else return 0;
}
int f(int i,int c){
	if(i==n)return 0;
	if(dp[i][c]!=-1)
		return dp[i][c];
	dp[i][c]=f(i+1,c);
	if(v[i].f.f<=c)
		dp[i][c]=max(dp[i][c],v[i].s+f(i+1,min(c-v[i].f.f,v[i].f.s)));
	return dp[i][c];
}
int32_t main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	cin >> n;
	int sum=0;
	for(int i=0;i<n;i++){
		cin >> v[i].f.f >> v[i].f.s >> v[i].s;
		sum+=v[i].f.f;
	}
	sort(v,v+n,comp);
	memset(dp,-1,sizeof(long long)*1009*10009);
	int m=0;
	for(int i=0;i<n;i++){
		m=max(v[i].s+f(i+1,v[i].f.s),m);
	}
	cout << m << endl;
}


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

int
main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << std::fixed << setprecision(15);

    int64_t n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    deque<pair<char, int64_t>> v;
    
    int64_t count = 0;
    int64_t len = 0;
    int64_t mlen = 0;
    char prev = s[0];
    char c;
    for (int64_t i = 0; i <= n; ++i) {
	if (i < n) {
	    c = s[i];
	}
	if (c != prev || i == n) {
	    // cerr << "(" << prev << "," << count << ")" << endl;
	    v.emplace_back(make_pair(prev, count));
	    if (prev == '1') {
		len += count;
	    } else {
		if (k > 0) {
		    k--;
		} else {
		    if (v[0].first == '0') {
			len -= v[0].second;
			v.pop_front();
		    } else {
			len -= v[0].second;
			v.pop_front();
			len -= v[0].second;
			v.pop_front();
		    }
		}
		len += count;
	    }
	    if (len > mlen) {
		mlen = len;
	    }
	    count = 0;
	}
	prev = c;
	count++;
    }
    cout << mlen << endl;
}


Measured memory_bytes: 1360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=4e5+10;
struct node{int x,L,R,l,r;};
bool operator < (node a,node b){
	if (a.x==b.x)return a.l<b.l;
	return a.x<b.x;
}
set<node> s,s1;
vector<node> d;
int n,L;
ll ans;
int al[N],ar[N],q[N],pl[N],pr[N];
void calc(int x){
	ll cnt=0;
	for (int i=0;i<d.size();i++){
		if (i>=L-1)cnt+=d[i-L+1].L;
		ans+=cnt*d[i].R;
	}
	int c1=1,t=0,t1,L1=0;
	L1=d[0].l;
	for (int i=0;i<d.size();i++){
		if (c1==L){
			ar[++t]=0;
			pl[t]=1e9;
			pr[t]=0;
			c1=0;
		}
		ar[t]+=d[i].R;
		pl[t]=min(pl[t],d[i].l);
		pr[t]=max(pr[t],d[i].r);
		c1++;
	}t1=t;
	c1=1,t++;
	for (int i=d.size()-1;i>=0;i--){
		if (c1==L){
			al[--t]=0;
//			pl[t]=1e9;
//			pr[t]=0;
			c1=0;
		}
		al[t]+=d[i].L;
		c1++;
	}
	d.clear();
	pl[1]=L1;
	for (int i=1;i<=t1;i++){
		d.push_back((node){x+1,al[i],ar[i],pl[i],pr[i]});
	}
	cnt=0;
	for (int i=0;i<d.size();i++){
		if (i>=L-1)cnt+=d[i-L+1].L;
		ans-=cnt*d[i].R;
	}
}
int main(){
	cin>>n>>L;
	for (int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		s.insert((node){x,1,1,i,i});
	}
	while (s.size()){
		s1.clear();
		int v=s.begin()->x;
		for (auto i:s){
			if (!d.empty()){
				if (d.back().r+1<i.l||i.x!=v){
					for (auto x:d)s.erase(x);
					if (d.size()<L){
						d.clear();
					}
					else calc(v);
					for (auto x:d)s.insert(x);
					d.clear();
					break;
				}
			}
			if (i.x!=v)break;
			d.push_back(i);
		}
		int tag=0;
		while (d.size()>=L){
			calc(v);
			tag=1;
		}
		if (d.size()||tag)break;
	}
	cout<<ans+n<<endl;
}

Measured memory_bytes: 18800
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		double[] A = new double[n];

		for (int i = 0; i < n; i++) {
			A[i] = sc.nextInt();
		}

		double ans = 0;

		for (double a: A) {
			ans += (1/a);
		}

		System.out.println(1/ans);

}}

Measured memory_bytes: 23380
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > pipii;
typedef vector<ll> vi;

const int INF = 1e9;
const int MOD = 1e9+7;

int main(void){
	int n;
	cin >> n;
	vi x(n), y(n), h(n);
	REP(i, n) cin >> x[i] >> y[i] >> h[i];
	for(int cx = 0; cx <= 100; cx++){
		for(int cy = 0; cy <= 100; cy++){
			int f = 1;
			int hh = 0;
			REP(i, n) {
				if(h[i] == 0) continue;
				hh = h[i] + abs(cx-x[i]) + abs(cy-y[i]);
			}
			REP(i, n){
				int hh2 = h[i] + abs(cx-x[i]) + abs(cy-y[i]);
				if(h[i] && hh2 != hh) f = 0;
				if(!h[i] && hh2 < hh) f = 0;
			}
			if(f) {
				cout << cx << " " << cy << " " << hh << endl;
			}
		}
	}
}

Measured memory_bytes: 256
S = list(input())  # 一文字ずつ格納
ans = 0
tmp = 0
for s in S:
    if s != "A" and s != "T" and s != "G" and s != "C":
        ans = max(ans, tmp)
        tmp = 0
    else:
        tmp += 1

ans = max(ans, tmp)

print(ans)


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

using namespace std;

#define MOD 1000000007
#define PI 3.1415926535897932384626433832795
#define INF (int)1e9
typedef long long int int64;

void print() {
    cout << endl;
}

void print(const char* s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(char s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(string s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(int64 s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(int s, bool endline = true) {
    cout << s;
    if (endline) print();
}

template <typename T, typename T2>
void print(pair<T, T2>& p, bool endline = true) {
    cout << "(";
    print(p.first, false);
    cout << ", ";
    print(p.second, false);
    cout << ")";

    if (endline) print();
}

template <typename T>
void print(T& t, bool endline = true) {
    cout << "[";
    for (auto it = t.begin(); it != t.end(); ++it) {
        if (it != t.begin()) cout << ", ";
        print(*it, false);
    }
    cout << "]";

    if(endline) print();
}

template <typename T>
vector<T> operator+(const vector<T> &a, const vector<T> &b)
{
    vector<T> ret;
    ret.reserve( a.size() + b.size() );                // preallocate memory
    ret.insert( ret.end(), a.begin(), a.end() );        // add A;
    ret.insert( ret.end(), b.begin(), b.end() );        // add B;

    return ret;
}

template <typename T>
vector<T> &operator+=(vector<T> &a, const vector<T> &b)
{
    a.reserve( a.size() + b.size() );                // preallocate memory without erase original data
    a.insert( a.end(), b.begin(), b.end() );         // add B;
    return a;
}

bool c(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    return (a.first + a.second > b.first + b.second); 
}

unordered_map<int, vector<int>> graph;
unordered_set<int> seen;
int ret = 0;

void dfs(int i, int target) {
    seen.insert(i);

    if(seen.size() == target) {
        ret += 1;
    } else {
        for(auto& next : graph[i]) {
            if(seen.find(next) == seen.end()) {
                dfs(next, target);
            }
        }
    }

    seen.erase(i);
}

int main() {
    // g++ -Wall -Wextra -O2 -std=c++17 helloworld.cpp  
    int m, n;

    cin >> n;
    cin >> m;

    for(int i = 0; i < m; i++) {
        int a;
        int b;

        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    seen.insert(1);
    dfs(1, n);

    cout << ret << endl;

    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring> 
#include<algorithm>
#include<iomanip>
using namespace std;
int main()
{
	int m,n;
	cin>>n>>m;
	if (n>=0&&n<10)
	cout<<1000-100*n+m;
	else
	cout<<m;
	return 0;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a<b)
    {
        for(int i=0;i<b;i++)
        {
            cout<<a;
        }
        cout<<endl;
    }
    else{
        for(int i=0;i<a;i++)
        {
            cout<<b;
        }
        cout<<endl;
    }



    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int partition (int *A, int n) {

  int base = A[n-1];

  int baseIndex = 0;

  for (int i = 0; i < n; i++) {

    if (A[i] <= base) {
      if (baseIndex != i) {
        int origin = A[i];
        A[i] = A[baseIndex];
        A[baseIndex] = origin;
      }
      baseIndex++;
    }

  }

  return baseIndex-1;

}

int main () {

  int n;
  scanf("%d", &n);

  int A[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }

  int baseIndex = partition(A, n);

  for(int i = 0; i < n; i++) {
    if (i != 0) {
      printf(" ");
    }
    if (i == baseIndex) {
      printf("[%d]", A[i]);
    } else {
      printf("%d", A[i]);
    }
  }

  printf("\n");

}

Measured memory_bytes: 3588
#include<stdio.h>

int main(){
	int a[31];
	int i, t;
	for( i = 0; i <= 30; i++ ){ a[i] = 0; }
	for( i = 0; i < 28; i++ ){
		scanf("%d", &t);
		a[t] = 1;
	}
	for( i = 1; i <= 30; i++ ){
		if( a[i] == 0 ){ printf("%d\n", i); }
	}
	return 0;
}

Measured memory_bytes: 596
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int N, C, S, F, T[500] = {0};
ll t = 0;

int main()
{
  cin >> N;

  REP(i, N - 1)
  {
    cin >> C >> S >> F;
    T[i] = S + C;
    REP(j, i)
    {
      T[j] = (S < T[j] ? S + (int)((T[j] - S + F - 1) / F) * F : S) + C;
    }
  }

  REP(i, N)
  {
    cout << T[i] << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200050;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;

void Yes() {
	cout<<"Yay!"<<endl; exit(0);
}
void No() {
	cout<<":("<<endl; exit(0);
}

void solve() {
	int A, B, C, D; cin >> A >> B >> C >> D;
	if (C == A)print(0);
	else print(1);
}


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

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

int main(){
    long long n, sum;
    cin >> n;

    sum = 0;

    for (int i = 1; i <= n; ++i){
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        else sum += i;
    }

    cout << sum << endl;


}


Measured memory_bytes: 3592
n=int(input())
res=""
l=[chr(i) for i in range(97,123)]
while(n>0):
    x=n%26
    if x==0:
        res+="z"
        n=n//26-1
    else:
        res+=l[x-1]
        n=n//26
print(res[::-1]) 
        
    


Measured memory_bytes: 61884
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin >> N;
  
  for(int a=0; a<N; a++){
    for(int b=0; b<N; b++){
      int total = 4*a + 7*b;
      if(total == N){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  
  cout << "No" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n){
    cin >> a.at(i);
    if(a.at(i)==0){
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans = 1LL;
  rep(i,n){
    ll tmp  = ans * a.at(i);
    if(tmp>(ll)pow(10,18)){
      cout << -1 << endl;
      return 0;
    }

  dump(LONG_MAX);
  dump(ans);
    if(a.at(i)>(LONG_MAX/(ll)ans)){
      cout << -1  << endl;
      return 0;
    }
    else{
      ans = tmp;
    }
    
 }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5580
#include<set>
#include<map>
#include<ctime>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
LL read(){
    LL f=1,x=0;char s=getchar();   
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
inline void print(int x){
	if(x<0) putchar('-'),x=-x;
	if(x>9)
		print(x/10);
	putchar(x%10+'0');
	return ;
}
#define MAXN 10
#define INF 0x3f3f3f3f
int D,p[MAXN+5],ans=INF;
bool vis[MAXN+5];
LL c[MAXN+5],s[MAXN+5];
void DFS(LL tmp,int cnt){
	for(int i=D;i>=1;i--)
		if(!vis[i]){
			if(tmp>s[i]) vis[i]=1,DFS(tmp-s[i],cnt+p[i]),vis[i]=0;
			else ans=min(ans,cnt+min(int((tmp+i*100-1)/(i*100)),p[i]));
		}
	return ;
}
int main(){
	D=read();LL G=read();
	for(int i=1;i<=D;i++)
		p[i]=read(),c[i]=read(),s[i]=100*i*p[i]+c[i];
	DFS(G,0);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        boolean[] sunuke = new boolean[N];
        for (int i = 0; i < K; i++) {
            int d = sc.nextInt();
            for (int j = 0; j < d; j++) {
                int A = sc.nextInt();
                sunuke[A - 1] = true;
            }
        }
        int counter = 0;
        for (int i = 0; i < sunuke.length; i++) {
            if (sunuke[i] == false) {
                counter++;
            }
        }
        System.out.println(counter);
        sc.close();
    }
}

Measured memory_bytes: 46180
import java.util.Scanner;

class Main {
   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       String input = sc.nextLine();
       String output = "";
       int i;
       Character c;
       for (i = 0; i < input.length(); i++) {
           c = input.charAt(i);
           if(c >= 'A' && c <= 'Z') output = output.concat(c.toString().toLowerCase());
           else if(c >= 'a' && c <= 'z') output = output.concat(c.toString().toUpperCase());
           else output = output.concat(c.toString());
       }
       System.out.println(output);
   }
}


Measured memory_bytes: 27948
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using vi = vector<int>;


int getpop(int x){
    int cnt = 0;
    while(x > 0){
        if(x % 2 == 1){
            cnt++;
        }
        x = x/2;
    }
    return cnt; 
}

int main(){
    int n;
    string x;
    cin >> n >> x;
    int pop_cnt = 0;
    rep(i,n){
        if(x[i] == '1') pop_cnt++;
    }


    vi plus(n),minus(n);
    int base = 1;
    rep(i,n){
        plus[i] = base % (pop_cnt+1);
        base *= 2;
        base %= (pop_cnt+1);
    }


    base = 1;
    if(pop_cnt>1){
        rep(i,n){
            minus[i] = base % (pop_cnt-1);
            base *= 2;
            base %= (pop_cnt-1);
        }
    }

    
    int plus_n=0,minus_n=0;
    rep(i,n){
        if(x[i] == '1'){
            plus_n += plus[n-i-1];
            plus_n %= (pop_cnt+1);
            if(pop_cnt>1){
                minus_n += minus[n-i-1];
                minus_n %= (pop_cnt-1);
            }
        }
    }

    int tmp = 0;
    int cnt = 0;
    rep(i,n){
        //cout << i << endl;
        tmp = 0;
        cnt = 0;
        if(x[i] == '1'){
            if(pop_cnt>1){
                tmp = minus_n - minus[n-i-1] + (pop_cnt-1);
                tmp %= (pop_cnt-1);
            }else{
                cout << 0 << endl;
                continue;
            }
        }else{
            tmp = plus_n + plus[n-i-1];
            tmp %= (pop_cnt+1);
        }
        cnt++;
        while(tmp > 0){
            int popcnt = getpop(tmp);
            tmp %= popcnt;
            cnt++;
        }
        cout << cnt << endl;
    }

    return 0;    
}

Measured memory_bytes: 5200
#!/usr/bin/env ruby

def calc_costs(buy_lists, costs)
  res = 0
  buy_lists.each_with_index do |buyed, idx|
    # puts "#{idx}: cost #{costs[idx]}" if buyed
    res += costs[idx + 1] if buyed
  end
  return res
end

n, m, x = gets.split.map(&:to_i)
costs = [-1000000000]
exps = [1000000000]
n.times do
  nums = gets.split.map(&:to_i)
  c = nums[0]
  as = nums[1..-1]
  costs << c
  exps << as
end

# dp[cost][idx] = [exps]
# dp = Array.new(100001).map { Array.new(100).map {Array.new(100, -1)} }

# [books_idx][true/false] = [exps]
# dfs = Array.new(100).map { Array.new(2).map {Array.new(100, 0)} }

status = Struct.new('Status', :books, :exps, :idx)


buyed = status.new([true], exps[1], 1)
not_buyed = status.new([false], Array.new(m, 0), 1)

queue = [buyed, not_buyed]
cands = []


while !queue.empty?
  top = queue.pop
  if top.books.size >= n
    # p top
    # p top
    next if top.exps.any? { |exp| exp < x }

    cost = calc_costs(top.books, costs)
    # puts cost
    cands << cost if cost >= 0
    next
  end
  next_idx = top.idx + 1
  current_books = top.books
  current_exps = top.exps
  added_exps = current_exps.dup

  unless exps[next_idx].nil?
    exps[next_idx].each_with_index do |exp, idx|
      added_exps[idx] += exp
    end
  end



  buyed = status.new(current_books + [true], added_exps, next_idx)
  # p buyed
  not_buyed = status.new(current_books + [false], current_exps, next_idx)
  queue << buyed
  queue << not_buyed
end

cands.sort!
puts cands.empty? ? -1 : cands[0]

Measured memory_bytes: 14420
#include<bits/stdc++.h>
using namespace std;
typedef pair<double,double> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N;
int col[100100];
int Query(int x){
	printf("%d\n",x);
	fflush(stdout);
	string res;
	cin >> res;
	if(res=="Male")return 0;
	else if(res=="Female")return 1;
	else{
		exit(0);
	}
}
int main(){
	scanf("%d",&N);
	int l=0,r=N;
	col[0]=col[N]=Query(0);
	while(1){
		int mid = (l+r)/2;
		col[mid]=Query(mid);
		if((mid-l)%2==1){
			if(col[mid]==col[l])r=mid;
			else l=mid;
		}else{
			if(col[mid]==col[l])l=mid;
			else r=mid;
		}
	}
	return 0;
}

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

void swap(int *x, int *y) {
	int tmp;
	tmp = *x;
	*x = *y;
	*y = tmp;
}

int main(void) {
	int i,j;
	int lot[10];

	// input
	for(i=0; i<10; i++) scanf("%d", &lot[i]);

	// sort
	for(i=0; i<10; i++) {
		for(j=9; j>i; j--) {
			if(lot[j] > lot[j-1]) swap(&lot[j],&lot[j-1]);
		}
	}

	// output
	for(i=0; i<3; i++) printf("%d\n",lot[i]);

	return 0;
}

Measured memory_bytes: 600
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
s=sum(a)%mod

aa=sum([i**2 for i in a])%mod

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def div(a, b):
    return mul(a, pow(b, mod-2,mod)) % mod

ans=div((pow(s,2)%mod-aa)%mod,2)

print(int(ans))

Measured memory_bytes: 31612
import java.util.Scanner;
import java.util.ArrayList;

public class Main{
 public static void main(String[] args){
  Scanner sc=new Scanner(System.in);
  ArrayList<Integer> ave=new ArrayList<Integer>();
  int i=0,n;
  do{
  int max=1000,min=0,counter_M=0,counter_m=0;
  int sum=0;
  n=sc.nextInt();
  for(int k=0;k<n;k++){
    int s=sc.nextInt();
    sum+=s;
    if(max<=s||counter_M==0){
      max=s;
      counter_M=1;
    }
    if(min>=s||counter_m==0){
      min=s;
      counter_m=1;
    }
  }
  double ave_s=(double)(sum-max-min)/(double)(n-2);
  ave.add(i,(int)ave_s);
  i++;
}while(n!=0);
for(int j=0;j<i-1;j++){
  System.out.println(ave.get(j));
}
}
}

Measured memory_bytes: 29024
#include <bits/stdc++.h>
using namespace std;
#define int long long int
double ar[55];
int32_t main(){
	int n;cin>>n;for(int i=1;i<=n;i++) cin>>ar[i];sort(ar+1,ar+n+1);
	double ans = ar[1];
	for(int i=2;i<=n;i++) ans = (ans+ar[i])/2;
	cout<<fixed<<setprecision(8)<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,cnt=0;
  cin>>n;
  for(int i=1;i<=n;i+=2){
    int c=0;
    for(int j=1;j<=i;j+=2){
      if(i%j==0){
        c++;
      }
    }
    if(c==8) cnt++;
  }
  cout<<cnt;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);






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

	int N;
	cin >> N;
	string s;
	cin >> s;
	int minnum = 0, sum = 0;
	rep(i, N) {
		if (s[i] == '(')sum++;
		else sum--;
		minnum = min(minnum, sum);
	}
	rep(i, -minnum)cout << '(';
	cout << s;
	rep(i, sum - minnum)cout << ')';


	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <deque>
using namespace std;
using ll = int64_t;

int main() {
  ll n,m;
  cin >> n >> m;
  vector<set<ll>> E(n, set<ll>{});
  for(ll i=0; i<m; i++) {
    ll a,b;
    cin >> a >> b;
    a--; b--;
    E[a].insert(b);
    E[b].insert(a);
  }
  vector<int> SEEN(n, false);
  ll ans = 0;
  for(ll i=0; i<n; i++) {
    if(!SEEN[i]) {
      ll size = 0;
      deque<ll> Q;
      Q.push_back(i);
      while(!Q.empty()) {
        ll x = Q.front(); Q.pop_front();
        if(SEEN[x]) { continue; }
        SEEN[x] = true;
        size++;
        for(ll y : E[x]) {
          Q.push_back(y);
        }
      }
      ans = max(ans, size);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 32988
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define nl <<"\n"
#define con continue
#define br break
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
ll mx=INT_MAX;
ll mi=INT_MIN;
const ll MOD=998244353;
const ll inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
#define io { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define cer cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
vll v(200);
ll f(ll x,ll n)
{
    for(ll i=0;i<n;i++)
    {
        if(v[i]==x) return 1;
    }
    return 0;
}
int main()
{
        io;
        //////////////////////////////////
        ll n,i,j,k=0,x,y=0;
        cin>>x>>n;
        for(i=0;i<n;i++) cin>>v[i];
        while(y==0)
        {
            if(f(x-k,n)==0)
            {
                cout<<x-k ;return 0;
            }
            else if(f(x+k,n)==0)
            {
                cout<<x+k; return 0;
            }
            k++;
        }
        //////////////////////////////////
        cer;
}

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

int main(){
    long long int N=0, x[100000]={0}, y[100000]={0}, t[100000]={0};
    long long int xn=0, yn=0;
    cin >> N;
    for(long long int i=0; i<N; i++){
        cin >> t[i] >> x[i] >> y[i];
    }
    for(long long int i=0; i<N; i++){
        if(x[i]+y[i]>yn+xn+t[i]){
            cout << "No" << endl;
            goto END;
        }else if(t[i]%2==0){
            if(((x[i]+y[i])-(xn+yn))%2!=0){
                cout << "No" << endl;
                goto END;
            }
        }else if(t[i]%2!=0){
            if(((x[i]+y[i])-(xn+yn))%2==0){
                cout << "No" << endl;
                goto END;
            }
        }
    }
    cout << "Yes" << endl;

END:
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N, R; cin >> N >> R;
  int result = N>=10 ? R : R+100*(10-N);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    x = list(map(int, input().split()))
    min = 10000000000
    for point in range(10000):
        s = sum([(i - point)**2 for i in x])
        if s < min:
            min = s
    print(min)


if __name__ == "__main__":
    main()




Measured memory_bytes: 90960
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;
 

int N,i,j,k,C[10][10]={0},n,m,ans,a,b,c;

int main()
{
  cin >>N;
  
  m=10;
  for(i=1;i<10;i++)
  {
    if(i<=N)
    {
      C[i][i]++;
    }
  }
  
  while(m<=100000)
  {
  for(i=1;i<10;i++)
  {
    for(j=1;j<10;j++)
    {
      for(a=0;10*a<m;a++)
      {
        k=m*j+10*a+i;
        if(k<=N)
        {
          C[i][j]++;
        }
      }      
    }
  }
  m=m*10;
  }
  
  ans=0;
  for(i=1;i<10;i++)
  {
    for(j=1;j<10;j++)
    {
      ans+=C[i][j]*C[j][i];
    }
  }
  
  cout<<ans;
  
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define ld long double
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i<n; i++) {
        cin >> a[i];
    }
    vector<vector<int>> g(n);
    for (int i = 0; i<m ; i++) {
        int l, r;
        cin >> l >> r;
        g[l-1].pb(r-1);
        g[r-1].pb(l-1);
    }
    int cnt = 0;
    for (int i = 0; i<n; i++) {
        int m = 0;
        for (int j : g[i]) {
            m = max(a[j], m);
        }
        if (a[i] > m) {
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 8732
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define Time (double)clock()/CLOCKS_PER_SEC
int mmod(int n, int m) {
    return (n % m + m) % m;
}   
void solve() {
    int a, b, c, d; cin >> a >> b >> c >> d;
    if (a < b || d < b) {
        cout << "No\n";
        return;
    }   
    int l = c + 1 - b;
    int mod = __gcd(b, d);
    if (mmod(l, mod) <= mmod(a, mod)) l += mmod(a, mod) - mmod(l, mod);
    else l += mod - (mmod(l, mod) - mmod(a, mod));
    if (l < 0) cout << "No\n";
    else cout << "Yes\n";
}   
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int t; cin >> t;
    while (t--) solve();
}

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

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

    int x = (100 * n + 107) / 108;

    if(x * 108 / 100 == n){
        cout << x << endl;
    }else{
        cout << ":(" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
  public static void main (String[] args) throws Exception {
    
    Scanner sc = new Scanner(System.in);
    
    int n=sc.nextInt();
    int x=sc.nextInt();
    int y=sc.nextInt();
    
    int[] ans =new int[n];
    
    for(int i=1; i<n+1; i++){
        for(int j=i+1; j<n+1; j++){
          int tmp =Math.min(Math.min(j-i, Math.abs(x-i)+1+Math.abs(y-j)),Math.abs(y-i)+1+Math.abs(x-j));
          ans[tmp-1]++;
          

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


Measured memory_bytes: 22228
#include<cstdio>
#include<iostream>
int main(){
    int n;
    while(1){
        int a,b,suma=0,sumb=0;
        scanf("%d",&n);
        if(n==0)
            break;
        for(int i=0;i<n;i++){
            scanf("%d%d",&a,&b);
            if(a>b)
                suma+=a+b;
            else if(a<b)
                sumb+=a+b;
            else
                suma+=a,sumb+=b;
        }
        printf("%d %d\n",suma,sumb);
    }
exit:
    return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

string cf = "CODEFESTIVAL2016";

int main(void)
{
  string s; cin >> s;
  ll c = 0;
  REP(i, cf.size()) {
    if(cf[i] != s[i]) c++;
  }
  cout << c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#define ALL(a) (a).begin(),(a).end()

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};




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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 510000; 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;
}


int main() {
  ll A;
  cin>>A;
  ll ans=0;

  cout<< (A-2)*180 <<endl;
 
}

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

const int N = 1e5 + 10, mod = 1e9 + 7;
int n, m, ar[N], dp[N];

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x;
		cin >> x;
		ar[x] = 1;
	}
	
	dp[0] = 1;
	for (int i = 1; i <= n; i++)
		if (!ar[i])
			dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
	cout << dp[n];
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
#define ss second
#define ff first 
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
const ll M=1000000007;
ll power(ll x,ll n,ll m){if(n==0)return 1;else if(n%2==0)return (power(((x%m)*(x%m))%m,n/2,m))%m;else return ((x%m)*power(x,n-1,m)%m);}
ll ncr(int n,int r){if(r>n)return 0;if(r > n - r) r = n - r;ll ans = 1;
int i;for(i = 1; i <= r; i++){ans *= n - r + i;ans /= i;}return ans;}
ll nCrModpDP(ll n, ll r, ll p){ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C)); 
    C[0] = 1;
    for (ll i = 1; i <= n; i++){ 
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
} 
ll ncrmod(ll n, ll r, ll p){ 
   if (r==0) 
      return 1; 
   ll ni = n%p, ri = r%p; 
   return (ncrmod(n/p, r/p, p) * 
           nCrModpDP(ni, ri, p)) % p;  
} 
ll modInverse(ll a,ll m) 
{ 
   ll m0 = m; 
   ll y = 0, x = 1; 
  
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    { 
       ll q = a / m; 
       ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
  
    return x; 
} 
int dx[] = {1,-1,0,0,1,1,-1,-1}; 
int dy[] = {0,0,1,-1,-1,1,-1,1}; 
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,x,t;
cin>>n>>x>>t;
ll a=n%x;
int d=0;
if(a>0)
d=1;
cout<<((n/x)+d)*t<<"\n";
return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;

const int N = 1000010;
long long fac[N], finv[N], inv[N];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < N; 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;
}

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

    long long X, Y;
    cin >> X >> Y;

    if((X + Y) % 3 != 0){
        cout << 0 << endl;
        return 0;
    }

    COMinit();

    long long x, y;
    x = (2 * Y - X) / 3;
    y = (2 * X - Y) / 3;

    cout << COM(x + y, x) << endl;

    return 0;
}

Measured memory_bytes: 23680
#! /usr/bin/python
# -*- coding: utf-8 -*-

def MaxPro(val):
    mul = 10
    dig = 1
    while val >= mul:
        dig += 1
        mul *= 10
    Max = 0
    for i in range(1, dig):
        tmp = (val%(10**i))*(val/10**i)
        if Max < tmp:
            Max = tmp
    return Max

def ProCnt(val, cnt):
    if val<10:
        return cnt
    else:
        return ProCnt(MaxPro(val), cnt+1)

q = int(raw_input())
for i in range(q):
    n = int(raw_input())
    print ProCnt(n, 0)
    

Measured memory_bytes: 4232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int k, s;
    cin >> k >> s;
    int ans = 0;
    for(int x = 0; x <= k; x++){
        for(int y = 0; y <= k; y++){
            int z = s - (x + y);
            if(z >= 0 && z <= k)
                ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
namespace ITP1_1_C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            //String.SplitメソッドとはStringクラスメソッドの一つで、文字列を指定した区切り文字で分割し配列に格納する場合に使う
            
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            
            Console.WriteLine(a * b + " " + (a + b) * 2);
        }
    }
}


Measured memory_bytes: 13936
n, ma, mb = [int(i) for i in input().split()]

# a,b,cを入力
lst = [[int(i) for i in input().split()] for _ in range(n)]

# コストの小さい順に並び替える
lst.sort(key=lambda x: x[2])
#print(lst)

dic = {}
#####
# 動的計画法

# 値の更新
def push(k,v):
    if k in dic:
        dic[k] = min(dic[k],v)
    else:
        dic[k] = v

for i in lst:
    # v = i[2]: コスト
    k, v = i[0] * mb - i[1] * ma, i[2]
    l = [[j, dic[j]] for j in dic]
    #print(l)
    for item in l:
        push(item[0] + k, item[1] + v)
    push(k, v)

#####
print(dic[0] if 0 in dic else '-1')


Measured memory_bytes: 3572
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;
const ll MOD = 1e9+7;
const ll INF = 1e18;


#define PB push_back
#define MP make_pair
#define F first
#define S second

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}

int main(){
  	ll x;
    cin >> x;
    for(ll i=-200;i<200;i++){
        for(ll j=-200;j<200;j++){
            if(x==(ll)(pow(i,5)-pow(j,5))){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 4076
#include <iostream>
#include <array>
#include <string>

using std::array;
using std::string;

const array<string, 3> result{"Alice", "Draw", "Bob"};

int main() {
    array<int, 2> t, r;
    for (auto& x : t) std::cin >> x;
    for (auto& x : r) std::cin >> x;

    int ans;
    if (r[0] < 0 || r[1] < 0) {
        ans = (t[0] < t[1] ? 0 : t[0] == t[1] ? 1 : 2);
    } else {
        ans = (r[0] > r[1] ? 0 : r[0] == r[1] ? 1 : 2);
    }
    std::cout << result[ans] << std::endl;
    return 0;
}



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

void input(int& rnTrgSu, int& rnTrgKin)
{
  cin >> rnTrgSu >> rnTrgKin;
}

void searchMoney(int nTrgSu, int nTrgKin)
{
  vector<int> cnvnMoney{10000, 5000, 1000};

  int nCalKin;
  int i, j;
  for (i = 0; i <= nTrgSu; i++)
  {
    for (j = 0; j <= (nTrgSu - i); j++)
    {
      nCalKin = nTrgKin;

      nCalKin -= cnvnMoney[0] * i;
      nCalKin -= cnvnMoney[1] * j;
      nCalKin -= cnvnMoney[2] * (nTrgSu - i - j);
      if ( !nCalKin )
        break;
    }
    if ( !nCalKin )
      break;
  }
  if ( !nCalKin )
    cout << i << " " << j << " " << (nTrgSu - i - j) << endl;
  else
    cout << -1 << " " << -1 << " " << -1 << endl;
}

int main()
{
  int nTrgSu, nTrgKin;
  
  input(nTrgSu, nTrgKin);
  searchMoney(nTrgSu, nTrgKin);

  return 0;
}

Measured memory_bytes: 3608
def divisors(x):
    '''公約数をリスト型で返す関数'''
    divisors = []
    divisor = 1
    while(divisor <= x / divisor):
        if x % divisor == 0:
            divisors.append(divisor)
            if divisor == int(x / divisor):
                pass
            else:
                divisors.append(int(x / divisor))
        else:
            pass
        divisor += 1
    return sorted(divisors)

A, B = map(int, input().split())

if A in divisors(B):
    print(A + B)
else:
    print(B - A)


Measured memory_bytes: 3060