akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)








int main() {
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    ll sum1 = 0, sum2 = 0;
    REP(i, n){
        cin >> a[i];
        sum1 += a[i];
    }
    REP(i, n){
        cin >> b[i];
        sum2 += b[i];
    }
    if(sum1 < sum2){
        cout << -1 << endl;
        return 0;
    }
    
    ll k = 0, ans = 0;
    REP(i, n){
        if(a[i] < b[i]){
            k += b[i] - a[i];
            ans++;
        }
    }
    if(k == 0){
        cout << 0 << endl;
        return 0;
    }
    
    vector<ll> v(n);
    REP(i, n){
        v[i] = a[i] - b[i];
    }
    sort(v.begin(), v.end(), greater<ll>());
    
    REP(i, n){
        k -= v[i];
        ans++;
        if(k <= 0){
            cout << ans << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    int c[n], a[n][m];
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    int ans = INF;
    for (int bit = 0; bit < (1 << n); bit++) {
        int prime = 0, und[m] = {};
        for (int i = 0; i < n; i++) {
            if (bit >> i & 1) {
                prime += c[i];
                for (int j = 0; j < m; j++) {
                    und[j] += a[i][j];
                }
            }
        }
        bool flag = false;
        for (int i = 0; i < m; i++) {
            if (und[i] < x) {
                flag = true;
                break;
            }
        }
        if (flag) continue;
        ans = min(ans, prime);
    }
    if (ans == INF) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 3636
import sys
n = int(input())
h = [int(i) for i in sys.stdin.readline().split()]
ans = [0]*n
ans[1] = abs(h[1] - h[0])
for i in range(n-2):
    ans[i+2] = min(abs(h[i] - h[i+2]) + ans[i], abs(h[i+2] - h[i+1]) + ans[i+1])
print(ans[-1])

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

class Main
{
    public static void main (String args[]) throws IOException         //?????????
    {
        InputStreamReader is = new InputStreamReader(System.in);       //?????????
        BufferedReader br = new BufferedReader(is);                    //?????????
        Scanner sc = new Scanner(System.in);

        int s = sc.nextInt();

        int h = s / 3600;
        int m = (s % 3600) / 60;
        int sec = s % 60;

        System.out.println(h + ":" + m + ":" + sec);
    }
}
    

Measured memory_bytes: 26348
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		int[] seq = null;
		
		try {
			seq = getSequence();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		selectionSort(seq);
	}
	
	public static int[] selectionSort(final int[] seq) {
		int count = 0;
		
		for (int i = 0; i < seq.length-1; i++) {
			int min = i;
			for (int j = i+1; j < seq.length; j++) {
				if (seq[j] < seq[min]) min = j;
			}
			if (min != i) {
				final int tmp = seq[i];
				seq[i] = seq[min];
				seq[min] = tmp;
				count++;
			}
		}
		
		printSequence(seq);
		System.out.println(count);

		return seq;
	}
	
	public static void printSequence(final int[] seq) {
		final StringBuilder p = new StringBuilder();
		
		for (int i = 0; i < seq.length; i++) {
			p.append(seq[i]).append(i < seq.length-1 ? " " : "");
		}
		System.out.println(p);
	}
	
	public static int[] getSequence() throws IOException {
		final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		final int n = Integer.parseInt(reader.readLine());
		final String[] line = reader.readLine().split(" ");
		reader.close();
		
		final int[] seq = new int[n];
		for (int i = 0; i < seq.length; i++) {
			seq[i] = Integer.parseInt(line[i]);
		}
		
		return seq;
	}
}

Measured memory_bytes: 17048
#include<stdio.h>
int main(void){
int x,y;
scanf("%d %d",&x,&y);
	if(x<y){
		printf("a < b\n");
	}else if(x>y){
		printf("a > b\n");
	}else if(x==y){
		printf("a == b\n");
	}





 return 0;
}

Measured memory_bytes: 2596
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && a != c) {
		cout << "Yes" << endl;
	}
	else if (b == c && b != a) {
		cout << "Yes" << endl;
	}
	else if (a == c && a != b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

ll N;

int main(void){
    
    cin >> N;
    
    string ans = N == 0 ? "0" : "";
    while(N != 0){
        if (N % 2 == 0) {
            ans = "0" + ans;
        }
        else {
            ans = "1" + ans;
            N--;
        }
        N /= -2;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";

int main()
{
  long long x;
  cin >> x;

  long long ans = 1 + ((x - 1) / 11) * 2 + ((x - 1) % 11) / 6;

  cout << ans << endl;
}


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

using namespace std;

typedef long long ll;

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    int r,g,b;
    cin >> r >> g >> b;
    int ans = r*100 + g*10 + b;
	if(ans%4==0) cout << "YES\n";
	else cout << "NO\n";    
    
	return 0;
}

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

import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.io.PrintWriter;
import java.io.OutputStream;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用 int
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    // 標準入力数値配列用 integer ソート用
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    public static void main(String[] args) throws Exception {
        // write your code here
        int intarray [] = inputval();
        int r = intarray[0] * 100;
        int g = intarray[1] * 10;
        int b = intarray[2];
        if ((r+g+b)%4==0){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }


    }

}



Measured memory_bytes: 25372
let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a - 1 in
  let bs = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun b -> b in
  let cs = Array.init (n - 1) @@ fun _ -> Scanf.scanf "%d " @@ fun c -> c in
  Printf.printf "%d\n" @@
  Array.fold_left ( + ) 0 @@
  Array.init n @@ fun i ->
    bs.(as_.(i)) +
    if i <> 0 && as_.(i - 1) + 1 = as_.(i)
    then cs.(as_.(i - 1))
    else 0



Measured memory_bytes: 384
#include <bits/stdc++.h>
 
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define debug cout << "Ok" << endl;

using namespace std;

void solve(){

	return;
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int n,m,aux,me=10000000,cont=0;
	cin >> n >> m;

	while(n--){
		cin >> aux;
		m-=aux;
		me = min(me, aux);
		cont++;
	}
	cout << cont + m/me << endl;
	return 0;
}

Measured memory_bytes: 3636
N=int(input())
A=list(map(int, input().split()))

  
def judge(n):
  return n//400

rate=[0]*8
masters=0
for a in A:
  if judge(a)<8:
    rate[judge(a)]+=1
  else:
    masters+=1
  
count=0
for r in rate:
  if r!=0:
    count+=1
MAX=count+masters


print(max(1,count),MAX)




Measured memory_bytes: 38384
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
  
typedef struct Node* NodePointer;
  
typedef struct Node {
  int key;
  NodePointer next, pre;
} Node;
  
NodePointer head, last;
  
NodePointer make_node(int key) {
  NodePointer tmp = malloc(sizeof(Node));
  tmp->next = tmp->pre = NULL;
  tmp->key = key;
  return tmp;
}
  
void init() {
  head = malloc(sizeof(Node));
  last = malloc(sizeof(Node));
  head->next = last;
  last->pre = head;
}
  
void insert(NodePointer s, int key) {
  NodePointer node = make_node(key);
  NodePointer t = s->next;
  s->next = node;
  node->pre = s;
  node->next = t;
  t->pre = node;
}
  
void delete(NodePointer p) {
  NodePointer s = p->pre;
  NodePointer t = p->next;
  s->next = t;
  t->pre = s;
  free(p);
}
  
int main() {
  int N, num;
  char str[30];
  NodePointer p;
  init();
  scanf(" %d ", &N);
  while(N--) {
    scanf(" %s ", str);
    if(!strcmp(str,"insert")) {
      scanf(" %d ", &num);
      insert(head,num);
    } else if(!strcmp(str,"delete")) {
      scanf(" %d ", &num);
      for(p = head->next; p != last; p = p->next) {
        if(p->key == num) {
          delete(p);
          break;
        }
      }
    } else if(!strcmp(str,"deleteFirst")) {
      delete(head->next);
    } else if(!strcmp(str,"deleteLast")) {
      delete(last->pre);
    }
  }
  
  for(p = head->next; p != last; p = p->next) {
    printf(p == head->next? "%d":" %d", p->key);
  }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 31792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <algorithm>
using namespace std;

int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if((a==5&&b==5&&c==7)||(a==5&&c==5&&b==7)||(b==5&&c==5&&a==7))
    printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


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

int main(){
	int a,b;
	cin >> a >> b;
	if(a>b){
		cout << "a > b\n";
	}else if(a==b){
		cout << "a == b\n";
	}else if(a<b){
		cout << "a < b\n";
	}




	return 0;
}

Measured memory_bytes: 1124
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   int r;
   if(400<=n and n<=599) r = 8;
   if(600<=n and n<=799) r = 7;
   if(800<=n and n<=999) r = 6;
   if(1000<=n and n<=1199) r = 5;
   if(1200<=n and n<=1399) r = 4;
   if(1400<=n and n<=1599) r = 3;
   if(1600<=n and n<=1799) r = 2;
   if(1800<=n and n<=1999) r = 1;
   cout << r;
   return 0;
} 

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

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

int main() {
	ll n,a,b,div,ans=0;
	cin >> a >> b;
	div=gcd(a,b);
	n=sqrt(div);
	for(ll i=2;i<=n;i++){
		if(div<i) break;
		if(div%i==0) {
			ans++;
			while(div%i==0) div/=i;
		}
	}	
	if(div==1) ans++;
	else ans=ans+2;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define cases long long test;cin>>test;while(test--)
#define f_io ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 1000000007
#define INF 1000000000
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main()
{
    f_io;
    ll n,d;
    cin >> n >> d;
    ll c=0;
    foi(0,n)
    {
        ll a,b;
        cin >> a >> b;
        ll dis = (a*a) + (b*b);
        if(dis<=d*d)
            c++;
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main(){
  int x;
  cin>>x;
  int ans=INF;
  if(x==1||x==2||x==3){
    cout<<1<<endl;
    return 0;
  }
  for(int i=2;i<=32;i++){
  int cnt=0;
    for(int j=2;pow(i,j)<=x;j++){
      cnt=pow(i,j);
    }
    cnt=x-cnt;
    ans=min(cnt,ans);
  }
  cout<<x-ans<<endl;
}

Measured memory_bytes: 4068
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL a,b,c,k;
    cin >> a >> b >> c >> k;
    if (k % 2) {
        cout << b - a << endl;
    } else {
        cout << a - b << endl;
    }
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=300010, inf=2e9, MOD=998244353;

ll n, a, b, k;
ll F[MX];

ll pw(ll a, int e){
	if(e==0) return 1;
	ll t=pw(a, e/2); t=(t*t)%MOD;
	return (e%2==0) ? t : t*a%MOD;
}

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

ll C(int n, int r){
	return F[n]*inv(F[n-r])%MOD*inv(F[r])%MOD;
}

ll count(ll a, ll b){
	return (C(n, a) * C(n, b))%MOD;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n>>a>>b>>k;

	ll ans=0;
	F[0]=1;
	for(int i=1; i<=n; i++) F[i]=(F[i-1]*i)%MOD;

	for(int i=0; i<=n; i++){
		ll mb=k-a*i;
		if(mb<0 || mb%b!=0 || mb/b>n) continue;
		ans=(ans+count(i, mb/b))%MOD;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2560
fn main() {
    let mut line: String = String::new();
    std::io::stdin().read_line(&mut line).unwrap();

    let target_line = line.trim();

    let word_length = target_line.len();
    let run = word_length / 2;

    let mut hug_count = 0;
    for i in 0..run {
        let head_c = target_line.as_bytes().get(i).unwrap();
        let tail_c = target_line.as_bytes().get(word_length - i - 1).unwrap();
        if head_c != tail_c {
            hug_count += 1;
        }
    }

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


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

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

    long long res = 0;
    for(long long b=K+1; b<=N; ++b) {
        long long p = N / b;
        long long r = N % b;
        res += p * max(0LL, b-K) + max(0LL, r - K + 1);
        if(K == 0) --res;
    }
    cout << res << endl;
}

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

using namespace std;
using ll = long long;


int main()
{
    ll k; cin >> k;
    ll n = 50;
    vector<ll> hight(n, 49);
    for(int i = 0; i < n; i++) {
        hight[i] += k / n;
    }

    for(int i = 0; i < k % n; i++) {
        hight[i] += (n - (k % n - 1));
    }
    for(int i = k % n; i < n; i++) {
        hight[i] -= (k % n);
    }
    cout << n << endl;
    for(int i = 0; i < n; i++)cout << hight[i] << (i == n - 1 ? '\n' : ' ');
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    long long multi = 1;
    long long A[N];

    long i;
    for (i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] == 0) {
            cout << 0;
            return 0;
        }
    }

    long long checker = 1000000000000000000;
    for (i = 0; i < N; i++) {
        if (multi > checker && A[i] != 1) {
            cout << "-1";
            return 0;
        } else if (multi > 10 && A[i] > checker/10) {
            cout << "-1";
            return 0;
        } else if (multi > 100 && A[i] > checker/100) {
            cout << "-1";
            return 0;
        } else if (multi > 1000 && A[i] > checker/1000) {
            cout << "-1";
            return 0;
        } else if (multi > 10000 && A[i] > checker/10000) {
            cout << "-1";
            return 0;
        } else if (multi > 100000 && A[i] > checker/100000) {
            cout << "-1";
            return 0;
        } else if (multi > 1000000 && A[i] > checker/1000000) {
            cout << "-1";
            return 0;
        } else if (multi > 10000000 && A[i] > checker/10000000) {
            cout << "-1";
            return 0;
        } else if (multi > 100000000 && A[i] > checker/100000000) {
            cout << "-1";
            return 0;
        } else if (multi > 1000000000 && A[i] > checker/1000000000) {
            cout << "-1";
            return 0;
        } else if (multi > 10000000000 && A[i] > checker/10000000000) {
            cout << "-1";
            return 0;
        } else if (multi > 100000000000 && A[i] > checker/100000000000) {
            cout << "-1";
            return 0;
        } else if (multi > 1000000000000 && A[i] > checker/1000000000000) {
            cout << "-1";
            return 0;
        } else if (multi > 10000000000000 && A[i] > checker/10000000000000) {
            cout << "-1";
            return 0;
        } else if (multi > 100000000000000 && A[i] > checker/100000000000000) {
            cout << "-1";
            return 0;
        } else if (multi > 1000000000000000 && A[i] > checker/1000000000000000) {
            cout << "-1";
            return 0;
        } else if (multi > 10000000000000000 && A[i] > checker/10000000000000000) {
            cout << "-1";
            return 0;
        } else if (multi > 10000000000000000 && A[i] > checker/10000000000000000) {
            cout << "-1";
            return 0;
        }

        multi = multi * A[i];
    }

    if (multi > checker) {
            cout << "-1";
            return 0;
    }

    cout << multi;

    return 0;
}

Measured memory_bytes: 4416
while True:
    m, f, r = map(int, raw_input().split(" "))
    if m==f==r==-1:
        break
    if m==-1 or f==-1:
        print("F")
    elif m+f >= 80:
        print("A")
    elif 65 <= m+f < 80:
        print("B")
    elif 50 <= m+f < 65:
        print("C")
    elif 30 <= m+f < 50:
        if r >= 50:
            print("C")
        else:
            print("D")
    elif m+f < 30:
        print("F")

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

using namespace std;

int main() {
    map<string,int> week {
            {"SUN", 7},
            {"MON", 6},
            {"TUE", 5},
            {"WED", 4},
            {"THU", 3},
            {"FRI", 2},
            {"SAT", 1}
    };
    string n;
    cin >> n;
    cout << week[n] << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class C
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = long.Parse(Console.ReadLine());
            Func<long, long, long> F = (x, y) => Math.Max(x.ToString().Length, y.ToString().Length);
            var answer = F(N, 1);
            var prime = new Prime(N);
            var factors = prime.Factors.SelectMany(x => Enumerable.Repeat(x.Key, x.Value)).ToArray();
            var length = factors.Length;
            for (var bit = 0; bit < (1 << length); bit++)
            {
                var a = 1L;
                var b = 1L;
                for (var i = 0; i < length; i++)
                {
                    if ((bit >> i & 1) == 1) a *= factors[i];
                    else b *= factors[i];
                }
                answer = Math.Min(answer, F(a, b));
            }
            Console.WriteLine(answer);
        }

        public class Prime
        {
            public Dictionary<long, int> Factors => new Dictionary<long, int>(_factors);
            private Dictionary<long, int> _factors;
            private static HashSet<long> _primes;
            public Prime(long n)
            {
                if (_primes == null) _primes = new HashSet<long>();
                _factors = new Dictionary<long, int>();
                var tmp = n;
                var max = (long)Math.Sqrt(n);
                var p = 2;
                while (p <= max)
                {
                    if (tmp % p == 0)
                    {
                        _factors[p] = 0;
                        _primes.Add(p);
                        while (tmp % p == 0)
                        {
                            tmp /= p;
                            _factors[p]++;
                        }
                    }
                    p++;
                }
                if (tmp > 1)
                {
                    _factors[tmp] = 1;
                    _primes.Add(tmp);
                }
            }
            public bool IsPrime(long n)
            {
                if (_primes.Contains(n)) return true;
                var p = new Prime(n);
                return _primes.Contains(n);
            }
        }
    }
}


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

int main() {
    int h, w;
    cin >> h >> w;
  
    for (int i = 0; i < w + 2; i++) {
      if (i == w + 1) {
      cout << "#" << endl; 
      } else {
      cout << "#";  
      }
    }

    for (int i = 0; i < h+1; i++) {
        string contents;
        getline(cin, contents);
        if (i != 0) {
          cout << "#" + contents + "#" << endl;
        }
    }
  
    for (int i = 0; i < w + 2; i++) {
      cout << "#"; 
    }
}


Measured memory_bytes: 256
list = input().split()
W = int(list[0])
H = int(list[1])
x = int(list[2])
y = int(list[3])
r = int(list[4])

if W >= (x + r ) and H >= (y + r ) and (x - r ) >= 0 and (y - r ) >=0 :
    print('Yes')
else:
    print('No')


Measured memory_bytes: 5596
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
          int[] aa = new int[9];
          int[] a1 = new int[3];
          int[] a2 = new int[3];
          aa = ReadLine().Split(' ').Select(int.Parse).ToArray();
          a1 = ReadLine().Split(' ').Select(int.Parse).ToArray();
          a2 = ReadLine().Split(' ').Select(int.Parse).ToArray();

          int[] aaa = aa.Concat(a1).ToArray();
          int[] a = aaa.Concat(a2).ToArray();
          


          int n = int.Parse(ReadLine());

          for(int i = 0; i < n; i++){
              var b = int.Parse(ReadLine());
              for(int j = 0; j < 9; j++){
                  if(a[j] == b){
                      a[j] = 0;
                  }
              }
          }

          if(a[0] == 0){
              if(a[1] + a[2] == 0) {
                  WriteLine("Yes");
                  return;
              }
              if(a[4] + a[8] == 0) {
                  WriteLine("Yes");
                  return;
              }
              if(a[3] + a[6] == 0) {
                  WriteLine("Yes");
                  return;
              }
          }

          if(a[1] == 0){
              if(a[4] + a[7] == 0){
                  WriteLine("Yes");
                  return;
              }
          }

          if(a[2] == 0){
              if(a[4] + a[6] == 0){
                  WriteLine("Yes");
                  return;
              }
              if(a[5] + a[8] == 0){
                  WriteLine("Yes");
                  return;
              }
          }

          if(a[3] == 0){
              if(a[4] + a[5] == 0){
                  WriteLine("Yes");
                  return;
              }
          }
          if(a[6] == 0){
              if(a[7] + a[8] == 0){
                  WriteLine("Yes");
                  return;
              }
          }

          WriteLine("No");
      }
   }
}

Measured memory_bytes: 13396
import collections
N = int(input())
ans = collections.defaultdict(lambda: 0)
for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      ans[x**2+y**2+z**2+x*y+y*z+z*x]+= 1
for i in range(1, N+1):
  print(ans[i])

Measured memory_bytes: 11968
#include<stdio.h>
int main(){

  int n,m,hi[1001][1001],k[1001],t[1001],i,j;

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

  for(i=1;i<=n;i++){
    scanf("%d",&k[i]);
  }

  for(i=1;i<=m;i++){
    scanf("%d",&t[i]);
  }


  for(i=0;i<=m;i++){
    for(j=0;j<=n;j++){
    hi[i][j]=1000000000;
  }
  }



  for(i=0;i<=m;i++){
    hi[i][0]=0;
  }

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      hi[i][j]=k[j]*t[i]+(hi[i-1][j-1]);
      if(hi[i][j]>hi[i-1][j]) hi[i][j]=hi[i-1][j];
    }
  }

  printf("%d\n",hi[m][n]);

  return 0;
}

Measured memory_bytes: 4516
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

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

#define INF INT_MAX/3
#define MAX_N 1000
ll a,b,c;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  std::vector<ll> v(3);
  rep(i,3) cin>>v[i];
  sort(all(v));
  ll cnt = 0;
  while(1){
    if(v[0]==v[1] && v[1] == v[2]) break;
    if(v[1]==v[2]) v[0]+=2;
    else {
      v[0]++;
      v[1]++;
    }
    cnt++;
    sort(all(v));
  }
  cout<<cnt<<endl;
}
int main(){
  solve();
  return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64 n;
    int64 k;
    cin >> n >> k;
    int64 a[n];
    REP(i,n)cin >> a[i];
    map<int64, int64> m;
    REP(i,n)m[a[i]] = -1;
    vector<int64> next(n, n);
    FORR(i, 2 * n, 0){
        int64 j = i % n;
        if(m[a[j]] != -1)
            next[j] = min(next[j], (m[a[j]] - j + n * 2 - 1) % n + 1);
        m[a[j]] = j;
    }
    int64 x = 0;
    int64 y = 0;
    while(true){
        int64 xprev = x;
        int64 yprev = y;
        x += next[x] + 1;
        while(x >= n){
            x-= n;
            y++;
        }
        if(y >= k){
            x = xprev;
            y = yprev;
            break;
        }
        if(x == 0 && y != 0){
            k %= y;
            y = 0;
        }
        // cout << x << " " << y << endl;
    }
    deque<int64> deq;
    set<int64> st;
    // cout << n << " " << k << " " << x << " " << y << endl;
    while(true){
        // for(int64 i : deq){
        //     cout << i << " ";
        // }
        // cout << endl;
        if(y >= k)break;
        int64 xprev = x;
        int64 yprev = y;
        x += next[x] + 1;
        while(x >= n){
            x -= n;
            y++;
        }
        if(y > k || (y == k && x != 0)){
            x = xprev;
            y = yprev;
        }else{
            continue;
        }
        if(st.find(a[x]) == st.end()){
            deq.push_back(a[x]);
            st.insert(a[x]);
        }else{
            while(deq.back() != a[x]){
                deq.pop_back();
            }
            deq.pop_back();
            st.erase(a[x]);
        }
        x++;
        if(x >= n){
            x -= n;
            y++;
        }
    }
    for(int64 i : deq){
        cout << i << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 28160
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt
    val M = sc.nextInt
    val L = new Array[Int](M)
    val R = new Array[Int](M)
    for (i <- 0 until M) {
      L(i) = sc.nextInt
      R(i) = sc.nextInt
    }

    val maxL = L.max
    val minR = R.min

    val ans =
      if (maxL <= minR) {
        minR - maxL + 1
      } else {
        0
      }

    println(ans)
  }
}

Measured memory_bytes: 70948
def solve(s):
    R = "qwertasdfgzxcvb"
    L = "yuiophjklnm"
    
    n = len(s)
    if n <= 1:
        return 0
    cnt = 0
    for i in range(n-1):
        if s[i] in R and s[i+1] in L:
            cnt += 1
        if s[i] in L and s[i+1] in R:
            cnt += 1
    return cnt

while True:
    s = raw_input()
    if s == "#":
        break
    print solve(s)


Measured memory_bytes: 4220
W, H, N = map(int, input().split())
width = [1 for _ in range(W)]
height = [1 for _ in range(H)]

for _ in range(N):
    x, y, a = map(int, input().split())
    if a==1: 
        for i in range(x):
            width[i] =0
    elif a==2:
        for i in range(x,W):
            width[i] =0
    elif a==3:
        for i in range(y):
            height[i] =0
    elif a==4:
        for i in range(y,H):
            height[i] =0
    #print("W：{}".format(width))
    #print("H：{}".format(height))

print(width.count(1)*height.count(1))

Measured memory_bytes: 3064
N,M = map(int,input().split())
shops = [list(map(int,input().split())) for i in range(N)]
shops.sort()
get = 0
money = 0
for i in range(0,N,1):
    if get == M:
        break
    tmp_buy = min(M-get,shops[i][1])
    get += tmp_buy
    money += tmp_buy*(shops[i][0])
print(money)


Measured memory_bytes: 90248
using System;

    class AGC027A
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            string[] inputs = Console.ReadLine().Split(' ');
            int n = int.Parse(inputs[0]);
            int x = int.Parse(inputs[1]);

            int[] a = new int[n];
            string[] somea = Console.ReadLine().Split(' ');

            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(somea[i]);
            }

            /*
             最も多く満足させるためには、要求する数が少ない人から順にあげていく
             よって昇順に並べ替える必要がある
             バブルソートを使う
             */

            int temp;

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

            int cnt = 0;

            for(int i = 0; i < n; i++)
            {
                //Console.WriteLine(a[i]);
                // ちょうど同じ数もらわなければいけない
                if (i == n - 1)
                {
                    if (x == a[i])
                        cnt++;
                }
                else
                {
                    if (x >= a[i])
                    {
                        x -= a[i];
                        cnt++;
                    }
                    else
                        break;
                }
            }

            Console.WriteLine(cnt);
        }
    }


Measured memory_bytes: 13140
#define _USE_MATH_DEFINES
#include <sstream> //string stream
#include<string>
#include<iostream>
#include<utility> //pair
#include <vector>
#include <algorithm>    // swap,sort,binary_search
#include <functional>   //greater
#include <map> //map
#include<set> //set
#include<queue>
#include<list> //list
#include<cmath>
#include<numeric>
#include<cassert>
#include<bitset>
#include <iomanip> //cout<<setprecision
using namespace std;
typedef long long ll;
#define rep(i,s,t) for(int i = s; i<t;i++)
const ll wari = 1000000007;

//omajinai yukue humei

int main(){
    int x[3];
    for(int i = 0 ;i<3;i++) cin>>x[i];
    sort(x,x+3);
    cout<<((x[0] == x[1] && x[1] == 5 && x[2] == 7)?"YES":"NO")<<endl;
}


Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {

  val arr: Array[Array[Int]] = (0 until 3).map { _ =>
    StdIn.readLine().replace("a", "0").replace("b", "1").replace("c", "2").map(c => c.toString.toInt).toArray
  }.toArray

  //arr.foreach(e => println(e.toList))

  def loop(position: Array[Int], current: Int): Int = {
    if (position(current) + 1 == arr(current).length) current
    else {
      position(current) += 1
      loop(position, arr(current)(position(current)))
    }
  }

  val r = loop(Array(-1, -1, -1), 0)
  println(if (r == 0) "A" else if (r == 1) "B" else "C")

}


Measured memory_bytes: 27208
#include <stdio.h>
#define INF (1<<21)
#define WHITE 0
#define BLACK 1
#define MAX 100

int n;
int matrix[MAX][MAX];

void dijkstra(){

    int i,u,v;
    int mincost;
    int d[MAX],color[MAX],pi[MAX];

    for( i = 0 ; i < n ; i++ ){
        d[i] = INF;
        color[i] = WHITE;
    }

    d[0] = 0;

    while( 1 ){

        mincost = INF;

        for( i = 0 ; i < n ; i++ ){
            if( color[i] != BLACK && d[i] < mincost ){
                mincost = d[i];
                u = i;
            }
        }

        if( mincost == INF ){
            break;
        }

        color[u] = BLACK;

        for( v = 0 ; v < n ; v++ ){

            if( matrix[u][v] + d[u] < d[v] ){
                d[v] = matrix[u][v] + d[u];
            }
        }

    }


    for( i = 0 ; i < n ; i++ ){
        if( d[i] != INF ){
            printf("%d %d\n",i,d[i]);
        }
    }

}

int main(){

    int i,j;
    int u,v;
    int k;
    int c;

    scanf("%d",&n);

    for( i = 0 ; i < n ; i++ ){
        for( j = 0 ; j < n ; j++ ){
            matrix[i][j] = INF;
        }
    }
    
    for( i = 0 ; i < n ; i++ ){
        scanf("%d %d",&u,&k);
        for( j = 0 ; j < k ; j++ ){
            scanf("%d %d",&v,&c);
            matrix[u][v] = c;
        }
    }
    
    dijkstra();

    return 0;
}

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

int main()
{
    int A, B, M;
    cin >> A >> B >> M;

    int mina = 100005;
    vector<int> a(A);
    for (int &aa : a)
    {
        cin >> aa;
        mina = min(mina, aa);
    }

    int minb = 100005;
    vector<int> b(B);
    for (int &bb : b)
    {
        cin >> bb;
        minb = min(minb, bb);
    }

    int ans = mina + minb;

    int x, y, c;
    for (int i = 0; i < M; i++)
    {
        cin >> x >> y >> c;
        x--;
        y--;
        ans = min(ans, a[x] + b[y] - c);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD 1000000007

int main()
{
    ll s;
    cin >> s;

    ll dp[2020];
    for (int i = 0; i < 2020; i++) dp[i] = 0;

    dp[3] = 1;
    dp[4] = 1;
    dp[5] = 1;

    for (int i = 6; i < 2020; i++)
    {
        dp[i]++;

        for (int j = 3; j <= i - 3; j++)
        {
            dp[i] += dp[j];
            dp[i] %= MOD;
        }
    }

    cout << dp[s] << endl;

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int K, A, B;
  cin>>K>>A>>B;

  if(K < A+1){
    Int ans = 1 + K;
    cout<<ans<<endl;
    return 0;
  }

  Int a = 1 + K;
  K -= A + 1;
  Int b = B + (B - A) * (K/2) + (K%2) ;
  Int ans = max(a, b);
  cout<<ans<<endl;
  

  

  

  return 0;
}


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

int main()
{
    int k;
    cin >> k;
    ll ans = 0;
    rep(a, k)
        rep(b, k)
            rep(c, k)
                ans += __gcd(a, __gcd(b, c));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
ans = 0
tmp = 10**9
for i in range(N):
  avg = T - H[i] * 0.006
  dff = abs(A - avg)
  if dff < tmp:
    tmp = dff
    ans = i + 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b;
    cin>>a>>b;
    if(a>b)
    {
        cout<<"a > b"<<endl;
    }
    else if(a==b)
    {
        cout<<"a == b"<<endl;
    }
    else
    {
        cout<<"a < b"<<endl;
    }
    return 0;
}





Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,a[15],x[15][15],y[15][15];
bool h[15];
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",a+i);
        for(int j=0;j<a[i];j++){
            scanf("%d%d",&x[i][j],&y[i][j]);
            x[i][j]--;
        }
    }
    int ans=0;
    for(int s=0;s<(1<<n);s++){
        for(int i=0;i<n;i++){
            if(s>>i&1)h[i]=true;
            else h[i]=false;
        }
        bool f=true;
        for(int i=0;i<n;i++){
            if(h[i]){
                for(int j=0;j<a[i];j++){
                    if(y[i][j]==1&&h[x[i][j]]==false){
                        f=false;
                        break;
                    }
                    if(y[i][j]==0&&h[x[i][j]]==true){
                        f=false;
                        break;
                    }
                }
            }
        }
        if(f==true){
            //cout<<s<<endl;
            ans=max(ans,__builtin_popcount(s));
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
from collections import deque #リスト風コンテナ

n=int(input())
a=deque()

for i in range(n):
    c=input()
    if c=="deleteFirst":
        a.popleft()
    elif c=="deleteLast":
        a.pop()
    else:
        c,v=c.split()
        if c=="insert":
            a.appendleft(v)
        else:
            try:
                a.remove(v)
            except:
                pass

print(" ".join(a))




Measured memory_bytes: 69732
S = list(input())
Child = [0]*len(S)
S.append('END')
p = 0

while S[p] != "END":
    oe = [0,0]
    while S[p] == 'R':
        oe[0],oe[1] = oe[1]+1,oe[0]
        p += 1
    Child[p-1] += oe[0]
    Child[p] += oe[1]
    
    while S[p] == "L":
        p += 1
    q = p-1
    
    oe = [0,0]

    while S[q] == "L":
        oe[0],oe[1] = oe[1]+1,oe[0]
        q -= 1
    Child[q] += oe[1]
    Child[q+1] += oe[0]
for i in Child:
    print(i,end = " ")

Measured memory_bytes: 5556
joinBy :: String -> [String] -> String
joinBy _ [] = []
joinBy _ [x] = x
joinBy sep (x:xs) = x ++ sep ++ joinBy sep xs

hms :: Integral a => a -> [a]
hms sec = [sec `div` 3600, sec' `div` 60, sec'']
  where sec' = sec `mod` 3600
        sec'' = sec' `mod` 60

main :: IO ()
main = readLn >>= putStrLn . joinBy ":" . map show . hms

Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

long dp[100005][3],ans;

long max(long a,long b);

int main(void){
  int N,a[100005],b[100005],c[100005],i;
  char str[1000],*p;
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  
  for(i=1;i<N+1;i++){
    fgets(str,sizeof(str),stdin);
    p=strtok(str," \n");
    a[i]=atoi(p);
    p=strtok(NULL," \n");
    b[i]=atoi(p);
    p=strtok(NULL," \n");
    c[i]=atoi(p);
  }
  
  for(i=1,a[0]=0,b[0]=0,c[0]=0;i<N+2;i++){
    dp[i][0]=max(dp[i-1][1]+b[i-1],dp[i-1][2]+c[i-1]);
    dp[i][1]=max(dp[i-1][0]+a[i-1],dp[i-1][2]+c[i-1]);
    dp[i][2]=max(dp[i-1][1]+b[i-1],dp[i-1][0]+a[i-1]);
  }
  
  ans=dp[N+1][0];
  for(i=1;i<3;i++){
    if(dp[N+1][i]>ans){
      ans=dp[N+1][i];
    }
  }
  
  printf("%ld\n",ans);
  
 return 0;
}

long max(long a,long b){
  if(a>=b){
    return a;
  }else{
    return b;
  }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> x(n), y(n), p(n), s(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> p[i];
        s[i] = min(abs(x[i]), abs(y[i]));
    }
    vector<ll> ans(n + 1, 1e18);
    vector<int> a(n);
    int z = 1;
    for (int i = 0; i < n; i++) {
        z *= 3;
    }
    for (int loop = 0; loop < z; loop++) {
        int b = 0;
        for (int i = 0; i < n; i++) {
            if (a[i]) {
                b++;
            }
        }
        vector<ll> t = s;
        for (int i = 0; i < n; i++) {
            if (a[i] == 1) {
                for (int j = 0; j < n; j++) {
                    t[j] = min(t[j], abs(x[i] - x[j]));
                }
            } else if (a[i] == 2) {
                for (int j = 0; j < n; j++) {
                    t[j] = min(t[j], abs(y[i] - y[j]));
                }
            }
        }
        ll sum = 0;
        for (int i = 0; i < n; i++) {
            sum += t[i] * p[i];
        }
        ans[b] = min(ans[b], sum);
        for (int i = n - 1; i >= 0; i--) {
            a[i]++;
            if (a[i] == 3) {
                a[i] = 0;
            } else {
                break;
            }
        }
    }
    for (ll i : ans) {
        cout << i << '\n';
    }
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>
#include <functional>
#include <memory>
#include <stack>
#include <numeric>
constexpr long long int mod = 1000000007LL;
long long int solve(const int position, const int target, const std::vector<int>& questions, std::vector<std::vector<long long int>>& memo) {
	if (position == memo.size()) return (target == 0) ? 1LL : 0LL;
	else if (memo[position][target] >= 0) return memo[position][target];
	else {
		memo[position][target] = 0LL;
		for (auto i = 0; i < 10; ++i) {
			memo[position][target] += solve(position + 1, ((target - questions[position] * i) % 13 + 13) % 13, questions, memo);
		}
		return memo[position][target] %= mod;
	}
}
int main() {
	std::string str; std::cin >> str;
	std::vector<int> questions;
	auto whole = 0;
	auto digit = 1;
	for (int i = str.size() - 1; i >= 0; --i) {
		if (str[i] == '?') {
			questions.push_back(digit);
		}
		else {
			whole += digit * (str[i] - '0');
			whole %= 13;
		}
		digit = (digit * 10) % 13;
	}
	const auto target = (18 - whole) % 13;
	std::vector<std::vector<long long int>> memo(questions.size(), std::vector<long long int>(13, -1));
	for (auto i = 1; i < questions.size(); i += 1000) {
		solve(questions.size() - i, 0, questions, memo);
	}
	std::cout << solve(0, target, questions, memo) << std::endl;
}

Measured memory_bytes: 14072
#include <stdio.h>

int main(void){
	int a,b,c;
	int loop_i;
	int n;

	scanf("%d",&n);
	for(loop_i = 0;loop_i < n;loop_i++){
		scanf("%d %d %d",&a,&b,&c);
		if(a*a + b*b == c*c || a*a + c*c == b*b || b*b + c*c == a*a)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 1008
#include <iostream>

#define pll pair<ll,ll>
#define NMAX 1000006
#define eps 1e-12

using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
    string s;
    int c=0;
    cin>>s;
    for(auto val:s)
    {
        if(val=='C' || c==1)
        {
            c=1;
            if(val=='F')
            {
                cout<<"Yes"<<'\n';
                return 0;
            }
        }
    }
    cout<<"No"<<'\n';
    return 0;
}

Measured memory_bytes: 256