akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

ll K,N;
vector<ll> A;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

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

  cin >> K >> N;
  A.resize(N);
  rep(i, N) {
    cin >> A[i];
  }
  rep(i, N) {
    A.push_back(K+A[i]);
  }
  ll ans = LONG_LONG_MAX;
  rep(i, N) {
    //cout << A[i] << endl;
    ans = min(ans, abs(A[N-1+i]-A[i]));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    ll a,b,v,w,t;
    cin>>a>>v;
    cin>>b>>w;
    cin>>t;
    if(abs(a-b)>t*(v-w))
        cout<<"NO";
    else
    cout<<"YES";
    return 0;
}

Measured memory_bytes: 3648
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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

int N, W;
vector<ll> weight, value;

// i番目の品物までを使って合計の重さをjにするときの価値の最大値
ll dp[110][100100] = { 0 };

int main() {
	cin >> N >> W;
	rep(i, N) {
		int x, y;
		cin >> x >> y;
		weight.push_back(x); value.push_back(y);
	}
	
	for (int i = 0; i < N; ++i) {
		for (int sum_w = 0; sum_w <= W; ++sum_w) {

			// i 番目の品物を選ぶ場合
			if (sum_w - weight[i] >= 0) {
				chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
			}

			// i 番目の品物を選ばない場合
			chmax(dp[i + 1][sum_w], dp[i][sum_w]);

		}
	}

	cout << dp[N][W] << endl;

	return 0;
}


Measured memory_bytes: 79360
import sys
from functools import lru_cache
sys.setrecursionlimit(10000)



n=int(input())

@lru_cache(maxsize=1000)
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
  
def lcm(a, b):
	return a * b // gcd (a, b)

x=1
for i in range(n):
  x=lcm(x,int(input()))

print(x)

Measured memory_bytes: 4068
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <complex>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cassert>
#include <fstream>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(a,b) for(:a<b;a++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;


int main (){
  int a,b,c,d;
  bool ans = false;
  while(cin >> a >> b >> c >> d){
    ans = false;
    if(abs(a-c) <= d){
      ans = true;
    }

    if(abs(a-b) <= d && abs(b-c) <= d){
      ans = true;
    }

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#define int long long
#define MOD 1000000007
using namespace std;

signed main(){
	int n,m,dp[3010][3010] = {},zero[3010] = {},one[3010] = {},migi[3010] = {};
	string s;
	cin >> n >> m >> s;
	for(int i = 0;i < n;i++){
		zero[i + 1] = zero[i];
		one[i + 1] = one[i];
		if(s[i] == '1') one[i + 1]++;
		else zero[i + 1]++;
	}
	for(int i = 0;i < m;i++){
		int l,r;
		cin >> l >> r;
		for(int j = l;j <= r;j++) migi[j] = max(migi[j],r);
	}
	for(int i = 1;i <= n;i++) migi[i] = max(migi[i],i);
	for(int i = 0;i <= one[n];i++){
		for(int j = 0;j <= zero[n];j++){
			if(!i && !j){
				dp[i][j] = 1;
				dp[i + 1][j]++;
				dp[i][j + 1]++;
			}
			else{
				int t = migi[i + j];
				if(one[t] < i || zero[t] < j) dp[i][j] = 0;
				(dp[i + 1][j] += dp[i][j]) %= MOD;
				(dp[i][j + 1] += dp[i][j]) %= MOD;
			}
		}
	}
	cout << dp[one[n]][zero[n]] << endl;
	return 0;
}

Measured memory_bytes: 71168
from collections import deque
n,q=map(int,input().split())
tree=[[] for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    tree[a].append(b)
    tree[b].append(a)
count=[0]*n
for _ in range(q):
    p,cnt=map(int,input().split())
    count[p-1]+=cnt
stack=deque([[0,0,-1]])
while stack:
    num,cnt,pr=stack.pop()
    count[num]+=cnt
    for k in tree[num]:
        if k==pr:
            continue
        stack.append([k,count[num],num])
print(*count)

Measured memory_bytes: 65936
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	long long n,x,ans;
	scanf("%lld%lld",&n,&x);
	ans=n;
	n-=x;
	while(x)
	{
		ans+=(n/x*x)<<1;
		n%=x;
		swap(n,x);
	}
	ans-=n;
	printf("%lld\n",ans);
}
/*
5 2
*/


Measured memory_bytes: 128
from sys import stdin
K, A, B = [int(_) for _ in stdin.readline().rstrip().split()]
if K < A-1 or B-A <= 2:
    print(K+1)
else:
    ans = A
    K -= A-1
    if K % 2 == 1:
        ans += 1
        K -= 1
    ans += (B-A)*(K//2)
    print(ans)

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

int main(){//main_program
  uint64_t N,D,count,H;
  count = 0;
  D = 0;
  H = 0;
  cin >> N;
  vector<uint64_t> A(N+1);
  vector<uint64_t> B(N+2);
  B.at(0) = 1;
  
  for(int i = 0; i <= N ; i++){
    cin >> A.at(i);
  }
  
  for(int i = 0; i <= N ; i++){
    if(B.at(i) < A.at(i)){
      cout << -1 << endl;
      D = 100;
      break;
    }
    B.at(i+1) = (B.at(i)-A.at(i))*2;
  }
  
  if(D == 0){
    for(int i = N; i >= 0 ; i--){
      H += A.at(i);
      if( B.at(i) >= H ){
        
      }else{
        H = B.at(i);
      }
      count += H;
    }
    
    cout << count << endl;
  }
  
}

Measured memory_bytes: 4848
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
    int n[4]={0};

    for(int count=0;count<4;count++){
        cin >> n[count];
    }

    sort(n,n+4);

    if(n[0]==1&&n[1]==4&&n[2]==7&&n[3]==9)cout << "YES" << endl;
    else cout << "NO" << endl; 

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 2e9
#define ALL(v) v.begin(), v.end()
int n, b, c;
vector<int> h;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        h.push_back(temp);
    }
    int dp[n+1];
    dp[0]=0;
    dp[1]=abs(h[0]-h[1]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
    }
    cout<<dp[n-1]<<"\n";
}


Measured memory_bytes: 1144
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
using namespace std;

const int MAXN = 1e3 + 5, MAXM = 1e6 + 5;
const int dr[10] = { 0, -1, 1, 0, 0 }, dc[10] = { 0, 0, 0, -1, 1 };
int H, W;
int R1, C1, R2, C2;
char C[MAXN][MAXN];
struct edge {
	int V, W;
	edge(){}
	edge (int v, int w) { V = v, W = w; }
	friend bool operator < (edge a, edge b) { return a.W > b.W; }
};
vector<edge> G[MAXM];
int dis[MAXM];
bool vis[MAXM];

void addEdge(int u, int v, int w) {
	G[u].push_back(edge(v, w));
	G[v].push_back(edge(u, w));
}

void Dijkstra(int s) {
	memset(dis, 0x3f, sizeof(dis));
	priority_queue<edge> q;
	q.push(edge(s, 0));
	dis[s] = 0;
	while (!q.empty()) {
		int u = q.top().V; q.pop();
		if (vis[u]) continue;
		vis[u] = 1;
		int siz = G[u].size();
		for (int i = 0; i < siz; i++) {
			int v = G[u][i].V, w = G[u][i].W;
			if (dis[u] + w < dis[v]) {
				dis[v] = dis[u] + w;
				q.push(edge(v, dis[v]));
			}
		}
	}
}

int main() {
	scanf("%d %d", &H, &W);
	scanf("%d %d %d %d", &R1, &C1, &R2, &C2);
	for (int r1 = 1; r1 <= H; r1++) {
		scanf("\n");
		for (int c1 = 1; c1 <= W; c1++)
			scanf("%c", &C[r1][c1]);
	}
	for (int r1 = 1; r1 <= H; r1++) {
		for (int c1 = 1; c1 <= W; c1++) {
			if (C[r1][c1] == '#') continue;
			int indexs = (r1 - 1) * W + c1;
			for (int r2 = r1 - 2; r2 <= r1 + 2; r2++) {
				for (int c2 = c1 - 2; c2 <= c1 + 2; c2++) {
					int indext = (r2 - 1) * W + c2;
					if (r2 < 1 || c2 < 1 || r2 > H || c2 > W || C[r2][c2] == '#' || indext == indexs) continue;
					addEdge(indexs, indext, 1);
				}
			}
			for (int i = 1; i <= 4; i++) {
				int nr = r1 + dr[i], nc = c1 + dc[i];
				int indext = (nr - 1) * W + nc;
				if (nr < 1 || nc < 1 || nr > H || nc > W || C[nr][nc] == '#') continue;
				addEdge(indexs, indext, 0);
			}
		}
	}
	int indexS = (R1 - 1) * W + C1, indexT = (R2 - 1) * W + C2;
	Dijkstra(indexS);
	if (dis[indexT] == 0x3f3f3f3f) printf("-1");
	else printf("%d", dis[indexT]);
	return 0;
}


Measured memory_bytes: 188396
n = gets.to_i
ary = []
n.times do
  ary << gets.to_i
end
if n==1
  puts 1
  exit
end
ary.sort! #ソートはO(logN)
i = 0
s = -1
cnt = 0
while i < n-1 do #左からO(N)
  if ary[i] != ary[i+1]
    if (i-s)%2 == 1
      cnt += 1
    end
    s = i
  end
  i += 1
end
if (n-1-s)%2 == 0
  puts cnt
else
  puts cnt+1
end

Measured memory_bytes: 16444
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=get_nsp.map(&:to_i)
ans=N.inject(:+)
if ans==1 and N.size>1
    puts 10
else
    puts ans
end

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

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

	vector<vector<long> > a(n);

	for (int i = 0; i < q; i++) {
		int s, t;
		cin >> s >> t;

		if (s == 0) {
			long x;
			cin >> x;
			a[t].push_back(x);
		}
		else if (s == 1) {
			vector<long>::iterator itr = a[t].begin();
			while (itr != a[t].end()) {
				if (itr != a[t].begin())
					cout << " ";
				cout << *itr;
				itr++;
			}
			cout << endl;
		}
		else if (s == 2)
			a[t].erase(a[t].begin(), a[t].end());
	}

	return 0;
}


Measured memory_bytes: 8824
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,a[10000],b[10000],countA,countB;
    while(cin>>n,n!=0){
        countA=0,countB=0;
        for(int i=0;i<n;i++){
            cin>>a[i]>>b[i];
            if(a[i]>b[i]){
                countA+=(a[i]+b[i]);
            }else if(a[i]<b[i]){
                countB+=(a[i]+b[i]);
            }else{//a[i]==b[i]
                countA+=a[i];
                countB+=b[i];
            }
        }
        cout<<countA<<" "<<countB<<endl;
    }
    return(0);
}

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

ll a, b, c, d, ans;

int main() {
  cin >> a >> b >> c >> d;
  ans = max({a*c, a*d, b*c, b*d});
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)

using namespace std;

typedef long long ll;
using pii = pair<int, int>;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

//--global--//



//----------//

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//
    
    int n;
    cin >> n;
    int *a;
    a = new int[MAX];
    rep(i, n){
        cin >> a[i];
    }

    ll *dp;
    dp = new ll[MAX];
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    rep2(i, 2, n){
        ll dp1 = dp[i-1] + abs(a[i] - a[i-1]);
        ll dp2 = dp[i-2] + abs(a[i] - a[i-2]);
        dp[i] = min(dp1, dp2);
    }
    
    cout << dp[n-1] << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define EPS 1e-7

int main(){
	int n;
	while(cin >> n && n){
		int sqrtn = (int)(sqrt(2*n) + EPS);
		int ret=0;
		bool isprimelow[sqrtn+1];
		bool isprimehigh[n];
		
		memset(isprimelow, true, sizeof(isprimelow));
		memset(isprimehigh, true, sizeof(isprimehigh));
		
		isprimelow[0] = false;
		isprimelow[1] = false;
		for(int i=2;i<=sqrtn;i++){
			if(isprimelow[i]){
				for(int j=2;i*j<=sqrtn;j++){
					isprimelow[i*j] = false;
				}
				for(int j=n/i;i*j <= 2*n;j++){
					if(n < i*j && i*j <= 2*n){
						isprimehigh[i*j-n-1] = false;
					}
				}
			}
		}
		for(int i=0;i<n;i++){
			if(isprimehigh[i]) ret++;
		}
		cout << ret << endl;
	}
}

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

int main() {
  ll Ans = 0;  // 回答：

  ll N; cin >> N; // 数値の個数は、+0 ～ +N の N+1 個：１～2*10^5
  ll K; cin >> K; // 選択数の最小値：1～N+1。数値を K 個 から N+1 個まで選択する。

  // K 個の数を選んだ時、異なる組み合わせで、その和が同じになる事は無い。
  // 最小値は、0+1+...+(K-1)。最大値は N+(N-1)+...+(N-(K-1))。
  // 和の種類数は、(N+(N-1)+...+(N-(K-1))) - (0+1+...+(K-1)) + 1 。
  //               = N*K - 2(0+1+...+(K-1)) + 1
  //               = N*K - 2 (K-1)(K-1+1)/2 + 1
  //               = N*K - K(K-1) + 1
  //               = K(N-K+1) + 1
  // 和の種類数を K から N+1 まで集計する。
  for(ll k=K;k<=N+1;k++){
    Ans += k * ( N - k + 1 ) + 1;
    Ans %= MOD;
  }

  cout << Ans << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
/*
  RMQ and RUQ
  区間の最小値を得る(RMQ)
  区間の値を変更する(RUQ)
 */

class RMQ{
public : 
  typedef long long ll;
  ll INF = 1LL<<55;
  struct data{
    bool type; //0 - empty   , 1 - update
    ll value;
  };
  ll n,n_;
  vector<ll> dat;
  vector<data> td;
  int toMax; //0 -> RangeMin 1->RangeMax;
  
  RMQ(){n=-1;}
  RMQ(int n_,int toMax = 0):n_(n_),toMax(toMax){
    n=1;
    while(n<n_)n*=2;
    td.resize(2*n-1,(data){0,0});
    dat.resize(2*n-1,INF);
  }
  
  //[a,b)の値をxに変更　update(a,b,x)
  ll update(int a,int b,ll x,bool flg=true,int k=0,int l=0,int r=-1){
    if(r == -1) {
      r = n;
      assert(a <= b), assert(a <= n_ && b <= n_), assert(a >= 0 && b >= 0);
      if(toMax) x *= -1;
    }
    
    if(r<=a||b<=l)return flg? dat[k]:INF;
    if(a<=l&&r<=b){
      if(flg==true){
        td[k]=(data){1,x};
        dat[k]=x;
      }
      return dat[k];
    }
    
    if(td[k].type){
      td[k].type=0;
      dat[k*2+1] = dat[k*2+2] = td[k].value;
      td[k*2+1] = td[k*2+2] = (data){1,td[k].value};
    }
    
    ll vl=update(a,b,x,flg,k*2+1,l,(l+r)/2);
    ll vr=update(a,b,x,flg,k*2+2,(l+r)/2,r);
    if(flg==true)dat[k]=min(vl,vr);
    return min(vl,vr);
  }
  
  //[a,b)の最小値を得る　find(a,b);
  ll find(int a,int b){return (toMax? -1:1) * update(a,b,0,false);};
};


int main(){
  int q,n;
  cin>>n>>q;
  RMQ T(n,1);

  for(int i=0;i<n;i++) T.update(0,n,-((1LL<<31)-1));
  while(q--){
    int cmd,s,t,x;
    scanf("%d%d%d",&cmd,&s,&t);
    if(cmd==0)cin>>x,T.update(s,t+1,-x);
    else cout <<-T.find(s,t+1)<<endl;
  }
  return 0;
}



Measured memory_bytes: 8908
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);
//const ll mod = 998244353;

ll lcm(ll a, ll b){
    return a / __gcd(a, b) * b;
}


int main(void)
{
    ll n, m, ans=0;
    cin >> n >> m;
    if(abs(n-m) > 1){
        puts("0");
        return 0;
    }
    bool d=false, w=false, dw=false;;
    if(n < m) d = true; 
    if(n > m) w = true;
    if(n == m) dw = true;
    ll dog=1, wolf=1;
    if(d){ //dog
        rep(i,m){
            dog *= (n+1-i);
            dog %= mod;
        }
        rep(i,n){
            dog *= (n-i);
            dog %= mod;
        }
        ans += dog%mod;
        ans %= mod;
    }
    if(w){ //wolf
        rep(i,n){
            wolf *= (m+1-i);
            wolf %= mod;
        }
        rep(i,m){
            wolf *= (m-i);
            wolf %= mod;
        }
        ans += wolf%mod;
        ans %= mod;
    }
    if(dw){
        rep(i,m){
            dog *= (n-i);
            dog %= mod;
        }
        rep(i,n){
            dog *= (n-i);
            dog %= mod;
        }
        ans += dog%mod;
        ans %= mod;
        rep(i,n){
            wolf *= (m-i);
            wolf %= mod;
        }
        rep(i,m){
            wolf *= (m-i);
            wolf %= mod;
        }
        ans += wolf%mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
int main(void) {
    int num,len,i,j,count,flag;
    char p[1000000];
    while (1) {
        scanf("%d\n",&num);
        if (num==0) break;
        count=0,flag=0;
        scanf("%d\n%s",&len,p);
        for (i=0; i<=len-(num*2+1); i++) {
            if (p[i]=='I') {
                if (flag==0) {
                    for (j=1; j<num*2+1; j++) {
                        if ((j%2==0&&p[i+j]!='I')||(j%2==1&&p[i+j]!='O')) {
                            flag=0;
                            break;
                        }
                        if (j==num*2) {
                            count++;
                            i++;
                            flag=1;
                        }
                    }
                } else {
                    if (p[i+num*2-1]=='O'&&p[i+num*2]=='I') {
                        count++;
                        i++;
                    } else {
                        i+=num*2-2;
                        flag=0;
                    }
                }
            }
        }
        printf("%d\n",count);
    }
    return 0;
}

Measured memory_bytes: 1584
n = int(input())
A = list(map(int, input().split()))

x2 = 0
for i in range(n):
    if i % 2:
        x2 -= A[i]
    else:
        x2 += A[i]
        
ans = [0]*n
ans[0] = int(x2/2)
for i in range(n-1):
    ans[i+1] = int(A[i]) - int(ans[i])
for i in range(n):
    ans[i] *= 2

L = [str(a) for a in ans]
print(" ".join(L))



Measured memory_bytes: 21272
a=[]
for i in range(0,5):
  a.append(int(input()))
s=0
import math
for i in a:
  s=s+(math.ceil(i/10))*10
x=10
for i in a:
  if i%10==0:
    pass
  elif i%10<x:
    x=i%10
print(s-10+x)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sx = sc.nextInt(), sy = sc.nextInt();
		int tx = sc.nextInt(), ty = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		sb.append(repeat("R", tx-sx));
		sb.append(repeat("U", ty-sy));
		sb.append(repeat("L", tx-sx));
		sb.append(repeat("D", ty-sy+1));
		sb.append(repeat("R", tx-sx+1));
		sb.append(repeat("U", ty-sy+1));
		sb.append("LU");
		sb.append(repeat("L", tx-sx+1));
		sb.append(repeat("D", ty-sy+1));
		sb.append("R");
		System.out.println(new String(sb));
		sc.close();
	}
	public static String repeat(String str, int n) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) sb.append(str);
		return sb.toString();
	}
}

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

static const int SENTINEL = 2000000000;
static const int MAX = 100000;
struct Card {char suit; int value; };
Card L[MAX/2+2], R[MAX/2+2];

void merge(Card A[], int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;

    for (int i = 0; i != n1; ++i)
    {
        L[i] = A[left+i];
    }
    for (int i = 0; i != n2; ++i)
    {
        R[i] = A[mid+i];
    }

    L[n1].value = R[n2].value = SENTINEL;

    int i = 0;
    int j = 0;

    for (int k = left; k != right; ++k)
    {
        if (L[i].value <= R[j].value)
        {
            A[k] = L[i++];
        }
        else
        {
            A[k] = R[j++];
        }
    }
}

void mergeSort(Card A[], int left, int right)
{
    if (left + 1 < right)
    {
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int partition(Card A[], int p, int r)
{
    int x = A[r].value;
    int i = p - 1;

    for (int j = p; j != r; ++j)
    {
        if (A[j].value <= x)
        {
            ++i;
            swap(A[j], A[i]);
        }
    }

    swap(A[i+1], A[r]);

    return i+1;
}

void quickSort(Card A[], int left, int right)
{
    if (left < right)
    {
        int mid = partition(A, left, right);
        quickSort(A, left, mid-1);
        quickSort(A, mid+1, right);
    }
}

int main()
{
    char str[10];
    bool flat = true;
    int n, x;
    Card A[MAX], B[MAX];

    scanf("%d", &n);

    for (int i = 0; i != n; ++i)
    {
        scanf("%s %d", str, &x);
        B[i].suit = A[i].suit = str[0];
        B[i].value = A[i].value = x;
    }

    mergeSort(A, 0, n);
    quickSort(B, 0, n-1);

    for (int i = 0; i != n; ++i)
    {
        if (A[i].suit != B[i].suit)
        {
            flat = false;
            break;
        }
    }

    if (flat)
    {
        printf("Stable\n");
    }
    else
    {
        printf("Not stable\n");
    }

    for (int i = 0; i != n; ++i)
    {
        printf("%c ", B[i].suit);
        printf("%d\n", B[i].value);
    }
    
    return 0;
}


Measured memory_bytes: 5544
/*
        @uthor: Kashish Gilhotra
        user: CodeChef, CodeForces, HackerEarth, HackerRank, SPOJ: kashish001
*/

#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
  
#define int long long int 
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

double EPS = 1e-9; 
int INF = 1000000005; 
long long INFF = 1000000000000000005LL;
const int mod = 1e9 + 7; 

//#define CI cpp_int
string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << " " ;
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define EB emplace_back
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define size(v) (int)v.size() 
#define endl "\n"
#define UMO unordered_map
#define USO unordered_set
#define setBits(n) __builtin_popcountll(n)
#define MX *max_element
#define MN *min_element
#define TC int t; cin >> t; while (t--) 

void Panda() {
    int a, b;
    cin >> a >> b;

    cout << (a * b) / __gcd(a, b) << endl;
}
  
int32_t main() {
 
    FAST;

    
    
    Panda();

    return 0; 
} 

Measured memory_bytes: 3620
n=int(input())
d=dict()

for _ in range(n):
  s=input()
  if s not in d:
    d[s]=1
  else:
    d[s]+=1
    
ans=[]
num=max(d.values())

for i in d.keys():
  #print(i,d[i])
  if d[i]==num:
    ans+=[i]
    
ans.sort()

for i in ans:
  print(i)

Measured memory_bytes: 91608
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back

using namespace std;

int n,m;

int main()
{
    cin >> n >> m;
    if (n==m)cout << "Yes\n";
    else cout << "No\n";
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int a,b,c,d;
    cin >> a >> b >> c >> d;
    long long int x, y;
    long long int maxn = a * c;
    
    if(maxn < a * d){
        maxn = a * d;
    }
    if(maxn < b * c){
        maxn = b * c;
    }
    if(maxn < b * d){
        maxn = b * d;
    }

    cout << maxn << endl;
}

Measured memory_bytes: 3632
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

N, M = map(int,input().split())
S=input()
T=input()

Slist=list(S)
Tlist=list(T)

L=int(N*M/gcd(N,M))
G=gcd(N,M)

A=int(N/G)
B=int(M/G)

for i in range(G):
    if Slist[i*A]!=Tlist[i*B]:
        ans=-1
        break
    else:
        ans=L
print(ans)

Measured memory_bytes: 4596
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#define llong long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000//10^12

int main(void)
{
	//変数の宣言
	llong int l;
	static llong int a[200010];
	static llong int even[200010];
	static llong int odd[200010];
	static llong int sum[200010];
	static llong int left1[200010];
	static llong int left2[200010];
	static llong int left3[200010];
	static llong int left4[200010];
	llong int temp;


	llong int ans;
	llong int i;
	llong int flag;

	//データの読み込み

	scanf("%lld", &l);
//	scanf_s("%lld", &l);


	for (i = 0;i < l;i++) {
		scanf("%lld", &a[i]);
	}
//	for (i = 0;i < l;i++) {
//		scanf_s("%lld", &a[i]);
//	}

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
		//実際の処理

		//累積和even[k]を作る
	for (i = 0;i < l;i++) {
		if (a[i] < 2) {
			even[i] = 2 - a[i];
		}
		else {
			even[i] = a[i] % 2;
		}
	}
	//oddを作る
	for (i = 0;i < l;i++) {
		odd[i] = (a[i] + 1) % 2;
		
	}

	//sumを作る
	for (i = 0;i < l;i++) {
		if (i == 0) {
			sum[i] = a[i];
		}
		else {
			sum[i] = sum[i - 1] + a[i];
		}
	}

	for (i = 0;i < l;i++) {
		if (i == 0) {
			left1[i] = min(even[0], a[0]);
		}else{
			left1[i] = min(left1[i - 1] + even[i], sum[i]);
		}
	}

	for (i = 0;i < l;i++) {
		if (i == 0) {
			left2[i] = min(left1[0], odd[0]);
		}
		else {
			left2[i] = min(left2[i - 1] + odd[i], left1[i]);
		}
	}

	for (i = 0;i < l;i++) {
		if (i == 0) {
			left3[i] = min(left2[0], even[0]);
		}
		else {
			left3[i] = min(left3[i - 1] + even[i], left2[i]);
		}
	}

	for (i = 0;i < l;i++) {
		if (i == 0) {
			left4[i] = min(left3[0], sum[0]);
		}
		else {
			left4[i] = min(left4[i - 1] + a[i], left3[i]);
		}
	}

	//	printf("計算部分終了\n");

		//出力
	printf("%lld", left4[l-1]);
/*
	for (i = 0;i < l;i++) {
		printf("i=%lld,left1[i]=%lld\n", i, left1[i]);
	}

	for (i = 0;i < l;i++) {
		printf("i=%lld,left2[i]=%lld\n", i, left2[i]);
	}

	for (i = 0;i < l;i++) {
		printf("i=%lld,left3[i]=%lld\n", i, left3[i]);
	}

	for (i = 0;i < l;i++) {
		printf("i=%lld,left4[i]=%lld\n", i, left4[i]);
	}
*/
	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 12672
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
int n, a[222];
int main() {
	cin >> n;
	for (int i = 0; i < 2 * n; i++) cin >> a[i];
	sort(a, a + 2 * n);
	int ret = 0;
	for (int i = 0; i < 2 * n; i += 2) ret += a[i];
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e9) + 1;
const int mod = 479001599;
const int maxn = 1e6 + 111;
        
using namespace std;          

int n, m;

void solve(){
	cin >> n >> m;

	cout << (n - 1) * n / 2 + (m - 1) * m / 2;
}                              
      
main(){
    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}


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

using namespace std;

int n, m, k;
int a[17][1007];
int s[17][1007];

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


  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    string t;
    cin >> t;
    for (int j = 1; j <= m; j++) {
      a[i][j] = (t[j - 1] - '0');
      s[i][j] = a[i][j] + s[i - 1][j];
    }
  }
  int sol = (int) 1e9;
  for (int mask = 0; mask < (1 << (n - 1)); mask++) {
    vector<int> cut = {0};
    for (int i = 0; (1 << i) <= mask; i++) {
      if (mask & (1 << i)) {
        cut.push_back(i + 1);
      }
    }
    cut.push_back(n);
    vector<pair<int, int>> lol;
    for (int i = 0; i + 1 < (int) cut.size(); i++) {
      lol.push_back({cut[i] + 1, cut[i + 1]});
    }
    int cur = (int) cut.size() - 2;
    vector<int> now((int) lol.size(), 0);
    for (int c = 1; c <= m; c++) {
      bool ok = 1;
      for (int j = 0; j < (int) lol.size(); j++) {
        int l = lol[j].first;
        int r = lol[j].second;
        int add = s[r][c] - s[l - 1][c];
        if (now[j] + add > k) {
          ok = 0;
          break;
        }
      }
      if (ok == 0) {
        cur++;
        for (int j = 0; j < (int) lol.size(); j++) {
          int l = lol[j].first;
          int r = lol[j].second;
          int add = s[r][c] - s[l - 1][c];
          now[j] = add;
          if (add > k) {
            cur = (int) 1e9;
            break;
          }
        }
      } else {
        for (int j = 0; j < (int) lol.size(); j++) {
          int l = lol[j].first;
          int r = lol[j].second;
          int add = s[r][c] - s[l - 1][c];
          now[j] += add;
        }
      }
    }
    sol = min(sol, cur);
  }
  cout << sol << "\n";
}


Measured memory_bytes: 384
n = int(input())
s = [[0,0,0]]
flag = 0
for i in range(n):
    t, x, y = map(int, input().split())
    s.append([t,x,y])
# print(s)
for i in range(1,n+1):
    dt = s[i][0]-s[i-1][0]
    dx = abs(s[i][1]-s[i-1][1])
    dy = abs(s[i][2]-s[i-1][2])
#     print(dt,dx,dy)
    if dt - (dx+dy) >= 0 and dt % 2 == (dx+dy) % 2:
        continue
    else:
        flag = 1
        print('No')
        break
if flag == 0:
    print('Yes')

Measured memory_bytes: 25572
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;

alias Card = Tuple!(int, "x", bool, "h");

void main() {
    int N;
    scan(N);

    auto a = readln.split.to!(int[]);
    auto b = readln.split.to!(int[]);

    if (N == 1) {
        writeln(0);
        return;
    }

    auto ans = inf;

    foreach (set ; 0 .. 1 << N) {
        Card[] cs;

        foreach (i ; 0 .. N) {
            if (set & 1 << i) {
                cs ~= Card(a[i], 1);
            }
            else {
                cs ~= Card(b[i], 0);
            }
        }

        chmin(ans, solve(N, cs));
    }

    writeln(ans == inf ? -1 : ans);
}


int solve(int N, Card[] cs) {
    int res;

    foreach (i ; 0 .. N) {
        foreach_reverse (j ; i + 1 .. N) {
            if (cs[j - 1].x > cs[j].x) {
                swap(cs[j - 1], cs[j]);
                cs[j - 1].h ^= 1;
                cs[j].h ^= 1;
                res++;
            }
        }
    }

    foreach (i ; 0 .. N - 2) {
        assert(cs[i].x <= cs[i + 1].x);

        if (!cs[i].h) {
            if (cs[i].x != cs[i + 1].x) {
                return inf;
            }
            if (!cs[i + 1].h) {
                res++;
                cs[i + 1].h ^= 1;
            }
            else if (cs[i + 2].x == cs[i].x && cs[i + 2].h) {
                res += 2;
                cs[i + 2].h ^= 1;
            }
            else {
                return inf;
            }
        }
    }

    if (cs[N - 2].h && cs[N - 1].h) {
        return res;
    }
    else if (cs[N - 2].x == cs[N - 1].x && !cs[N - 2].h && !cs[N - 1].h) {
        res++;
    }
    else {
        return inf;
    }

    return res;
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 1276
#include<stdio.h>
int a[100005];

long long int sum[100005],sum2[100005];
long long int zet(long long int a){
    if(a>=0)return a;
    else return 0;
}


int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    int i;
    for(i=0;i<=n-1;i++)scanf("%d",&a[i]);
    sum[0]=a[0];
    sum2[0]=zet(a[0]);
    for(i=1;i<=n-1;i++){
        sum[i]=sum[i-1]+a[i];
        sum2[i]=sum2[i-1]+zet(a[i]);
    }
    
    
    long long int max=sum2[n-1]-sum2[k-1]+zet(sum[k-1]);
    for(i=1;i<=n-k;i++){
        long long int gou=0;
        gou+=sum2[n-1]-sum2[i+k-1]+zet(sum[i+k-1]-sum[i-1])+sum2[i-1];
        if(max<gou)max=gou;
    }
    printf("%lld",max);
    
    
    return 0;
}


Measured memory_bytes: 2176
/********************************************************************************
	
	Code by a weak man who named CYJian, and he hope the code can get more points.

	Algorithm: 

 ********************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

const int N = 200010;

ll n, m, v, p, a[N];

bool check(int pos) {
	long long tmp = (v - p - pos + 1) * m, MAX = a[pos] + m;
	for (int i = pos + 1; i <= n - p + 1; ++i) {
		if (a[i] > MAX) return false;
		tmp -= MAX - a[i];
	}

	if (tmp <= 0) return true;
	else return false;
}

int main() {
  	n = rl, m = rl, v = rl, p = rl;
	for (int i = 1; i <= n; ++i) a[i] = rl;
	sort(a + 1, a + n + 1);

	int l = 1, r = n - p + 1, mid, ans;
	while (l <= r) {
		mid = l + r >> 1;
		if (check(mid)) ans = mid, r = mid - 1;
		else l = mid + 1;
	}

	printf("%lld\n", n - ans + 1);
	return 0;
}

Measured memory_bytes: 1280
fn main() {
    let v = read_vec::<u32>();
    let a = v[0];
    let b = v[1];

    let mut count = 0;
    for i in a..b+1 {
        if i.to_string().chars().rev().collect::<String>() == i.to_string() {
            count += 1;
        };
    }
    println!("{}", count);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>//
#include <vector>//
#include <map>
#include <cstdlib>
#include <numeric>
#include <algorithm>//ソート等に使用
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <thread>///////////////////
#include <queue>//幅優先等のキュー
#include <stack>
#include <bitset>

#define rep(i,m,n) for(int i=(m);i<=(n);i++)
#define mer(i,m,n) for(int i=(m);i>=(n);--i)

#define MOD 1000000007
//#define MOD 998244353
//#define MAX

using namespace std;

using ll = long long int;
using ld = long double;
using std::swap;

vector<int> v;
vector<long long int> vll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;
vector<char> vc;
vector<string> vs;

struct UnionFind{
	vector<int> r;

	UnionFind (int N){
		r = vector<int>(N,-1);
	}
	int root(int x){
		if(r[x]<0)return x;
		return r[x] = root(r[x]);
	}

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

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

int main() {
	int N,M;
	cin >>N>>M;

	UnionFind UF(N);
	rep(i,0,M-1){
		int A,B;
		cin >>A>>B;
		A-=1;B-=1;
		UF.unite(A,B);
	}

	int ans = 0;
	rep(i,0,N-1){
		ans = max(ans,UF.size(i));
	}
	cout << ans <<'\n';
	return 0;
}


Measured memory_bytes: 3996
import math

input = input().split()

intInput = [int(i) for i in input]

division = min(intInput[0],intInput[1])

list=[1]

for i in range(2, division+1):
	if intInput[0] % i == 0 and intInput[1] % i == 0:
		list.append(i)

print(list[len(list)-intInput[2]])

Measured memory_bytes: 3060
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int ans = 0;
vector <VI> mylist;
VI visited;
void solve(long long N, std::vector<long long> B){

}
bool result = true;
bool dfs(int i){ //i == index
    visited[i]=1;
    bool res;
    for(int j=0; j < mylist[i].size(); j++){
        if(visited[mylist[i][j]]==1){
            return false;
        }
        else if(visited[mylist[i][j]]==0 && !dfs(mylist[i][j])){return false;}
        
    }
    return true;
}

int main(){
    int N;cin>>N;
    VI arr;
    REP(i, N){
        int v;cin>>v;
        if(i%2==0)arr.push_back(v);
        else arr.insert(arr.begin(), v);
    }
    if(N%2==1){
        REP(i, N){
            cout<<arr[N-i-1]<<" ";
        }cout<<endl;
    }
    else{
        REP(i, N){
            cout<<arr[i]<<" ";
        }cout<<endl;
    }
    return 0;

}


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

int main(int argc, char** argv)
{
	std::string str;
	int count[26] = { 0 };
	while (std::getline(std::cin, str))
	{
		for (char c : str)
		{
			int idx = -1;
			if (c >= 'a' && c <= 'z')
			{
				idx = c - 'a';
			}
			else if (c >= 'A' && c <= 'Z')
			{
				idx = c - 'A';
			}

			if (idx >= 0)
			{
				count[idx] += 1;
			}
		}
	}

	for (int i = 0; i < 26; ++i)
	{
		std::cout << (char)('a' + i) << " : " << count[i] << std::endl;
	}

	return 0;
}


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

int main(){
  ll n, k;
  cin >> n >> k;
  vector<ll> p(n);
  for(int i=0; i<n; i++){
    cin >> p[i];
  }
    
  //『合計の期待値』の最大値⇒『期待値の合計』の最大値
  ll sum = 0;
  for(int i=0; i<k; i++){
    sum += p[i];
  }
  
  ll smax = sum;
  for(int i=1; i+k-1<n; i++){
    sum = sum - p[i-1] + p[i+k-1];
    smax = max(sum, smax);
  }
  double answer = 0.5 * (smax + k);
  
  cout << fixed << setprecision(10) << answer << endl;
  return 0;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-

W,H,x,y = map(int, raw_input().split())
s = W*H
ans = s/2.0
ans2=0
if(W/2.0==x and H/2.0==y):
	ans2 = 1
else:
	ans2 = 0

# 出力
print str(ans) + " " + str(ans2)

Measured memory_bytes: 2568
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const ll INF = 1000000000;
const double PI = acos(-1);
const int mod = 1000000007;

int dp[100001] = {0};

int main()
{
    int n;
    cin >> n;
    vector<int> h(n+1, 0);
    for(int i = 1; i<=n; i++) cin >> h[i];

    for (int i = 2; i <= n; i++) {
        if (i == 2) {
            dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        }
        else {
            dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]),
                        dp[i - 1] + abs(h[i] - h[i - 1]));
        }
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 4040
# -*- coding: utf-8 -*-
import math

if __name__ == '__main__':
    N, K = map(int, input().split())
    A, B = [], []
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)

    z = zip(A, B)
    z = sorted(z)

    A, B = zip(*z)

    val = 0
    for i in range(len(A)):
        val += B[i]
        if val >= K:
            print(A[i])
            exit()


Measured memory_bytes: 26920
n=int(input())
list1=list(map(int,input().split()))
dp=[0]*n
dp[1]=abs(list1[1]-list1[0])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(list1[i]-list1[i-1]), dp[i-2]+abs(list1[i]-list1[i-2]))
print(dp[n-1])


Measured memory_bytes: 13980
#include<vector>
#include<iostream>
#include<algorithm>
#include<chrono>
#include<set>
#include<cstdio>
#include<string>
#include<unordered_map>

using namespace std;
typedef long long ll;
const int mod=1e9+7;

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

int n,m;
ll ans,f[2000005]={1}, inv[2000005]={1};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    for(int i=1;i<=2e6+3;i++){
        f[i] = f[i-1] * i%mod;
        inv[i] = qpow(f[i],mod-2); //质数模下的逆元，根据费马定理
    }
    int K;
    long long ans = 0;
    string S;
    cin >> K >> S;
    int n = S.length();
    for(int i = 0; i <= K; i++){
        ans = (ans + qpow(26,i)%mod*f[n+K-i-1]%mod*inv[n-1]%mod*inv[K-i]%mod*qpow(25,K-i)%mod)%mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 35740
#include <iostream>
#include <set>

std::set<long int> prime_factorization(long int n) {

    long int a;
    std::set<long int> s = {1};

    a = 2;

    while (n >= a * a) {
        if (n % a == 0) {
            s.insert(a);
            n /= a;
        } else {
            a++;
        }
    }
    s.insert(n);

    return s;
}

int main() {
    long int A, B;
    std::cin >> A >> B;

    std::set<long int> A_s = prime_factorization(A);
    std::set<long int> B_s = prime_factorization(B);

    int count = 0;
    for (long int a : A_s) {
        for (long int b : B_s) {
            if (a == b) count++;
        }
    }

    std::cout << count << '\n';

}

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

int main(void)
{
	int n;
	string str;
	cin >> n;
	getline(cin, str);
	while (n--)
	{
		getline(cin, str);
		while (str.find("Hoshino") != -1)
		{
			int x = str.find("Hoshino");
			str.replace(x,7,"Hoshina");
		}
		cout << str << endl;
	}
	return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define fep(i,n) for(i=0;i<(n);i++)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second
#define N 1000000007
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t,r,j,i,n,k;
    cin>>n>>k;
    r=k;
    vi a(n);
    for(i=0;i<n;i++)
    cin>>a[i];
    int dp[n]={0};
    dp[0]=0;dp[1]=abs(a[1]-a[0]);
    int ans=0;
    ans+=dp[1];
    if(n==2)
    {cout<<ans;return 0;}
    for(i=2;i<n;i++){
        k=r;
        j=2;
        
        dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
        k--;
        while(k>0&&i-j>=0){
        dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
            k--;
            j++;
        }
    }
    cout<<dp[n-1];
    
}

Measured memory_bytes: 1792