akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   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;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }    
  
  int main(){
 double l;
cin>>l;
l/=3;
printf("%.9f",l*l*l);
  }
  
  
     
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int sx,sy,tx,ty;scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
  cout << string(tx-sx,'R') << string(ty-sy,'U') << string(tx-sx,'L') << string(ty-sy,'D');
  cout << "L" << string(ty-sy+1,'U') << string(tx-sx+1,'R') << "D";
  cout << "R" << string(ty-sy+1,'D') << string(tx-sx+1,'L') << "U";
  cout << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}


int main(){
  ll n,i=1;
  cin >> n;
  string s;
  if(n==0)s.push_back('0');
  while(n!=0){
    if(n%-2!=0){
      s.push_back('1');
      n-=1;
    }else{
      s+="0";
    }
    n/=-2;
  }
  reverse(s.begin(),s.end());
  cout << s << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<set>
#include<cmath>
#include<vector>
#define int long long int
#define mod 1000000007
double answer=0.0;
int fact(int n)
{
	return n==0?1:n*fact(n-1);
}
bool finish(vector<int> &s)
{
	int j;
	for(j=0;j<s.size();j++)
	{
		if(s[j]!=-1)
		  return false;
	}
	return true;
}
void function(int arr[][2],vector<int> &v,vector<int> s)
{
	if(finish(s))
	{
		int j;
		double final=0.0;
		for(j=1;j<v.size();j++)
		{
			int p=v[j-1];
			int q=v[j];
			double x1=arr[p][0];
			double y1=arr[p][1];
			double x2=arr[q][0];
			double y2=arr[q][1];
			double val=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
			val=(double)sqrt(val);
			final=final+val;
		}
		answer=answer+final;
	}
	else
	{
       int j;
       for(j=0;j<s.size();j++)
       {
		   if(s[j]!=-1)
		   {
			   int val=s[j];
			   v.push_back(val);
			   s[j]=-1;
			   function(arr,v,s);
			   v.pop_back();
			   s[j]=val;
		   }
	   }   
	}
}
int32_t main()
{
    int n;
    cin>>n;
    int arr[n+1][2];
    int j;
    for(j=1;j<=n;j++)
    {
		cin>>arr[j][0]>>arr[j][1];
	}
	vector<int> s;
	for(j=1;j<=n;j++)
	  s.push_back(j);
	vector<int> v;
	function(arr,v,s);
	int val=fact(n);
	double final=answer/val;
	printf("%.10f\n",final);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 55;
int a,b;
char A[maxn][maxn],B[maxn][maxn];
bool find(int x,int y){
	for(register int i=0;i<b;++i){
		for(register int j=0;j<b;++j){
			if(A[x+i][y+j]!=B[i][j])return 0;
		}
	}return 1;
}
int main(){
	scanf("%d%d",&a,&b);
	for(register int i=0;i<a;++i){
		scanf("%s",A[i]);
	}
	for(register int i=0;i<b;++i){
		scanf("%s",B[i]);
	}
	for(register int i=0;i<=a-b;++i){
		for(register int j=0;j<=a-b;++j){
			if(find(i,j)){
				printf("Yes");return 0;
			}
		}
	}
	printf("No");return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

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

    int sum = 0;
    for (int i = 0; i < m; i++)
    {
        int x;
        cin >> x;
        sum += x;
    }

    if (sum > n)
        cout << "-1";
    else cout << n-sum;
}

Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
using static Atcoder.IO;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var nxt = RSInt;

            var ans = 0;

            ans = (nxt[0] / nxt[1]) * nxt[2];
            if (nxt[0] % nxt[1] != 0) ans += nxt[2];
            WriteLine(ans);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long
#define ld long double

const int INF = 2e9 + 1;
const ll INFLL = 1e18 + 1;
const int mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n, k;
    cin >> n >> k;
    if (n > k) {
        ll cnt = n / k;
        n -= cnt * k;
    }
    cout << min(n, k - n);
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

main(){
    int N,L,sum=0;
    scanf("%d%d",&N,&L);
    if(L>=0){
        for (int i = 2; i <= N; ++i) {
            sum+=L+i-1;
        }
    } else {
        if (N > -L) {
            for (int i = 1; i <= N; ++i) {
                sum+=L+i-1;
            }
        } else {
            for (int i = 1; i < N; ++i) {
                sum+=L+i-1;
            }
        }
    }
    printf("%d",sum);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


#include <bits/stdc++.h>
using namespace std;
signed main(){
    int N; cin>>N;
    vec A(N); REP(i,N) cin>>A[i];
    int ans = 0;
    map<int,int> count;
    REP(i,N){
        ans += count[i-A[i]];
        count [i+A[i]] ++;
    }
    Out(ans);
}

Measured memory_bytes: 27348
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 101010101000;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;

int main(){
  //int n;
  //cin >> n;
  string s;
  cin >> s;
  if(s=="AAA"||s=="BBB") cout << "No";
  else cout << "Yes";
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,a,b,c,d,e,f;
    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
    e=n/a;
    f=n/c;
    if(n%a!=0)e++;
    if(n%c!=0)f++;
    e=e*b;
    f=f*d;
    if(e<f)printf("%d\n",e);
    else printf("%d\n",f);
    return 0;
    
}


Measured memory_bytes: 2112
import java.io.*;
import java.util.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Iterator<String> sc) {
		int K = Integer.parseInt(sc.next());
		int S = Integer.parseInt(sc.next());
		int sum = 0;
		for (int x = 0; x <= K && x <= S; x++) {
			int remaining = S - x;
			sum += Math.max(Math.min(remaining, K) - Math.max(remaining - K, 0) + 1, 0);
		}
		System.out.println(sum);
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Iterator<String> tokens = reader.lines().map(s -> s.split(" ")).flatMap(Arrays::stream).iterator();
		Solver.INSTANCE.solve(tokens);
	}
}

Measured memory_bytes: 26452
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
const int mod2 = 998244353;
const int mod = (int)1e9 + 7, inf = (int)1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] *= fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	int ans= fact[n] * modpow(fact[n - r], mod - 2) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

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

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

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

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

int n;
int a[100010];
int ans, cnt;
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n - 1) {
		if (a[i] >= a[i + 1]) cnt++;
		else {
			ans = max(ans, cnt);
			cnt = 0;
		}
	}
	ans = max(ans, cnt);
	cout << ans << endl;
}

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

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

vector<vector<ll>>g;
ll n;
void dfs(ll v,vector<bool>&c,ll &ans){
    bool flg=true;
    for (int i = 0; i < n; ++i) {
        if(c[i]&&i!=v)flg=false;
    }
    if(flg){
        ans++;
        return;
    }
    c[v]=false;
    for(auto u:g[v]){
        if(!c[u])continue;
        dfs(u,c,ans);
    }
    c[v]=true;
};

int main(){
    ll m;cin >>n>>m;
    g.assign(n,vector<ll>());
    for (int i = 0; i < m; ++i) {
        ll a,b;cin >>a>>b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    ll ans=0;
    vector<bool>c(n,true);
    dfs(0,c,ans);
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
c = 0
for _ in range(n):
    a = int(input())
    if a % 2 == 0:
        if a != 2:
            c += 1
        continue
    for b in range(3,a,2):
        if a % b == 0:
            c += 1
            break
        if b * b > a:
            break
print(n-c)


Measured memory_bytes: 5608
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200010

using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int N;
double pi=2.0*acos(0.0);
vector<pair<pair<double,double>,int> > data;
vi ans;
double calcvec(pair<double,double> hoge1,pair<double,double> hoge2){
	double x=hoge2.first,y=hoge2.second;
	x-=hoge1.first,y-=hoge1.second;
	double ret=acos(x/sqrt(x*x+y*y));
	if(y<0)ret=2.0*pi-ret;
	return ret;
}
double calckaku(double a,double b){
	double ret=b-a;
	if(ret<0)ret+=2.0*pi;
	return ret;
}
int main(){
	cin>>N;
	int lef=0;
	for(int i=0;i<N;i++){
		double x,y;
		cin>>x>>y;
		data.pb(mp(mp(x,y),i));
	}
	sort(data.begin(),data.end());
	reverse(data.begin(),data.end());
	int num=0,nxnum;
	double kakub=acos(0.0);
	while(1){
		nxnum=0;
		double mi=2.0*pi,kakumemo;
		for(int i=0;i<N;i++){
			if(i!=num){
				double kaku=calcvec(data[num].first,data[i].first);
				double kakuc=calckaku(kakub,kaku);
				if(kakuc<mi){
					mi=kakuc,nxnum=i,kakumemo=kaku;
				}
			}
		}
		ans.pb(num);
		kakub=kakumemo;
		if(nxnum==0)break;
		num=nxnum;
	}
	double ans2[105]={0.0};
	int n=ans.size();
	for(int i=0;i<n;i++){
		int n1=ans[i],n2=ans[((i+1)%n)],n0=ans[((i+n-1)%n)];
		double ka1=calcvec(data[n1].first,data[n2].first);
		double ka2=calcvec(data[n0].first,data[n1].first);
		double ka=calckaku(ka2,ka1);
		ans2[data[ans[i]].second]=ka/(2.0*pi);
	}
	for(int i=0;i<N;i++)printf("%.7lf\n",ans2[i]);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 int main()
 {
     int n, r;
     cin >> n >> r;
     ll rest = 100*(10-n);
     if(n <= 10)
     {
         cout << r+rest << endl;
     }
     else
     {
         cout << r << endl;
     }
     return 0;
 }


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

struct Book {
	int cost;
	int a[20];
};

int understand[20];
int x;
Book books[20];
int minCost;
int n, m;

void doSearch(int depth, int curCost) {
	if (depth >= n) {
		for (int i = 0 ; i < m ; i++) {
			if (understand[i] < x) {
				return ;
			}
		}
		
		if ((minCost == -1) || (minCost > curCost))
			minCost = curCost;
	} else {
		int newCost = curCost + books[depth].cost;
		for (int i = 0 ; i < m ; i++) {
			understand[i] = understand[i] + books[depth].a[i];
		}
		doSearch(depth + 1, newCost);
		
		//回滚 
		for (int i = 0 ; i < m ; i++) {
			understand[i] = understand[i] - books[depth].a[i];
		}		
		doSearch(depth + 1, curCost);
		
	}
}

int main()
{
	scanf("%d%d%d", &n, &m, &x);
	
	minCost = -1;
	for (int i = 0 ; i < n ; i++) {
		scanf("%d", &(books[i].cost));
		
		for (int j = 0 ; j < m ; j++) {
			scanf("%d", &(books[i].a[j]));
		}
	}
	
	for (int i = 0 ; i < m ; i++)
		understand[i] = 0;
	
	doSearch(0, 0);
	
	printf("%d\n", minCost);

	return 0;
}


Measured memory_bytes: 1732
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = 0
prev_idx = -10
for a in A:

    ans += B[a-1]
    if prev_idx + 1 == a-1:
        ans += C[a-2]
    prev_idx = a-1

print(ans)



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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    vector<vector<set<int>>> g(n, vector<set<int>>(2));
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        int vcol = s[v]-'A';
        int ucol = s[u]-'A';
        g[u][vcol].insert(v);
        g[v][ucol].insert(u);
    }
    vector<int> q;
    for (int i = 0; i < n; i++) {
        q.push_back(i);
    }
    for (int qi = 0; qi < q.size(); qi++) {
        int v = q[qi];
        int vcol = s[v]-'A';
        auto &gv = g[v];
        if (gv[0].size() > 0 && gv[1].size() > 0) {
            continue;
        }
        for (auto u: gv[0]) {
            g[u][vcol].erase(v);
            q.push_back(u);
        }
        gv[0].clear();
        for (auto u: gv[1]) {
            g[u][vcol].erase(v);
            q.push_back(u);
        }
        gv[1].clear();
    }
    bool ok = false;
    for (auto gv: g) {
        if (gv[0].size() > 0) {
            ok = true;
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
}


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

#define FOR(i, a, b)  for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << "\n"
#define _ << " _ " <<
#define ll long long

using namespace std;

int arr[310][310];
int spo[310];

int num[310];
int bio[310];

int main() {
  ios_base::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;
  REP(i, n) {
    REP(j, m) {
      cin >> arr[i][j];
      arr[i][j]--;
    }
  }

  int out = n;
  REP(i, m - 1) {
    memset(num, 0, sizeof num);
    REP(j, n) {
      int k = 0;
      while (bio[arr[j][k]]) k++;
      num[arr[j][k]]++;
    }
    int ma = 0, ind = -1;
    REP(k, m) {
      if (ma < num[k]) {
        ma = num[k];
        ind = k;
      }
    }
    out = min(ma, out);
    bio[ind] = 1;
  }
  cout << out << endl;

  return 0;
}


Measured memory_bytes: 640
def main():
    while True:
        # 引数を受け取る
        args = input().split(' ')
        if int(args[0]) == 0 and int(args[1]) == 0:
            break
        else:
            if int(args[0]) > int(args[1]):
                print('{} {}'.format(args[1], args[0]))
            else:
                print('{} {}'.format(args[0], args[1]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 5624
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
Q = INT()

dic = Counter(A)
su = sum(A)
ans = []
for _ in range(Q):
    B, C = MAP()
    su -= dic[B]*B
    su += dic[B]*C
    dic[C] += dic[B]
    dic[B] = 0
    ans.append(su)
print(*ans, sep="\n")


Measured memory_bytes: 28288
#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 <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <regex>
#include <numeric>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007

LL gcd(LL a, LL b) {
	return b != 0 ? gcd(b, a % b) : a;
}

int main() {
	int t;
	cin >> t;
	REP(i, t) {
		LL a, b, c, d;
		cin >> a >> b >> c >> d;
		if (d < b) {
			cout << "No" << endl;
			continue;
		}
		if (a < b) {
			cout << "No" << endl;
			continue;
		}
		if (a % b > c) {
			cout << "No" << endl;
			continue;
		}
		LL x = gcd(b, d);
		LL y = a % b;
		if (b <= ((c - y) / x+1)*x + y)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N,L,T = map(int,input().split())
x,w = map(int,input().split())
D = []
m = 0
def f(x,w):
    if w == 1:
        a = (x+T) % L
        return a
    else:
        a = (x-T) % L
        return a
for i in range(2,N+1):
    X,W = map(int,input().split())
    a = f(X,W)
    if f(X,W) < f(x,w):
        a += L
    D.append(a)
    if w != W:
        if w == 1:
            l = (X - x)%L
        else:
            l = (x - X)%L
        if l <= 2*T:
            t = (2*T - l)//L + 1
            if (2*T - l)%L == 0:
                if w == 1:
                    t -= 1
        else:
            t = 0
        m += t
if w == 1:
    p = m%N + 1
else:
    p = (1-m)%N
    if p == 0:
        p = N
D.sort()
dic = {}
dic[p] = f(x,w)
for i in range(N-1):
    p += 1
    if p > N:
        p -= N
    q = D[i]
    dic[p] = q%L
for i in range(1,N+1):
    print(dic[i])

Measured memory_bytes: 21772
def main():
    s=input()
    t=input()
    ans=[]
    for i in range(len(s)-len(t)+1):
        for j in range(len(t)):
            if len(s) <= i+j or (s[i+j] != t[j] and s[i+j] != "?"):
                break
        else:
            ans.append((s[:i]+t+s[i+j+1:]).replace("?", "a"))
    ans.sort()
    print(ans[0] if len(ans) > 0 else "UNRESTORABLE")
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9012
from sys import stdin, setrecursionlimit
from itertools import accumulate


def main():
    input = stdin.buffer.readline
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(k):
        tmp = [0] * (n + 1)
        for j in range(n):
            tmp[max(0, j - a[j])] += 1
            tmp[min(n, j + a[j] + 1)] -= 1
        a = list(accumulate(tmp))[:n]
        for ai in a:
            if ai != n:
                break
        else:
            break
    print(*a)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 182452
/*
"Won't stop until I'm phenomenal."
- Phenomenal, Eminem
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;



int main(){
    Shazam;
    int n; cin>>n;
    int k; cin>>k;
    vector<long double> a(n);
    for(long double &i : a) cin>>i,  i = (i+1)/2;
    long double ans = 0, sum ;
    for(int i = 0; i < k; i++) ans += a[i];
    sum = ans;
    for(int i = k; i < n; i++){
        sum-=a[i-k];
        sum+=a.at(i);
        ans = max(ans, sum);
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 100100100100100;
int main(){
  ll h,w,l,m,r,a,b = inf,c,d = inf,i;scanf("%lld%lld",&h,&w);
  if(h==2) a = inf;
  else a = ((h%3==0) ? 0:w);
  for(i=1;i<h;i++){
    l = i*w;
    m = (h-i)*(w/2);r = h*w-l-m;
    b = min(b,max({l,m,r})-min({l,m,r}));
  }
  if(w==2) c = inf;
  else c = ((w%3==0) ? 0:h);
  for(i=1;i<w;i++){
    l = i*h;
    m = (w-i)*(h/2);r = h*w-l-m;
    d = min(d,max({l,m,r})-min({l,m,r}));
  }
  printf("%lld\n",min({a,b,c,d}));
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
long dp[1<<17];
inline void solve(void){
  int N;in(N);
  fill(dp,dp+(1<<17),1L<<60);
  dp[0]=0;
  rep(i,N)chmin(dp[i+1],dp[i]+1);
  rep(i,N)for(int j=1;i+j<=N;j*=6)chmin(dp[i+j],dp[i]+1);
  rep(i,N)for(int j=1;i+j<=N;j*=9)chmin(dp[i+j],dp[i]+1);
  out(dp[N]);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

using namespace std;

int main() {
  int n, cx = 0, cy = 0, sum = 0, max = -1;
  cin >> n;
  int a[n][2];
  for (int j = 0; j < 2; j++)
    for (int i = 0; i < n; i++)
      cin >> a[i][j];

  for (int i = 0; i < n; i++) {
    sum = 0;
    for (int j = 0; j <= i; j++) {
      sum += a[j][0];
    }
    for (int j = i; j < n; j++) {
      sum += a[j][1];
    }
    if (sum > max) max = sum;
  }

  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int N, tmp;
    char s[200], t[200];
    int i, j=0;

    scanf("%d", &N);
    scanf("%s", &s);
    scanf("%s", &t);

    for(i=0; i<N; i++){
        tmp=0;
        for(j=0; j<N-i; j++){
            if(s[i+tmp]==t[j]){
                tmp++;
            }
        }
        //printf("%d\n", tmp);
        if(tmp==N-i){
            break;
        }
    }

    printf("%d", N+i);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
  	int n,k;
  	cin >> n >> k;
  	vector<int> p;
  	int sum = 0;
  	for (int i = 0; i < n; i++) {
      	int j;
      	cin >> j;
      	p.push_back(j);
    }
  	
  	sort(p.begin(), p.end());
  	for (int i=0; i < k; i++)
      sum += p[i];
	cout << sum << endl;
  	return 0;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define INF 1000000000000
#define MOD 1000000007
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3)                                                 \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << endl
#define debug_4(x1, x2, x3, x4)                                             \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5)                                         \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

using namespace std;
using ll = long long;

int main() {
    int l, r, d, cnt = 0;
    cin >> l >> r >> d;
    for (int i = l; i <= r; i++) {
        if (i % d == 0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

divisors = set()
for i in range(1, int(-(-n**.5//1))+1):
    if n % i == 0:
        divisors |= {i, n//i}

ans = set()
for div in divisors:
    x = n
    if div == 1:
        continue
    while x % div == 0:
        x = x//div
    if x % div == 1:
        ans |= {div}


n -= 1
for i in range(1, int(-(-n**.5//1))+1):
    if n % i == 0:
        ans |= {i, n//i}

ans ^= {1}
print(len(ans))


Measured memory_bytes: 3580
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int main() {
	int A, B, K;

	cin >> K >> A >> B;

	for (int ii = A; ii <= B; ii++) {
		if (ii % K == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
//BEGIN CUT HERE
template <typename T,typename E>
struct SegmentTree{
  typedef function<T(T,E)> G;
  typedef function<T(E,E)> H;
  int n;
  G g;
  H h;
  T d1;
  E d0;
  vector<T> dat;
  vector<E> laz;
  SegmentTree(){};
  SegmentTree(int n_,G g,H h,T d1,E d0,
	      vector<T> v=vector<T>()):
    g(g),h(h),d1(d1),d0(d0){
    init(n_);
    if(n_==(int)v.size()) build(n_,v);
  }
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(n,d1);
    laz.clear();
    laz.resize(2*n-1,d0);
  }
  void build(int n_, vector<T> v){
    for(int i=0;i<n_;i++) dat[i]=v[i];
  }
  void eval(int k){
    if(k*2+1<2*n-1){
      laz[k*2+1]=h(laz[k*2+1],laz[k]);
      laz[k*2+2]=h(laz[k*2+2],laz[k]);
      laz[k]=d0;
    }
  }
  
  void update(int a,int b,E x,int k,int l,int r){
    eval(k);
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      laz[k]=h(laz[k],x);
      return;
    }
    update(a,b,x,k*2+1,l,(l+r)/2);
    update(a,b,x,k*2+2,(l+r)/2,r);
  }
  void update(int a,int b,E x){
    update(a,b,x,0,0,n);
  }
  void eval2(int k){
    if(k) eval2((k-1)/2);
    eval(k);
  }
  
  T query(int k){
    T c=dat[k];
    k+=n-1;
    eval2(k);
    return g(c,laz[k]);
  }
};
//END CUT HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n,q;
  cin>>n>>q;
  SegmentTree<int,int> beet(n,
			    [&](int a,int b){ return b<0?a:b;},
			    [&](int a,int b){ return b<0?a:b;},
			    INT_MAX,-1);
  for(int i=0;i<q;i++){
    int c;
    cin>>c;
    if(c){
      int x;
      cin>>x;
      cout<<beet.query(x)<<endl;
    }else{
      int s,t,x;
      cin>>s>>t>>x;
      t++;
      beet.update(s,t,x);
    }
  }
  return 0;
}
/*
  verified on 2017/11/05
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_D&lang=jp
*/

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

int main()
{
  int n, p;
  cin >> n >> p;
  vector<int> a(n);
  int i;
  int sum = 0;
  for(i = 0; i < n; i++)
  {
    cin >> a.at(i);
  }
  long long re0 = 1;
  long long re1 = 0;
  if(a.at(0)%2==0) re0++;
  else re1++;
  for(i = 1; i < n; i++)
  {
    if(a.at(i)%2==0)
    {
      re0 *= 2;
      re1 *= 2;
    }
    else
    {
      re0 += re1;
      re1 = re0;
    }
  }
  if(p == 0)cout << re0 << endl;
  else cout << re1 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int sideA = sc.nextInt();
		int sideB = sc.nextInt();
		int angleC = sc.nextInt();

		// 角度をラジアンで指定
		double radianC = Math.toRadians(angleC);

		double sideC = Math.sqrt(Math.pow(sideA, 2) + Math.pow(sideB, 2) - 2 * sideA * sideB * Math.cos(radianC));
		double length = sideA + sideB + sideC;
		double area = 0.5 * sideA * sideB * Math.sin(radianC);
		double height = sideB * Math.sin(radianC);
		System.out.println(area);
		System.out.println(length);
		System.out.println(height);

		sc.close();

	}

}



Measured memory_bytes: 26340
import bisect
from collections import Counter
def MI(): return map(int, input().split())
def II(): return int(input())
def IS(): return input()
def LI(): return list(map(int, input().split()))


n = IS()
a = []
for i in n:
    if i == '1': a.append('9')
    else: a.append('1')
print(''.join(a))


Measured memory_bytes: 3316
#include<stdio.h>
#include<stdlib.h>
int p[100005], y[100005];
int asc(const void* a, const void* b)
{
	if (p[*(int*)a] > p[*(int*)b])return 1;
	if (p[*(int*)a] < p[*(int*)b])return -1;
	if (y[*(int*)a] > y[*(int*)b])return 1;
	if (y[*(int*)a] < y[*(int*)b])return -1;
	return 0;
}
int keta(int n)
{
	int res = 0;
	while (n > 0)
	{
		res++;
		n /= 10;
	}
	return res;
}
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int i, j;
	for (i = 0; i < m; i++)
		scanf("%d %d", &p[i], &y[i]);
	int c[100005];
	for (i = 0; i < m; i++)
		c[i] = i;
	qsort(c, m, sizeof(int), asc);
	int count[100005];
	count[0] = 1;
	for (i = 1; i < m; i++)
	{
		if (p[c[i]] == p[c[i - 1]])
			count[i] = count[i - 1] + 1;
		else
			count[i] = 1;
	}
	int d[100005];
	for (i = 0; i < m; i++)
		d[c[i]] = i;
	for (i = 0; i < m; i++)
	{
		for (j = 0; j < 6 - keta(p[i]); j++)
			printf("0");
		printf("%d", p[i]);
		for (j = 0; j < 6 - keta(count[d[i]]); j++)
			printf("0");
		printf("%d\n", count[d[i]]);
	}
	return 0;
}

Measured memory_bytes: 3444
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

int phi(int n){
   int ret = n;
   for(int i = 2; i * i <= n; i++){
	   if( n % i == 0){
		   while(n % i == 0)
		     n /= i;
		    ret -= ret / i;  
		 }  
	 }
  if(n > 1) ret -= ret / n;
  return ret;	
}

void solve(){
    int n;
    cin >> n;
    int val = phi(n);
    cout << val << endl;
    
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
//const int mod = 1e9 + 7;
const int mod = 998244353;
const double eps = 1e-9;

/*{
  }*/

#define ll long long
class segtree
{
public:
  int n;
  vector<ll> dat;

  segtree(int n_)
  {
    n = 1;
    while(n < n_) n *= 2;
    dat.resize(2*n, inf);
  }

  void update(int k, ll v)
  {
    k += n-1;
//    dat[k] = v;
    chmin(dat[k], v);
    while(k > 0){
      k = (k-1)/2;
      dat[k] = min(dat[k*2+1], dat[k*2+2]);
    }
  }

  ll query(int a, int b, int k, int l, int r)
  {
    if(r <= a or b <= l) return inf;
    if(a <= l and r <= b) return dat[k];

    ll vl = query(a, b, k*2+1, l, (l+r)/2);
    ll vr = query(a, b, k*2+2, (l+r)/2, r);
    return min(vl, vr);
  }

  ll query(int a, int b)
  {
    return query(a, b, 0, 0, n);
  }
};

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

  vector<pair<pii, int>> q(m); 
  rep(i, 0, m) cin >> q[i].first.second >> q[i].first.first >> q[i].second;
  sort(all(q));

  segtree st(n+1);
  st.update(1, 0);
  rep(i, 0, m){
//    int l, r, c;
//    cin >> l >> r >> c;

    int l = q[i].first.second;
    int r = q[i].first.first;
    int c = q[i].second;
    int t = st.query(l, r+1);
    st.update(r, t+c);
  }

  int ans = st.query(n, n+1);
  if(ans == inf) cout << -1 << endl;
  else cout << ans << endl;


  return 0;
}



Measured memory_bytes: 4608
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {

	const int num = 1000;
	int a[num], b[num];
	int endOfInput;
	char op;
	int output[num];

	for (int i = 0; i < num; i++) {
		cin >> a[i] >> op >> b[i];

		if (op == '+') {
			output[i] = a[i] + b[i];
		}
		else if (op == '-') {
			output[i] = a[i] - b[i];
		}
		else if (op == '*') {
			output[i] = a[i] * b[i];
		}
		else if (op == '/') {
			output[i] = a[i] / b[i];
		}
		else if (op == '?') {
			endOfInput = i;
			break;
		}
	}

	for (int i = 0; i < endOfInput; i++) {
		cout << output[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3108
import re


def solve(s, t):
    s = s.replace('?', '.')
    ls, lt = len(s), len(t)
    if ls < lt:
        return 'UNRESTORABLE'
    ans = []
    for i in range(ls - lt + 1):
        m = re.match(s[i:i + lt], t)
        if m is None:
            continue
        ans.append((s[:i] + t + s[i + lt:]).replace('.', 'a'))
    if not ans:
        return 'UNRESTORABLE'
    return min(ans)


s = input().strip()
t = input().strip()

print(solve(s, t))


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <utility>
#include <tuple>
#include <cstdint>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <cctype>
#include <cmath>
#include <cstring>

using namespace std;

typedef long long    ll;
typedef long double  ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;

template <typename T> bool chmax(T &a, T& b) {if (a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, T& b) {if (a > b) {a = b; return true;} return false;}
#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define mset(x, val) memset(x,(val),sizeof(x))
#define cons(a, b) make_pair((a), (b))
#define car first
#define cdr second

#define endl '\n'
const ll   INF  = 0x7f7f7f7f7f7f7f7f;
const int  INFi = 0x7f7f7f7f;
const string YES = "Yes";
const string NO = "No";

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

bool solve(string a, string b) {
  ll x = stoi(a+b);
  rep(i, 1000) if (x==i*i) return 1;
  return 0;
}

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

  string a, b;
  cin >> a >> b;

  auto ans = solve(a, b);
  cout << (ans ? YES : NO) << endl;

  return 0;
}


Measured memory_bytes: 3016
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

N, X = map(int, input().split())
x = list(map(int, input().split()))
X_x = [0] * N
for i in range(N):
    X_x[i] = max(X-x[i], x[i]-X)
 
ans = gcd(*X_x)
print(ans)

Measured memory_bytes: 16280