akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<long long,long long>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define eb emplace_back

const int MOD1=1000000007;
const int MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const int dx[]={0,1,0,-1,1,-1,1,-1};
const int dy[]={1,0,-1,0,1,1,-1,-1};

#define unless(a) if(!(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(n);i++)
#define bitrep(i,s,n) for(int i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}
long long cutup(long long a,long long b){return (a+b-1)/b;}
long long popcnt(long long a){return __builtin_popcountll(a);}
template<class T,class U> inline bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template<class T,class U> inline bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}

struct edge{long long to,cost;};
struct edge2{long long from,to,cost;};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,l,t;
    cin>>n>>l>>t;
    vl x(n),w(n);
    rep(i,n)cin>>x[i]>>w[i];
    int ind=0;
    rep(i,n){
        if(w[i]==1){
            x[i]+=t;
            if(x[i]>=l){
                ind-=x[i]/l;
                x[i]%=l;
                if(ind<0){
                    ind%=n;
                    ind+=n;
                    ind%=n;
                }
            }
        }else{
            x[i]-=t;
            if(x[i]<0){
                ind+=-(x[i]-(l-1))/l;
                x[i]=(x[i]%l+l)%l;
                if(ind>=n){
                    ind%=n;
                }
            }
        }
    }
    sort(all(x));
    vl Ans(n);
    rep(i,n){
        Ans[ind]=x[i];
        ind++;
        if(ind>=n)ind-=n;
    }
    rbf(a,Ans)cout<<a<<endl;
}

Measured memory_bytes: 5504
#include <iostream>
using namespace std;
int main(){
    int n, tmp, s = 0;
    cin >> n;
    tmp = n;
    while(tmp){
        s += tmp%10;
        tmp /= 10;
    }
    if(n%s == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
vector<ll> x;
pair <ll,ll> p[110000];
ll a[100],b[100],c[110];
int main(){
  ll n,sum=0,ps=0;
  cin>>n;
  rep(i,0,n){cin>>a[i];a[i]-=1;}
  rep(i,0,n)cin>>b[i];
  rep(i,0,n-1)cin>>c[i];
  sum=b[a[0]];
  rep(i,0,n-1){
    if(a[i]==a[i+1]-1){sum+=b[a[i+1]]+c[a[i]];}
    else sum+=b[a[i+1]];
  }
  cout<<sum;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mx=1e9;
int s;
bool check(int a,int b,int c,int d)
{
	int tmp1=0,tmp2=0;
	if(min(a,c)<0)
	{
		tmp1=-min(a,c);
	}
	if(min(b,d)<0)
	{
		tmp2=-min(b,d);
	}
	if(a+tmp1<=mx&&c+tmp1<=mx&&b+tmp2<=mx&&d+tmp2<=mx)
	{
		printf("%lld %lld %lld %lld %lld %lld",tmp1,tmp2,a+tmp1,b+tmp2,c+tmp1,d+tmp2);
		return 1;
	}
	return 0;
}
main()
{
	scanf("%lld",&s);
	int t=max(1ll,(int)sqrt(s)-1);
	for(;t<=1e9;t++)
	{
		int tmp=t*t-s;
		if(tmp<0)continue;
		if(tmp==0)
		{
			check(0,t,t,0);
			return 0;
		}
		for(int i=sqrt(tmp);i>=1;i--)
		{
			if(tmp%i==0)
			{
				if(check(t,i,tmp/i,t))return 0;
			}
		}
	}
}
/*
999469992399999999
1000000000000000000
*/

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

class vec{
public:
	double x,y;
	vec(){
		x = y = 0.0;
	}
	vec(double x,double y){
		this->x = x;
		this->y = y;
	}
	vec operator+(vec &r) const{
		return vec(x+r.x,y+r.y);
	}
	vec operator-(vec &r) const{
		return vec(x-r.x,y-r.y);
	}
	void operator=(vec &r){
		this->x = r.x;
		this->y = r.y;
	}
	double norm2(){
		return x*x+y*y;	
	}
};

double dot(vec v,vec u){
	return v.x*u.x + v.y*u.y;
}
double closs(vec v,vec u){
	return v.x*u.y - v.y*u.x;
}


int main(){
	vec p0,p1,p2;
	int q;
	cin >> p0.x >> p0.y >> p1.x >> p1.y;
	cin >> q;
	for(int i = 0; i < q; i++){
		cin >> p2.x >> p2.y;
		vec v = p1 - p0;
		vec u = p2 - p0;
		double cl = closs(u,v);
		if(cl < 0){
			cout << "COUNTER_CLOCKWISE" << endl;
		}
		else if (cl > 0){
			cout << "CLOCKWISE" << endl;
		}
		else if (cl == 0){
			double dt = dot(u,v);
			if(dt < 0){
				cout << "ONLINE_BACK" << endl;
			}
			else if (u.norm2() > v.norm2()){
				cout << "ONLINE_FRONT" << endl;
			}
			else{
				cout << "ON_SEGMENT" << endl;
			}
		}
	}

	return 0;
}



Measured memory_bytes: 3224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            
            //文字列と命令数の入力読取。
            string strWord = Console.ReadLine();
            string strNum = Console.ReadLine();
            int intNum = int.Parse(strNum);
            
            //命令の入力を読み取り、処理。
            for(int order = 0; order < intNum; order++){
                string strOrder =Console.ReadLine();
                Transformation insT = new Transformation(strWord, strOrder);
                strWord = insT.GetWord();
            }
            
        }
        
    }
    
    class Transformation{
        
        private string strWord;
        private string strOrder;
        
        public Transformation(string strWord, string strOrder){
            this.strWord = strWord;
            this.strOrder = strOrder;
            Judge();
        }
        
        private void Judge(){
        
            //命令の詳細をそれぞれ変数に格納。
            string[] orderArray = strOrder.Split(' ');
            string strOperation = orderArray[0];
            string strStart = orderArray[1];
            int intStart = int.Parse(strStart);
            string strEnd = orderArray[2];
            int intEnd = int.Parse(strEnd);

            //文字列操作。            
            char[] chWord = strWord.ToCharArray();
            if(strOperation == "print"){
                for(int index = intStart; index <= intEnd; index++){
                    Console.Write(chWord[index]);
                }
                Console.WriteLine();
            }else if(strOperation == "reverse"){
                //int intReverseEnd = (intEnd - intStart) / 2;
                for(int index = intStart; index <= intEnd; index++){
                    char chTemp = chWord[index];
                    chWord[index] = chWord[intEnd];
                    chWord[intEnd] = chTemp;
                    intEnd--;
                }
                strWord = "";
                for(int index = 0; index < chWord.Length; index++){
                    strWord += chWord[index].ToString();
                }
            }else{
                char[] chReplace = orderArray[3].ToCharArray();
                int intForEnd = intEnd - intStart;
                for(int index = 0; index <= intForEnd; index++){
                    chWord[intStart + index] = chReplace[index];
                }
                strWord = "";
                for(int index = 0; index < chWord.Length; index++){
                    strWord += chWord[index].ToString();
                }
            }
            
        }
        
        public string GetWord(){
            return strWord;
        }
        
    }

}



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

using namespace std;

typedef long long LL;

const int maxn=3005;
const int INF=0x3f3f3f3f;
const int MOD=1e9+7;

struct Question{
	int l,r;
}q[maxn];

LL C[maxn][maxn],dp[maxn][maxn];
int sum[maxn];
char s[maxn];
int n,m;

void pre_C(){
	for(int i=0;i<=n;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++){
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;
		}
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	pre_C();
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+s[i]-'0';
	for(int i=1;i<=m;i++){
		scanf("%d%d",&q[i].l,&q[i].r);
		if(q[i].r<=q[i-1].r)m--,i--;
	}
	
	q[m+1].l=n+1;q[m+1].r=n+1;
	sum[n+1]=sum[n];
	dp[1][sum[q[1].r]-sum[q[1].l-1]]=1;
	for(int i=1;i<=m;i++){
		if(q[i].r<q[i+1].l){
			int len=q[i].r-q[i].l+1;
			for(int j=0;j<=len;j++){
				dp[i+1][sum[q[i+1].r]-sum[q[i+1].l-1]]+=dp[i][j]*C[len][j]%MOD,dp[i+1][sum[q[i+1].r]-sum[q[i+1].l-1]]%=MOD;
			}
		}
		else{
			int LEN=q[i].r-q[i].l+1;//qujianchang
			int len=q[i].r-q[i+1].l+1;//jiaojichang
			int pre=q[i+1].l-q[i].l;//qianzhui
			for(int j=0;j<=LEN;j++)
				for(int k=max(0,j-pre);k<=j&&k<=len;k++){
					dp[i+1][sum[q[i+1].r]-sum[q[i].r]+k]+=dp[i][j]*C[pre][j-k]%MOD,dp[i+1][sum[q[i+1].r]-sum[q[i].r]+k]%=MOD;
				}
		}
	}
	printf("%lld\n",dp[m+1][0]);
	return 0;
}

Measured memory_bytes: 104832
N = gets.to_i
As = gets.split.map(&:to_i)

as = As.sort
am = as.last
h = Array.new(am + 1, true)
as.each_with_index do |a, i|
  next unless h[a]
  h[a] = false if a == as[i + 1]
  (2*a).step(am, a){h[_1] = false}
end
puts as.count{h[_1]}

Measured memory_bytes: 38252
import java.util.Scanner;

public class Main{

public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
  int a = scanner.nextInt();
  int b = scanner.nextInt();
  int area = area(a, b);
  int length = length(a, b);

  System.out.println(area + " " + length);
}

public static int area(int a, int b){
  return a * b;
}

public static int length(int a, int b){
  return (a + b) * 2;
}
}

Measured memory_bytes: 26060
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int a[][] = new int[M][2];
		for(int i = 0; i < M; i++) {
			a[i][0] = sc.nextInt();
			a[i][1] = sc.nextInt();
		}
		//Arrays.sort(a, Comparator.comparingInt(o -> o[1]));
		Arrays.sort(a, Comparator.comparingInt(o -> o[0]));
		
		int min = Integer.MAX_VALUE;
		int ans = 0;
		for(int i = 0; i < M; i++) {
			if(a[i][0] >= min) {
				ans++;
				min = a[i][1];
			} else {
				min = Math.min(min, a[i][1]);
			}
		}
		ans++;
		
		System.out.println(ans);
	}
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────────────────

int main() {
	string s; cin >> s;
	int cnt = 0;
	for (int i = 0; i < s.size() / 2; ++i) {
		if (s[i] != s[s.size() - i - 1]) cnt++;
	}
	cout << cnt << endl;
}

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

int main() {
    string s;
    cin >> s;
    
    sort(s.begin(), s.end());
    int count = 1;
    char ref = s.at(0);
    
    for(int i = 1; i < s.size(); i++) {
        if (s.at(i) != ref) {
            count++;
            ref = s.at(i);
        }
    }
    
    if(count == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

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

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    int n,m;
    cin >> n >> m;

    vector<pii> students(n);
    for(auto &x:students)cin >> x.first >> x.second;
    vector<pll> plane(m);
    for(auto &x:plane)cin >> x.first >> x.second;

    vector<ll> ans(n,0);
    for(int i=0;i<n;i++){
        ll maxval=INF;
        int anspt;
        int x=students[i].first,y=students[i].second;
        for(int j=0;j<m;j++){
            if(maxval>abs(plane[j].first-x)+abs(plane[j].second-y)){
                maxval=abs(plane[j].first-x)+abs(plane[j].second-y);
                anspt=j+1;
            }
        }
        ans[i]=anspt;
    }

    for(auto x:ans)cout << x << endl;

    return 0;
}


Measured memory_bytes: 3640
program sequence_sum
  implicit none
  integer(8) :: n, m, num, a(0:100000) = 0
  integer :: x, b(0:100000) = 0, period, offset, rem, i
  read(*,*) n, x, m
  if (n == 1) then
    write(*,'(i0)') x
    stop
  end if
  a(1) = x
  b(x) = 1
  do i = 2, int(m) + 1
    x = int(mod(int(x, 8) * x, m))
    a(i) = a(i - 1) + x
    if (i == n) then
      write(*,'(i0)') a(i)
      stop
    end if
    if (b(x) > 0) then
      offset = b(x) - 1
      period = i - offset - 1
      exit
    end if
    b(x) = i
  end do
  num = (n - offset) / period
  rem = int(n - offset - num * period)
  write(*,'(i0)') (a(offset + period) - a(offset)) * num + a(offset + rem)
end program sequence_sum

Measured memory_bytes: 3568
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    for(int i=0; i<n; ++i)
        cin >> s[i] >> t[i];

    string x;
    cin >> x;
    int i = 0;
    while(s[i] != x)
        ++ i;

    int ans = 0;
    for(++i; i<n; ++i)
        ans += t[i];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
		
        boolean first=true;
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int result=0;
            
            while ((line = br.readLine()) != null) {
            	if(line.equals("=")){
            		break;
            	}else if(first){
            		result=Integer.parseInt(line);
            		first=false;
            	}else{
            		if(line.equals("+")){
            			result+=Integer.parseInt(br.readLine());
            		}else if(line.equals("-")){
            			result-=Integer.parseInt(br.readLine());
            		}else if(line.equals("/")){
            			result/=Integer.parseInt(br.readLine());
            		}else if(line.equals("*")){
            			result*=Integer.parseInt(br.readLine());
            		}
            	}
            	
            }
            System.out.println(result);
        }
    }

}

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

using namespace std;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, h;
  while(cin >> n >> h && (n || h)){
    int ans = n * n * n;
    set<pair<int, pair<int, int> > > ps;
    for(int i = 0; i < h; i++){
      string str;
      int p[2];
      cin >> str >> p[0] >> p[1];
      for(int j = 1; j <= n; j++){
        if(str == "xy"){
          ps.insert(make_pair(p[0], make_pair(p[1], j)));
        }
        if(str == "xz"){
          ps.insert(make_pair(p[0], make_pair(j, p[1])));
        }
        if(str == "yz"){
          ps.insert(make_pair(j, make_pair(p[0], p[1])));
        }
      }
    }
    ans -= ps.size(); 
    cout << ans << "\n";
  }
  return 0;
}

Measured memory_bytes: 4348
from math import ceil
ans = float('inf')
D, G = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(D)]
for i in range(1 << D):
    point = 0
    count = 0
    tmp = 0
    for j in range(D):
        if ((i >> j) & 1) == 0:
            if (100 * j + 100) * p[j][0] + p[j][1]:
                tmp = j
        else:
            point += (100 * j + 100) * p[j][0] + p[j][1]
            count += p[j][0]
    if G - point > 100 * (tmp + 1) * p[tmp][0]:
        continue
    count += max(0, ceil((G - point) / (100 * (tmp + 1))))
    ans = min(ans, count)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL<<60;
const long long MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int H,W;
string field[60];
int dist[60][60];

void bfs() {
    dist[0][0]=1;
    queue<P> q;
    q.push(P(0,0));
    while (!q.empty()) {
        P p=q.front();q.pop();
        rep(i,4) {
            int ny=p.first+dy[i];
            int nx=p.second+dx[i];
            if (ny>=0&&ny<H&&nx>=0&&nx<W&&dist[ny][nx]==-1&&field[ny][nx]=='.') {
                dist[ny][nx]=dist[p.first][p.second]+1;
                q.push(P(ny,nx));
            }
        }
    }
}

int main () {

    cin>>H>>W;
    rep(i,H) {
        cin>>field[i];
    }
    int cnt=0;
    rep(i,H) {
        rep(j,W) {
            dist[i][j]=-1;
            if (field[i][j]=='#') cnt++;
        }
    }
    bfs();
    if(dist[H-1][W-1]==-1) cout<<-1<<endl;
    else cout<<H*W-cnt-dist[H-1][W-1]<<endl;

}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    int a[50], b[50];
    for(int i=0;i<n;++i) cin >> a[i];
    for(int i=0;i<n;++i) cin >> b[i];
    
    static bool init[50][51], dp[50][51];
    for(int i=0;i<n;++i) init[i][a[i]] = true;
    int64_t ans = 0;
    
    for(int k=51;k>0;--k){
        for(int i=0;i<n;++i) for(int v=0;v<=50;++v) dp[i][v] = init[i][v];
        for(int r=k-1;r>0;--r){
            for(int i=0;i<n;++i){
                for(int v=0;v<=50;++v){
                    if(dp[i][v]) dp[i][v%r] = true;
                }
            }
        }
        bool ok = true;
        for(int i=0;i<n;++i) ok = ok && dp[i][b[i]];
        if(!ok && k == 51){ cout << -1 << endl; return 0; }
        if(!ok){
            ans |= INT64_C(1) << k;
            for(int i=0;i<n;++i){
                for(int v=0;v<=50;++v){
                    if(init[i][v]) init[i][v%k] = true;
                }
            }
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
v = input().split(" ")
x = int(v[0])
k = int(v[1])
d = int(v[2])

if (x == 0):
    if (k % 2 == 0):
        ans = 0
    else:
        ans = d
else:
    if ((k * d) > abs(x)):
        y = abs(x) // d
        ans = abs(abs(x) - y * d)
        if ((k - y) % 2 == 1):
            ans = abs(d - ans)
    else:
        ans = abs(x) - k * d
print(ans)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0){
            return false;
        }
    }
    return true;
}

int main()
{
	ll n,k,r,s,p,ans=0;
	string t;
	cin >> n >> k >> r >> s >> p >> t;
	rep(i,SIZE(t)){
		if(i+k<SIZE(t) && t[i]==t[i+k] && t[i]!='x'){
			t[i+k]='x';
		}
	}
	rep(i,SIZE(t)){
		if(t[i]=='r') ans+=p;
		else if(t[i]=='s') ans+=r;
		else if(t[i]=='p') ans+=s;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static long[] kaijo;
	 static long[] kaiinv;
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();
	        String S = sc.next();
	        char[] c = S.toCharArray();
	        int[] m = new int[26];
	        for(int i=0;i<N;i++) {
	        	m[c[i]-'a']++;
	        }
	        long ans=1;
	        for(int i=0;i<26;i++) {
	        	ans=ans*(m[i]+1)%mod;
	        }
	        ans=(ans-1+mod)%mod;
	        
	        System.out.println(ans);
	 }

}

Measured memory_bytes: 26964
import java.util.*;
import java.math.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int n;
	static BigInteger a, b;
	public static void main(String[] args) {
		while(read()){
			
		}
	}
	static boolean read(){
		if(!sc.hasNext())return false;
		n = sc.nextInt();
		for(int i = 0; i < n; i++){
			a = sc.nextBigInteger(); b = sc.nextBigInteger();
			solve();
		}
		return true;
	}
	static void solve(){
		if(a.toString().length() > 80 || b.toString().length() > 80 || a.add(b).toString().length() > 80){
			System.out.println("overflow");
		}else{
			System.out.println(a.add(b));
		}
	}
}

Measured memory_bytes: 0
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
#include<cmath>
#define MAX 100005
typedef long long LL;

using namespace std;

struct node{
	int value;
	int num;	
};
node a[MAX];
int main()
{
	int n;
	LL sum = 0;
	cin >> n;
	for(int i = 0;i <= MAX;i++)
	{
		a[i].num = 0;
		a[i].value = i;
	}
	for(int i = 1;i <= n;i++)
	{
		int b;
		cin >> b;
		a[b].value = b;
		a[b].num++;
		sum += b;
	}
	int q;
	cin >> q;
	for(int i = 0;i < q;i++)
	{
		int b,c;
		cin >> b >> c;
		if(a[b].num == 0)
			cout << sum << endl;
		else
		{
			sum += a[b].num*(c-a[b].value);
			a[c].num += a[b].num;
			a[b].num = 0;
			cout << sum << endl;
		}
	}
	return 0;
}

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

#define MAX 25
#define NIL -1

struct Node{
    int parent;
    int left;
    int right;
} info[MAX];

/*先行順巡回*/
void Preorder(int node){
    if(node == NIL){
        return;
    }
    cout << " " << node;
    Preorder(info[node].left);
    Preorder(info[node].right);
}

/*中間順巡回*/
void Inorder(int node){
    if(node == NIL){
        return;
    }
    Inorder(info[node].left);
    cout << " " << node;
    Inorder(info[node].right);
}

/*後行順巡回*/
void Postorder(int node){
    if(node == NIL){
        return;
    }
    Postorder(info[node].left);
    Postorder(info[node].right);
    cout << " " << node;
}

int main() {

    int n;
    cin >> n;
    rep(i, n){ //初期化
        info[i].parent = NIL;
    }

    int id, left, right;
    rep(i, n){
        cin >> id >> left >> right;
        info[id].left = left;
        info[id].right = right;
        if(left != NIL){
            info[left].parent = id;
        }
        if(right != NIL){
            info[right].parent = id;
        }
    }

    int root;
    rep(i, n){
        if(info[i].parent == NIL){
            root = i;
        }
    }

    cout << "Preorder" << endl;
    Preorder(root);
    cout << "\n";
    cout << "Inorder" << endl;
    Inorder(root);
    cout << "\n";
    cout << "Postorder" << endl;
    Postorder(root);
    cout << "\n";

    return 0;
}


Measured memory_bytes: 3104
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end

sx,sy,ex,ey = inp
n = inp[0]
t = []
rec = na(n+2,1e100)
t[0] = [sx,sy,0]
t[1] = [ex,ey,0]
n.times do 
  t.push(inp)
end
ind = 0
tab = (1..n+1).to_a
rec[0] = 0
(n+1).times do
  max = 1e100
  nex = -1
  tab.each do |d|
    kyori = rec[ind] + [Math.hypot(t[ind][0] - t[d][0], t[ind][1] - t[d][1]) - (t[ind][2] + t[d][2]) ,0].max
    rec[d] = kyori if rec[d] > kyori
    if max > rec[d]
      max = rec[d]
      nex = d
    end
  end
  ind = nex
  tab.delete(ind)
  rererereerer[missmissniu] += [waawawawawwa[bugbugbubg]] if(nex < 0)
end
p rec[1]

Measured memory_bytes: 4220
#include <stdio.h>

int main(void){
  int N, D;
  int i=1;
  int S;
  
  scanf("%d %d", &N, &D);
  S = i*2*D+i;
  
  if(S < N){
    do{
      i++;
      S = i*2*D+i;
    }while(S < N);
  }
    
  printf("%d", i);
  
  return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline

N = int(input())
S = input()[:-1]
accR = [0]
accG = [0]
accB = [0]

for i in range(N):
    accR.append(accR[-1]+(1 if S[i]=='R' else 0))
    accG.append(accG[-1]+(1 if S[i]=='G' else 0))
    accB.append(accB[-1]+(1 if S[i]=='B' else 0))

ans = 0

for i in range(N):
    for j in range(i+1, N):
        if S[i]==S[j]:
            continue
        
        s = {S[i], S[j]}
        k = 2*j-i
        
        if 'R' not in s:
            ans += accR[N]-accR[j+1]
            
            if k<N and S[k]=='R':
                ans -= 1
        elif 'G' not in s:
            ans += accG[N]-accG[j+1]
            
            if k<N and S[k]=='G':
                ans -= 1
        else:
            ans += accB[N]-accB[j+1]
            
            if k<N and S[k]=='B':
                ans -= 1
    
print(ans)

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

int main(){
  int N,max,mplace;
  bool flag = 0;
  cin >> N;
  vector<int> array(N);
  vector<int> ans(N);
  for(int i=0;i<N;i++)
    cin >> array.at(i);
  for(int j=0;j<N;j++){
    max = 0;
  	for(int k=0;k<array.size();k++){
    	if(array.at(k)==k+1&&max<=array.at(k)){
      		max = array.at(k);
      		mplace = k;
    	}
  	}
    if (max == 0){
      flag = 1;
      break;
    }
    ans.at(j) = array.at(mplace);
  	array.erase(array.begin()+mplace);
  }
  if(flag)
    cout << -1 << endl;
  else{
    reverse(ans.begin(),ans.end());
    for(int m;m<N;m++)
    cout << ans.at(m)<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  int q;
  cin >> q;
  string x, y;
  rep(_, q){
    cin >> x >> y;
    int n = x.size();
    int m = y.size();
    vector<vector<int>> dp(n+1, vector<int>(m+1, 0));
    rep(i, n)rep(j, m){
      if (x[i] == y[j]) dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1);
      dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j]);
      dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1]);
    }
    cout << dp[n][m] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 6836
<?php
fscanf(STDIN, "%d" , $N);

$ans = PHP_INT_MAX;

for ($i = 1; $i < $N; $i++) {
    $j = $N - $i;
    $numI = array_sum(str_split(strval($i)));
    $numJ = array_sum(str_split(strval($j)));
    $prev = $ans;
    $ans = min($numI + $numJ, $ans);
    // if ($prev != $ans) {
    //     echo "{$i}+{$j} {$ans}\n";
    // }
}
echo $ans . PHP_EOL;


Measured memory_bytes: 5240
#include<cstdio>
#define MAX 10000
#define NIL -1

struct Node { int parent,left,right;};

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){
  if(u==NIL)return;
  D[u]=d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u){
  int h1=0,h2=0;
  if(T[u].left!=NIL)h1=setHeight(T[u].left)+1;
  if(T[u].right!=NIL)h2=setHeight(T[u].right)+1;
  return H[u]=(h1>h2 ? h1:h2);
}
//節点uの兄弟を返す
int getSibling(int u){
  if(T[u].parent==NIL)return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
    return T[T[u].parent].right;
  return NIL;
}

void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg=0;
  if(T[u].left != NIL)deg++;
  if(T[u].right != NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u] );
  
  if(T[u].parent == NIL){
    printf("root\n");
  }else if(T[u].left == NIL && T[u].right == NIL){
    printf("leaf\n");
  }else{
    printf("internal node\n");
  }
}

int main(){
  int v,l,r,root=0;
  scanf("%d",&n);
  
  for (int i = 0; i < n; i++) {
    T[i].parent=NIL;
  }
  
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d",&v,&l,&r);
    T[v].left=l;
    T[v].right=r;
    if(l!=NIL)T[l].parent=v;
    if(r!=NIL)T[r].parent=v;
  }
  
  for(int i=0;i<n;i++)if(T[i].parent==NIL)root=i;
  
  setDepth(root,0);
  setHeight(root);
  
  for(int i=0;i<n;i++)print(i);
  
  return 0;
  
}



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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  char c;
  cin >> c;
  putchar(c+1);
  
  cout << "\n";
  return 0;
}
/***** MAIN *****/


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

int main(){

  int64_t n, y;
  cin >> n >> y;
  
  y= y/1000;
  
  bool flaga=0, flagb=0;
  for(int i=0; i<=n; i++){
  	for(int j=0; j<=(n-i); j++){
    	for(int k=0; k<=(n-i-j); k++){
        	if((10*i + 5*j + k) == y && (i + j + k) == n){
            	cout << i << " " << j << " " << k << endl;
              	flaga =1;
                flagb =1;
              	break;
            }
        }
      if(flaga) break;
    }
    if(flagb) break;
  }
 if(flaga==0){
 	cout << -1 << " " << -1 << " " << -1 << endl;
 }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1010];
int main()
{
	int n, m;
	scanf("%d",&n);
	int i;
	for(i=0; i<n; i++) scanf("%d",&a[i]);
	scanf("%d",&m);
	while(m--)
	{
		int l, mid, r;
		scanf("%d%d%d",&l,&mid,&r);
		swap_ranges(l+a, mid+a, r+a);
	}
	for(i=0; i<n; i++)
	{
		if(i == n-1) printf("%d\n",a[i]);
		else printf("%d ",a[i]);
	}
	return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define random_shuffle asdasdd

const int MAXN = 105000;

int n, m;
vector < pair<int, int> > g[MAXN];
int inLeft[MAXN];
int x[MAXN];
bool used[MAXN];

void dfs(int v, int newX) {
  used[v] = true;
  x[v] = newX;
  for (pair<int, int> p : g[v]) {
    int to = p.first, dist = p.second;
    if (!used[to]) {
      dfs(to, newX + dist);
    }
  }
}

int main() { 

  scanf("%d %d", &n, &m);

  for (int i = 0; i < m; i++) {
    int from, to, d;
    scanf("%d %d %d", &from, &to, &d);
    from--; to--;
    g[from].push_back(make_pair(to, d));
    if (d != 0) {
      inLeft[to]++;
    }
    g[to].push_back(make_pair(from, -d));
  }

  for (int i = 0; i < n; i++) {
    if (!used[i] && inLeft[i] == 0) {
      dfs(i, 0);
    }
  }

  for (int i = 0; i < n; i++) {
    for (pair<int, int> p : g[i]) {
      int to = p.first, dist = p.second;
      if (x[i] + dist != x[to]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 11648
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
using ll = long long;
#define MOD 1000000007
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    for(int i = (M+N-1)/N; i > 0; i--)
    {
        if (M % i == 0) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) begin(x),end(x)
#define F(i,n) for (int i = 0; i < n; ++i)
#define F1(i,n) for (int i = 1; i <= n; ++i)
#define dbg(x) cerr << #x << " = " << x << endl
#define dbgg(x) cerr << #x << " = " << x << ' '
#define T(x) x[pool]
#define mineq(x,y) { if ((x) > (y)) (x) = (y); }
#define maxeq(x,y) { if ((x) < (y)) (x) = (y); }
#define MEOW cout << "meowwwww" << '\n'; system("pause");
#define int long long
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

template<typename T>
ostream& operator <<(ostream &s, const vector<T> &c)
{
	s << "[ "; for (auto it : c) s << it << " "; s << "\b]\n";
	return s;
}

template<typename T>
ostream& operator <<(ostream &s, const pair<int, T> &c)
{
	s << "[ "; cout << c.fi << " , " << c.se << " ] ";
	return s;
}

int n;
string s;

void input()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> s;
}

void solve()
{
	vi ze;
	n = s.length();
	int c0 = 0;
	int c1 = 0;
	int tw = 0;
	int one = 0;
	for (int i = 0; i < n; ++i)
	{
		if (s[i] == '0')
		{
			if (c1 > 0) 
			{
				if (c1 & 1)
				{
					ze.pb(c0);
					c0 = 0;
				}
				tw += c1 / 2;
				c1 = 0;
			}
			++c0;
		} else
			++c1, ++one;
	}
	if (c1 > 0)
	{
		if (c1 & 1)
		{
			ze.pb(c0);
			c0 = 0;
		}
		tw += c1 / 2;
		c1 = 0;
	}
	int ans = 0;
	F1 (i, one) ans += (i + 1) / 2;
	ans += (n - one) * tw;
	int pre = 0, suf = 0;
	for (int i = 0; i < ze.size(); ++i)
	{
		if (i == 0)
		{
			suf += ze[i];
		} else
		{
			suf += ze[i] - 1;
			++pre;
		}
		ans += (pre + 1) / 2 + suf / 2 + n - one - pre - suf;
	}
	cout << ans << '\n';
}

main()
{
	input();
	solve();
}


Measured memory_bytes: 4360
import java.util.Scanner;

public class Main {
	private static final int Y = 1;
	private static final int X = 0;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int[][][] t = new int[100][100][2];
		int n;
		while ((n = in.nextInt()) > 0) {
			// System.out.println("n=" + n);
			for (int y = 0; y < n; y++) {
				for (int x = 0; x < n; x++) {
					t[x][y][X] = in.nextInt();
					t[x][y][Y] = in.nextInt();
				}
			}
			int count = 0;
			int stepNum = 0;
			for (int startX = 0; startX < n; startX++) {
				for (int startY = 0; startY < n; startY++) {
					stepNum -= 1;
					int posiX = startX, posiY = startY;
					int nextX = t[posiX][posiY][X], nextY = t[posiX][posiY][Y];
					while (nextX >= 0) {
						t[posiX][posiY][X] = stepNum;
						posiX = nextX;
						posiY = nextY;
						nextX = t[posiX][posiY][X];
						nextY = t[posiX][posiY][Y];
						if (nextX == stepNum) {
							count++;
						}
					}

				}
			}
			// for (int x = 0; x < n; x++) {
			// for (int y = 0; y < n; y++) {
			// System.out.print(t[x][y][X] + " ");
			// }
			// System.out.println();
			// }
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 61964
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int N, L, minA, sum = 0, index = 0;
	cin >> N >> L;
	int a[N];
	for(int i = 0; i < N; i++){
		a[i] = L + i;
	}
	minA = abs(a[0]);
	for(int i = 1; i < N; i++){
		if(abs(a[i]) < abs(minA)){
			minA = abs(a[i]);
			index = i;
		}
	}
	for(int i = 0; i < N; i++){
		sum += a[i];
	}
	sum -= a[index];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
vector<int> enum_div(int n)//nの約数を列挙
{
	vector<int> ret;
	for(int i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> v = enum_div(n);
    int ans = INF;
    rep(i, v.size()) {
        int l = n / v[i];
        int r = v[i];
        int a = to_string(l).length();
        int b = to_string(r).length();
        ans = min(ans, max(a,  b));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
typedef long long int ll;
#define pb push_back
#define endl        '\n'
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    int a,b;
    cin>>a>>b;
    if(a<=9&&b<=9)
        cout<<a*b<<endl;
    else cout<<-1;

}


Measured memory_bytes: 256
import math

As,Bs=input().split()
if As=="0" or Bs=="0.00":
    print("0")
else:
    A=int(As)
    Bs=Bs.replace('.','')
    B=int(Bs)
    ans=int(A)*int(B)
    anss=str(ans)
    if len(anss)<3:
        print("0")
    else:
        print(anss[:-2])

Measured memory_bytes: 9192
#include "bits/stdc++.h"

using namespace std;



int main(){

	int a[3] = {-1,-1,-1};
	int n,m,s,c;
	bool ac = true;

	cin >>n>>m;

	for (int i = 0; i < m; i++){
		cin >> s >> c;
		if (a[(3-n)+s-1] == -1 || a[(3-n)+s-1] == c) a[(3-n)+s-1] = c;
		else ac = false;
	}


	if (n > 1 && a[3 - n] == 0){
		ac = false;	
	}

	if (n > 1 && a[3 - n] == -1){
		a[3 - n] = 1;	
	}

	if (ac) {
		for (int i = 3-n; i < 3; i++){
			cout << ( (a[i]==-1) ? 0 : a[i])  ;
		}
		cout << endl;
	}
	else{
		cout << -1 << endl;
	}
	cin >> n;
	return 0;

	
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b, c, d; cin >> a >> b >> c >> d;
    for (;;) {
        c -= b;
        if (c <= 0) {
            puts("Yes");
            return 0;
        }
        a -= d;
        if (a <= 0) {
            puts("No");
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int n,m,q;
  cin >> n >> m >> q;
  vvi data(n+1,vi(n+1,0));
  rep(i,m){
    int x,y;
    cin >> x >> y;
    data.at(x).at(y)++;
  }
  vector<vector<long>> sum(n+1,vector<long>(n+1,0));
  rep(i,n){
    rep(j,n){
      sum.at(i+1).at(j+1) = sum.at(i+1).at(j) + data.at(i+1).at(j+1);
    }
  }
  rep(i,q){
    int x,y;
    cin >> x >> y;
    long ans = 0;
    for(int i=x;i<=y;i++){
      ans += (sum.at(i).at(y) - sum.at(i).at(x-1));
    }
    cout << ans << endl;
  }
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& e : a) {
    cin >> e;
  }
  if (n & 1) {
    if (accumulate(begin(a), end(a), 0LL) & 1) {
      cout << "First\n";
    } else {
      cout << "Second\n";
    }
  } else {
    int even = count_if(begin(a), end(a), [](int x) { return x % 2 == 0; });
    int mn = *min_element(begin(a), end(a));
    int mx = *max_element(begin(a), end(a));
    if (even & 1) {
      if (mn == mx and mn % 2 == 0) {
        cout << "Second\n";
      } else {
        cout << "First\n";
      }
    } else {
      if (mn & 1) {
        cout << "First\n";
      } else {
        cout << "Second\n";
      }
    }
  }
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
// int gcd(int a,int b)
// {
// 	if(b==0)
// 	return a;
	
// 	return gcd(b,a%b);
// }
ll power(ll x,ll y)
{
	ll res=1;
	x=x;
	while(y>0)
	{
		if(y&1)
		res=(res*x);
		
		y=y>>1;
		x=(x*x);
	}
	return res;
}

int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 ll n;
	 cin>>n;
	 ll N=n;
	 vector<pair<ll,ll>> v;
	 ll c=0;
	 while(n%2==0)
	 {
	 	n=n/2;
	 	c++;
	 }
	 if(c!=0)
	 v.push_back({2,c});
	 for(ll i=3;i<=sqrt(n);i+=2)
	 {
	 	if(n%i==0)
	 	{
	 		c=0;
	 		while(n%i==0)
	 		{
	 			n=n/i;
	 			c++;
	 		}
	 		v.push_back({i,c});
	 	}
	 }
	 if(n!=1)
	 v.push_back({n,1});
	 
	 ll ans=0;
	 for(ll i=0;i<(int)v.size();i++)
	 {
	 	for(ll p=1;p<=v[i].second;p++)
	 	{
	 		ll z=power(v[i].first,p);
	 		if(N%z==0)
	 		{
	 			N=N/z;
	 			ans++;
	 		}
	 	}
	 	if(N==1)
	 	break;
	 }
	 cout<<ans;
	 return 0;
}

Measured memory_bytes: 3676
import java.util.ArrayDeque

//

fun main() {
    msolutions2020c()
}

fun msolutions2020c() {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val a = readLine()!!.split(" ").map { it.toLong() }
    val queue = ArrayDeque<Long>()
    queue.addAll(a.subList(0, k))
    for (i in k until n) {
        val out = queue.poll()
        val next = a[i]
        if (next.toDouble() / out > 1.0) {
            println("Yes")
        } else {
            println("No")
        }
        queue.add(next)
    }
}


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

#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,vector<int> > piv;
typedef vector< vector<int> > vvi;

int g[1002][1002];
int s, t;
vector<int> res;
bool visit[1002];
int m, n;

bool dfs(int p) {
	if(p == t) {
		res.push_back(p);
		return true;
	}
	rep(i, n+m+2) {
		if( !visit[i] && g[p][i] ) {
			visit[i] = true;
			if( dfs(i) ) {
				res.push_back(p);
				return true;
			}
		}
	}
	return false;
}

int main() {
	while(cin >> m >> n, m) {
		memset(g, 0, sizeof(g));
		vector<int> b(m), r(n);
		rep(i,m) {
			cin >> b[i];
		}
		rep(i,n) {
			cin >> r[i];
		}
		rep(i, m) {
			rep(j, n) {
				g[i][j+m] = ( __gcd(b[i], r[j]) > 1 ? 1 : 0);
				g[j+m][i] = 0;
			}
		}
		s = m+n;
		t = m+n+1;
		rep(i, m) {
			g[s][i] = 1;
		}
		rep(i, n) {
			g[i+m][t] = 1;
		}
		while(1) {
			memset(visit, 0, sizeof(visit));
			res.clear();
			if( dfs(s) ) {
				reverse(res.begin(), res.end());
				rep(i, res.size()-1) {
					g[res[i]][res[i+1]] = 0;
					g[res[i+1]][res[i]] = 1;
				}
			} else break;
		}
		int cnt = 0;
		rep(i, m) {
			rep(j, n) {
				if( g[j+m][i] ) {
					cnt++;
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 5180