akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */

int main() {
    string s;cin >> s;
    int k = 0;
    ll count = 0;
    rep(i, s.size()) {
        if(s[i]=='W') {
            count += i-k;
            k++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3764
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
			double lf=48.0,fl,b,f,li,lw,w,lm,m,lh,x;
			fl=lf+3;//51
			b=fl+3;//54
			f=b+3;//57
			li=f+3;//60
			lw=li+4;//64
			w=lw+5;//69
			lm=w+6;//75
			m=lm+6;//81
			lh=m+10;//91
			while(sc.hasNext()){
				x=sc.nextDouble();
				if(x<=lf){
					System.out.println("light fly");
				}
				else if(x<=fl){
					System.out.println("fly");
				}
				else if(x<=b){
					System.out.println("bantam");
				}
				else if(x<=f){
					System.out.println("feather");
				}
				else if(x<=li){
					System.out.println("light");
				}
				else if(x<=lw){
					System.out.println("light welter");
				}
				else if(x<=w){
					System.out.println("welter");
				}
				else if(x<=lm){
					System.out.println("light middle");
				}
				else if(x<=m){
					System.out.println("middle");
				}
				else if(x<=lh){
					System.out.println("light heavy");
				}
				else{
					System.out.println("heavy");
				}
			}
	}

}

Measured memory_bytes: 11000
program Guidebook
    implicit none
    integer(4):: n,i,j
    integer(4),allocatable:: p(:), ind(:)
    character(10),allocatable:: s(:)
    logical:: changed

    read*, n
    allocate(p(n), s(n),ind(n))

    do i=1,n
        read*, s(i),p(i)
        ind(i) = i
    end do

    changed = .true.
    do while(changed)
        changed=.false.
        do i=1, n-1
            if (s(i+1) < s(i)) then
                changed = .true.
                call cswap(s(i),s(i+1))
                call swap(p(i),p(i+1))
                call swap(ind(i),ind(i+1))
            else if (s(i+1) == s(i) .and. p(i+1) > p(i)) then
                changed = .true.
                call swap(p(i),p(i+1))
                call swap(ind(i),ind(i+1))
            end if
        end do
    end do

    do i=1,n
        print*, ind(i)
    end do

contains
subroutine swap(x,y)
    integer(4),intent(inout):: x,y
    integer(4):: tmp

    tmp = x
    x = y
    y = tmp
end subroutine

subroutine cswap(c1, c2)
    character(10),intent(inout)::c1,c2
    character(10):: tmp

    tmp = c1
    c1 = c2
    c2 = tmp
end subroutine
end program Guidebook

Measured memory_bytes: 384
#include<iostream>
#include<climits>
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> 
#include<ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define f first
#define s second
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vi vector<int>
#define vll vector<ll>
#define endl '\n'
#define SIZE 1000002
#define w(t) int t;cin>>t;while(t--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define value_at_idx find_by_order
#define idx order_of_key
#define MOD 1000000007
#define inf INT_MAX
#define Maxheap(T) priority_queue<T>
#define Minheap(T) priority_queue<T,vector<T>,greater<T>>
#define mem(name,value) memset(name,value,sizeof(name))
#define pi 3.14159265358979323846 
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
const int p = 31;

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

    int a,b,c,k;
    cin>>a>>b>>c>>k;
   
    if(k <=a)
        cout<<k<<endl;
    else if(k <=a+b)
        cout<<a<<endl;
    else 
    {
        cout<< a-(k-a-b)<<endl;
    }
    
    
    return 0;
        
    
    
}

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

void solve() {
	long long n;
	cin >> n;
	if (n & 1) {
		cout << "0\n";
		return;
	}
	n /= 2;
	unsigned long long mult = 5;
	unsigned long long ans = 0;
	while (mult <= n) {
		ans += n / mult;
		mult *= 5;
	}
	cout << ans << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


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

	int N;
	cin >> N;
	P p[N];
	rep(i,N){
		int a;
		cin >> a;
		p[i] = {a, i};
	}
	sort(p, p+N);
	int num = -1;
	int cou = 0;
	int ans = 0;
	rep(i,N){
		if(num < p[i].second){
			num = p[i].second;
			cou++;
			ans = max(ans, cou);
		}
		else{
			num = p[i].second;
			cou = 1;
		}
	}
	cout << N-ans << endl;
}

Measured memory_bytes: 3456
function main(input) {
    num	= parseInt(input, 10);
	str = input;

    if(num >= 100){
    	hitoketa = parseInt(str.split("")[2], 10);
    } 
    else if(num >= 10 && num < 100){
    	hitoketa = parseInt(str.split("")[1], 10);
    }
    else{
    	hitoketa = num;
    }

    if(hitoketa === 3 ){
    	console.log("bon");
    }
    else if(hitoketa === 0 || hitoketa === 1 || hitoketa === 6 || hitoketa === 8){
    	console.log("pon");
    }
    else{
    	console.log("hon");
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29628
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;

  int n,q,t,x,c;

  cin >> n >> q;

  priority_queue<int> p[n];  

  for(ii=0;ii<q;ii++){
    cin >> c;

    switch(c){
    case 0:
      cin >> t >> x;
      p[t].push(x);
      break;
    case 1:
      cin >> t;
      if(p[t].size()>=1){
        cout << p[t].top() << endl;
      }
      break;
    case 2:
      cin >> t;
      if(p[t].size()>=1){
        p[t].pop();
      }
      break;
    }
  }

  return 0;
}



Measured memory_bytes: 3980
// luogu-judger-enable-o2
#include <bits/stdc++.h>
using namespace std;
#define LL long long
int main(){
    string a;
    cin>>a;
    for(int i=0;i<a.size();i++){
        if(a[i]!=',')cout<<a[i];
        else cout<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll=long long;

int main()
{
	ll N;
	cin>>N;
	if(N%2==1){
		cout<<0<<endl;
		return 0;
	}
	ll res = 0;
	ll base=5;
	N/=2;
	while(base<=N){
		res+=N/base;
		base*=5;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=k;i<n;i++){
		if(a[i-k]<a[i]) cout<<"Yes\n";
		else cout<<"No\n";
	}
	re 0;
}


Measured memory_bytes: 3964
n = int(input())
a_list = list(map(int,input().split()))

tmp = a_list[0]
for i in range(1,len(a_list)):
    tmp = tmp ^ a_list[i]
    
ans_list = []
for i in a_list:
    ans_list.append(i ^ tmp)
print(*ans_list)

Measured memory_bytes: 31412
#include <stdio.h>

int main() {
	int mo, da, i, sda;
	// the list of the number of days in each month
	int dlist[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	char dayname[7][10] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	while(1) {
		scanf("%d %d",&mo,&da);
		if (mo==0) break;
		
		sda=0;
		for(i=0;i<(mo-1);i++) {
			sda += dlist[i];
		}
		printf("%s\n",dayname[ (sda+da+2)%7 ]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} 


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

int H, W, K; cin >> H >> W >> K;
VVI cnt(H+1, VI(W, 0));
cnt[0][0] = 1;
rep(i, 0, H) rep(j, 0, W){
    rep(hori, 0, 1<<(W-1)){
        bool ok = true;
        rep(bit, 0, W-2) if (hori & (1<<bit) && hori & (1<<(bit + 1))){
            ok = false;
            break;
        }
        if (!ok) continue;
        if (j >= 1 && hori & (1<<j-1))
            (cnt[i+1][j-1] += cnt[i][j]) %= MOD;
        else if (j <= W-2 && hori & (1<<j))
            (cnt[i+1][j+1] += cnt[i][j]) %= MOD;
        else
            (cnt[i+1][j] += cnt[i][j]) %= MOD;
    }
}

cout << cnt[H][K-1] <<  "\n";

return 0;
}
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	int k;cin>>k;
	string s;cin>>s;
	if (s.size() <= k)cout << s << endl;
	else{
		for(int i = 0; i < k; i++) {
			cout << s[i];
		}
		cout << "..." << endl;
	}
	return 0;
}

Measured memory_bytes: 3560
#include <stdio.h>

int main(void)
{
	int n[5], num;
	int i, j;
	
	for(i = 0; i < 5; i++){
		scanf("%d", &n[i]);
	}
	
	for(i = 0; i < 5; i++){
		for(j = 0; j < 4; j++){
			if(n[j] < n[(j + 1)]){
				num = n[j];
				n[j] = n[(j + 1)];
				n[(j + 1)] = num;
			}
		}
	}
	
	for(i = 0; i < 5; i++){
		printf("%d", n[i]);
		
		if(i != 4)    printf(" ");
	}
	puts("");
	
	return 0;
}

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

int main() {
	string S;
	char p;
	int t,rc=0,lc=1,n;
	cin >> S;
	n = S.size();
	vector<int> r(n);
	
	S += 'R';
	p = 'R';
	rep(i,n+1) {
		if(S.at(i) != p) {
			if(S.at(i) == 'L') {
				t = i;
			} else {
				int m = (rc+lc)/2;
				if(rc%2 == lc%2) {
					r.at(t-1) = m;
					r.at(t) = m;
				} else {
					r.at(t-1) = m+(rc%2);
					r.at(t) = m+(lc%2);
				}
				rc=1, lc=1;
			}
		} else {
			if(S.at(i) == 'R')
				++rc;
			else
				++lc;
		}
		p = S.at(i);
	}

	rep(i,n)
		cout << r.at(i) << " ";
	cout << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
#define N 100000


int main(void){
    int numTeam , i;
    long long ans = 0;
    int a[3 * N];
    cin >> numTeam;

    for (i = 0; i < 3 * numTeam; i++) cin >> a[i];

    sort(a, a + 3 * numTeam, greater<int>());
    for(int j = 0; j < numTeam; j++){
        ans += a[2*j + 1];
        // cout << "the process of ans is " << ans << endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1408
N=int(input())
count=1
size=1
p=list(map(int,input().split()))
q=[p[0]]
for i in range (1,N):
  if p[i]!=p[i-1]:
    q.append(p[i])
    size+=1
j=0
while True:
  if j>=size-2:
    break
  while (q[j]-q[j+1])*(q[j+1]-q[j+2])>=0:
    if j>=size-3:
      count-=1
      break
    j+=1    
  count+=1
  j+=2
print(count)

Measured memory_bytes: 14252
S=str(input())
ans="WA"
if S[0]=="A":
    if "C" in S[2:-1] and S.count("C")==1:
        x=S.index("C")
        S=S[0].lower()+S[1:x]+S[x].lower()+S[x+1:]
        if S==S.lower():
            ans="AC"
print(ans)

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

using namespace std;

class Solution {
public:
	void solve() {
		int n, q;
		string s;
		cin >> n >> s >> q;
		vector<set<int>> idxs(26);
		for(int i=0; i < n; i++)idxs[s[i]-'a'].insert(i);
		while(q--){
			int T;
			cin >> T;
			if(T == 1){
				int i;
				char c;
				cin >> i >> c;
				i--;
				if(s[i] == c)continue;
				idxs[s[i]-'a'].erase(i);
				s[i] = c;
				idxs[s[i]-'a'].insert(i);
			}else{
				int l, r;
				cin >> l >> r;
				l--, r--;
				int ans = 0;
				for(int i=0; i < 26; i++){
					auto it = idxs[i].lower_bound(l);
					if(it != idxs[i].end() && *it <= r)ans++;
				}
				cout << ans << "\n";
			}
		}
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 24220
#include <iostream>
using namespace std;
 
#define INF 2147483647
#define ASTART (1<<17)
int a[1<<18][2];
int ti=1;
 
int find(int i){
  int nv=INF,t=0;
  i+=ASTART-1;
  nv=a[i][0];
  t=a[i][1];
  while (i>0){
    i=(i-1)/2;
    if (t<a[i][1])nv=a[i][0],t=a[i][1];
  }
  return nv;
}
void update(int s,int t,int x,int k,int l,int r){
  if (l>=s&&r<=t){
    a[k][0]=x;
    a[k][1]=ti;
    return;
  }
  if (r<=s||l>=t)return;
  int m=(l+r)/2;
  update(s,t,x,k*2+1,l,m);
  update(s,t,x,k*2+2,m,r);
}
int main(){
  int n,q,com,s,t,x;
  for (int i=0;i<(1<<18);i++)a[i][0]=INF,a[i][1]=0;
  cin >> n>>q;
 
  for (int i=0;i<q;i++){
    cin >> com;
    if (com==0) {
      cin >> s >> t >> x;
      update(s,t+1,x,0,0,ASTART);
      ti++;
    }else {
      cin >> s;
      cout << find(s)<< endl;
    }
  }
 
  return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>
#include <cstdint>
#include <complex>
#include <bitset>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

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


int main() {
    int n; cin >> n;
    vector<int> a(3*n); rep(i, 3*n) cin >> a[i];

    priority_queue<int, vector<int>, greater<int>> to;
    priority_queue<int, vector<int>> rev;

    ll to_sum = 0;
    vector<ll> to_score(3*n+1);
    rep(i, n) {
        to_sum += a[i];
        to.push(a[i]);
    }
    to_score[n] = to_sum;
    for (int i = n; i < 2*n; i++) {
        to.push(a[i]);
        to_sum = to_sum - ll(to.top()) + ll(a[i]);
        to.pop();
        to_score[i+1] = to_sum;
    }

    ll rev_sum = 0;
    vector<ll> rev_score(3*n+1);
    for (int i = 3*n-1; i >= 2*n; i--) {
        rev_sum += a[i];
        rev.push(a[i]);
    }
    rev_score[2*n] = rev_sum;
    for (int i = 2*n-1; i >= n; i--) {
        rev.push(a[i]);
        rev_sum = rev_sum - ll(rev.top()) + ll(a[i]);
        rev.pop();
        rev_score[i] = rev_sum;
    }

    ll ans = -LINF;
    for (int i = n; i <= 2 * n; i++) {
        ans = max(ans, to_score[i] - rev_score[i]);
    }

    cout << ans << endl;


    return 0;
}


    


Measured memory_bytes: 7288
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	private static int n;

	public static void main(String[] args) {

		Set<Integer> set = new HashSet<>(5);
		int[][] arr = scan();
		int candies = 0;
		int f = 0;
		for (int i = 0; i < n; i++) {
			f += arr[0][i];
			for (int j = i; j < n; j++) {
				candies += arr[1][j];
			}
			set.add(f + candies);
			candies = 0;
		}

		System.out.println(Collections.max(set));
	}

	private static int[][] scan() {

		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int[][] arr = new int[2][n];
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < n; j++) {
				arr[i][j] = sc.nextInt();
			}
		}
		sc.close();
		return arr;
	}
}

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

int main(){
    string str;
    cin >> str;
    int num= str.size();
    if(num%2==1){
        cout << "No" << endl;
    }
    else{
        int count=0;
        for(int i=0; i<num; i+=2){
            if(str[i]=='h' && str[i+1]=='i'){
                count++;
            }
        }
        if(count==num/2){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 998244353;
const ll LINF = 1e18;

ll dp[11][200005];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,x,m; cin>>n>>x>>m;
  
  ll sum=x, pre=x, cycle_sum=0;
  vll v;
  vll cnt(m);
  rep(i,n-1){
    ll a=(pre*pre)%m;
    if(cnt[a]==2){
      ll len=v.size();
      sum+=(n-1-i)/len*cycle_sum;
      ll rem=(n-1-i)%len;
      rep(j,rem){
        sum+=v[j];
      }
      break;
    }else if(cnt[a]==1){
      cnt[a]++;
      v.push_back(a);
      cycle_sum+=a;
      sum+=a;
    }else{
      cnt[a]++;
      sum+=a;
    }
    pre=a;
  }
  cout<<sum<<endl;
}

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

int p[333][333];
int yoko[333][333];
int tate[333][333];
int dp[301][301][301];

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

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

  for(int i=0;i<n;i++){
    int sum=0;
    for(int j=0;j<n;j++){
      sum+=p[i][j];
      yoko[i][j]=sum;
    }
    sum=0;
    for(int j=0;j<n;j++){
      sum+=p[j][i];
      tate[j][i]=sum;
    }
  }
  int INF=100000000;
  fill_n(**dp,301*301*301,INF);
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      for(int k=n-1;k>=0;k--){
	dp[i][j][k]=yoko[i][k]+yoko[j][k]+tate[j][k]-tate[i][k]-p[j][k];
	if(i==j){
	  dp[i][j][k]-=yoko[i][k];
	  dp[i][j][k]+=p[j][k];
	}
	if(k<n-1)dp[i][j][k]=max(dp[i][j][k],dp[i][j][k+1]);
	//	cout<<i<<" "<<j<<" "<<k<<" "<<dp[i][j][k]<<endl;
      }
    }
  }
  int ans=-INF;
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      for(int k=0;k<n;k++){
	int sum=tate[j][k]-tate[i][k]+p[i][k];
	if(k<n-1){
	  int tmp=sum;
	  tmp+=dp[i][j][k+1];
	  tmp-=(yoko[i][k]+yoko[j][k]);
	  if(i==j)tmp+=yoko[i][k];
	  sum=max(sum,tmp);
	}
	ans=max(ans,sum);
	//	cout<<i<<" "<<j<<" "<<k<<" "<<ans<<endl;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 110796
/*
“Being happy doesn't mean that everything is perfect.
It means that you decided to look beyond the imperfections.”
*/

#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include <limits>
using namespace std;


#define int int64_t
#define pr(x) cout << x << endl;
#define vi vector<int>
#define vii vector< vector<int> >
#define mp make_pair
#define ii pair<int,int>
#define fr(i,x,n) for(i = x ; i< n ; i++)
#define f(i,n) for(i = 0 ; i< n ; i++) 
#define ff first
#define ss second
#define pb push_back
#define SIZE 200001
#define mod 1000000007
#define int_max 1e12
int i, j, k, l, n, a, c, nn, t, dot=0, toko=0, x, y, z;
// void solve();



int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
//	freopen("input.txt", "r",stdin);
//	freopen("output.txt", "w", stdout);
   cin >> n;
   l=0;
   for(i=1;i<=n;i++)
   {
       for(j=1;j<=n;j++)
       {
           for(k=1;k<=n;k++)
           {l += __gcd(i, __gcd(j, k));}
       }

   }

   cout << l << '\n';

//    cout << k ;
}







Measured memory_bytes: 3652
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		prepareFact();
		int num = sc.nextInt();
		int k = sc.nextInt();
		for(int i = 1; i <= k; i ++) {
			long ans = combiMod(num - k + 1, i);
			long mul = combiMod(k - i + i - 1, i - 1);
			ans = mod(ans * mul);
			System.out.println(ans);
		}
	}

	static long MOD = (long)Math.pow(10, 9) + 7;
	public static long mod(long i) {
		return i % MOD + ((i % MOD) < 0 ? MOD : 0);
	}
	
	static long powerMod(long x, long y) {
		if (y == 0) {
			return 1;
		} else if (y == 1) {
			return x;
		} else if (y % 2 == 0) {
			long tmp = powerMod(x, y / 2);
			return mod(tmp * tmp);
		} else {
			long tmp = powerMod(x, y / 2);
			return mod(mod(tmp * tmp) * x);
		}
	}
	
	static long invMod(long x) {
		return powerMod(x, MOD - 2);
	}
	
	static int MAX_FACT = 20_100;
	static long factMod[] = new long[MAX_FACT];
	static void prepareFact() {
		factMod[0] = 1;
		for(int i = 1; i < MAX_FACT; i ++) {
			factMod[i] = mod(factMod[i - 1] * i);
		}
	}
	
	static long combiMod(int n, int r) {
		if(n < 0 || n < r) { return 0; }
		if(r == 0 || r == n) { return 1; }
		return mod(mod(factMod[n] * invMod(factMod[r])) * invMod(factMod[n - r]));
	}
}

Measured memory_bytes: 22484
#include <iostream>
#include <queue>
#include <algorithm>
#include <set>
#include <vector>
#include <string>

using namespace std; using ll=long long; const int INF=1e9; using P=pair<ll,ll>;

int main() {
  string s; cin>>s; int n=s.size();
  reverse(s.begin(), s.end());

  string d[4]={"maerd", "remaerd", "esare","resare"};

  bool update=true; int i=0;
  while(update) {
    update=false;
    for(int j=0;j<4;j++) {
      if (i+d[j].size() <= n && s.substr(i,d[j].size()) == d[j]) {
        i+=d[j].size();
        update=true; break;
      }
    }
    if (i==n) break;
  }
  if (i==n) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll ;
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 ll mod=1e9+7;

void test_case()
{
	set<ll>s={0,1,2,3,4,5,6,7,8,9};
	
	ll n,k;
	cin>>n>>k;
	ll a[k];
	for(int i=0;i<k;i++)
	{
		cin>>a[i];
		s.erase(a[i]);
	}
	ll ans=0,N=0;
	ll i=0,temp=n;
	
	while(n>0)
	{
		N=N*10+n%10;
		n=n/10;
	}
	
ll digit=0,yes=0;	
	while(N>0)
	{
		ll y=N%10;
		for(auto x:s)
	{
		//cout<<x<<" "<<y<<" "<<"\n";
		if(x>y)
		{
		ans=ans*10+x;
		yes=1;
		
		break;	
		}
		if(x==y)
		{
		
			ans=ans*10+x;
			
			
			break;
		}
		
		
		
	}
	N/=10;
	
	
	if(yes)break;
	
	
	}
	
	//cout<<ans<<" "<<yes<<"\n";
	if(yes||ans<temp)
	{
	//	cout<<ans<<" "<<temp<<"\n";
		while(ans<temp)
		{
			for(auto x: s)
			{
				ans=ans*10+x;
			//	cout<<ans<<"\n";
				break;
			}
		}
		
	}
	
	
	cout<<ans;
	
	
	
}

int main()
{
    fast;
    
//    ll t;
//    cin>>t;
//    while(t--)
    test_case();
    
    
 
   
}

		
	
	
	
	


Measured memory_bytes: 3596
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
use = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [[0] * 10 for i in range(n+1)]
for i in range(1,n+1):
    for j in a:
        if i - use[j] >= 0:
            if dp[i-use[j]] == [0] * 10 and i - use[j] != 0: # マッチの数が合わない場合
                continue #何もしない
            else:
                if sum(dp[i-use[j]])+1 >= sum(dp[i]):
                    copy = dp[i-use[j]][:]
                    copy[j] += 1
                    dp[i] = copy
ans = ""
for i in range(9,0,-1):
    ans += (str(i) * dp[n][i])
print(ans)

Measured memory_bytes: 4972
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int x, n;
  cin >> x >> n;
  vector<int> v(n);
  rep(i, 0, n) cin >> v[i];
  sort(v.begin(), v.end());

  if (n == 0) {
    cout << x << endl;
    return 0;
  }

  int val = 1e9, ans = 0, j = 0;
  rep(i, -100, 102) {
    if (i == v[j]) {
      j++;
      continue;
    }

    if (val > abs(x - i)) {
      ans = i;
      val = abs(x - i);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define FOR(i,n) for(int i = 0; i < n; i++)
#define FORa(i,a,b) for(int i = a; i < b; i++)
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define SORT(a,n) sort(begin(a), begin(a) + n)
#define VSORT(v) sort(v.begin(), v.end())
#define MAX 1000000
#define ll long long
#define LOW(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define UP(s) transform(s.begin(),s.end(),s.begin(),::toupper)

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

int main() {
	ll x, k, d;
	cin >> x >> k >> d;
	
	ll walks = min(k, abs(x)/d);
	x = (x > 0 ? x - walks*d : x + walks*d);
	k -= walks;
	
	if(k == 0 || k%2 == 0) cout << abs(x) << endl;
	else cout << abs(x > 0 ? x - d : x + d) << endl;
	
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll i,j,k;

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

int main(){   
    ll a,b,c;cin>>a>>b;
    c=gcd(a,b);
    ll ins=c;

    int ans=1;
    for(i=2;i*i<=c;i++){
        ll ins2=ins;
        while(ins%i==0){
            ins/=i;
        }
        if(ins!=ins2){ans++;}
    }
    if(ins!=1){ans++;}
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int ans = 0;
    for(int i = 0; i < n - 2; i++) {
      if((s.charAt(i) == 'A') && (s.charAt(i + 1) == 'B') && (s.charAt(i + 2) == 'C')) ans++;
    }
    System.out.println(ans);
  }
}

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<int>> V(H+2,vector<int>(W+2,0));
  queue<pair<int,int>> Q;
  for(int i=1;i<=H;i++){
    string s;
    cin >> s;
    for(int j=1;j<=W;j++){
      if(s[j-1]=='.') V[i][j] = -1;
      else Q.push(make_pair(i,j));
    }
  }
  
  while(!Q.empty()){
    pair<int,int> u = Q.front();
    Q.pop();
    int x = u.first, y = u.second;
    if(V[x+1][y]==-1){
      V[x+1][y] = V[x][y]+1;
      Q.push(make_pair(x+1,y));
    }
    if(V[x][y+1]==-1){
      V[x][y+1] = V[x][y]+1;
      Q.push(make_pair(x,y+1));
    }
    if(V[x-1][y]==-1){
      V[x-1][y] = V[x][y]+1;
      Q.push(make_pair(x-1,y));
    }
    if(V[x][y-1]==-1){
      V[x][y-1] = V[x][y]+1;
      Q.push(make_pair(x,y-1));
    }
  }
  
  int ans = 0;
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      ans = max(ans,V[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12432
import sys
input = sys.stdin.readline
import numpy as np

def main():
    N, K = [int(item) for item in input().split()]
    h =np.array([int(item) for item in input().split()])
    # print(h.shape)
    dp = np.full(N+K, 10**10+1, dtype='int64')
    dp[0] = 0

    for i in range(1, N):
        max1 = min(N, i+K)
        cost = abs(h[i:max1] - h[i-1])
        # print(cost.shape, dp[i:max1].shape)
        dp[i:max1] = np.minimum(dp[i:max1], dp[i-1] + cost)

        # print(dp)
    return dp[N-1]

print(main())


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        string S; cin >> S;
        bool ok = true;
        int l = 0, r = S.size() - 1;
        while(l < r) {
            while(l < r and S[l] == 'x') l++;
            while(l < r and S[r] == 'x') r--;
            if(l < r and (S[l] != S[r])) {
                ok = false;
                break;
            }
            while(l < r and S[l] == S[r]) {
                l++; r--;
            }            
        }
        // debug(l); debug(r);
        if(not ok) {
            cout << -1 << endl;
        } else {
            if(l == r) {
                int ans = 0;
                int i = 0;
                int j = S.size() - 1;
                while(i < j) {
                    while(S[i] != S[j]) {
                        if(S[i] == 'x') {
                            ans++;
                            i++;
                        }
                        else if(S[j] == 'x') {
                            ans++;
                            j--;
                        }
                    }
                    i++; j--;
                }
                cout << ans << endl;
            } else {
                int len = max<int>(l, S.size() - r - 1);
                                int ans = 0;
                int i = 0;
                int j = S.size() - 1;
                while(i + 1 < j) {
                    while(S[i] != S[j]) {
                        if(S[i] == 'x') {
                            ans++;
                            i++;
                        }
                        else if(S[j] == 'x') {
                            ans++;
                            j--;
                        }
                    }
                    i++; j--;
                }
                cout << ans << endl;
            }            
        }
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int c=1;
    int val = a[0];
    for(int i=1;i<n;i++)
    {
        if(a[i]>=val){
            c++;
            val=a[i];
        }
    }
    cout<<c<<'\n';
    return 0;
}


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

int main() {
  ll n; cin>>n;
  vector<pll> v(n);
  rep(i,n){cin>>v[i].first>>v[i].second;}
  ll ans=0;
  for(int i=n-1; i>=0; i--){
    ll a =  (v[i].first+ans) % v[i].second;
    if(a !=0){ans+= v[i].second-a;}
  }
  cout<<ans;
}
   

Measured memory_bytes: 4844
#include<bits/stdc++.h>
#define test int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define endl "\n"
typedef long long ll;
using namespace std;

int main()
{

   ll d,t,s;
   cin>>d>>t>>s;
   if(s*t>=d)
    cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;
}




Measured memory_bytes: 3640
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    int n=s.length()+1;
    long[] d=new long[n];
    long[] p=new long[n];
    d[0]=0;
    p[n-1]=0;
    for(int i=1;i<n;i++){
      if(s.charAt(i-1)=='<'){
        d[i]=d[i-1]+1;
      }else{
        d[i]=0;
      }
    }
    for(int i=n-2;i>=0;i--){
      if(s.charAt(i)=='>'){
        p[i]=p[i+1]+1;
      }else{
        p[i]=0;
      }
    }
    long sum=0;
    for(int i=0;i<n;i++){
      sum+=Math.max(d[i],p[i]);
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 40484
import java.util.Scanner;

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

    char[] s = scanner.next().toCharArray();
    StringBuilder sb = new StringBuilder();
    for (char ch : s) {
      if (ch == 'B') {
        if (sb.length() > 0) sb.setLength(sb.length() - 1);
      } else {
        sb.append(ch);
      }
    }
    System.out.println(sb.toString());
  }
}


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

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

using namespace std;

inline int nxt() {
	int x;
	// scanf("%d", &x);
	cin >> x;
	return x;
}

int ask(string s) {
	cout << "? " << s << endl;
	return nxt();
}

const int L = 128;

string f(const string& alphabet, const vector<int>& freq, int l, int r) {
	if (r == l + 1) {
		return string(freq[l], alphabet[l]);
	}
	int m = (l + r) / 2;
	auto le = f(alphabet, freq, l, m);
	auto ri = f(alphabet, freq, m, r);
	// cerr << "[" << l << ", " << r << "): '" << le << "', '" << ri << "'\n";
	int len = accumulate(all(freq), 0);
	string s = le;
	int i = le.size();
	int j = (int)ri.size() - 1;
	for (j = (int)ri.size() - 1; j >= 0; --j) {
		while (i > 0) {
			s.insert(s.begin() + i, ri[j]);
			if (ask(s) == len - (int)s.size()) {
				break;
			} else {
				s.erase(s.begin() + i);
				--i;
			}
		}
		if (i == 0) {
			break;
		}
	}
	s = ri.substr(0, j + 1) + s;
	return s;
}

int main() {
	string alphabet;
	for (char c = 'a'; c <= 'z'; ++c) {
		alphabet += c;
	}
	for (char c = 'A'; c <= 'Z'; ++c) {
		alphabet += c;
	}
	for (char c = '0'; c <= '9'; ++c) {
		alphabet += c;
	}
	vector<int> freq(alphabet.size());
	for (int i = 0; i < (int)alphabet.size(); ++i) {
		freq[i] = L - ask(string(L, alphabet[i]));
	}
	auto res = f(alphabet, freq, 0, (int)alphabet.size());
	cout << "! " << res << endl;

	return 0;
}


Measured memory_bytes: 3748
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class E { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		var a = GetLongs(N);

		var list = new List<(long, long)>();
		list.Add((-1, 0));
		for(long i = 0; i < N; i++)
			list.Add((i, a[i]));

		var grps = list.GroupBy(x => x.Item2).ToList();
		grps.Sort((x, y) => y.Key.CompareTo(x.Key));
      
		var ans = new long[N];
		long cnt = 0;
		long minIdx = long.MaxValue;
		for(int i = 0; i < grps.Count - 1; i++)
		{
			chmin(ref minIdx, grps[i].Min(x => x.Item1));
			cnt += grps[i].Count();
			ans[minIdx] += cnt * (grps[i].Key - grps[i + 1].Key);
		}
		WriteLine(string.Join("\n", ans));
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


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

using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define fi first
#define se second
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using pii = pair<int,int>;
using ll = long long;


int w,h;

int table[30][30];
int d[30][30];
ll vv[20][20];

int dd[] = {0,1,0,-1,0};

bool inside(pii a){
	return 0<=a.fi&&a.fi<h&&0<=a.se&&a.se<w;
}

void bfs(pii s){
	rep(i,h) rep(j,w) d[i][j] = INF;
	d[s.fi][s.se] = 0;
	queue<pii> q;
	q.push(s);
	int len = 0;
	while(q.size()){
		len++;
		int qs = q.size();
		rep(i,qs){
			pii top = q.front();
			q.pop();
			rep(j,4){
				pii next = top;
				next.fi += dd[j];
				next.se += dd[j+1];
				if(!inside(next) || d[next.fi][next.se]!=INF) continue;
				if(table[next.fi][next.se] == 1) continue;
				d[next.fi][next.se] = len;
				q.push(next);
			}
		}
	}
}

int main(){
	while(cin>>w>>h,w){
		vector<pii> dirt(1);
		pii robot;
		rep(i,h){
			rep(j,w){
				char t;
				cin>>t;
				table[i][j] = 0;
				if(t=='o'){
					robot = pii(i,j);
				}
				else if(t=='*'){
					dirt.push_back(pii(i,j));
				}
				else if(t=='x'){
					table[i][j] = 1;
				}
			}
		}
		dirt[0] = robot;
		int n = dirt.size();
		if(n==1){
			cout<<0<<endl;
			continue;
		}
		bool ok = true;
		rep(i,n){
			bfs(dirt[i]);
			rep(j,h){
				rep(k,w){
					rep(l,n){
						if(l==i) continue;
						if(dirt[l] == pii(j,k)){
							vv[i][l] = d[j][k];
						}
					}
				}
			}
		}
		// rep(i,n){
		// 	rep(j,n){
		// 		cout<<vv[i][j]<<" ";
		// 	}
		// 	cout<<endl;
		// }
		ll ans = INFL;
		vector<int> per(n-1);
		rep(i,n-1) per[i] = i+1;
		do{
			int p = 0;
			ll tmp = 0;
			rep(i,n-1){
				tmp += vv[p][per[i]];
				p = per[i];
			}
			ans = min(ans, tmp);
		}while(next_permutation(per.begin(), per.end()));
		if(ans >= INF){
			cout<<-1<<endl;
		}
		else{
			cout<<ans<<endl;
		}
	}
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	int ans = 0;
	for(a;a<=b;a++)if(c%a==0)ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3104
n, m = map(int,input().split())
lis = [0 for i in range(m)]
for i in range(m):
    lis[i] = list(map(int,input().split()))
    
seen = []
count = 0
visited = [0 for i in range(n)]
def route(x=1):
    visited[x-1] = 1
    if [1]*n == visited:
        global count
        count +=1
        return
    for i in range(m):
        if lis[i][0] == x and visited[lis[i][1]-1] == 0:
            route(lis[i][1])
            visited[lis[i][1]-1] = 0
        elif lis[i][1] == x and visited[lis[i][0]-1] == 0:
            route(lis[i][0])
            visited[lis[i][0]-1] = 0
    return
            
        
route(1)
print(count)

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

#ifdef TESTING
  #include "dump.hpp"
#else
  #define DUMP(...)
  #define DEBUG(...)
#endif

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define INT(n) int n;assert(0<scanf("%d",&n))
#define VI(v,n) vector<int> v(n);REP(i,n){assert(0<scanf("%d",&v[i]));}

int main(){
  vector<ll> ans;
  INT(k); VI(as, k);
  ll l = 1, r = 1ll << 60;
  int cnt = 0;
  while (1 < r - l && cnt < 100){
    cnt++;
    ll c = (l + r) / 2, d = c;
    for(int a: as){
      d = (d / a) * a;
    }
    if (d < 2){
      l = c;
    } else {
      r = c;
    }
  }
  ans.PB(r);
  l = 1, r = 1ll << 60; cnt = 0;
  while (1 < r - l && cnt < 100){
    cnt++;
    ll c = (l + r) / 2, d = c;
    for(int a: as){
      d = (d / a) * a;
    }
    if (d <= 2){
      l = c;
    } else {
      r = c;
    }
  }
  ans.PB(l);
  if (ans[0] <= ans[1] && as[k - 1] == 2){
    printf("%lld %lld\n", ans[0], ans[1]);
  } else {
    printf("-1\n");
  }
  return 0;
}

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

using namespace std;

int n,i,j;
char s[55],s1[55];
vector <char> s2;

const int MOD = 1e9 + 7;

int main(){
	scanf("%d", &n);
	scanf("%s", s);
	scanf("%s", s1);
	
	long long ways = 1LL;
	
	bool flag = 0;
	
	for(i = 0; i < n; i++){
		if(s[i] == s1[i])
		s2.push_back('S');
		else if(flag){
			s2.push_back('R');
			flag = 0;
		}
		else
		flag = 1;
	}
	
	for(i = 0; i < s2.size(); i++){
		if(s2[i] == 'S'){
			if(i == 0)
			ways = 3LL;
			else{
				if(s2[i - 1] == 'S')
				ways = (ways * 2LL) % MOD;
			}
		}
		
		if(s2[i] == 'R'){
			if(i == 0)
			ways = 6LL;
			else{
				if(s2[i - 1] == 'S')
				ways = (ways * 2LL) % MOD;
				else
				ways = (ways * 3LL) % MOD;
			}
		}
		
		//printf(">> %c %d %lld\n", s2[i], i, ways);
	}
	
	printf("%lld\n", ways);
}


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

int n,m,q,ans=0;
vector<int>a,b,c,d;

void dfs(vector<int>x){
    if(x.size()==n+1){
        int cnt=0;
        rep(i,q){
            if(x[b[i]]-x[a[i]]==c[i])cnt+=d[i];
        }
        ans=max(ans,cnt);
        return;
    }
    x.push_back(x.back());
    while(x.back()<=m){
        dfs(x);
        x.back()++;
    }
}

int main(){
    cin>>n>>m>>q;
    a=b=c=d=vector<int>(q);
    rep(i,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    dfs(vector<int>(1,1));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3612
// abc145_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    string S;
    cin >> S;

    if (N % 2 != 0) {
        print("No");
        return 0;
    }

    if (S.substr(0, N/2) == S.substr(N/2, N/2)){
        print("Yes");
    } else{
        print("No");
    }

    return 0;
}


Measured memory_bytes: 256