akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int main(void){
    long long int a,b,c,k,ans=0;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
    for(int i=0;k>i;++i){
        if(a>0){
            ++ans;
            --a;
        }
        else if(b>0){
            --b;
        }
        else if(c>0){
            --ans;
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x=max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<P>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,sz(v))i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(sz(v))o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
template <class T> inline ll suma(const v(T)& a) 
{ ll res(0); for(auto&& x:a) res += x; return res;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
const int MX = 200005;
//----------------------------------------------------------------

#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
#define MOD 1000000007
//----------------------------------------------------------------

void Main(){
  int n,m;
  cin>>n>>m;
  vi f(n+1,0),s(n+1,0);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    if(a==1){f[b]=1;}
    if(b==n){s[a]=1;}
  }
  bool a=false;
  rep(i,n){
    if(f[i+1] && s[i+1]){ a=true; break;}
  }
  if(a){
    cout<<"POSSIBLE"<<endl;
  }else{
    cout<<"IMPOSSIBLE"<<endl;
  }
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();
		int X = scan.nextInt();

		int count = 0;
		for(int i=0; i<=A; i++){
			for(int j=0; j<=B; j++){
				for(int k=0; k<=C; k++){
					if(X == (500*i + 100*j + 50*k)){
						count += 1;
					}
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1000000000
vector<ll>vec;

int main(){
  ll n;
  cin>>n;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      vec.push_back(i);
      if(i!=n/i)vec.push_back(n/i);
    }
  }
  sort(vec.begin(),vec.end());
  ll ans=0;
  for(ll i=0;i<vec.size();i++){
    //cout<<vec[i]<<endl;
    if((n-vec[i])%vec[i]!=0)continue;
    ll temp=(n-vec[i])/vec[i];
    if(i+1==vec.size()){
      if(vec[i]<temp&&0<temp&&temp<=n/vec[i]){
	ans+=temp;
      }
    }
    else{
      if(vec[i]<temp&&n/vec[i+1]<temp&&temp<=n/vec[i]){
	//cout<<vec[i]<<endl;
	ans+=temp;
      }
    }
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>
#include <regex>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define P pair<int, int>

using namespace std;
//using ll = long long;
using ll = int64_t;

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

void solve(){
    int a, b, c, x, res=0;
    cin >> a >> b >> c >> x;

    rep(i, c+1){
        rep(j, b+1){
            int k = (x - 50*i - 100*j)/500;
            if(k <= a && k >= 0 && 50*i+100*j+500*k == x){
                res++;
            }
        }
    }
    cout << res << endl;
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    long long int N,A,B,ans=0,sum;
    cin >> N >> A >> B;
    sum = A + B;
    ans = (N / sum) * A;
    if((N%sum)<A) ans+=(N%sum);
    else ans+=A;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int H, W;
string a[110];
int cnt[30];

int main(void) {
	cin >> H >> W;
	rep(i, H) cin >> a[i];
	rep(i, H) {
		for(auto u : a[i]) cnt[u - 'a']++;
	}
	
	if(H == 1 && W == 1) {
		printf("Yes\n");
		return 0;
	}

	bool f = true;
	if(H > 1 && W > 1) {
		if((H * W) % 2 == 0) { // guusuu
			int d2 = 0;
			rep(i, 26) if(cnt[i] % 2) d2++; // kisuu
			int d4 = 0;
			rep(i, 26) if(cnt[i] > 0 && cnt[i] >= 4) d4 += cnt[i] / 4;
			
			if(d2 > 0) f = false;
			int even =(H / 2) * (W / 2);
			if(d4 < even) f = false;

		}else { // kokokana 6TLE
			// printf("koko\n");	
			int d2 = 0;
			rep(i, 26) if(cnt[i] % 2) d2++;
			int d4 = 0;
			rep(i, 26) if(cnt[i] > 0 && cnt[i] >= 4) d4 += cnt[i] / 4;
			
			if(d2 != 1) f = false;
			int even =(H / 2) * (W / 2);
			// printf("d4 %d e %d\n", d4, even);
			if(d4 < even) f = false;
		}
	}else{
		// printf("k\n");	
		int d2 = 0;
		rep(i, 26) if(cnt[i] % 2) d2++;
		// printf("d2 %d\n", d2);
		if((H * W) % 2) {
			// printf("k2\n");
			if(d2 != 1) {

				// printf("k\n");
				f = false;
			}
		}
		else if(d2 > 0) f = false;
	}
	

	if(f) printf("Yes\n");
	else printf("No\n");
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    int x,a,b;
    cin >> x;
    cin >> a;
    cin >> b;

    cout << (x - a) % b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
    bool ans=true;
   string s;
   cin>>s;
   string t;
   cin>>t;
   for(int i=0;i<s.size();i++){
       if(s.at(i)!=t.at(i))ans=false;
   }
   if(ans)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}
   



Measured memory_bytes: 3596
#include <iostream>
int a[15][10005];
int r , c;
int ans = 0;
void f1(){
    int sum = 0;
    for(int i = 0;i < c;i++){
        int x = 0;
        for(int j = 0;j < r;j++){
            x = (a[j][i] == 1)? x + 1 : x;
        }
        sum = (x > r - x)? sum + x : sum + r - x;
    }
    ans = (sum > ans)? sum : ans;
}
void f(int p){
    if(p == r){
        f1();
    }else{
        f(p + 1);
        for(int i = 0;i < c;i++){
            a[p][i] = 1 - a[p][i];
        }
        f(p + 1);
        for(int i = 0;i < c;i++){
            a[p][i] = 1 - a[p][i];
        }
    }
}
int main(){
    while(std::cin >> r >> c){
        if(r == 0 && c == 0){
            break;
        }
        ans = 0;
        for(int i = 0;i < r;i++){
            for(int j = 0;j < c;j++){
                std::cin >> a[i][j];
            }
        }
        f(0);
        std::cout << ans << "\n";
    }
}


Measured memory_bytes: 3376
import java.util.*;

class Main {
	public static void main (String [] args){
		printAns();	
	}

	static void isRightTriangle(int a, int b, int c){
		if(a*a + b*b == c*c) System.out.println("YES");
		else System.out.println("NO");
	}

	static void printAns(){
		Scanner sc = new Scanner(System.in);
		int set = sc.nextInt();
		int[] triangle = new int[3];

		for(int cnt=0; cnt<set; cnt++){
			for(int i=0; i<triangle.length; i++){
				triangle[i] = sc.nextInt();
			}
			sort(triangle);
			isRightTriangle(triangle[0], triangle[1], triangle[2]);
		}	
	}

	static void sort(int[] data){
		int min, tmp;
		for(int i=0; i<data.length; i++){
			min = i;
			for(int j=i+1; j<data.length; j++)
				if(data[min]>data[j]) min = j;
			tmp = data[i];
			data[i] = data[min];
			data[min] = tmp;
		}
	}	
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(v) v.begin(), v.end()

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


int main(){
    int A, B, C, K; cin >> A >> B >> C >> K;
    int res;
    if (A >= K) res = K;
    else if ( A + B >= K) res = A;
    else res = A - (K - (A + B));
    cout << res << endl;
}
    

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<int> a(N+1);
  for(int i=0;i<=N;i++){
    a.at(i)=0;
    for(int j=0;j<i;j++){
      if(S.at(j)=='I'){
        a.at(i)+=1;}
      else{
        a.at(i)-=1;}
    }
  }
  sort(a.begin(),a.end());
  cout << a.at(N) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j,ii,jj,zx,xc,val=2000,pas,st[4];
bool bo[4][4][4009],bl;
string s[4];
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>s[1]>>s[2]>>s[3];
    /*for(i=1; i<=2000; i++){
        if(i%2==1) s[1].push_back('a'); else s[1].push_back('b');
    }
    for(i=1; i<=2000; i++){
        if(i%2==0) s[2].push_back('a'); else s[2].push_back('b');
    }
    for(i=1; i<=2000; i++){
        if(i%2==1) s[3].push_back('a'); else s[3].push_back('b');
    }*/
    for(i=1; i<=3; i++) st[i]=s[i].size();
    for(ii=1; ii<=3; ii++){
        for(jj=ii+1; jj<=3; jj++){
            for(i=-2000; i<=2000; i++){
                bl=0;
                for(j=0; j<s[ii].size(); j++){
                    if(j-i<0||j-i>=s[jj].size()) continue;
                    if(s[ii][j]=='?'||s[jj][j-i]=='?') continue;
                    if(s[ii][j]!=s[jj][j-i]){
                        bl=1;
                        break;
                    }
                }
                if(bl==0){
                    bo[ii][jj][i+val]=1;
                }
            }
        }
    }
    pas=16009;
    for(a=-4000; a<=4000; a++){
        if(a>=-2000&&a<=2000) if(bo[1][2][a+val]==0) continue;
        for(b=-4000; b<=4000; b++){
            if(b>=-2000&&b<=2000) if(bo[2][3][b+val]==0) continue;
            c=a+b;
            /*if(c<-2000) c=-2000;
            if(c>2000) c=2000;*/
            if(c>=-2000&&c<=2000) if(bo[1][3][c+val]==0) continue;
            d=min(0,min(a,c));
            e=max(st[1]-1,max(a+st[2]-1,c+st[3]-1));
            if(pas>e-d+1) pas=e-d+1;
            /*if(e-d+1==4){
                cout<<a<<" "<<b<<" "<<c<<endl;
            }*/
        }
    }
    cout<<pas;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

typedef pair<long long, long long> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

bool f(long long x, long long y) {
  if (x<y) swap(x,y);
  if (x-y <= 1) return false;
  return true;
}

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

  long long X, Y;
  cin >> X >> Y;
  if (f(X, Y)) cout << "Alice\n";
  else cout << "Brown\n";
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

if a.count(0)==n:
  print('Yes')
  exit()

if n%3!=0:
  print('No')
  exit()


x=list(set(a))

z=[]

if len(x)>3:
  print('No')
  exit()

for i in x:
  if a.count(i)==n//3:
    z+=[i]
  
  elif a.count(i)==(n//3)*2:
    z+=[i]
    z+=[i]

  elif a.count(i)==n:
    z+=[i]
    z+=[i]
    z+=[i]

  else:
    print('No')
    exit()


ans=0

for i in z:
  ans^=i

if ans==0:
  print('Yes')

else:
  print('No')

Measured memory_bytes: 93772
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <list>
#include <bitset>

using namespace std;

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;
typedef pair<int,ii> iii;

ii arr[100003];
set<ii> ki, ka, temp1, temp2;

int main()
{
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);

	int n; scanf("%d", &n);
	for(int i = 0; i < n; i++)
	{
		scanf("%d %d", &arr[i].fi, &arr[i].se);
		ki.insert({arr[i].fi,i});
		ka.insert({arr[i].se,i});
	}
	int cnt = 0;
	long res1 = 0, res2 = 0;
	int curr = 0;
	int turn = 0;
	temp1 = ki, temp2 = ka;
	while(ki.size() || ka.size())
	{
		ii kir = *(--ki.end());
		ii kan = *ka.begin();
		// printf("curr : %d\n", curr);
		// printf("%d %d %d %d %d\n", kir.fi, kir.se, kan.fi, kan.se, turn); 
		if(turn == 0)
		{
			res1 += max(0,kir.fi-curr);
			curr = max(curr,kir.fi);
			ki.erase(kir);
			ka.erase({arr[kir.se].se, kir.se});
		}
		else
		{
			res1 += max(0,curr-kan.fi);
			curr = min(curr,kan.fi);
			ka.erase(kan);
			ki.erase({arr[kan.se].fi, kan.se});
		}
		turn^= 1;
	}
	res1 += abs(curr);

	turn = 1; curr = 0;
	ki = temp1, ka = temp2;
	while(ki.size() || ka.size())
	{
		ii kir = *(--ki.end());
		ii kan = *ka.begin();
		if(turn == 0)
		{
			res2 += max(0,kir.fi-curr);
			curr = max(curr,kir.fi);
			ki.erase(kir);
			ka.erase({arr[kir.se].se, kir.se});
		}
		else
		{
			res2 += max(0,curr-kan.fi);
			curr = min(curr,kan.fi);
			ka.erase(kan);
			ki.erase({arr[kan.se].fi, kan.se});
		}
		turn^=1;
	}
	res2 += abs(curr);

	printf("%lld\n", max(res1,res2));
}	











Measured memory_bytes: 19840
package main

import "fmt"

func main() {
	arr := []int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
	var k int
	fmt.Scanf("%d", &k)
	fmt.Printf("%d", arr[k-1])
}


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

int main() {
	
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	sort(h.begin(), h.end());
	
	int min = 1000000002;
	for(int i = 0; i < n - k + 1; i++){
		int diff = h[i + k - 1] - h[i];
		if(min > diff) min = diff;
	}
	cout << min << endl;
	return 0;
}

Measured memory_bytes: 640
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <bits/stdc++.h>

using namespace std;

#define POW2(X) (1<<(X))
#define CKBIT(S,X) (((S)&POW2(X))!=0)

template<class T> inline void nlmin(T &a,T b){ a=min(a,b); }
template<class T> inline void nlmax(T &a,T b){ a=max(a,b); }
template<class T> inline T sqr(T x){ return x*x; }
#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())

#define PB(X) push_back(X)
#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 ALL(A) A.begin(),A.end()
template<class T> int CMP(T a[],const T b[],int n) { return memcmp(a,b,n*sizeof(T)); }
template<class T> void COPY(T a[],const T b[],int n) { memcpy(a,b,n*sizeof(T)); }
template<class T> void SET(T a[],int val,int n) { memset(a,val,n*sizeof(T)); }
//using uint=unsigned int;
typedef long long int64;
//using uint64=unsigned long long;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VII;
// using VD=vector<double>;
const int kmod = 1000000007;


int main() {
	int n, k;
	while (cin >> n >> k) {
		VI v(n+1);
		FOR (i, 1, n + 1) cin >> v[i];
		VI dp(n+1, INT_MAX);
		dp[1] = 0;
		FOR (i, 2, n + 1) {
			FOR (j, max(i-k, 1), i) {
				nlmin(dp[i], dp[j] + abs(v[i] - v[j]));
			}
		}
		cout << dp[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
int main(){
  int h,w,a,b;
  std::cin>>h>>w>>a>>b;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      std::cout<<((i<b)==(j<a))?"0":"1";
    }
    std::cout<<std::endl;
  }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using longlong=long long;

int main(){
    std::cin.tie(nullptr);std::cin.sync_with_stdio(false);
    int a,b,c;std::cin>>a>>b>>c;
    std::cout<<(a==b?c:a==c?b:a)<<std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 1000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
int n,k,ans=INF;
signed main(){
	string s,t;
	cin>>s>>t;
	rep(i,s.size()-t.size()+1){
		string  s2=s.substr(i,t.size());
		//cout<<s2<<endl;
		int cnt=0;
		rep(j,t.size()){
			if(s2[j]!=t[j])cnt++;
		}
		ans=min(ans,cnt);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3604
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define rep0(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)

#define shosu setprecision(10)

typedef long long ll;
ll longinf=1ll<<60;
int inf=1<<29;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};


bool connect[9][9];
bool visited[9];
int N,M;
int ans;
void dfs(int i,int cnt){
    if(cnt==N) ans++; 
    visited[i]=true;
    rep0(j,N){
        if(connect[i][j]&&!visited[j]){
            dfs(j,cnt+1);
        }
    }
    visited[i]=false;
}


int main(){
    cin>>N>>M;
    rep0(i,M){
        int a,b;
        cin>>a>>b;
        connect[a-1][b-1]=connect[b-1][a-1]=true;
    }
    dfs(0,1);
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a = []
for i in range(n):
    a.append(input())
b = []
for g in range(m):
    b.append(input())
#print(a)
#print(b)
ans = 'No'
for c in range(n-m+1):
    for d in range(n-m+1):
        flag = 0
        for e in range(m):
            if a[d+e][c:c+m] != b[e]:
                flag = 1
        if flag == 0:
            ans = 'Yes'

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
	int a ,b ,c;
	c=0;
	for(a=0;a<=100000;a++)
	{
		scanf("%d" ,&b);
		if(b==0) break;
		c=c+1;
		printf("Case %d: %d\n" ,c ,b);
	}
	return 0;
}

Measured memory_bytes: 600
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
  long long x = 1;
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  ll n;
  std::cin>>n;

  std::set<ll> used;

  rep(i,0,n){
    ll a;
    std::cin>>a;
    if(used.find(a)!=used.end()){
      std::cout<<"NO\n";
      return 0;
    }
    used.insert(a);
  } 

  std::cout<<"YES\n";


  return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
 int h,w;cin>>h>>w;
 string s[h];
 rep(i,h){
     cin>>s[i];
 }
 int A[] = {1,0,-1,0};
 int B[] = {0,-1,0,1};

 rep(i,h){
     rep(j,w){
        // cout<<s[i][j]<<endl;
         if(s[i][j] == '.') continue;
         bool flag=false;
         rep(g,4){
             if(i+A[g] == -1 || i+A[g] == h||j+B[g] == -1 || j+B[g] == w) continue;
                if(s[i+A[g]][j+B[g]] == '#') flag = true; 
         }
         if(!flag){
             cout<<"No"<<endl;
             return 0;
         }
     }
 }
cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3608
/*  /$$                                     /$$
      | $$                                    | $$
  /$$$$$$$  /$$$$$$   /$$$$$$$  /$$$$$$   /$$$$$$$  /$$$$$$   /$$$$$$
 /$$__  $$ /$$__  $$ /$$_____/ /$$__  $$ /$$__  $$ /$$__  $$ /$$__  $$
| $$  | $$| $$$$$$$$| $$      | $$  \ $$| $$  | $$| $$$$$$$$| $$  \__/
| $$  | $$| $$_____/| $$      | $$  | $$| $$  | $$| $$_____/| $$
|  $$$$$$$|  $$$$$$$|  $$$$$$$|  $$$$$$/|  $$$$$$$|  $$$$$$$| $$
 \_______/ \_______/ \_______/ \______/  \_______/ \_______/|__//$$$$$$ /$$$$$$
                                                               |______/|______/

*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#define fastio        ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ln            cout << endl;
#define vi            vector<int>
#define vll           vector<long long>
#define sortl(vec)    sort(vec.begin(), vec.end());
#define sortr(vec)    sort(vec.rbegin(), vec.rend());
#define forn(i, x, n) for(long long i = x; i < n; i++)
#define revn(i, n, x) for(long long i = n; i >= x; i--)
#define in(vec)       for(auto &it : vec) cin >> it;
#define loop(vec)     for(auto &it : vec)
#define	out(vec)      for(auto &it : vec) cout << it << " "; ln
#define ll            long long
#define mod           1000000007
#define pb            emplace_back
#define mp            make_pair
#define um            unordered_map
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define f             first
#define s             second
#define pi            3.14159265359
#define o(x)		  cout << x << endl;
#define CLOCK         cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
using namespace std;

ll bS(ll l, ll r, ll x, vll arr) {
	while (l <= r) {
		ll m = l + (r - l) / 2;

		if (arr[m] == x)
			return m;

		if (arr[m] < x)
			l = m + 1;

		else
			r = m - 1;
	}

	return -1;
}

void primeFactors(ll n) {
	while (n % 2 == 0) {
		//cout << 2 << " ";
		n = n / 2;
	}

	for (ll i = 3; i <= sqrt(n); i += 2) {
		while (n % i == 0) {
			//cout << i << " ";
			n = n / i;
		}
	}

	if (n > 2)
		cout << n << " ";
}

ll power(ll x, ll y, ll p) {
	ll res = 1;
	x = x % p;

	while (y > 0) {
		if (y & 1)
			res = (res * x) % p;

		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

ll modulo(ll a, ll b) {
	ll c = a % b;
	return (c < 0) ? c + b : c;
}

int main() {
// in(vec) works for size-defined type vectors

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input1.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output1.txt", "w", stdout);
#endif

	fastio
	ll t = 1;
	//cin >> t;
	while (t--) {
		ll n;
		cin >> n;
		ll sum = 0;
		forn(i, 1, n + 1) {

			ll c = n / i;
			sum += (i * c * (c + 1)) / 2;

		}
		o(sum)

	}
	CLOCK
	return 0;
}
//Credits: https://codeforces.com/blog/entry/79438


Measured memory_bytes: 3816
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define X first
#define Y second

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

int B[50];
map<ll,int> power;
vector<int> edge[50];
ll admask[50];

void dfs(ll &mask, int n, ll m2){
	if( m2 & (1ll<<n) ) return;
	mask |= (1ll<<n);
	for(auto t: edge[n]) if(((mask|m2) & (1ll<<t)) == 0){
		dfs(mask, t, m2);
	}
}

void print(ll n){
	rep(i,10) cout << (n&(1ll<<i) ? 1 : 0 );
}

int N;
ll solve(int n, ll m2);
ll solve1(ll mm, ll m2){
	if( power.count(mm) ) return power[mm];
	ll mx = 0;
	rep(j,N+1) if( (mm&(1ll<<j)) ){
		ll p = solve(j, m2);
		mx = max<ll>( mx, p );
		//cout << "j = " << j << " " << p << endl;
	}
	return power[mm] = mx;
}

ll solve(int n, ll m2){
	//cout << "solve: " << n << " " << m2 << endl;
	ll m = 0;
	dfs(m, n, m2);
	m ^= (m & m2);
	if( power.count(m) ) return power[m];

	ll to = 0;
	ll ret = 0;
	ll mask = (1ll<<n) | admask[n];
	mask ^= mask & m2;
	for(auto t: edge[n]) if( !((1ll<<t)&m2) ) to |= admask[t];
	to ^= to & m2;
	rep(i,N+1) if( ((to&mask)^to) & (1ll<<i) ){
		ll mm = 0, mx=0;
		dfs(mm, i, m2|mask);
		mm ^= mm&mask;
		mx = solve1(mm, m2|mask);
		//cout << "mm = " << i << " "; print(mm); cout << endl;
		ret += mx;
		//cout << "mx=" << mx << "  ret=" << ret << endl;

		mask |= mm;
	}
	//print(m);cout << ":\t" << ret + B[n] << endl;
	return ret + B[n];
}

int main(){
	while(cin >> N, N){
		map<string, int> idx;
		vector<string> Ds[50];

		B[N] = 0;
		power.clear();
		power[0] = 0;
		rep(i,50) edge[i].clear();
		rep(i,50) admask[i] = 0;

		rep(i,N){
			string A, D;
			int C;
			cin >> A >> B[i] >> C;
			idx[A] = i;
			rep(j,C){
				cin >> D;
				Ds[i].push_back(D);
			}
		}
		rep(i,N) for(auto s: Ds[i]){
			int j = idx[s];
			edge[i].push_back(j);
			edge[j].push_back(i);
			admask[i] |= (1ll<<j);
			admask[j] |= (1ll<<i);
		}
		rep(i,N){
			int j = N;
			edge[i].push_back(j);
			edge[j].push_back(i);
			admask[i] |= (1ll<<j);
			admask[j] |= (1ll<<i);
		}

		cout << solve(0, 0) << endl;
	}
	return 0;
}

Measured memory_bytes: 8996
// ~maqsat~
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n";
#define TEZ ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout);
 
using namespace std;
using namespace __gnu_pbds;
 
using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T, class U> inline void cmin(T &a, U b) { a = min(a, b); }
template <class T, class U> inline void cmax(T &a, U b) { a = max(a, b); }
template <class T, class U, class X, class Y> inline void psmn(T &a, U b, X &p, Y i) { if(b < a)a = b,p = i; }
template <class T, class U, class X, class Y> inline void psmx(T &a, U b, X &p, Y i) { if(b > a)a = b,p = i; }
 
const int oo = 0x3f3f3f3f;
const ll N = 1e5 + 345;
const ll MOD = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
 
int main() {
	fre(""); TEZ;

	string s;
	cin >> s;
	if(s[0] == 'S') cout << "Cloudy"; else
	if(s[0] == 'C') cout << "Rainy"; else
	if(s[0] == 'R') cout << "Sunny";

	return 0;
}


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

int main(){
  int N;
  string S;
  cin >> N;
  int G = 0,Y = 0,P = 0,W = 0;
  for(int i = 0 ; i < N ; i++){
    cin >> S;
    if(S == "G")
      G = 1;
    if(S == "Y")
      Y = 1;
    if(S == "P")
      P = 1;
    if(S == "W")
      W = 1;
  }
  int count;
    count = W + G + P + Y;
  if(count == 3)
    cout << "Three" << endl;
  if(count == 4)
    cout << "Four" << endl;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  int X,Y,Z;cin>>X>>Y>>Z;
  cout<< (X-Z)/(Z+Y)<<endl;
}







Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    if(n==1)
        {
            n=14;
        }
    if(m==1)
        {
            m=14;
        }
    if(n==m)
        {
            cout<<"Draw";
        }
    else if(n<m)
        {
            cout<<"Bob";
        }
    else
        {
            cout<<"Alice";
        }
    return 0;
}

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

int main(){
    long long int N,W;
    cin >> N >> W;

    vector<vector<long long int>> w(N, vector<long long int> (2));
    for(int i = 0; i < N; i++){
        cin >> w[i][0] >> w[i][1];
    }

    long long int dp[N+1][W+1];
    for(long long int i = 0; i <= N; i++){
        for(long long int j = 0; j <= W; j++){
            if(i == 0 || j == 0){
                dp[i][j] = 0;
            }
            else if(w[i-1][0] <= j){
                dp[i][j] = max(w[i-1][1]+dp[i - 1][j - w[i-1][0]], dp[i-1][j]);
            }
            else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout << dp[N][W];
    return 0;
}


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

typedef unsigned long long int ll;

map<ll, ll> f(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1) res[n] = 1;
  return res;
}

int main() {
  ll N, P;
  cin >> N >> P;
  if (N == 1) {
    cout << P << endl;
    return 0;
  }
  if (P == 1) {
    cout << 1 << endl;
    return 0;
  }
  map<ll, ll> M = f(P);
  ll ans = 1;
  for (auto p : M) {
    ll x = p.first, n = p.second;
    ll tmp = n / N;
    for (ll j = 0; j < tmp; j++) {
      ans *= x;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
   int N;
   std::cin >> N;
   int A, B;
   std::vector<std::pair<int,int> > AB(N);
   for(int i=0; i<N; ++i){
      std::cin >> A >> B;
      AB[i] = {B, A};
   }
   std::sort(AB.begin(),AB.end());

   int t = 0;
   for(int i=0; i<N; ++i){
      t += AB[i].second;
      if(t>AB[i].first){
	 std::cout << "No" << std::endl;
	 return 0;
      }
   }
   std::cout << "Yes" << std::endl;
   return 0;
   
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define PII pair<int,int>
#define MP make_pair
#define PB push_back
typedef long long LL;
const LL MOD = 998244353;
const int N = 200010;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,a[N<<1],b[N],nxt[N],round1[N];
LL k;

int main(){
	//freopen("test.in","r",stdin);
	scanf("%d%lld",&n,&k);
	rep(i,1,n)scanf("%d",a+i);
	rep(i,1,n)a[i+n]=a[i];
	memset(nxt,0,sizeof nxt);
	memset(b,0,sizeof b);
	rrep(i,n<<1,1){
		if(i<=n && b[a[i]]) nxt[i] = b[a[i]];
		b[a[i]]=(i-1)%n+1;
	}
	int i = 1, now = 1;
	memset(round1,0,sizeof round1);
	while(true){
		//cout<<now<<" "<<i<<endl;
		round1[i] = now;
		if(nxt[i] <= i) ++now;
		i = nxt[i] % n + 1;
		if(i==1) ++now;
		if(round1[i]) break;
	}
	//cout<<round1[i]<<" "<<now<<" "<<i<<endl;
	LL diff = now - round1[i];
	if(k >= now) k = (k - round1[i]) % diff + round1[i];
	
	i = 1, now = 1;
	while(now<=k){
		if(nxt[i] <= i) ++now;
		i = nxt[i] % n + 1;
		if(i==1) ++now;
	}
	//cout<<endl<<k<<endl;
	//cout<<now<<" "<<i<<endl;
	if(now==k+1 && i==1){
		printf("\n");
	}else{
		int j = 1;
		--i; if(i==0) i=n;
		for(;;++j)if(nxt[j]==i)break;
		for(int i=j;i<=n;++i){
			if(nxt[i]>i) i = nxt[i];
			else printf("%d ", a[i]);
		}
		printf("\n");
	}
	return 0;
}

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

int main(){
    string s;
    string t;
    cin>>s>>t;
    ll ans=0;
    for(ll i=0;i<s.size();i++){
        if(s[i]!=t[i])ans+=1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    vector<ll> a(n);
    vector<ll> b(n);
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    ll count=0;
    for(int i=n-1;i>=0;i--){
        a[i]+=count;
        a[i]%=b[i];
        if(a[i]!=0){
            count+=b[i]-a[i];
        }
    }
    cout<<count<<endl;

}

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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n, ans = 0; cin >> n;
    vector<ll> a; // 約数リスト
    for(ll i = 1; i <= sqrt(n+0.1); i++) {
        if((n%i) == 0) {
            a.push_back(i);
            if(i*i != n) {
                a.push_back(n/i);
            }
        }
    }

    sort(ALL(a));
    rep(i, a.size()) {
        ll m = a[i]-1;
        if(m == 0) continue;
        // 条件を満たすか
        if((a[i])*(n%m) == n) {
            ans += m;
        }
    }


    cout << ans << endl;

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 3728
N = int(input())

x = []
for i in range(N):
    x.append([j for j in input().split()])

ans = 0
for i in range(N):
    if x[i][1] == 'BTC':
        ans += 380000.0 * float(x[i][0])
    else:
        ans += float(x[i][0])

print(ans)


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

#define MAXN (200010)
#define ll long long

int n;
std::pair<int, int> vec[MAXN];
std::multiset<int> setr, setb;

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++ i){
		scanf("%d%d", &vec[i].first, &vec[i].second);
	}
	
	for(int i = 1; i <= n; ++ i){
		if(vec[i].first > vec[i].second) std::swap(vec[i].first, vec[i].second);
		setr.insert(vec[i].first);
		setb.insert(vec[i].second);
	}
	
	std::sort(vec + 1, n + vec + 1);
	
	ll ans = 1ll * (*setr.rbegin() - *setr.begin()) * (*setb.rbegin() - *setb.begin());
	for(int i = 1; i <= n; ++ i){
		setr.erase(setr.find(vec[i].first)); setr.insert(vec[i].second);
		setb.erase(setb.find(vec[i].second)); setb.insert(vec[i].first);
		
		ans = std::min(ans, 1ll * (*setr.rbegin() - *setr.begin()) * (*setb.rbegin() - *setb.begin()));
		
		//setr.erase(setr.find(vec[i].second)); setr.insert(vec[i].first);
		//setb.erase(setb.find(vec[i].first)); setb.insert(vec[i].second);
	}
	
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 22656
#include <iostream>
#include <cstring>

const char PATTERN[10][9] = {
	"* = ****", "* =* ***", "* =** **", "* =*** *", "* =**** ",
	" *= ****", " *=* ***", " *=** **", " *=*** *", " *=**** "};

int main()
{
	std::string input;
	int loops = 0;
	while (getline(std::cin, input)) {
		int n = input.length();
		char abacus[5][9];
		
		for (int i=0; i<5-n; i++) strcpy(abacus[i], PATTERN[0]);
		for (int i=0; i<n; i++) {
			int d = input[i] - '0';
			strcpy(abacus[i+5-n], PATTERN[d]);
		}
		if (loops>0) std::cout << std::endl;
		
		for (int j=0; j<8; j++) {
			for (int i=0; i<5; i++) {
				std::cout << abacus[i][j];
			}
			std::cout << std::endl;
		}
		
		loops++;
	}
	return 0;
}




Measured memory_bytes: 3172
from fractions import gcd

def mygcd(x, y):
    if x == 0 or y == 0:
        return max(x, y)
    return gcd(x, y)

def main():
    N = int(input())
    A = list(map(int, input().split()))

    L = [0]; R = [0]
    for i in range(len(A)):
        Lbase = mygcd(L[-1], A[i])
        L.append(Lbase)
        Rbase = mygcd(R[-1], A[-i-1])
        R.append(Rbase)
    
    ans = 0
    R.reverse()
    for i in range(len(A)):
        tmp = mygcd(L[i], R[i+1])
        ans = max(ans, tmp)

    print(ans)

if __name__ == "__main__":
    main()


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

const int MOD = (int)1e9+7;

int main(){
	int N;
	cin >> N;
	vector<string> s(N);
	for(int i=0;i<N;i++){
		cin >> s.at(i);
		sort(s.at(i).begin(),s.at(i).end());
	}

	sort(s.begin(),s.end());
 	long long ans=0;
 	long long count=1;
	for(int i=0;i<N-1;i++){
		if(s.at(i)==s.at(i+1))	count++;
		else{
			ans+=count*(count-1)/2;
			count=1;
		}
	}
	ans+=count*(count-1)/2;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int begin = max(a, c);
  int end = min(b, d);
  cout << max(end-begin, 0) << endl;
  return 0;
}

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

using namespace std;

inline int inv(int n, int p) {
	int i = 1;
	for (int r = n; r > 1; r = p % r)
		i = p / r * long(p - i) % p;
	return i;
}
long c[333333];
int main()
{
	int n, a, b;
	long k;
	cin >> n >> a >> b >> k;
	int p = 998244353;
	c[0] = 1;
	for (int i = 0; i < n; i++)
		c[i + 1] = long(n - i)*inv(i + 1, p) % p*c[i] % p;
	long r = 0;
	for (int i = 0; i <= n; i++) {
		long x = k - long(i)*a;
		if (x%b || x<0 || x / b>n) continue;
		r += c[i] * c[x / b];
		r %= p;
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 2688
/*
	Nishant Singh
	nishant.ns19@gmail.com
*/
#include <bits/stdc++.h>
#include <functional> 
#include <iostream> 
// ******** Big Integer ********
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// #define ll1024  int1024_t
// ******** Big Integer ********
// ******** Using PBDS ********
// #include <ext/pb_ds/assoc_container.hpp> // Common file 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ook order_of_key    //count of strictly smaller elements
// #define fbo find_by_order   //find element at an index 
// ******** Using PBDS ********
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vll vector<ll>
#define vec vector
#define setcount(x) __builtin_popcountll(x)
#define f first
#define s second
#define mp make_pair
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define REV(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define in insert
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
#define pq priority_queue
#define ffl fflush(stdout)
#define mset multiset
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define ub upper_bound
#define lb lower_bound 
#define ln "\n"
#define Y "YES"
#define N "NO"
ll const mod=1e9 + 7;
ll const inf=2e18;
// ******** Using PBDS ********
// typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//                 os; 
// ******** Using PBDS ********
inline ll add(ll a,ll b) 
{ 
	return (a%mod + b%mod + mod)%mod; 
}
inline ll mul(ll a,ll b) 
{ 
	return (a%mod * b%mod + mod)%mod; 
}
inline ll sub(ll a,ll b) 
{ 
	return (a%mod - b%mod + mod)%mod; 
}
ll gcd(ll a,ll b)
{
	if (b == 0) 
		return a; 
	return gcd(b, a % b);  
}
ll modexp(ll x, ll n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}
ll modinv(ll n)
{
	return modexp(n,mod-2);
}
// ******** GLOBAL VARIABLES ********
// ******** GLOBAL VARIABLES ********
void solve(){
	ll x,k,d;
	cin>>x>>k>>d;
	ll pos=min(k,abs(x)/d);
	ll to=abs(x)-pos*d;
	k=k-pos;
	if(k&1)
	{
		cout<<min(abs(to+d),abs(to-d));
	}
	else
	{
		cout<<to;
	}
}  
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll T=1;
	// cin>>T; 	
	for(int t=1;t<=T;t++)
	{
		// cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3636
n = int(input())
if 0<= n < 2:
    print(n)
    exit()

bit = 2
i = 0
l,r = 0,1
rang = [(0,1)]
while n < l or r < n:
    i += 1
    bit *= -2
    if i % 2:
        l = bit+1 + r
    else:
        r = bit-1 + l
    rang.append((l,r))
    # print(l,r,bit, i)

ans = []
# print(rang)
bit //= 2
# print(bit)
while i >= 0:
    t = n - bit
    # print(t, rang[i])
    if rang[i][0] <= t <= rang[i][1]:
        ans.append('1')
        n = t
    else:
        ans.append('0')
    i -= 1
    bit //= -2
print(''.join(ans))


Measured memory_bytes: 38392
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main(void) {
	string str;
	getline(cin, str);

	int s = atoi(str.c_str());

	int sec = s % 60;
	int buf = s / 60;
	int hour = buf / 60;
	int min = buf % 60;

	cout << hour << ":" << min << ":" << sec << endl;

	return 0;
}

Measured memory_bytes: 3164
n, q = list(map(int, input().split()))
s = input()


ac = [0] * n

for i in range(n - 1):
  if s[i : i + 2] == "AC":
    ac[i + 1] = ac[i] + 1
  else:
    ac[i + 1] = ac[i]

for _ in range(q):
  l, r = list(map(int, input().split()))
  print(ac[r - 1] - ac[l - 1])

Measured memory_bytes: 6188