akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int64_t f(int64_t x,int64_t y){
if(y==0)
  return 1;
  else{
  if(y%2==0)
    return (f(x,y/2)*f(x,y/2))%mod;
    else
      return (x*((f(x,y/2)*f(x,y/2))%mod))%mod;
  }
}
int main(){
int64_t N;
  cin>>N;
  vector<int64_t>C(N);
  for(int64_t i=0;i<N;i++)
    cin>>C.at(i);
  sort(C.begin(),C.end());
  if(N==1)
    cout<<(2*C.at(0))%mod<<endl;
  else{
  int64_t ans=0;
    int64_t a=f(2,N-1);
    int64_t b=f(2,N-2);
    for(int64_t i=0;i<N;i++){
    ans=(ans+(((N-1-i)*b+a)%mod)*C.at(i))%mod;
    }int64_t c=f(2,N);
    ans=(ans*c)%mod;
    cout<<ans<<endl;
 }
   return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

template <typename T> using Vec = vector<T>; // c++11
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

bool bfs(Vec<Vec<int> >& table, Vec<int>& color) {
    queue<int> que;
    que.push(0);
    color[0] = 1;

    while (!que.empty()) {
        int now = que.front();
        que.pop();
        int len = table[now].size();
        for (int i = 0; i < len; i++) {
            int target = table[now][i];
            if (color[target] == 0) {
                que.push(target);
                color[target] = color[now] * (-1);
            } else if (color[target] == color[now]) {
                return true;
            }
        }
    }

    return false;
}

int main(void) {
    long long int n;
    long long int m;
    cin >> n >> m;
    Vec<Vec<int> > table(n);

    int a;
    int b;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        a--;
        b--;
        table[a].push_back(b);
        table[b].push_back(a);
    }

    Vec<int> color(n, 0);
    bool flag = bfs(table, color);

    if (flag == true) {
        cout << n * (n - 1) / 2 - m << endl;
    } else {
        long long int b = 0;
        long long int w = 0;
        for (int i = 0; i < n; i++) {
            if (color[i] == 1) {
                w++;
            } else if (color[i] == -1) {
                b++;
            }
        }
        cout << b * w - m << endl;
    }

    return 0;
}



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

using namespace std;

int main(){
  int n,l; cin >> n >> l;
  if(l<1-n){
    cout << (l-1)*n+n*(n+1)/2-(l+n-1)<< endl;
  }
  else if(l>0){
    cout << (l-1)*n+n*(n+1)/2-l<< endl;
  }
  else{
    cout << (l-1)*n+n*(n+1)/2 << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<tuple>
#include<utility>

using namespace std;



int main() {

	string s;
	cin >> s;

	bool ans =true;

	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < s.size(); j++) {
			if (i != j && s[i] == s[j]) {
				ans = false;
			}
		}
	}

	if (ans)cout << "yes" << endl;
	else cout << "no" << endl;

	return 0;
}




Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        n: usize,
        p: [i64; n],
    }

    let mut x = 0;

    for i in 1..n + 1 {
        let y = i as i64;
        if p[i - 1] != y {
            x += 1;
        }
    }

    if x <= 2 {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
#include<iostream>

using namespace std;

int main()
{
 long long  n;
 cin>>n;
 long long sum=100;
 int count=0;
 for(int i = 1 ; i <= 5000;i++){
   sum=sum+(sum/100);
   count++;
   if(sum>=n){cout<<count<<endl;
   break;}
 }
 return 0 ;
}


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

using namespace std;

int main() {
  int k;
  cin >> k;
  long long res = 0;
  for (int i=1; i<=k; ++i) {
    for (int j=1; j<=k; ++j) {
      for (int l=1; l<=k; ++l) {
        res += gcd(i, gcd(j, l));
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3592
using System;

class Circle{
        static void Main(string[] args){
	  double r = double.Parse(Console.ReadLine());
	  double S = Math.PI*r*r;
	  double l = 2.0*Math.PI*r;
	  Console.WriteLine("{0:f5} {1:f5}",S,l);
	}
}

Measured memory_bytes: 9268
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
       


int main() {
  string s;
   cin >> s;
  int n=s.size()+1;
  int a[n+1]={};
  ll sum=0;
  
  for(int i=0;i<n-1;i++){
    if(s[i]=='<'){
      a[i+1]=max(a[i+1],a[i]+1);
    }
  }
    for(int i=n-1;i>=0;i--){
    if(s[i]=='>'){
      a[i]=max(a[i+1]+1,a[i]);
    }
  }
  for(int i=0;i<n;i++){
  sum+=a[i];
  }
      cout << sum <<  endl;
}

Measured memory_bytes: 2820
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <iomanip>

#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

using namespace std;

int main(){

  double a,b,c;
  double x;
  double L,S,h;

  cin >>a >>b >>c;

  x=a*a+b*b-2*a*b*cos(c*M_PI/180);

  L=sqrt(x)+a+b;
  h=b*sin(c*M_PI/180);
  S=a*h/2;

  cout <<fixed <<setprecision(8) <<S <<endl <<fixed <<setprecision(8) <<L <<endl <<fixed <<setprecision(8) <<h <<endl;

  return 0;
}

Measured memory_bytes: 1332
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int N; 
	long long int X; 
	cin >> N >> X;
	long long int A[60] = {}; 
	A[0] = 1; 
	for(int i = 0; i < 55; i++){
		A[i+1] = 2 * A[i] + 3;  
	}
	long long int B[60] = {}; 
	B[0] = 1; 
	for(int i = 0; i < 55; i++){
		B[i+1] = 2 * B[i] + 1;  
	}
	long long int ans = 0; 
	for(int j = N; j >= 2; j--){
        if(X == 1){
                X = 0; 
                break; 
        }
	else if(X <= A[j-1] + 1){
		X--; 
	}
	else if(X == A[j-1] + 2){
		X = 0; 
		ans += B[j-1] + 1; break; 
	}
	else if(X < A[j]){
		ans += B[j-1] + 1; 
		X -= (A[j-1] + 2); 
	}
        else if(X == A[j]){
		ans += B[j]; 
		X = 0; 
                break;
	}
	}
	if(X == 2){ans += 1;}
	else if(X == 3){ans += 2;}
	else if(X >= 4){ans += 3;}
	cout << ans << endl; 
}

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

int main(){
    vector<int> d(5);
    for(int i = 0; i < 5; i++)  cin >> d[i];
    sort(d.begin(), d.end());

    int ans = 1<<30;
    do{
        int tmp = 0;
        for(int i = 0; i < 5; i++){
            tmp += d[i];
            if(i != 4)  tmp = (tmp+9)/10 * 10;
        }
        ans = min(ans, tmp);
    }while(next_permutation(d.begin(), d.end()));
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
//abc111_c.cpp
//Sat Sep 29 20:23:32 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int v[n];
	unordered_map<int,int> v1;
	unordered_map<int,int> v2;

//	int v1[10],v2[10];
//	int v1sorted[10],v2sorted[10];

	for (int i=0;i<n;i++){
		cin >> v[i];
	}

	for (int i=0;i<n;i++){
		if (i%2 == 0){
			auto itr = v1.find(v[i]);
			if (itr != v1.end()){
				v1[v[i]]++;
			}else{
				v1[v[i]] = 1;
			}
		}else {
			auto itr = v2.find(v[i]);
			if (itr != v2.end()){
				v2[v[i]]++;
			}else{
				v2[v[i]] = 1;
			}
		}
	}

	int v1max = 0;
	vector<int> v1sorted;
	for (auto itr = v1.begin(); itr!=v1.end();++itr){
		int tempkey = itr->first;
		int tempval = itr->second;
		if (tempval > v1[v1max]){
			v1max = tempkey;
		}
		v1sorted.push_back(tempval);
	}

	int v2max = 0;
	vector<int> v2sorted;
	for (auto itr = v2.begin(); itr!=v2.end();++itr){
		int tempkey = itr->first;
		int tempval = itr->second;
		if (tempval > v2[v2max]){
			v2max = tempkey;
		}
		v2sorted.push_back(tempval);
	}


	sort(v1sorted.begin(),v1sorted.end());
	sort(v2sorted.begin(),v2sorted.end());

	int ans = v1[v1max] + v2[v2max];

//	for (int i=0;i<v1.size();i++){
//		cout << v1sorted[i] << endl;
//	}
//	cout << v1.size() << " " << v2.size() << endl;

	if (v1max == v2max){
//		int v1dif = v1sorted[v1sorted.size()-1]-v1sorted[v1sorted.size()-2];
//		int v2dif = v2sorted[v2sorted.size()-1]-v2sorted[v2sorted.size()-2];
		if (v1.size() == 2 && v2.size() == 2){
			ans = ans - v2[v2max];
		} else if (v1.size() == 2){
			ans = ans - v2[v2max] + v2sorted[v2sorted.size()-2];
		} else if (v2.size() == 2){
			ans = ans - v1[v1max] + v1sorted[v1sorted.size()-2];
		} else if (v1sorted[v1sorted.size()-1]-v1sorted[v1sorted.size()-2] > v2sorted[v2sorted.size()-1]-v2sorted[v2sorted.size()-2]){
			ans = ans - v2[v2max] + v2sorted[v2sorted.size()-2];
		}else {
			ans = ans - v1[v1max] + v1sorted[v1sorted.size()-2];
		}
	}

	cout << n-ans << endl;
//	printf("%.4f\n",ans);
}

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

#define FILE                          \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);

#define FIO                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

#define PI 3.14159265358979323846264338327950L

int main()
{
    //FILE;
    FIO;
    double a, b, h, m, ans, ang;
    cin >> a >> b;
    cin >> h >> m;
    ang = PI * 2 * ((double)h / 12.0 + ((double)m / 60.0) / 12.0 - (double)m / 60.0);

    ans = (double)(a * a + b * b) - (double)(2 * a * b) * cosl(ang);
    printf("%20.20Lf\n", sqrtl(ans));
    //system("pause");
    return 0;
}

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

int main() {
  
  int d, t, s;
  cin>>d>>t>>s;

  if ((double)d/t <= s) {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
  
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  for(int i = 0; i < 10; i++)
    if (N == 0){
      cout << 0 << endl;
      break;
    }
    else if((i + 1) * 1000 >= N){
      cout << (i + 1) * 1000 - N << endl;
      break;
    }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long int
#define pi 3.1415926536
using namespace std;
bool sortbysecdesc(const pair<string,ll> &a, 
				const pair<string,ll> &b) 
{ 
	return a.second>b.second; 
} 
void solve()
{ll t=1,n,m,k;  
 while(t--){ cin>>n>>m; cout<<((n*3)+m)/2<<endl;
 }
}
int main()
{
fast
ll t=1;
while(t--)
{solve();
 //cout<<ma<<endl;
}
return 0;}

Measured memory_bytes: 256
import math
def facts(n):
    ans = []
    for  i in range(1, int(math.sqrt(n)+1)):
        if(n%i==0):
            ans.append(i)
            ans.append(n//i)
    ans = sorted(list(dict.fromkeys(ans)))
    if(ans[-1]==n):
        ans = ans[:-1]
    return ans

x,n = map(int, input().split())
nums = sorted(list(map(int, input().split())))
ans = 101
bfnd, ffnd = False, False
s1, s2 = 0,0
a, b = x,x
while(not bfnd):
    if(x-s1 not in nums):
        a = x-s1
        bfnd = True
        break
    else:
        s1+=1
while(not ffnd):
    if(x+s2 not in nums):
        b = x+s2
        ffnd = True
        break
    else:
        s2+=1
ans = 0
if(abs(x-a) <= abs(x-b)):
    ans = a
else:
    ans = b
print(ans)

Measured memory_bytes: 61640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
 
int main() {
	ll k; string s;
	cin >> s >> k;
	int non_one;
	if (s[0] != '1') {
		cout << s[0] << endl;
		return 0;
	}

	rep(i,s.size()) {
		if (s[i] != '1') {non_one = i; break;}
	}
	//non_one++;
	if (non_one+1 > k) cout << 1 << endl;
	else cout << s[non_one] << endl;
	return 0;
}

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

char M[3][8][8];
int main() {
  
  char dum;
  for(int i = 0; i < 8; i++) {
    for(int j = 0; j < 8; j++) {
      scanf("%c", &M[0][i][j]);
    }
    scanf("%c", &dum);
  }
  
  
  for(int k = 0; k < 3; k++) {
    cout << 90*(k+1) << endl;
    for(int i = 0; i < 8; i++) {
      for(int j = 0; j < 8; j++) {
	cout << M[k][7-j][i];
	if(k!=2) M[k+1][i][j] = M[k][7-j][i];
      }
      cout << endl;
    }
  }
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  map<string, ll> m;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    sort(begin(s), end(s));
    m[s]++;
  }
  ll r = 0;
  for (auto e : m) r += e.second * (e.second - 1) / 2;
  cout << r << endl;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

typedef long long i64;
typedef pair<i64, i64> pii;

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int a[200010];
  int left[200010] = {};
  int right[200010] = {};
  reps(i, 1, n) cin >> a[i];

  reps(i, 1, n) {
    left[i] = max(left[i-1], a[i]);
  }

  for (int i = n; i >= 1; --i) {
    right[i] = max(right[i+1], a[i]);
  }

  int ans;
  reps(i, 1, n) {
    ans = max(left[i-1], right[i+1]);
    cout << ans << "\n";
  }

  return 0;
}

Measured memory_bytes: 3968
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		PrintWriter out=new PrintWriter(System.out);
		FastScanner fs=new FastScanner();
		int x=fs.nextInt();
		int n=fs.nextInt();
		int a[]=fs.readArray(n);
		HashSet<Integer> s=new HashSet();
		for(int i:a)
		s.add(i);
		
		int res=0,ans=Integer.MAX_VALUE;
		for(int i=-101;i<=101;i++)
		{
		    if(!s.contains(i)&&Math.abs(x-i)<ans){
		        ans=Math.abs(x-i);
		        res=i;
		    }
		}
		out.println(res);
		out.close();
	
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
}
}


Measured memory_bytes: 25496
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] c = new int[n];
		int[] s = new int[n];
		int[] f = new int[n];
		for (int i = 0; i < n - 1; i++) {
			c[i] = sc.nextInt();
			s[i] = sc.nextInt();
			f[i] = sc.nextInt();
		}
		sc.close();

		for (int i = 0; i < n; i++) {
			int ans = s[i] + c[i];
			for (int j = i + 1; j < n - 1; j++) {
				ans += (f[j] - (ans % f[j]))  % f[j];
				ans = Math.max(ans, s[j]);
				ans += c[j];
			}
			System.out.println(ans);
		}
	}
}


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

int main(){
    int X,Y;
    cin>>X>>Y;

    int ans=0;

    for(int i=0;i<=100;i++){
        for (int j=0;j<=100;j++){
            if(i+j==X && 2*i+4*j==Y) ans=1;
        }
    }

    if (ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3632
use std::io::*;
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::LinkedList;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let n: u64 = read();
    let m: u64 = read();

    if m <= 2 * n {
        println!("{}", m / 2);
    } else {
        println!("{}", (m - 2 * n) / 4 + n);
    }
}

struct Town {
    x: f64,
    y: f64,
}



Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
using namespace std;
#define MAX 1000000

int main(){
	bool p[MAX+1];
	int n, ans;

	for(int i=0 ; i<=MAX ; i++){
		p[i] = (i<=1)? false : true ;
	}

	for(int i=2 ; i<=sqrt(MAX)+1 ; i++){
		if(p[i]){
			for(int j=i*2 ; j<=MAX ; j+=i){
				p[j] = false;
			}
		}
	}

	while( cin >> n ){		
		ans = 0;
		for(int i=0 ; i<=n ; i++){
			if(p[i]){
				ans++;
			}
		}
		cout << ans << endl;
	}
}

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

using namespace std;

signed main()
{
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int a[n];
    int64_t ans = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        ans += max(0, a[i] - 1) / 2;
        a[i] -= max(0, a[i] - 1) / 2 * 2;
    }
    for(int i = 0; i < n; i++)
    {
        int j = i;
        int cnt = a[i];
        while(j + 1 < n && a[j + 1])
        {
            j++;
            cnt += a[j];
        }
        ans += cnt / 2;
        i = j;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, A;
  cin >> H >> A;
  
  int cnt =0;
  
  for(;;){
    cnt ++;
    H = H - A;
    if(H<=0)
      break;
  }
  
  cout<<cnt<<endl;
  
  }

Measured memory_bytes: 256
N,M = map(int, input().split())
C= list(map(int, input().split()))
inf = float("inf")

dp =  [inf] * (N+1)

dp[0] = 0

for i in range(1, N+1):
    for c in C:
        if i-c  >= 0:
            dp[i] = min(dp[i], dp[i-c]+1)

print(dp[N])



Measured memory_bytes: 7268
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define rep(i , n)  		for(int i=0 ; i<n ; i++)
#define rep1(i , n) 		for(int i=1 ; i<=n ; i++)
#define mp 	        		make_pair
#define pb  				push_back
#define INF					2147483647		// INT_MAX
#define MOD					1000000007
#define print(a)			cout << a;
#define prints(a)			cout << a << " "; 
#define printl(a)			cout << a << "\n";
#define fe                  first
#define se                  second

typedef long long int  ll;
typedef pair<int,int>  p;
typedef pair<p , int>  p1;		   


int main()
{
	FAST;
	int r,d,start;

	cin >> r >> d >> start; 

	int prev = start;
	rep(i , 10)
	{
		int current = prev*r - d;
		printl(current);
		prev = current;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  // スペース区切りの整数の入力
  int n,k;
  cin >> n >> k;
  // vectorに入力
  std::vector<int> a;
  int d=0;
  for(int i=0;i<n;i++){
    cin >> d;
    a.push_back(d);
  }
  for(int i=k;i<n;i++){
    if(a[i-k]<a[i]) cout <<  "Yes" << endl;
    else cout <<  "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3888
n = input()
line1 = input()
line2 = input()
line3 = input()

a_list = line1.split(" ")
a_list = [int(a) for a in a_list]
b_list = line2.split(" ")
b_list = [int(b) for b in b_list]
c_list = line3.split(" ")
c_list = [int(c) for c in c_list]

temp = a_list[0]
ans = 0
for a in a_list:
    if a == temp + 1:
        ans = ans + b_list[a-1] + c_list[temp-1]
    else:
        ans = ans + b_list[a-1]
    temp = a
print(ans)


Measured memory_bytes: 3064
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:isize,
    b:isize,
    }
    println!("{}",(a-1)*(b-1))
}

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

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

    int n;
    cin >> n;

    if(n/100 == n%10) puts("Yes");
    else puts("No");
}

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

int N, r, t;
int res[300];
int need[300][300];
int R[200000];
int P[200000];
typedef pair<int, int> Pii;

bool check(int x){
	int sum[300][300] = { 0 };
	int rem[300] = { 0 };
	memcpy(rem, res, sizeof res);

	for(int i = 0; i < x; i++){
		//if(rem[R[i]] == 0) return false;
		rem[R[i]]--;
		sum[P[i]][R[i]]++;
	}
	int fin[300] = { 0 };
	for(int i = 0; i < N; i++){
		int cnt = 0;
		for(int j = 0; j < r; j++){
			if(sum[i][j] == need[i][j]) cnt++;
		}
		if(cnt == r){
			fin[i] = 1;
			for(int j = 0; j < r; j++){
				rem[j] += sum[i][j];
			}
		}
	}
	while(true){
		bool update = false;
		for(int i = 0; i < N; i++){
			if(fin[i]) continue;
			int cnt = 0;
			for(int j = 0; j < r; j++){
				int c = need[i][j] - sum[i][j];
				if(c <= rem[j]) cnt++;
			}
			if(cnt == r){
				fin[i] = 1;
				for(int j = 0; j < r; j++){
					rem[j] += sum[i][j];
				}
				update = true;
			}
		}
		if(!update) break;
	}
	for(int i = 0; i < N; i++){
		if(fin[i] == 0) return false;
	}
	return true;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	while(cin >> N >> r >> t){
		for(int i = 0; i < r; i++){
			cin >> res[i];
		}
		for(int i = 0; i < N; i++){
			for(int j = 0; j < r; j++){
				cin >> need[i][j];
			}
		}
		for(int i = 0; i < t; i++){
			cin >> P[i] >> R[i];
			P[i]--, R[i]--;
		}

		for(int i = 0; i <= t; i++){
			//cout << i << " " << check(i) << endl;
		}

		if(check(t)){
			cout << -1 << endl;
			continue;
		}

		int ok = 0, ng = t;
		while(abs(ok - ng) > 1){
			int mid = (ok + ng) / 2;
			if(check(mid)) ok = mid;
			else ng = mid;
		}

		cout << ng << endl;
		//cout << "---------------" << endl;
	}
}

Measured memory_bytes: 5456
#include <stdio.h>

int main() {
	int a=0;
	int b=0;
	int c=0;
	
	printf("");
	scanf("%d %d %d",&a,&b,&c);
	
	while(1){
		if(a>=0 && a<=100 && b>=0 && b<=100 && c>=0 && c<=100){
			break;
		}else{
			printf("");
			scanf("%d %d",&a,&b);
			continue;
		}	
	}
	
	if(a<b){
		if(b<c){
			printf("Yes\n");
		} else {
			printf("No\n");
		}
	} else {
		printf("No\n");
	}
	
	return 0;
}

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

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
using ll  = long long;
using vi  = vector<int>;
constexpr int mod = 1e9+7;

// map<int,int> pf(int n){
//   map<int,int> res;
//   int i = 2;
//   while(n != 1){
//     if(n % i == 0){
//       res[i]++;
//       n /= i;
//     }else
//       i++;
//   }
//   return res;
// }

map<int,int> pf(int n){
  map<int,int> res;
  FOR(i,2,sqrt(n)+1){
    if(n == 1) break;
    while(n%i == 0){
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n]++;
  return res;
}

class ModuloCombination{
public:
  vector<ll> fact, fact_inv;

  static ll mod_pow(ll a, ll n){
    if(n == 0) return 1;
    if(n % 2 == 0) return mod_pow((a * a) % mod, n/2);
    return (a * mod_pow(a, n-1) % mod);
  }

  ModuloCombination(ll N):fact(N+1), fact_inv(N+1){ // N log Nで初期化
    fact[0] = 1;
    FOR(i, 1, N+1) fact[i] = (i * fact[i-1]) % mod;
    FOR(i, 0, N+1) fact_inv[i] = mod_pow(fact[i], mod-2);
  }

  ll op(ll n, ll r){ // nCr
    if(r < 0 or n < r) return 0;
    return fact[n] * fact_inv[r] % mod * fact_inv[n-r] % mod;
  }
};

main(){
  int n,m; cin >> n >> m;
  auto fact = pf(m);

  ModuloCombination C(n+30);
  int res = 1;
  for(auto x : fact){
    int tmp = C.op(n+x.second-1,x.second);
    tmp %= mod;
    res *= tmp;
    res %= mod;
  }
  cout << res << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    int64_t ans = 0;

    cin >>N;
    vector<int> data(N);
    for (int i =0; i < N; i++){
        cin >> data.at(i);
    }

    sort(data.begin(),data.end());
    reverse(data.begin(),data.end());

    if(N == 2){
        ans += data.at(0);

    }else if(N%2 ==0){
        ans += data.at(0);
        for(int i = 1; i <= (N-2)/2; i++){
            ans += 2*data.at(i);
        }
    }else if(N%2 ==1){
        ans += data.at(0);
        for(int i = 1; i <= (N-3)/2; i++){
            ans += 2*data.at(i);
        }
        ans += data.at((N-1)/2);
    }    

cout << ans << endl;

}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  ll n, k;
  cin >> n >> k;

  ll ans;

  if(n >= k) {
    if(n % k == 0) {
      ans = 0;
    } else {
      ans = min(n % k, abs(n % k - k));
    }
  } else {
    ans = min(n, abs(n - k));
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n_s,n_c;
    cin >> n_s >> n_c;
    
    if(n_s>n_c/2){
        cout << n_c / 2 << endl;
    } else {
        n_c -= n_s * 2;
        cout << n_c / 4 + n_s << endl;
    }
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
l = [0]*8
red = 0
for i in range(n):
    if a[i]<=399:
        l[0]+=1
    elif a[i]<=799:
        l[1]+=1
    elif a[i]<=1199:
        l[2]+=1
    elif a[i]<=1599:
        l[3]+=1
    elif a[i]<=1999:
        l[4]+=1
    elif a[i]<=2399:
        l[5]+=1
    elif a[i]<=2799:
        l[6]+=1
    elif a[i]<=3199:
        l[7]+=1
    else:
        red+=1
k = 8-l.count(0)
if k>=1:
    print(k,red+k)
else:
    print(1,red+k)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;
constexpr char kRock = '#';

int main() {
  int N, A, B, C, D; std::cin >> N >> A >> B >> C >> D;
  std::string S; std::cin >> S;

  --A; --B; --C; --D;

  if (C < D) {
    int cnt = 0;
    for (int i = A; i < D; ++i) {
      if (S[i] == kRock && S[i+1] == kRock) {
        std::cout << "No" << std::endl;
        return 0;
      }
    }
  } else {
    for (int i = A; i < C; ++i) {
      if (S[i] == kRock && S[i+1] == kRock) {
        std::cout << "No" << std::endl;
        return 0;
      }
    }

    bool ok = false;
    for (int i = B; i <= D; ++i) {
      if (S[i-1] != kRock && S[i] != kRock && S[i+1] != kRock) {
        ok = true;
        break;
      }
    }
    if (!ok) {
      std::cout << "No" << std::endl;
      return 0;
    }
  }
  std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;


ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
bool root(string s){
    int n=s.length();
    if(n==2){
        if(s[0]==s[1]){
            return true;
        }
        else return false;
    }
    if(n==3){
        if(s[0]==s[2]){
            return true;
        }
        else return false;
    }
 
    return false;
}
 
 
//深さ優先
vector<int> seen;
vector<ll> h;
 
//普通の深さ優先探索seenを返す感じ
void dfs(const Graph &G,int v){
    seen[v] = 0; //v探索済み
 
    P good=make_pair(v,h[v]);
    for(auto next_v :G[v]){
        if(seen[next_v]!=-1) continue;//もう探索していた
        if(h[next_v]>good.second){
            good=make_pair(next_v,h[next_v]);
        }
        dfs(G,next_v);
    }
 
    if(!(h[v]==good.second && v==good.first)){
        seen[good.first]=1;
    }
}
 
signed main(){
    /*
    int n,m;
    cin>>n>>m;
 
    h.assign(n,0);
    rep(i,0,n) cin>>h[i];
 
    Graph G(n);
    rep(i,0,m){
        int a,b; cin>>a>>b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
 
    seen.assign(n,-1);
 
    rep(i,0,n){
        if(seen[i]==-1){
            dfs(G,i);
        }
    }
 
    int sum=accumulate(all(seen),0);
 
    cout<<sum<<endl;*/
 
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> bri(m);
    rep(i,0,m){
        int ai,bi;
        cin>>ai>>bi;
        bri[i]=(make_pair(ai,bi));
    }

    sort(all(bri));

    int ans=1;
    int cnt=1;
    int pre=bri[0].second;

    /*
    for(int i=0;i<m;i++){
        cout<<bri[i].first<<" "<<bri[i].second;
    }
    cout<<endl;
    */

    for(int i=1;i<m;i++){
        if(bri[i].first<pre){
            pre=min(pre,bri[i].second);
        }else{
            ans+=cnt;
            pre=bri[i].second;
        }
    }

    cout<<ans<<endl;
}   

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using v = vector<T>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
void dump_debug(T list) {
#ifdef MY_DEBUG
    each(e, list) cout << e << " ";
    printf("\n");
#endif
}

inline ll inl() {
    ll x;
    cin >> x;
    return x;
}

inline string ins() {
    string x;
    cin >> x;
    return x;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        ll n, k;
        cin >> n >> k;
        vl x(n);
        rep(i, n) cin >> x[i];
        
        ll ans = 0;
        rep(i, n) {
            ans += min(x[i], k - x[i]) * 2;
        }
        cout << ans << endl;
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int x, y;
    cin >>x>>y;
    if(y%2==1){
        cout<<"No"<<endl;
    }
    else if(2*x>y || 4*x<y){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
}

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

int main() {

  vector <char> S(3);

  for (int i = 0; i < 3; i++){
   cin >> S.at(i);
  }


  int ans = 0;

  for (int i = 0; i < 3; i++) {
   if (S.at(i) == '1') ans++;
  } 

  cout << ans << endl;

}

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

int main(){
	
	string n;
  	cin >> n;
  	
  	for(int i; i < 3; i++){
    	if(n[i]=='1'){
        	n[i] = '9';
        }else if(n[i]=='9'){
        	n[i] = '1';
        }
      
    }
  	
  	cout << n << endl;
  	
} 

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <cmath>
#define SIZE 200005

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

map <ll,int> mp;

int main()
{
	int n;
	scanf("%d",&n);
	ll ret=0,sum=0;
	mp[0]++;
	for(int i=0;i<n;i++)
	{
		ll a;
		scanf("%lld",&a);
		sum+=a;
		ret+=mp[sum];
		mp[sum]++;
	}
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 12800
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Ciniii(a,b,c);
    Cini(k);
    if(k<=a) cout << k << nn;
    else if(k<=a+b) cout << a << nn;
    else cout << a + min((k-a-b),c) * -1 << nn;
    return 0;
}

Measured memory_bytes: 3168
h,w = map(int,input().split())
x = ["." for i in range(w+2)]
z = [x]
for i in range(h):
    t = ["."]
    y = list(input())
    t = t + y + t
    z.append(t)
z.append(x)
ans = 0
for i in range(1,w+1):
    for j in range(1,h+1):
        if z[j][i] == "#":
            if (z[j+1][i] ==
                z[j-1][i] ==
                z[j][i+1] ==
                z[j][i-1] == "."):
                ans = 1
if ans == 0:
    print('Yes')
else:
    print('No')

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

map<long long,long long> s;
long long d[200010], m[200010], po[200010];

int main() {
	ios::sync_with_stdio(false);
	int n,p; cin >> n >> p;
	string st; cin >> st;
	for (int i = n; i > 0; i--) d[i] =st[i-1]-'0';
	
	long long ans = 0;
	if (p == 2) {
		for (int i = 1; i <= n; i++) if (!(d[i]&1)) ans += i;
		cout << ans << "\n";
		return 0;
	}
	else if (p == 5) {
		for (int i = 1; i <= n; i++) if ((d[i] == 0) || (d[i] == 5)) ans += i;
		cout << ans << "\n";
		return 0;
	}
	
	s[0]++;	
	po[n] = 1;
	for (int i = n-1; i > 0; i--) po[i] = po[i+1] * 10 % p;
	for (int i = n; i > 0; i--) {
		m[i] = (m[i+1] + d[i] * po[i]) % p;	
		s[m[i]]++;
	}
	for (int i = n+1; i > 1; i--) {
		auto it = s.find(m[i]);
		ans += --it->second;
		if (it->second == 0) s.erase(it);
	}
	cout << ans << "\n";
	
}

Measured memory_bytes: 5780
import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0;i < n;i++) {
            a[i] = sc.nextInt();
        }
        
        long ret = 0;
        for (int i = 0;i < n-1;i++) {
            int sum = a[i] + a[i+1];
            if (sum>x) {
                int d = sum - x;
                a[i+1] -= d;
                ret += d;
                if (a[i+1]<0) a[i+1] = 0;
            }
        }
        
        System.out.println(ret);
    }
}


Measured memory_bytes: 33556
s = gets.chomp
chunks = []
s.each_char{|c|
	if chunks.empty? || c != chunks[-1][0]
		chunks << [c, 1]
	else c == chunks[-1][0]
		chunks[-1][1] += 1
	end
}
max = 0
chunks.each_cons(3){|c1, c2, c3|
	if c1[0] == ?J && c2[0] == ?O && c3[0] == ?I
		k = c2[1]
		next if c1[1] < k || c3[1] < k
		max = k if k > max
	end
}
p max

Measured memory_bytes: 270404
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

void get_N1234 (int64 *n1, int64 *n2, int64 *n3, int64 *n4)
{
  int cnt;

  if (n2 == NULL) {
    cnt = scanf("%lld", n1);
    return;
  }
  if (n3 == NULL) {
    cnt = scanf("%lld %lld", n1, n2);
    return;
  }
  if (n4 == NULL) {
    cnt = scanf("%lld %lld %lld", n1, n2, n3);
    return;
  }
  cnt = scanf("%lld %lld %lld %lld", n1, n2, n3, n4);
  return;
}

void omit_LF (void)
{
  char c;
  int  cnt;
  
  cnt = scanf("%c", &c);
  return;
}

char *get_S (int64 n)
{
  char *buf;
  int  i;
  int  cnt;

  buf = malloc((size_t)(n * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  return buf;
}

char *get_SN (int64 max, int64 *size)
{
  char *buf;
  int  i;
  int  n;

  buf = malloc((size_t)(max * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  scanf("%s", buf);

  n = strlen(buf);

  *size = n;
  
  return buf;
}

int64 *get_NSeq (int64 n)
{
  int64 *buf;
  int64 i;

  buf = malloc((size_t)(n * sizeof(int64)));
  for (i=0; i<n; i++) {
    get_N(&buf[i]);
  }

  return buf;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;


int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

int main()
{
  int64 N = 10;
  int64 i;
  int64 size;
  char *str;
  
  str = get_SN(N, &size);

  if (size & 1) {
      printf("No");
      return 0;
  }

  for (i=0; i<size; i++) {
    if (((i&1) == 0) && (str[i] != 'h')) {
      printf("No");
      return 0;
    }
    if (((i&1) == 1) && (str[i] != 'i')) {
      printf("No");
      return 0;
    }
  }

  printf("Yes");
  return 0;
}



Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <vector>

#define pb push_back

using namespace std;

vector<int> adj[200010];
bool visited[200010];
int val[200010], ans[200010], nxt;

void dfs(int pos, int value) {
	int temp = value + val[pos];
	ans[pos] = temp;
	for (int i = 0; i < (int) adj[pos].size(); i++) {
		nxt = adj[pos][i];
		if (ans[nxt] < 0)
			dfs(nxt, temp);
	}
}

int main() {
	int n, q, a, b, p, x;
	scanf("%d %d", &n, &q);
	for (int i = 1; i < n; i++) {
		scanf("%d %d", &a, &b);
		adj[a].pb(b);
		adj[b].pb(a);
	}
	memset(val, 0, sizeof val);
	memset(ans, -1, sizeof ans);
	while (q--) {
		scanf("%d %d", &p, &x);
		val[p] += x;
	}
	dfs(1, 0);
	for (int i = 1; i <= n; i++) {
		if (i > 1)
			putchar(' ');
		printf("%d", ans[i]);
	}
	printf("\n");
	return 0;
}

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

using namespace std;

#define Vi vector<int>
#define FOR(i,s,e) for (int i=s; i<e; i++)
#define ITER(v) v.begin(), v.end()

constexpr int N_MAX = 10;

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

    int a_max = 0;
    int a[N_MAX];
    int n;
    cin >> n;
    FOR(i,0,n) {
        cin >> a[i];
        a_max = max(a_max, a[i]);
    }

    Vi fact;
    Vi divided;
    int f = 2;
    while (f <= a_max) {
        FOR(i,0,n) {
            if (a[i] % f == 0) {
                divided.push_back(i);
            }
        }
        if (divided.size() > 1) {
            for (auto& elm : divided) {
                a[elm] /= f;
            }
            fact.push_back(f);
        } else {
            f++;
        }
        divided.clear();
        FOR(i,0,n) {
            a_max = max(a_max, a[i]);
        }
    }

    int res = 1;
    for (auto& elm : fact) {
        res *= elm;
    }
    FOR(i,0,n) {
        res *= a[i];
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3220
A, B, C, D = map(int, input().split())

if C % B == 0:
    takahashi_attack = C // B
else:
    takahashi_attack = C // B + 1

if A % D == 0:
    aoki_attack = A // D
else:
    aoki_attack = A // D + 1

if takahashi_attack > aoki_attack:
    print('No')
else:
    print('Yes')


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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;
}

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

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

  string S;

  while (N != 1) {
    PRINT(N)
    if (N % 2 == 0) {
      S =  "0" + S;
      N /= -2;
    } else {
      S = "1"+S;
      N -= 1;
      N /= -2;
    }
    PRINT(S)
  }
  S = "1" + S;

  cout << S << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

ll check(ll a){
  ll now = a%10;
  ll ret = a;
  a/=10;
  while(a>0){
    if(now-1 != a%10)return -1;
    a/=10;
    now--;
  }
  return ret;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  for(auto &a:A)cin>>a;
  ll ans=-1;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      ans=max(ans,check(A[i]*A[j]));
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3232
n,m = map(int,input().split())
brokensteps = set([int(input()) for x in range(m)])
dp = [0] * (n+1)
for i in range(n+1):
    if i in brokensteps:
        dp[i] = 0
        continue
    
    elif i <= 1:
        dp[i] = 1

    else:
        dp[i] = (dp[i-1] + dp[i-2])%(10**9+7)

print(dp[n])

Measured memory_bytes: 13216