akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <iostream>
#include <memory>
#include <numeric>

#include <array>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cstring>
#include <ostream>
#include <type_traits>
#include <utility>
#include <chrono>
#include <random>

#pragma GCC optimize ("O3")

#pragma GCC target ("avx,avx2")

using namespace std;

using u64 = uint64_t;
using i64 = int64_t;
using u32 = uint32_t;
using vi = vector<int>;
using vi64 = vector<i64>;

#define seq(i,a,b) for (int i = (a); i < (b); ++i)
#define rev(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define dbg(x) {cerr << #x << ": " << x << endl;}

u64 const BASE = 37;

using mod_t = u64;

template <size_t n>
auto computePows(array<mod_t, n> &p)
{
    p[0] = 1ull;
    for (int i = 1; i < n; ++i) {
        p[i] = p[i-1]*BASE;
    }
    return p;
}
array<mod_t,100001> base_pows;

struct StrHash {
    vector<u64> chash;
    StrHash(string str) {
        chash.reserve(str.size() + 1);
        u64 hashval = 0;
        chash.push_back(hashval);
        for (char c : str) {
            hashval = hashval*BASE + (c - 'a' + 1);
            chash.push_back(hashval);
        }
    }

    u64 hash(int i, int j) const {
        // [i,j)
        return (chash[j] - base_pows[j-i]*chash[i]);
    }
};


int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    computePows(base_pows);

    int n; cin >> n;
    string s; cin >> s;

    StrHash h(s);

    int mx = 0;
    seq(i,0,n) {
        seq(j,i+1,n) {
            int l = i;
            int r = j+1;
            while (l + 1 < r) {
                int mid = (l+r)/2;
                if (h.hash(i,mid) == h.hash(j,j + mid-i)) {
                    l = mid;
                } else {
                    r = mid;
                }
            }
            mx = max(mx, l - i);
        }
    }

    cout << mx << endl;

    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
int y,n,a,b,c,f=1;
int main() {
	scanf("%d",&n);
	while(n--){
        scanf("%d",&a);
        if(a%2) continue;
        if(a%3&&a%5) f=0;
	}
	printf("%s\n",f?"APPROVED":"DENIED");
	return 0;
}


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

#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl

typedef long long ll;

using namespace std;

void solve() {
    int N;
    cin >> N;

    bool ans = false;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            if (i * j == N) {
                ans = true;
                break;
            }
        }
    }
    if (ans) print("Yes");
    else print("No");
}

signed main() {
    solve();
}


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

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}

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

signed main(void)
{
  int n;
  cin >> n;
  set<int> st;
  REP(i, n) {
    int a;
    cin >> a;
    st.insert(a);
  }
  cout << st.size() << endl;

  return 0;
}


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

int main()
{
  int n, m;
  while (~scanf("%d %d", &n, &m)) {
    if ((n|m) == 0)
      break;

    list<int> p;
    for (int i = 1; i <= n; ++i)
      p.push_back(i);

    int cnt = 1;
    list<int>::iterator it = p.begin();
    while (p.size() > 1) {
      if (cnt%m == 0) {
	it = p.erase(it);
	cnt = 0;
      } else {
	++it;
      }
      ++cnt;
      if (it == p.end())
	it = p.begin();
    }
    printf("%d\n", *p.begin());
  }
  return 0;
}

Measured memory_bytes: 824
#include<stdio.h>
int main()
{
int a,b;
char op;
while(1)
{
scanf("%d %c %d",&a,&op,&b);
if(op=='?')
{
break;
}
else if(op=='+')
{
printf("%d\n",a+b);
}
else if(op=='-')
{
printf("%d\n",a-b);
}
else if(op=='*')
{
printf("%d\n",a*b);
}
else if(op=='/')
{
printf("%d\n",a/b);
}
}
return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
int main(void)
{
  int a,b,c;
  int min=0;

  scanf("%3d %3d %3d",&a,&b,&c);
  
  min=a+b;
  if(a+c<min)
    min=a+c;
  if(b+c<min)
    min=b+c;

  printf("%d",min);

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=100005;
int n,m,cc,ff,sv,se,hd[N],vis[N],f[3];ll ans;
struct E{int v,nxt,w;}e[N*2];
inline void add(int u,int v,int w){e[++cc]=(E){v,hd[u],w};hd[u]=cc;}
void dfs(int x,int c)
{
	vis[x]=c;f[c]++;sv++;
	for(int i=hd[x];i;i=e[i].nxt)
	{
		int y=e[i].v;se+=(e[i].w==1);
		if(vis[y]==-1)dfs(y,(c+e[i].w)%3);
		else if(vis[y]!=(c+e[i].w)%3)ff=0;
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1,u,v;i<=m;i++)scanf("%d%d",&u,&v),add(u,v,1),add(v,u,2);
	memset(vis,-1,sizeof(vis));
	for(int i=1;i<=n;i++)if(vis[i]==-1)
	{
		ff=1;f[0]=f[1]=f[2]=0;sv=se=0;dfs(i,0);
		ans+=!ff?1ll*sv*sv:(!min(f[0],min(f[1],f[2]))?se:(1ll*f[0]*f[1]+1ll*f[1]*f[2]+1ll*f[2]*f[0]));
	}
	printf("%lld\n",ans);return 0;
}


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

int main(){
    int n, m;
    vector<int> p;
    vector<long long> t, x;
    
    cin >> n;
    for(int i=0; i<n; i++){
        long long k;
        cin >> k;
        t.push_back(k);
    }
    cin >> m;
    for(int i=0; i<m; i++){
        int j;
        long long k;
        vector<long long> ans;
        ans = t;
        cin >> j >> k;
        ans[j-1]=k;
        cout << accumulate(ans.begin(), ans.end(), 0LL) << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <memory>        // unique_ptr, shared_ptr, weak_ptr
#include <cstring>
#include <cmath>

using namespace std;

using ll = long long int;
using vi = vector<int>;
using vvi = vector<vi>;

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

int main() {
	long N, X, cnt=0, sum=0;
	cin >> N >> X;

	vector<int> a(N, 0);
	for (size_t i=0; i<N; i++) {
		cin >> a.at(i);
		sum += a.at(i);
	}

	if (sum == X) {
		cout << N << endl;
	} else if (sum > X) {
		sort(a.begin(), a.end());

		int i = 0;
		while (X >= a.at(i)) {
			X -= a.at(i);
			cnt++;
			i++;
		}

		cout << cnt << endl;
	} else if (sum < X) {
		cout << N-1 << endl;
	}

	return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
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 main(){
	while(1){
		int m,t,p,r;
		cin >> m >> t >> p >> r;
		if(t==0) break;
		int WAnum[51][11];// 1-
		REP(i,51) REP(j,11) WAnum[i][j] = 0;
		pair<int,pair<int,int> > data[51];//p-ac_num penalty
		REP(i,51) {
			data[i].first = p;
			data[i].second.second = t-i;
		}
		REP(i,r){
			int mm,tt,pp,jj;
			cin >> mm >> tt >> pp >> jj;
			if(jj==0){
				//AC
				data[tt-1].first--;
				data[tt-1].second.first += (mm+WAnum[tt-1][pp]*20);
			}else{
				//WA
				WAnum[tt-1][pp]++;
			}
		}
		sort(data,data+t);

		int topac = data[0].first;
		int toppenalty = data[0].second.first;
		cout << t-data[0].second.second+1;
		FOR(i,1,t){
			if(data[i].first==topac&&data[i].second.first==toppenalty){
				cout << "=" << t-data[i].second.second+1;
			}else{
				topac = data[i].first;
				toppenalty = data[i].second.first;
				cout << "," << t-data[i].second.second+1;
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 1164
#include<stdio.h>
int main(void)
{
	int n,m,si,ai,x[100001],sum,s,i;
	scanf("%d%d",&n,&m);
	x[0]=0;
	for(i=1;i<n;i++){
		scanf("%d",&si);
		x[i]=si+x[i-1];
	}
	//for(i=0;i<n;i++)printf("x[%d]=%d\n",i,x[i]);
	s=0; sum=0;
	for(i=1;i<=m;i++){
		//printf("sum=%d\n",sum);
		scanf("%d",&ai);
		if(ai>=0){
			sum+=x[s+ai]-x[s];
			s+=ai;
		}
		else{
			sum+=x[s]-x[s+ai];
			s+=ai;
		}
		sum%=100000;
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 3120
a, b, c, x, y = map(int, input().split())

ans = 0
if a + b <= c * 2:
    ans += a * x + b * y
else:
    if x == y:
        ans += c * 2 * x
        x, y = 0, 0
    elif x > y:
        ans += c * 2 * y
        x -= y
        y = 0
    elif y > x:
        ans += c * 2 * x
        y -= x
        x = 0
    if x > 0:
        if a <= c * 2:
            ans += a * x
        else:
            ans += c * 2 * x
    elif y > 0:
        if b <= c * 2:
            ans += b * y
        else:
            ans += c * 2 * y

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef vector<bool> vb;
 
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()
 
const ll mod=1e9+7;
ll n,m;
 
void solve(){
  cin >> n >> m;
  vll a(n),b(m);
  rep(i,0,n) cin >> a[i];
  rep(i,0,m) cin >> b[i];
  
  sort(all(a));
  sort(all(b));
  
  ll res=1;
  repr(x,n*m,1){
   ll s=upper_bound(all(a),x)-lower_bound(all(a),x);
   ll t=upper_bound(all(b),x)-lower_bound(all(b),x);
    
   if(s*t>1) {
     res*=0; 
     break; 
   }else if(s*t==1){
     res*=1; 
   }else if(s==1){
    res*=b.end()-lower_bound(all(b),x);
  }else if(t==1){
    res*=a.end()-lower_bound(all(a),x);
   }else {
    res*=((a.end()-lower_bound(all(a),x))*(b.end()-lower_bound(all(b),x))-n*m+x);
   }
    res%=mod;
  }
  cout << res << endl;
  }

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

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


Measured memory_bytes: 3112
import heapq
x, y, z = [int(item) for item in input().split()]
gsb = []
for i in range(x + y + z):
    gsb.append([int(item) for item in input().split()])
gsb.sort(key=lambda x: x[0] - x[1], reverse=True)

g_sum = sum(item[0] for item in gsb[:x])
s_sum = sum(item[1] for item in gsb[x+z:x+y+z])
b_sum = sum(item[2] for item in gsb[x:x+z])

gb_pq = [a - c for a, b, c in gsb[:x]]
sb_pq = [b - c for a, b, c in gsb[x+z:x+y+z]]
heapq.heapify(gb_pq)
heapq.heapify(sb_pq)

ans_gb = [0]
gb_total_delta = 0
for a, b, c in gsb[x:x+z]:
    new_gb = a - c
    small_gb = heapq.heappushpop(gb_pq, new_gb)
    gb_total_delta += new_gb - small_gb
    ans_gb.append(gb_total_delta)
ans_sb = [0]
sb_total_delta = 0
for a, b, c in gsb[x:x+z][::-1]:
    new_sb = b - c
    small_sb = heapq.heappushpop(sb_pq, new_sb)
    sb_total_delta += new_sb - small_sb
    ans_sb.append(sb_total_delta)
ans_sb.reverse()

max_delta = 0
for gb, sb in zip(ans_gb, ans_sb):
    max_delta = max(max_delta, gb + sb)
print(g_sum + s_sum + b_sum + max_delta)

Measured memory_bytes: 32704
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
template<typename T> void cmin(T &a, T b) { a = min(a, b); }
template<typename T> void cmax(T &a, T b) { a = max(a, b); }

signed main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  int cnt[100005] = {};
  rep(i, n - 1) {
    if (s[i] == 'A' && s[i + 1] == 'C') cnt[i + 2] = 1;
  }

  rep(i, 100003) cnt[i + 1] += cnt[i];
  while (q--) {
    int l, r;
    cin >> l >> r;
    cout << cnt[r] - cnt[l] << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
S = list(input())

cnt = 0

for i in range(len(S)-1):
    if S[i] == S[i+1] == '0':
        S[i+1] = '1'
        cnt += 1
    elif S[i] == S[i+1] == '1':
        S[i+1] = '0'
        cnt += 1
    else:
        pass

print(cnt)


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

int main(){
  int n;
  float a;
  float sum = 0;
  
  cin >> n;
  
  for(int i =0; i < n; i++){
  	cin >> a;
    sum += (1/a);
  }
  cout << 1/sum;
}


Measured memory_bytes: 384
#include<cstdio>
#include<vector>
using namespace std;
vector<int>x[10];
bool vis[10];
int n,m,ans=0;
void dfs(int v)
{
	bool flag=true;
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			flag=false;
		}
	}
	if(flag)
	{
		ans++;
		return;
	}
	for(int i=x[v].size()-1;i>=0;i--)
	{
		if(!vis[x[v][i]])
		{
			vis[x[v][i]]=1;
			dfs(x[v][i]);
			vis[x[v][i]]=0;
		}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		x[a].push_back(b);
		x[b].push_back(a);
	}
	vis[1]=1;
	dfs(1);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int r;
  cin >> r;
  const double PI = acos(-1);
  cout << PI*r*2 << endl;
}


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

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 r = sc.nextInt();
      if(n>=10){
      	System.out.println(r);
      }else{
        System.out.println(r+100*(10-n));
      }
    }
}

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

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

using namespace std;

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

int main() {
  int p, q, r;
  cin >> p >> q >> r;

  int result = p + q + r - max(p, max(q, r));

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007;
#define INF 1000000001

class Tree
{
	public:
//		Tree(int _root);
		int root;
		vector<int> next;
		int value = 0;
};


vector<vector<char>> C;
	

int main(void) {
	
	int N;
	inp(N);
	vector<double> p(N+1,0);
	rep(i,N){
		double a;
		inp(a);
		p[i+1] = a;
	}
	vector<vector<double>> dp(N+1,vector<double>(N+1,0));
	dp[0][0]=1.0;
	dp[1][1]=p[1];
	dp[1][0]=1-p[1];
	if(N!=1){
		rep2(i,2,N+1)rep2(j,0,i+1){
			if(j==0) dp[i][j] = dp[i-1][j]*(1-p[i]);
			else dp[i][j] = dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);

		}
	}
	double ans=0;
	rep(j,N+1){
		if(j>=N/2+1) ans+=dp[N][j];
	}
	cout << setprecision(16) << ans << endl;

}


Measured memory_bytes: 70784
import sys
#input = sys.stdin.buffer.readline
import collections

def main():
    S = str(input())
    c = collections.Counter(S)
    c = c.keys()
    if len(c) == 4:
        print("Yes")
    elif len(c) == 2:
        if ("S" in c and "N" in c):
            print("Yes")
        elif ("W" in c and "E" in c):
            print("Yes")
        else:
            print("No")
    else:
        print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

int main(){
    fast_io

    int n, m;
    map<int, int> mpd, mpt;
    cin>>n;
    vector<int> d(n);
    rep(i,n) {
        cin>>d[i];
        mpd[d[i]]++;
    }
    cin>>m;
    vector<int> t(m);
    rep(i,m) {
        cin>>t[i];
        mpt[t[i]]++;
    }

    for(int i=0;i<m;i++){
        int x=t[i];
        if(mpd[x]<mpt[x]){
            cout<<"NO"<<endl;
            return 0;
        }
    }

    cout<<"YES"<<endl;
    

    return 0;

}


Measured memory_bytes: 20608
tmp=input().split(" ")
n = int(tmp[0])
initialPoint = int(tmp[1])

points= [ abs(int(s)-initialPoint) for s in input().split(" ") ]

def gcd(m, n):
    # 入力を m, n (m ≧ n) とする。
    tmp = max(m,n)
    n = min(m,n)
    m = tmp
    # n = 0 なら、 m を出力してアルゴリズムを終了する。
    if n == 0:
        return m
    # m を n で割った余りを新たに n とし、更に 元のnを新たにm とし 2. に戻る。
    return gcd(n, m % n)

if n == 1:
    print(points[0])
    exit()

now=gcd(points[0], points[1])
for i in range(2, len(points)):
    now = gcd(now, points[i])

print(now)

Measured memory_bytes: 14248
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(10);
}

#define int ll
void solve() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) return;
		int cnt[21][21] = {};
		REP(i, n) {
			int a, b;
			cin >> a >> b;
			cnt[a][b] = 1;
		}
		pair<int, int> now = mp(10, 10);
		int m;
		cin >> m;
		REP(i, m) {
			string a;
			int b;
			cin >> a >> b;
			REP(q, b) {
				if (a == "N") {
					now.second++;
				}
				else if (a == "S") {
					now.second--;
				}
				else if (a == "E") {
					now.first++;
				}
				else {
					now.first--;
				}
				n -= cnt[now.first][now.second];
				cnt[now.first][now.second] = 0;
			}
		}
		if (n == 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}
#undef int

int main() {
	init();
	solve();
}


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

int main(){
    int n;
    int r;
    // 内部レーティング
    int i;

    // 参加回数
    cin >> n;
    // 表示レーティング
    cin >> r;
    if(n >= 10){
        i = r;
    }
    else{
        i = r + 100 * (10 - n);
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n,k; cin >> n >> k;
  string s; cin >> s;

  vector<int> nums;
  int cnt = 0;
  int now = 1;
  REP(i, n) {
    if (s[i]-'0' == now) cnt++;
    else {
      nums.push_back(cnt);
      now ^= 1; // 0と1を切り替える
      cnt = 1;
    }
  }
  if (cnt != 0) nums.push_back(cnt);

  // 1-0-1-0-1 の配列がほしい. 1-0-1-0のように0で終わっていたら1つ足す
  if (nums.size() % 2 == 0) nums.push_back(0);

  int add = 2*k+1; // 1-0-1-0-1 の配列になっているため
  int ans = 0;

  // 累積和
  vector<int> sum(nums.size()+1, 0);
  REP(i,nums.size()) sum[i+1] = sum[i]+nums[i];

  for(int i = 0; i < nums.size(); i+=2) {
    int left = i;
    int right = min(i+add, (int)nums.size());
    int tmp = sum[right] - sum[left];

    chmax(ans,tmp);
  }

  /*
  // しゃくとり法
  int left=0, right=0;
  int tmp = 0; // [left, right) の sum
  // 1-0-1... の偶数番目だけみる
  for (int i = 0; i < nums.size(); i+=2) {
    int nextL = i;
    int nextR = min(i+add, (int)nums.size());
    while(nextL > left) {
      tmp -= nums[left];
      left++;
    }
    while(nextR > right) {
      tmp += nums[right];
      right++;
    }
    chmax(ans,tmp);
  }
  */
  COUT(ans);
  return 0;
}

Measured memory_bytes: 1272
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

A,B,C = I()
if A == B and A != C:
    print(C)
if B == C and A != B:
    print(A)
if A == C and A != B:
    print(B)

Measured memory_bytes: 10048
#include<bits/stdc++.h>
 
using namespace std;
 
struct Manachan
{
  vector< int > radius;
 
  void build(const string &s)
  {
    radius.resize(s.size());
 
    int i = 0, j = 0;
    while(i < s.size()) {
      while(i - j >= 0 && i + j < s.size() && s[i - j] == s[i + j]) {
        ++j;
      }
      radius[i] = j;
      int k = 1;
      while(i - k >= 0 && i + k < s.size() && k + radius[i - k] < j) {
        radius[i + k] = radius[i - k];
        ++k;
      }
      i += k;
      j -= k;
    }
  }
 
  int operator[](const int k) const
  {
    return (radius[k]);
  }
 
  size_t size()
  {
    return (radius.size());
  }
};
 
const int _base = 1e9 + 7;
 
struct RollingHash
{
  vector< unsigned long long > hashed, power;
 
  RollingHash(const string &s)
  {
    int sz = s.size();
    hashed.assign(sz + 1, 0);
    power.assign(sz + 1, 0);
 
    power[0] = 1;
    for(int i = 0; i < sz; i++) {
      power[i + 1] = power[i] * _base;
    }
    for(int i = 0; i < sz; i++) {
      hashed[i + 1] = (hashed[i] + s[i]) * _base;
    }
  }
 
  unsigned long long get(int l, int r) // [l, r)
  {
    return ((hashed[r] - hashed[l] * power[r - l]));
  }
};
 
int main()
{
  string S, T;
  cin >> S >> T;
 
  string A[2];
  A[0] += S[0], A[1] += T[0];
  for(int i = 1; i < S.size(); i++) A[0] += "$", A[0] += S[i];
  for(int i = 1; i < T.size(); i++) A[1] += "$", A[1] += T[i];
 
  Manachan latte[2];
  latte[0].build(A[0]), latte[1].build(A[1]);
 
  priority_queue< tuple< int, int, int > > que;
  unordered_map< unsigned long long, int > sz[2];
  RollingHash hash[2] = {RollingHash(A[0]), RollingHash(A[1])};
 
  auto gethash = [&](int idx, int center, int length)
  {
    return (hash[idx].get(center - length + 1, center + length));
  };
 
  for(int z = 0; z < 2; z++) {
    for(int i = 0; i < latte[z].size(); i++) {
      if(sz[z][gethash(z, i, latte[z][i])]++ == 0) {
        que.emplace(latte[z][i], i, z);
      }
    }
  }
 
  long long ret = 0;
 
  while(!que.empty()) {
    int length, center, idx;
    tie(length, center, idx) = que.top();
    que.pop();
 
    auto hash1 = gethash(idx, center, length);
 
    if(A[idx][center - length + 1] != '$' && idx == 0) {
      ret += 1LL * sz[0][hash1] * sz[1][hash1];
    }
 
    if(length > 1) {
      auto hash2 = gethash(idx, center, length - 1);
      if(!sz[idx].count(hash2)) que.emplace(length - 1, center, idx);
      sz[idx][hash2] += sz[idx][hash1];
    }
  }
 
  cout << ret << endl;
}

Measured memory_bytes: 19112
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main(void){
  int a,b,c,d,l;
  cin >> l >> a >> b >> c >> d;
  cout << l - max((a+c-1)/c,(b+d-1)/d) << endl;
}

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

using namespace std;

#define FOR(i,a,b)  for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n)    FOR(i,0,n)
#define ALL(a)      a.begin(),a.end()
#define vi          vector<int>
#define vvi         vector<vi>
#define P           pair<int,int>
#define vP          vector<P>
#define vvP         vector<vP>

int main(){
    int m,d;cin>>m>>d;
    int res=0;
    for(int i=1;i<=m;i++){
        for(int j=22;j<=d;j++){
            if(j%10 == 1)continue;
            if(j%10*(j/10) == i){
                res++;
                cerr<<i<<j<<endl;
            }
        }
    }
    cout<<res<<endl;
    return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n, c[10101], e[10101], a[10101], b[10101];
P d[10101];
vector<int> v[10101];
bool used[10101];
int cnt = 0;
void dfs(int pos){
	for(int i = 0; i < v[pos].size(); i++){
		int I = v[pos][i];
		if(used[I]) continue;
		used[I] = 1;
		dfs(I);
	}
	e[pos] = c[cnt];
	cnt++;
}
void solve(){
	cin >> n;
	for(int i = 0; i < n-1; i++){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		v[a[i]].push_back(b[i]);
		v[b[i]].push_back(a[i]);
	}
	for(int i = 0; i < n; i++){
		cin >> c[i];
	}
	sort(c,c+n);
	
	used[0] = 1;
	dfs(0);
	i64 ans = 0;
	for(int i = 0; i < n-1; i++){
		ans += min(e[a[i]], e[b[i]]);
	}
	cout << ans << endl;
	for(int i = 0; i < n; i++){
		cout << e[i] << " ";
	}
	cout << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

using namespace std;

int main() {
    char S[3];
    
    char in;
    for (int i = 0; i < 3; i++)
    {
        cin >> in;
        S[i] = in;
    }

    int c = 0;
    for (int i = 0; i < 3; i++)
    {
        cin >> in;

        if (S[i] == in)
        {
            c++;
        }
    }

    cout << c;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int main() {
	int n; read(n);
	cout << 360 / __gcd(n, 360) << endl;
	return 0;
}


Measured memory_bytes: 3628
s = int(input())
l = list(int(x) for x in input().split())
cnt = 0
l.sort()
#print(l[len(l)//2-1])
#print(l[len(l)//2])
#print(l[len(l)//2-1]+1)
#print(l[len(l)//2]+1)
if l[len(l)//2-1] == l[len(l)//2]:
  print(0)
  exit()
for i in range((l[len(l)//2-1]+1),l[len(l)//2]+1):
  cnt += 1
print(cnt)

Measured memory_bytes: 52204
import java.util.*;
import java.lang.*;
public class Main{
    public static void main(String[] args){
        int test;
        Scanner sc=new Scanner(System.in);

            int n=sc.nextInt();

            int arr[]=new int[n];
            int dp[]=new int[n];
            for(int i=0;i<n;i++){
                arr[i]=sc.nextInt();
            }
            dp[0]=0;
            dp[1]=Math.abs(arr[1]-arr[0]);
            for(int i=2;i<n;i++){
                dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
            }
            System.out.println(dp[n-1]);
        }

    
}

Measured memory_bytes: 54616
#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++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
typedef priority_queue<p> pq;
typedef priority_queue<p, vector<p>, greater<p>> gpq;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, ans = 0, maxv = -1;
    cin >> n;

    REP(i, n)
    {
        int tmp;
        cin >> tmp;

        chmax(maxv, tmp);
        ans += tmp;
    }

    cout << ans - (maxv / 2) << endl;
}

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

using namespace std;


int main() {

	int a, b, m;
	cin >> a >> b >> m;

	int* as = new int[a];
	int* bs = new int[b];
	int* mxs = new int[m];
	int* mys = new int[m];
	int* mcs = new int[m];

	int amin = 10000000;
	int bmin = 10000000;

	for (int i = 0; i < a; ++i)
	{
		cin >> as[i];
		if (amin > as[i]) amin = as[i];
	}
	for (int i = 0; i < b; ++i)
	{
		cin >> bs[i];
		if (bmin > bs[i]) bmin = bs[i];
	}
	for (int i = 0; i < m; ++i)
	{
		cin >> mxs[i];
		cin >> mys[i];
		cin >> mcs[i];

		mxs[i]--;
		mys[i]--;
	}

	int cmin = 10000000;

	for (int i = 0; i < m; ++i) {
		int cbuf = as[mxs[i]] + bs[mys[i]] - mcs[i];

		if (cmin > cbuf) cmin = cbuf;
	}

	int nocmin = amin + bmin;

	int min = cmin < nocmin ? cmin : nocmin;

	cout << min << endl;


	delete[] as;
	delete[] bs;
	delete[] mxs;
	delete[] mys;
	delete[] mcs;

	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
using namespace std;
int main() {
    int N;
    cin >> N;
    long long tmp0 = 2;
    long long tmp1 = 1;
    long long ans = tmp0 + tmp1;
    if (N == 1) {
        ans = tmp1;
    }
    else{
        for(int i = 0; i < N - 2; ++i){
            tmp0 = tmp1;
            tmp1 = ans;
            ans = tmp0 + tmp1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

struct v{
	double x,y,ang;
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<v> p(2*n);
	rep(i,n){
		cin>>p[i].x>>p[i].y;
		p[i+n].x=p[i].x;
		p[i+n].y=p[i].y;
		p[i].ang=atan2(p[i].y,p[i].x);
		p[i+n].ang=p[i].ang+2*PI;
	}
	double ans=0;
	sort(begin(p),end(p),[](const v &a,const v &b){
		return a.ang<b.ang;
	});
	vector<double> sx(2*n+1,0),sy(2*n+1,0);
	rep(i,2*n){
		sx[i+1]=sx[i]+p[i].x;
		sy[i+1]=sy[i]+p[i].y;
	}
	rep(i,n)FOR(j,i,2*n){
		if(p[j].ang-p[i].ang>PI+EPS) break;
		double nx=sx[j+1]-sx[i],ny=sy[j+1]-sy[i];
		chmax(ans,nx*nx+ny*ny);
	}
	cout<<setprecision(15)<<sqrt(ans)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i < (int)n; i++)
#define Loopr(i, n) for(int i= (int)n - 1; i >= 0; i--)
using namespace std;
typedef long long int ll;

int main() {
	int h;
	cin >> h;
	vector<int> A(h + 1);
	Loop1(i, h + 1) cin >> A[i];
	Loop1(i, h + 1) {
		cout << "node " << i << ": key = " << A[i] << ", ";
		if (i / 2 > 0) cout << "parent key = " << A[i / 2] << ", ";
		if (i * 2 <= h) cout << "left key = " << A[i * 2] << ", ";
		if (i * 2 + 1 <= h) cout << "right key = " << A[i * 2 + 1] << ", ";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
field=[]
result="Yes"
for i in range(3):
  field.append(list(map(int,input().split())))
for i in range(3):
  for j in range(3):
    if not (field[i][j]>=0 and field[i][j]<=100*2):
      result="No"
    if j ==0:
      pos_i0=field[i][j]
    field[i][j]-=pos_i0
for j in range(3):
  if not (field[0][j]==field[1][j] and field[0][j]==field[2][j]):
    result="No"
print(result)

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

int main(){
  ll X,K,D;cin>>X>>K>>D;
  ll tmp = abs(X)/D;
  ll ans;
  if(tmp>=K) ans=abs(X)-K*D;
  else if((tmp-K)%2==0) ans=abs(X)%D;
  else ans=D-abs(X)%D;
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;
int main() {
    int N; cin >> N;
    vector<ll> A(N);
    for (int i=0;i<N;i++) cin >> A[i];
    int res=0;
    for (int i=0;i<N;i++) {
        if (A[i]%2==1) res++;
    }
    if (res%2==0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
struct UnionFind{
  vector<int> par;
  UnionFind(int n) : par(n,-1) {}
  void init(int n) {par.assign(n,-1);}
  int root(int x){
    if(par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }
  bool issame(int x,int y){
    return root(x) == root(y);
  }
  bool merge(int x,int y){
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]){
      swap(x,y);
    }
    par[x] += par[y];
    par[y] = x;
    return true;
  }

  int size(int x){
    return -par[root(x)];
  }
};

int main(){
  long long N=0,M=0;
  cin >> N >> M;
  vector<int> A(M),B(M);
  for(int i=0;i<M;i++){
    cin >> A[i] >> B[i];
    A[i]--;B[i]--;
  }
  UnionFind uf(N);
  long long cur = N * (N - 1) / 2;
  vector<long long> res;

  for(int i=0;i<M;i++){
    res.push_back(cur);
    int a = A[M-1-i],b = B[M-1-i];
    if(uf.issame(a,b)) continue;

    long long sa = uf.size(a) , sb = uf.size(b);
    cur -= sa * sb;
    uf.merge(a,b);
  }
  reverse(res.begin(),res.end());
  for(int i=0;i<res.size();i++){
    cout << res[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3444
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   200005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"
 
const int inf = (int)1e18 + 10;

priority_queue < pii >  pq;
int a[N] , b[N];
signed main(){
  fast;

  int n , x , y , val , ans = 0;
  cin >> n;
  for(int i = 0 ; i < n ; i++)
       cin >> a[i];
  for(int i = 0 ; i < n ; i++){
       cin >> b[i];
       if(b[i] != a[i])
       pq.push(mp(b[i] , i));
     }
   int cnt = 0;
    while(pq.size() > 0){
          pii p = pq.top();
          pq.pop();
          x = p.ss;
          val = p.ff ;
          y = b[(x- 1 + n) % n] + b[(x + 1) % n];
          int r = (val - a[x])/y;
          if(r == 0){
            ans = -1;
            break;
          }
          
          ans += r;
          
          b[x] -= r*y;
          if(b[x] != a[x]) 
          pq.push(mp(b[x]  , x));

    }
    
    cout << ans << endl;

 
}

Measured memory_bytes: 9072
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll A;
    string B;
    cin>>A>>B;
    ll B_100;
    B_100=(B[0]-'0')*100+(B[2]-'0')*10+(B[3]-'0');

    ll ans=A*B_100/100;
    
    cout<<ans<<endl;
}

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

import numpy as np
N, M, X = mapint()
CAs = [list(mapint()) for _ in range(N)]

ans = 10**18
flg = False
for i in range(1<<N):
    tar = np.array([0]*M)
    m = 0
    for j in range(N):
        if (i>>j)&1:
            c, *As = CAs[j]
            tar += np.array(As)
            m += c
    if all(tar>=X):
        ans = min(ans, m)
        flg = True

if flg:
    print(ans)
else:
    print(-1)

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

using namespace std;

int main(){
    double a, b, x;
    double rad;
    double deg;

    cin >> a >> b >> x;

    if (x == a*a*b){
        cout << 0 << endl;
    }else{
        if(x <= a * a * b /2){
            rad = atan(a * b * b / x / 2);
            deg = rad * 180 / M_PI;
            cout << fixed << setprecision(10) << deg << endl;
        }else{
            float l = (2 * a * a * b - 2 * x) / (a * a * a);
            rad = atan(l);
            deg = rad * 180 / M_PI;
            cout << fixed << setprecision(10) << deg << endl;
        }
    }
}

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

using namespace std;
int main()
{
    // スペース区切りの整数の入力
    int n;
    cin >> n;


    char s[n];
    char t[n];
    char ans[2*n];
    cin >> s >> t;


    /*for (int i = 0; i < n; i++)
    {
        ans[2*i] = s[i];
        ans[2*i+1] = t[i];
    }*/

    for (int i = 0; i < n; i++)
    {
        cout << s[i];
        cout << t[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
// {{{ by shik
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REP1(i, a, b) for (int i = (a); i <= int(b); i++)
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

namespace { namespace shik {

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }

template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }

#ifdef SHIK
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); }
template<class T> inline T bit(T x, int i) { return (x >> i) & 1; }
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

// }}}

const int N=314;
char s[N];
int n,k,dp[N][N][N];

int go( int l, int r, int t ) {
    if ( l>r ) return 0;
    if ( l==r ) return 1;
    int &v=dp[l][r][t];
    if ( v!=0 ) return v;
    if ( s[l]==s[r] ) v=go(l+1,r-1,t)+2;
    else {
        chkmax(v,go(l+1,r,t));
        chkmax(v,go(l,r-1,t));
        if ( t>0 ) chkmax(v,go(l+1,r-1,t-1)+2);
    }
    return v;
}

void main() {
    R(s,k);
    n=strlen(s);
    int ans=go(0,n-1,k);
    W(ans);
}

// {{{ main
}}
int main() { shik::main(); return 0; }
// }}}


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

const ll INF = 10000 * 20005;

// dp[i]: 合計iダメージ以上になる場合の、最小コスト
ll dp[20005];

int main(){
  ll H,N;
  cin >> H >> N;
  vector< ll > A(N);
  vector< ll > B(N);
  REP(i,N) cin >> A[i] >> B[i];

  REP(i,20005) dp[i] = INF;
  dp[0] = 0;

    
  REP(i,H+1) REP(j,N) {
    dp[i+A[j]] = min(dp[i+A[j]], dp[i]+B[j]);
  }
  ll ans = INF;
  REP(i,10000) {
    ans = min( dp[i+H], ans);
  }
  cout << ans << endl;
}


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

int main(){
  int N;
  cin >>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >>A.at(i);
  }
  vector<double> B(N);
  for(int i=0;i<N;i++){
    B.at(i) = 1.0/A.at(i);
  }
  double souwa = 0;
  for(int i=0;i<N;i++){
    souwa +=B.at(i);
  }
  double ans;
  ans=1.0/souwa;
  cout <<fixed<<setprecision(10);
  cout <<ans<<endl;
}
    
 
/*int main() {
  int N;
  cin >>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >>A.at(i);
  }
  long souseki = 1;
  for(int i = 0;i<N;i++){
    souseki *=A.at(i);
  }
  long bunbo = 0;
  for(int i = 0;i<N;i++){
    long tmp =souseki/A.at(i);
    bunbo +=tmp;
  }
  cout <<fixed<<setprecision(10);
  cout <<souseki/bunbo<<endl;
}*/
  
    

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

input_data = {}

for r in range(2):
    line_data = [int(x) for x in input().split(" ")]
    for c, value in enumerate(line_data):
        input_data[(r, c)] = value

from collections import defaultdict
answer = defaultdict(int)


#for c, value in enumerate(range(n)):
#    answer[(0,c)] = input_data[(0, c)] + answer[(0,c - 1)]

for r in range(2):
    for c, value in enumerate(range(n)):
        answer[(r,c)] = input_data[(r, c)] + max(answer[(r,c - 1)], answer[(r - 1, c)] )


print(answer[(1,n-1)])


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

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, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;



int main(){
  string n;
  cin>>n;
  REP(i,3){
    if(n[i]=='7'){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

void inputVector(int n, vector<int>& va) {
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		va.push_back(a);
	}
}

int calculateTime(int i, int k, vector<int> va) {
	int j = i + k - 1;
	int time1, time2;
	time1 = abs(va[i]) + abs(va[i] - va[j]);
	time2 = abs(va[j]) + abs(va[j] - va[i]);
	return min(time1, time2);
}

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

	int n, k;
	cin >> n >> k;
	vector<int> va;
	inputVector(n, va);

	int time, timeMin;
	timeMin = 300000000;
	for (int i = 0; i < n - k + 1; i++) {
		time = calculateTime(i, k, va);
		timeMin = min(timeMin, time);
	}
	cout << timeMin << "\n";
	return 0;
}

Measured memory_bytes: 1144
import math
from functools import reduce
a=1;b=1;c=1;d=0
n=int(input());
for i1 in range(n):
	for i2 in range(n):
		for i3 in range(n):
			d+=reduce(math.gcd,(a,b,c))
			c+=1
		b+=1;c=1;i3=0 #毎回b,cをリセットさせないと増え続ける
	a+=1;b=1;i2=0 #i2,i3もリセットしないとどうなるのかはわからんけど変になる
print(d)

Measured memory_bytes: 69972