akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = long long ;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    string s;
    cin >> n >> s;
    ll res = 0;
    rep(i,1000){
        bool res1 = false;
        bool res2 = false;
        bool res3 = false;
        string si = to_string(i);
        if(si.size()==1) si = "00" + si;
        if(si.size()==2) si = "0" + si;
        rep(j,s.size()){
            if(!res1){
                if(s.at(j)==si.at(0)) res1 = true;
                continue;
            }
            if(!res2){
                if(s.at(j)==si.at(1)) res2 = true;
                continue;
            }
            if(!res3){
                if(s.at(j)==si.at(2)) res3 = true;
            }
            if(res1 && res2 && res3){
                res++;
                break;
            }
        }
    }
    cout << res << endl;
}

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

#define pb push_back
#define mp make_pair
#define fs first
#define se second

typedef long long LL;

int n,m ;
int check[212345];
vector <int > a[212345];

int main() {
//    freopen("test.txt","r",stdin);
    cin >> n >> m ;
    for (int i =1 ; i <= m ; i++) {
        int x,y;
        cin >> x >> y ;
        a[x].pb(y);
        if ( x == 1 ) {
            check[y] = 1;
        }
        a[y].pb(x);
    }
    for (int i =2 ; i <= n ; i++) {
        sort(a[i].begin() , a[i].end());
    }
    for (int i = 2 ; i < n ; i++) {
        if ( check[i] && a[i][a[i].size() -1] == n ) {
            cout << "POSSIBLE";
            return 0;
        }
    }
    cout << "IMPOSSIBLE";
}


Measured memory_bytes: 13040
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] s = scanner.nextLine().toCharArray();
			int max = (int) Math.pow(2, s.length - 1);
			System.out.println(IntStream.range(0, max).mapToLong(i -> eval(i, s)).sum());
		}
	}

	/**
	 * @param n 「+」ありなしの2進数
	 * @param s 入力数字の文字列
	 * @return 文字列に「+」を追加した後の数式の計算結果
	 */
	private static long eval(int n, char[] s) {
		StringBuilder sb = new StringBuilder();
		long sum = 0L;
		for (int i = 0; i < s.length - 1; i++) {
			sb.append(s[i]);
			if (1 == ((n >> i) & 1)) {
				sum += Long.parseLong(sb.toString());
				sb.setLength(0);
			}
		}
		// 最後の項目を追加
		sb.append(s[s.length - 1]);
		return sum + Long.parseLong(sb.toString());
	}
}


Measured memory_bytes: 28372
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let n = read::<i64>();
  let m = read::<i64>();

  let mut map_n: Vec<String> = vec![];
  let mut map_m: Vec<String> = vec![];
  let mut ans = "No";

  for _ in 0..n {
    map_n.push(read::<String>())
  }

  for _ in 0..m {
    map_m.push(read::<String>())
  }

  for h in 0..n - m + 1 {
    for w in 0..n - m + 1 {
      // 検証
      let mut allright = true;
      for i in h..h + m {

        let w_size = w as usize;
        let m_size = m as usize;
        let row = &map_n[i as usize];
        if &map_m[(i - h) as usize] != &row[w_size..w_size + m_size] {
          allright = false;
        }
      }

      if allright {
        ans = "Yes";
        break;
      }
    }
    if ans == "Yes" {
      break;
    }
  }

  println!("{}", ans);
}



Measured memory_bytes: 4352
#131_D
n=int(input())
ab=[tuple(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x:x[1])

tmp=0
flg=True
for a,b in ab:
    tmp+=a
    if tmp>b:
        flg=False
        break
print('Yes' if flg else 'No')

Measured memory_bytes: 31828
X = int(input())

for A in range(100000000):
    flg=0
    for B in range(A):
        if A**5 - B**5 == X:
            print(A,B)
            flg=1
            break
        if A**5 + B**5 == X:
            print(A,B*(-1))
            flg=1
            break
    if flg==1:
        break


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

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

int main()
{
	int h, w;
	cin >> h >> w;

	string snuke[h][w];
	string ans = "snuke";

	int ansh, answ;

	REP(i, h){
		REP(j, w){
			cin >> snuke[i][j];
			if (snuke[i][j] == ans){
				ansh = i; answ = j;
			}
		}
	}

	cout << (char)('A' + answ) << ansh + 1 << endl;
}


Measured memory_bytes: 256
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys

sys.setrecursionlimit(10**9)
mod = 998244353
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

n = I()
s = S()

ans=0
for i in range(0,n-2):
    if s[i:i+3]=="ABC":
        ans+=1
print(ans)

Measured memory_bytes: 5552
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
 
 
const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int main() {

	int max = 2000000000;
	int n = getint();
	for(int i = 0; i < n; i++){
		int a = getint();
        int b = getint();
		if(a+b < max) {
			max = a+b;
		}
	}
	printf("%lld", max);
	return 0;
}


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

int cnt[26];

int main(){
    string S;
    cin >> S;
    for(int i = 0; i < 4; i++){
        cnt[S[i] - 'A']++;
    }
    bool ok = true;
    for(int i = 0; i < 26; i++){
        if(cnt[i] != 0 && cnt[i] != 2){
            ok =false;
        }
    }
    cout << (ok?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

int main() {
	string s;
	CI s;

	int ans = 0;
	int len = s.length()-1;
	if (s[0] == '0' ) {
		string ori = s;
		int tmp = 0;
		for (int i = 1; i < len + 1; i++) {
			if (ori[i] == ori[i-1]) {
				tmp++;
				if (ori[i] == '1')ori[i] = '0';
				else ori[i] = '1';
			}
		}

		ans = tmp;
		ori = s;
		ori[0] = '1';

		tmp = 1;
		for (int i = 1; i < len + 1; i++) {
			if (ori[i] == ori[i - 1]) {
				tmp++;
				if (ori[i] == '1')ori[i] = '0';
				else ori[i] = '1';
			}
		}
		ans=min(ans, tmp);
	}
	if (s[0] == '1' ) {
		string ori = s;
		int tmp = 0;
		for (int i = 1; i < len + 1; i++) {
			if (ori[i] == ori[i - 1]) {
				tmp++;
				if (ori[i] == '1')ori[i] = '0';
				else ori[i] = '1';
			}
		}

		ans = tmp;
		ori = s;
		ori[0] = '0';

		tmp = 1;
		for (int i = 1; i < len + 1; i++) {
			if (ori[i] == ori[i - 1]) {
				tmp++;
				if (ori[i] == '1')ori[i] = '0';
				else ori[i] = '1';
			}
		}
		ans = min(ans, tmp);

	}

	CO ans EN;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long ans = 0;
  for(int i=1;i<=n;i++) {
    if(i % 3 == 0 || i % 5 == 0) continue;
    else ans += i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
using namespace std;

pair<int,int> dfs(vector< vector<int> > &G, int v, int c, vector<int> &visited){
  pair<int,int> ret = make_pair(1, 0);
  for(int i = 0; i < G[v].size(); ++i){
    int u = G[v][i];
    if(visited[u] == c) continue;
    if(visited[u] == 1-c) return make_pair(-1,-1);
    visited[u] = c;
    pair<int,int> p = dfs(G, u, 1 - c, visited);
    if(p == make_pair(-1,-1)) return p;
    ret.first += p.second;
    ret.second += p.first;
  }
  return ret;
}

int main(){
  int V, E;
  cin >> V >> E;
  vector< vector<int> > G(V);
  for(int i = 0; i < E; ++i){
    int a, b;
    cin >> a >> b;
    --a,--b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> visited(V, -1);
  bitset<100001> dp = 1;
  for(int i = 0; i < V; ++i){
    if(visited[i] >= 0) continue;
    visited[i] = 1;
    pair<int,int> p = dfs(G, i, 0, visited);
    if(p == make_pair(-1, -1)){
      cout << -1 << endl;
      return 0;
    }
    dp = (dp << p.first)|(dp << p.second);
  }
  long long int ans = 0;
  for(int i = 0; i <= V/2; ++i){
    if(dp[i]) ans = max(ans, (long long int)i*(V-i) - E);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 9464
#include <iostream>
#include<string>
using namespace std;
int a,b,du=0,qu=0,od=0;
int main(){
	cin>>a;
	for(int i;i<a;i++){
		cin>>b;if(b%4==0)qu++;else if(b%2==0)du++;else od++;
	}
	if(qu>=od||(qu==od-1&&du==0))cout<<"Yes"<<endl;else cout<<"No"<<endl;
		return 0;
}

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

using namespace std;

#define INF 1000000000
#define pb(a) push_back(a)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x;
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < sz(v);i++)


int main(){
	set<int> d;
	int buf;
	int n;
	cin>>n;
	REP(i,n){
		cin>>buf;
		d.insert(buf);
	}
	cout<<d.size()<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

const int N = 2e5 + 5, MOD = 998244353;
int dp[N],nxt[N],n;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	cin >> n;
	vector<pii> v(n);
	rep(i,0,n)cin >> v[i].first >> v[i].second;
	sort(all(v));
	dp[n] = 1;
	nxt[n] = n;
	for(int i = n-1;i>=0;--i){
		int d = v[i].first + v[i].second;
		if(d > v[i+1].first){
			int j = nxt[i+1];	
			while(j < n && v[j].first < d){
				gmax(d, v[j].first + v[j].second);	
				j = nxt[j];
			}
			nxt[i] = j;
		}
		else nxt[i] = i + 1; 
	}
	for(int i = n-1;i >= 0; --i){
		dp[i] = (dp[i+1] + dp[nxt[i]]) % MOD;
	}
	cout << dp[0] << '\n';
}


Measured memory_bytes: 3328
n = int(input())
a = sorted([int(input()) for i in range(n)])

m = n//2
a1 = a[:m]
a2 = a[:m-1:-1]
if n%2==1:a1.append(a[m])

from collections import deque
l = deque([])

for i in range(m):
    if i%2==0:
        l.append(a1[i])
        l.appendleft(a2[i])
    else:
        l.append(a2[i])
        l.appendleft(a1[i])

if n%2==1:
    if abs(l[0]-a1[-1])>abs(l[-1]-a1[-1]):
        l.appendleft(a1[-1])
    else:
        l.append(a1[-1])

ans = 0
for i in range(n-1):
    ans += abs(l[i]-l[i+1])

print(ans)

Measured memory_bytes: 10944
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define INF 1e9
#define MOD 1000000007
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main(void){
   ll N,K,S;
   cin>>N>>K>>S;
   REP(i,K)cout<<S<<" ";
   REP(i,N-K){
       if(S==1000000000)cout<<1<<" ";
       else cout<<S+1<<" ";
   }cout<<endl;
}

Measured memory_bytes: 1280
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[] alreadyAC = new boolean[n];
        long[] penaltyCount = new long[n];
        for(int i = 0; i < m; ++i) {
            int p = sc.nextInt() - 1;
            String s = sc.next();
            if(!alreadyAC[p]) {
                penaltyCount[p] += (s.equals("WA")) ? 1 : 0;
                alreadyAC[p] = s.equals("AC");
            }
        }

        long acSum = 0, penaltySum = 0;
        for(int i = 0; i < n; ++i) {
            acSum += (alreadyAC[i]) ? 1 : 0;
            penaltySum += (alreadyAC[i]) ? penaltyCount[i] : 0;
        }

        System.out.printf("%d %d", acSum, penaltySum);
    }
}

Measured memory_bytes: 64720
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int num[] = new int[10000];
		int cnt = 0, input;
		
		while(true){
			if((input = sc.nextInt()) == 0)
				break;
			num[cnt] = input;
			cnt ++;
		}
		
		for(int i = 0; i < cnt; i++)
			System.out.println("Case " + (i+1) + ": " + num[i]);
	}
}

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

int main() {
  int A, B, C, D;
  int Acnt, Ccnt = 0;
  cin >> A >> B >> C >> D;
    A -= D;
  while(A > 0) {
    A -= D;
    Acnt++;
  }
    C -= B;
  while(C > 0) {
    C -= B;
    Ccnt++;
  }
  if (Acnt < Ccnt) cout << "No";
  else        cout << "Yes";
}


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

int main(){
  int N;
  cin >> N;
  
  vector<int> L(N);
  for (int i = 0 ; i < N; i++) cin >> L.at(i);
  
  sort(L.begin(), L.end(),greater<int>());
  long cnt = 0;
  
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (L.at(j) <= L.at(i) / 2) break;
      else {
        for (int k = j + 1; k < N; k++) {
          if (L.at(i) < L.at(j) + L.at(k)) cnt++;
        }
      }
    }
  }
  
  cout << cnt;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair
using namespace std;


int main(void) {
	int H, W, N; cin >> H >> W >> N;	
	int a = max(H , W);
	int i=1;
	while (a*i < N) {
		i++;
	}
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
   int a, b, c, d, e;
   cin >> a >> b ;
   
   c = a + b;
   d = a - b;
   e = a * b;
   
   if(c < d)swap(c,d);
   if(d < e)swap(e,d);
   if(c < d)swap(c,d);
   
   cout << c << endl;
   
    return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
//Some custom functions for quick use(fast_power,nCr,lcm,gcd)
ll power(ll a, ll b)
{
  if(b == 0)
   {
      return 1;
   }
   else if(b % 2 == 0)
   {
      return power(a*a, b/2);
   }
   else
   {
      return a * power(a*a, b/2);
   }
}
long long int nChoosek( long long int n, long long int k )
{
if (k > n) return 0;
if (k * 2 > n) k = n-k;
if (k == 0) return 1;
    int result = n;
for( int i = 2; i <= k; ++i )
{
        result *= (n-i+1);
        result /= i;
}
    return result;
}

long long int lcm(long long int a,long long int b)
{
    long long int m,n;
    m=a;
    n=b;
    while(m!=n)
    {
        if(m < n)
        {
            m=m+a;
        }
        else
        {
            n=n+b;
        }
    }
    return m;
}

long long int gcd(long long int a,long long int b)
{ 
if (a == 0) 
return b; 
return gcd(b % a, a);
}
/* Basic DFS Boilerplate */ 
vector<ll> adj[10005]; // graph is stored as adjacency list
bool visited[10005];
void dfs(ll s)  //given node s
{
    if(visited[s])
        return;
    visited[s]=true;
    //the process on node 's'
    for(auto u : adj[s])
    {
        dfs(u);
    }    
}
/* Basic BFS Boilerplate */
ll x;   // given node
queue<ll>q;
bool vis[10005];
ll dist[10005];
//
void bfs(ll x)
{
    vis[x]=true;
    dist[x]=0LL;
    q.push(x);
    while (!q.empty())
    {
        ll s=q.front();
        q.pop();
        //the process
        //on node x
        for(auto u :adj[x])
        {
            if(vis[u]==true)
                continue;
            vis[u]=true;
            dist[u]=dist[x]+1;
            q.push(u);
        }
    }
    
}
int main()
{
    fastio
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    int t=0;
    while (true)
    {
        if(t%2==0)
            c-=b;
        else
            a-=d;
        if(t%2!=0&&a<=0)
        {
            cout<<"No"<<'\n';
            break;
        }
        else if(t%2==0 && c<=0)
        {
            cout<<"Yes"<<'\n';
            break;
        }
        t++;
        
    }
    
    return 0;
}


Measured memory_bytes: 3904
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	int N,K;
	scanf("%d %d",&N,&K);

	int ans = K;

	for(int i=1;i<N;i++){
		ans *= K-1;
	}

	printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    int ans = 0;
    REP1(i, n - 1) ans += (n - 1) / i;
    cout << ans << endl;
}


Measured memory_bytes: 3608
n = int(input())
s = input()
l = [chr(i) for i in range(65,91)]
ss=len(l)-1
ans=""
for si in s:
  i=l.index(si)
  if i+n>ss:
    ans+=l[abs(i+n-ss)-1]
  else:
    ans+=l[i+n]
print(ans)

Measured memory_bytes: 3064
s = int(input())
TMP = [s]

if s==1 or s==2:
    print(4)
else:
    while TMP[-1]!=1:
        if TMP[-1] % 2 == 0:
            TMP.append(TMP[-1]//2)
        elif TMP[-1] % 2 != 0:
            TMP.append(3 * TMP[-1] + 1)
    print(len(TMP)+1)

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

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)
//計算量はsqrt(N)
template<typename T>
vector<T> Divisors(T n)
{
    vector<T> result;

    T boundary = sqrt(n);

    for (T i = 1; i <= boundary; i++) {
        if (n % i == 0) {
            result.push_back(i);
            if(i != (n / i) && i * i != n)
                result.push_back(n/i);
        }
    }
    sort(result.begin(),result.end());
    return result;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c;
    cin>>a>>b>>c;
    vector<ll> ad = Divisors(a);
    vector<ll> bd = Divisors(b);
    map<ll,ll> mp;
    FOR(i,0,ad.size()){
      mp[ad[i]] += 1;
    }
    FOR(i,0,bd.size()){
      mp[bd[i]] += 1;
    }
    vector<ll> ans;
    FORm(i,mp){
      if(i->second == 2){
        ans.push_back(i->first);
      }
    }
    ll s = ans.size();
    cout<<ans[s-c]<<endl;


}


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

int main(void) {
    int a, b, c, temp;
    cin >> a >> b >> c;
    temp = a;
    a = b;
    b = temp;
    temp = a;
    a = c;
    c = temp;
    cout << a << " " << b << " " << c << endl;
    
    
}

Measured memory_bytes: 256
def main():
    H, W = [int(ele) for ele in input().split()]
    N = int(input())
    a = [int(ele) for ele in input().split()]
    ans = [[0] * W for _ in range(H)]

    ct = 0

    # paint
    init = 0
    for color, a_i in enumerate(a, 1):
        for _ in range(a_i):
            if init == 0:
                h = 0
                w = 0
                ans[h][w] = color
                init = 1
                continue

            if 1 <= h and ans[h - 1][w] == 0:
                h -= 1
            elif w + 1 < W and ans[h][w+1] == 0:
                w += 1
            elif h + 1 < H and ans[h + 1][w] == 0:
                h += 1
            elif 1 <= w and ans[h][w-1] == 0:
                w -= 1

            ans[h][w] = color

    for row in ans:
        print(" ".join(map(str, row)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3572
#include <cstdio>
#include <vector>
#include <algorithm>

#define INFL (1LL << 60)

using namespace std;

typedef long long ll;

int main() {
    ll a, b, q, ps = 0, pt = 0, x;
    scanf("%lld%lld%lld", &a, &b, &q);
    vector<ll> s(a + 2), st(a + 2), t(b + 2), ts(b + 2);
    s.front() = (t.front() = -INFL);
    s.back() = (st.front() = (st.back() = (t.back() = (ts.front() = (ts.back() = INFL)))));
    for (ll i = 1; i <= a; ++i) scanf("%lld", s.begin() + i);
    for (ll i = 1; i <= b; ++i) {
        scanf("%lld", t.begin() + i);
        while (t.at(i) > s.at(ps)) ++ps;
        ts.at(i) = min(s.at(ps) - t.at(i), t.at(i) - s.at(ps - 1));
    }
    for (ll i = 1; i <= a; ++i) {
        while (s.at(i) > t.at(pt)) ++pt;
        st.at(i) = min(t.at(pt) - s.at(i), s.at(i) - t.at(pt - 1));
    }
    for (ll i = 0; i < q; ++i) {
        scanf("%lld", &x);
        ps = lower_bound(s.begin(), s.end(), x) - s.begin();
        pt = lower_bound(t.begin(), t.end(), x) - t.begin();
        printf("%lld\n", min({t.at(pt) - x + ts.at(pt), x - t.at(pt - 1) + ts.at(pt - 1), s.at(ps) - x + st.at(ps), x - s.at(ps - 1) + st.at(ps - 1)}));
    }
    return 0;
}


Measured memory_bytes: 4480
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
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)
#define pint pair<int,int>
#define pll pair<ll,ll>
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll dp[50][500][500]; // dp[i][j][k] i個までで状態[j][k]を作るのに必要な最小費用

int main(){
  int n,ma,mb;
  cin >> n >> ma >> mb;
  int a[n+1]={},b[n+1]={},c[n+1]={};
  rep(i,n)cin >> a[i+1] >> b[i+1] >> c[i+1];
  for(int i=0;i<50;i++){
    for(int j=0;j<500;j++)for(int k=0;k<500;k++)dp[i][j][k]=longinf;
  }
  dp[0][0][0]=0;
  for(int i=1;i<=n;i++){
    for(int j=0;j<=400;j++){
      for(int k=0;k<=400;k++){
        dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k]);
        if(j>=a[i] && k>=b[i])dp[i][j][k]=min(dp[i][j][k],dp[i-1][j-a[i]][k-b[i]]+c[i]);
      }
    }
  }
  ll ans=longinf;
  for(int i=ma;i<500;i++){
    for(int j=mb;j<500;j++){
      if(i%ma==0 && j%mb==0 && i/ma==j/mb){
        ans=min(ans,dp[n][i][j]);
      }
    }
  }
  if(ans>=longinf)ans=-1;
  cout << ans << endl;
return 0;}

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

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

    string s;
    cin >> s;
    int k;
    cin >> k;

    int n = s.size();
    for(int i = 0; i < n; i++){
        if(i < n - 1){
            int diff = 'z' - s[i];
            if(diff == 25) continue;
            diff++;

            if(diff <= k){
                k -= diff;
                s[i] = 'a';
            }
        }else{
            k %= 26;
            s[i] = char('a' + ((int)(s[i] - 'a') + k) % 26);
        }
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 592
#include"bits/stdc++.h"
using namespace std;

#define ll long long int
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define sz(a) int((a).size())
#define mod 1000000007
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
template <typename T>
inline T gcd(T a, T b)
{
    while (b != 0) swap(b, a %= b);
    return a;
}

template <typename T>
inline void seethis(vector<T>vect)
{
    for(T x : vect)
        cout << x << " ";
    cout << "\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

//Top down:
int dp[100005];
int solve(int current, int n, vector<int> &vect)
{
    //Base Case:
    if(current <= 0)
        return INT_MAX;

    if(current == 1)
        return 0;
    if(current == 2)
        dp[current] = abs(vect[2] - vect[1]);

    if(dp[current] != -1)
        return dp[current];

    //Recursive case:
    int a, b;
    a = solve(current - 1, n, vect);
    b = solve(current - 2, n, vect);

    if(a!=INT_MAX)
    {
      a+=abs(vect[current]-vect[current-1]);
    }
    if(b!=INT_MAX)
    {
      b+=abs(vect[current]-vect[current-2]);
    }

    dp[current]=min(a,b);

    return dp[current];

}



int main()
{
    FASTIO;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;

    vector<int>vect(n+1);
    memset(dp, -1, sizeof dp);

    f(i, 1, n+1)
    cin >> vect[i];

    cout<<solve(n,n,vect)<<"\n";

    return 0;
}

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

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define MOD 1000000007

#define trace1(x)                    cout <<#x<<": "<<x<< endl;
#define trace2(x, y)                 cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)              cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)           cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;

typedef long long ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    ll i,j,n,m;
    cin>>n;
    ll cnt=0;
    for(i=1;i<=n;i++)
    {
        ll temp=i;
        ll tp=0;
        while(temp>0)
        {
            temp/=10;
            tp++;
        }
        if(tp%2)
        cnt++;
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int x; cin >> x;
    ll id=1;
    while((360LL*id)%x!=0){
        id++;
    }
    cout << 360*id/x << endl;
}


Measured memory_bytes: 3632
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    map<ll,ll> cnt;
    ll ans=0;
    FORI(i,1,N+1)
    {
        READV(x); 
        ans+=cnt[i-x];
        cnt[i+x]++;
    }
    cout<<ans<<endl;

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


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

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

using namespace std;

typedef long long int ll;

#define FOR(i,l,r) for(i=l;i<r;i++)

#define REP(i,n) FOR(i,0,n)

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

#define P pair<ll,ll>

#define F first

#define S second

signed main(){

  ll x,y;cin>>x>>y;

  if(y%2==0&&4*x>=y&&y>=2*x)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;
const int INF = 1001001001;


int main() {
  string s,t; cin >> s >> t;
  int cnt = 0;
  rep(i,s.size()){
    if(s[i]!=t[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3852
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int a;
	double b,c;
	char x;
	while(cin>>a>>x>>b>>x>>c){
		if(b/c/c+EPS>25.0)cout<<a<<endl;
	}
}

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

using namespace std;

typedef long long ll;

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

int main(){
    int n, f;
    cin >> n >> f;
    int x[100005];
    int y[100005];
    for(int a = 0; a < n; a++){
        cin >> x[a];
        y[a] = abs(x[a]-f);
    }
    for(int b = 1; b < n; b++){
        y[0] = gcd(y[0], y[b]);
    }
    cout << y[0] << endl;
    return 0;
}

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

using namespace std;

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

  for(i = 0;i < k;i++){
    if(a >= b){
      b *=2;

    }else{
      break;
    }
  }
  for(;i  < k ; i++){
    if(b >= c){
      c *=2;
    }else{
      break;
    }
  }

  if(a < b && b < c){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}


Measured memory_bytes: 3596
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

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

int main(){
	int n;
	cin >> n;
	vector<pair<int, int> > r(n), b(n);
	for(int i=0; i<n; i++)
		cin >> r[i].first >> r[i].second;
	for(int i=0; i<n; i++)
		cin >> b[i].first >> b[i].second;
	sort(r.begin(), r.end());
	sort(b.begin(), b.end());
	int ans=0;
	for(int i=0; i<n; i++){
		int tmp=-1;
		for(int j=0; j<n; j++){
			if(r[j].first<b[i].first && r[j].second<b[i].second){
				if(tmp==-1)
					tmp=j;
				else if(r[j].second>r[tmp].second)
					tmp=j;
			}
		}
		if(tmp!=-1){
			r[tmp].second=n*2;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)

#h,w
def main():
	a,b,x = map(int,input().split())
	min_x = a//x + (1 if a%x!=0  else 0)
	max_x = b//x 
	print(max_x-min_x+1)



def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Measured memory_bytes: 63596
#include"bits/stdc++.h"
//#include<boost/multi_array.hpp>
//#include<boost/optional.hpp>
//#include<boost/range/irange.hpp>
//#include<boost/range/algorithm.hpp>
//#include<boost/range/adaptors.hpp>

using namespace std;
//namespace adaptor = boost::adaptors;

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main()
{
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
}

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

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
const int INF = 100000000;
int dx[] = {0,1,-1,0,1,-1,1,-1};
int dy[] = {1,0,0,-1,1,-1,-1,1};

int main(){
    vector<int> v(3);
    cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(), v.end());
    cout << v[0] * v[1] / 2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

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

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	if ((a + b) <= n) {
		ll num = n / (a + b);
		ll mod = n % (a + b);
		cout << num * a + min(a,mod) << endl;
	}
	else {
		cout << min(a, n) << endl;
	}
}

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

using namespace std;

#define ll long long int
#define ld long double
#define MAX 100005
#define MOD 1000000007
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358979323846
#define Q ll _; cin >> _; while(_--)
#define endl "\n"
#define flush fflush(stdout);
ll power(ll x, ll y){
    ll res = 1;
    x=x%MOD;
    if(x==0)return 0;
    while(y>0){
        if(y&1){
            res=(res*x)%MOD;
        }
        y = y>>1;
        x = (x*x)%MOD;
    }
    return res;
}
int main(){

    fast

    ll n;
    cin >> n;
    ll x = power(10,n);
    ll y = power(9,n);
    ll z = power(8,n);

    ll ans = (x%MOD);
    ans+=MOD;
    ans-=(y%MOD);
    ans+=MOD;
    ans-=(y%MOD);
    ans+=(z%MOD);
    ans = ans%MOD;
    cout << ans << endl;

}


//    cout << fixed << setprecision(12);


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)10e9+7;
const int INF = 0x3f3f3f3f;

map< int, map<int, int> > mp;
ll ans[10];
pair<int, int> help[9] = {{0, 0}, {1, 0}, {-1, 0}, {0, 1}, {0, -1}, {1, 1}, {1, -1}, {-1, -1}, {-1, 1}};
ll h, w, n;
void upd(int x, int y)
{
    if(x<=1||y<=1||x>=h||y>=w) return;
    int c=0;
    for(int i=0; i<9; i++)
    {
        if(mp[help[i].first+x][help[i].second+y]) c++;
    }
    ans[c-1]--;
    ans[c]++;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> h >> w >> n;
    ans[0] = (h-2)*(w-2);
    for(int i=0; i<n; i++)
    {
        int a, b;
        cin >> a >> b;
        mp[a][b] = 1;
        for(int i=0; i<9; i++)
            upd(a+help[i].first, b+help[i].second);
    }
    for(int i=0; i<10; i++) cout << ans[i] << endl;
}

//TODO: 45


Measured memory_bytes: 166144
#include<iostream>
#include<cstdio>
#include<cstring>
#define N 5010
using namespace std;

int n,k,dp[20][N],num[N],ans;

void sol(int l,int r,int now)
{
	if(l==r)
	{
		int i;
		for(i=max(0,k-num[l]); i<k; i++)
		{
			if(dp[now][i]) break;
		}
		if(i<k) ans++;
		return;
	}
	int i,j,mid=((l+r)>>1);
	for(i=0;i<k;i++) dp[now+1][i]=dp[now][i];
	for(j=l; j<=mid; j++)
	{
		for(i=k-1; i>=num[j]; i--)
		{
			dp[now+1][i]|=dp[now+1][i-num[j]];
		}
	}
	sol(mid+1,r,now+1);
	for(i=0;i<k;i++) dp[now+1][i]=dp[now][i];
	for(j=mid+1;j<=r;j++)
	{
		for(i=k-1;i>=num[j];i--)
		{
			dp[now+1][i]|=dp[now+1][i-num[j]];
		}
	}
	sol(l,mid,now+1);
}

int main()
{
	int i,j;
	cin>>n>>k;
	for(i=1; i<=n; i++)
	{
		scanf("%d",&num[i]);
	}
	dp[0][0]=1;
	sol(1,n,0);
	cout<<n-ans;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   ll n,k;cin >>n>>k;
   vector<ll>l;
   vector<ll>r;
   l.push_back(0);
   r.push_back(0);
    for (int i = 0; i < n; ++i) {
        ll x;cin >>x;
        if(x<0)l.push_back(-x);
        else r.push_back(x);
    }
    for (int i = 0; i <= k; ++i) {
        r.push_back(INF);
        l.push_back(INF);
    }
    sort(all(l));
    ll ans=INFll;
    for (int i = 0; i <=k; ++i) {
        ans=min(2*r[i]+l[k-i],ans);
        ans=min(2*l[i]+r[k-i],ans);
    }
    cout <<ans <<endl;
   return 0;
}

Measured memory_bytes: 3568
x = int(input())

def sieve(lim):
    primes = [True] * (lim+1)
    primes[0:2] = False, False
    for i in range(2, int(lim**0.5)+1):
        if not primes[i]: continue
        for j in range(i*2, lim+1, i):
            primes[j] = False
    return primes

p = sieve(10**6)

for i in range(x, 10**6):
    if p[i]: print(i); exit()


Measured memory_bytes: 10868
#include<stdio.h>
int main(){
  int a,b,c,i,count=0;

  scanf("%d %d %d",&a,&b,&c);
  for(i=a;i<=b;i++){
    if(c % i == 0) count++;
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2148
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#define ll long long
#define INF 100000000000
#define N 10000000
using namespace std;


int main(void){
    ll k;
    cin>>k;
    
    if (k==1 or k==7){
        cout<<"1"<<endl;
        return 0;
    }
    
    ll data[k+2];
    data[0]=7%k;
    for(ll i=1; i<=k+1; i++){
        data[i]=(data[i-1]*10)%k;
    }
    
    ll num[k+2];
    num[0]=data[0];
    for(ll i=1; i<=k+1; i++){
        num[i]=(num[i-1]+data[i])%k;
        if(num[i]==0){
            cout<<i+1<<endl;
            return 0;
        }
    }
    
    cout<<"-1"<<endl;
}
    
    
    

Measured memory_bytes: 19220
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


// 階乗mod
ll fmod(ll n){
    ll ans = 1;
    for(ll i = 1; i <= n; i++){
        ans *= i;
        ans %= MOD;
    }

    return ans;
}

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

    if(N == M){
        cout << (2 * fmod(N) % MOD) * fmod(M) % MOD << endl;
    }else if(abs(N - M) == 1){
        if(N < M){
            swap(N, M);
        }
        cout << fmod(N) * fmod(M) % MOD << endl;
    }else{
        cout << 0 << endl;
    }


    return 0;
}

Measured memory_bytes: 3596
A, B = map(int, input().split())

# 最大公約数
def gcd(a, b) :
    if b > a : 
        a, b = b, a
    
    while b != 0 :
        a, b = b, a % b
    return a
    
# 最小公倍数
def lcm(a, b) :
    return a * b // gcd(a, b)
    
print(lcm(A, B))

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
string debug_string(const string& s){
	return '"' + s + '"';
}
string debug_string(bool b){
	return (b ? "true" : "false");
}
string debug_string(const char* s){
	return debug_string((string)s);
}
template<class T, class U>
string debug_string(const pair<T, U>& p);
template<class U>
struct can_be_string{
	template<typename...>
	static int f(...){
		return 0;
	}
	template<typename T>
	static char f(decltype(to_string(T()), char())) { 
		return 'a';
	}
	static const bool value = sizeof(f<U>(char())) == sizeof(char);
};
template<class T> 
typename enable_if<can_be_string<T>::value, string>::type debug_string(const T& a){
	string s = to_string(a);
	return s;
}
template<class T>
typename enable_if<!can_be_string<T>::value, string>::type debug_string(const T& a){
	bool first = true;
	string s = "{";
	for(const auto& x : a){
		if(!first){
			s += ", ";
		}
		first = false;
		s += debug_string(x);
	}
	s += "}";
	return s;
}
template<class T, class U>
string debug_string(const pair<T, U>& p){
	string s = "[";
	s += debug_string(p.first);
	s += ", ";
	s += debug_string(p.second);
	s += "]";
	return s;
}
void debug_out(){cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail){
	cerr << ' ' << debug_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 1e18l + 100;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	ll a, b;
	cin >> a >> b;
	ll tiv1 = (a * a - b * b);
	ll tiv2 = (2 * a - 2 * b);
	if(tiv1 % tiv2 != 0){
		cout << "IMPOSSIBLE\n";
		return 0;
	}
	cout << (a * a - b * b) / (2 * a - 2 * b) << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long int x,a;
	cin>>x;
	a=x/100;
	a=a*105;
	if(x<=a)
	{
		cout<<1<<endl;
	}
	else
	{
		cout<<0<<endl;
	}
	
}

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

using namespace std;

using ll = long long;

int main() {
    int N;
    cin >> N;
    std::vector<double> p(N);
    std::for_each(p.begin(), p.end(), [](auto &x) { cin >> x; });

    std::vector<std::vector<double>> dp(N, std::vector<double>(N + 1, 0.0));
    dp[0][0] = 1 - p[0];
    dp[0][1] = p[0];

    for (int i = 1; i < N; ++i) {
        dp[i][0] = dp[i - 1][0] * (1 - p[i]);
        for (int num_head = 1; num_head <= i + 1; ++num_head) {
            dp[i][num_head] = dp[i - 1][num_head] * (1 - p[i]) + dp[i - 1][num_head - 1] * p[i];
        }
    }

    const double ans = std::accumulate(dp[N - 1].cbegin() + N / 2 + 1, dp[N - 1].cend(), 0.0);

    std::cout << std::fixed << std::setprecision(12) << ans << endl;

    return 0;
}


Measured memory_bytes: 70656
#include <iostream>

using namespace std;

int main(void){
	int x, y, s, ans, tmp;
	while(1){
		cin >> x >> y>> s;;
		if(x==0 && y==0 && s==0)break;

		//p(100+x) / 100
		ans = 0;
		for(int i=1; i<s; i++){
			for(int j=1; j<s; j++){
				if(i*(100+x)/100 + j*(100+x)/100 ==  s){
					if((tmp = ((i*(100+y)/100 + j*(100+y)/100))) > ans){
						ans = tmp;
					}
				}
			}
		}
		cout << ans << endl;
	}//endwhile
	
	return 0;
}


Measured memory_bytes: 3056