akhauriyash/Code-Regression huggingface dataset:
#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 debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;cin>>n;
    for(int i=1;i<=9;i++){
        if(n%i==0&&(1<=n/i)&&(n/i<=9)){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


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


int main()
{
  int A,B;
  int i,j,num;
  int digit=0,count=0,ans_count=0;

  scanf("%d %d",&A,&B);

  for(i=A; i<=B; i++){
    num = i;
    j=0;
    int name[5];
    while(num!=0){
      name[j]= num % 10;
      num /= 10;
      digit++;
      j++;
    }

    for(j=0; j<digit/2; j++){
      if(name[j] == name[digit-j-1]){
        count++;
      }
    }
    if(count == digit/2){
      ans_count++;
    }
    count=0;
    digit=0;
  }

  printf("%d",ans_count);
  return 0;
}

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

#define pb push_back
#define S second
#define F first
#define sz size()
#define eps 0.000001
#define endl '\n'
#define bg begin()
#define nd end()
#define up upper_bound
#define lw lower_bound
#define debug(x) #x << " = " << x << "; "
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int MAX = 401;
ll cost[MAX][MAX];
ll dp[MAX][MAX];
ll oo = (1ll<<61);

ll f(int i, int j){
	if(j - i <= 1) return 0;
	ll &ans = dp[i][j];
	if(ans != -1) return ans;
	ans = oo;
	for(int k = i + 1; k < j; k++){
		ans = min(ans, f(i, k) + f(k, j) + cost[i][k - 1] + cost[k][j - 1]);
	}
	//cout << i << " " << j << " " << ans << endl;
	return ans;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int arr[n];
	for(int i = 0; i < n; i++) cin >> arr[i];
	for(int i = 0; i < n; i++){
		cost[i][i] = arr[i];
		for(int j = i + 1; j < n; j++){
			cost[i][j] = cost[i][j - 1] + arr[j];
		}
	}
	memset(dp, -1, sizeof(dp));
	ll ans = f(0, n);
	cout << ans << endl;
}

Measured memory_bytes: 2816
#include <iostream>

using namespace std;

int main() {
    int 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: 3088
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

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

  if( a - b >= 0 ) cout << "delicious";
  else if(b - a <= x) cout << "safe";
  else if(x < b - a) cout << "dangerous";

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

//Squid Multiplication
public class Main{

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

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			List<Long> even = new ArrayList<Long>(), odd = new ArrayList<Long>(), list = new ArrayList<Long>();
			for(int i=0;i<n*(n+1)/2;i++){
				long x = sc.nextLong();
				list.add(x);
				if(x%2==0)even.add(x);
				else odd.add(x);
			}
			Collections.sort(list);
			boolean con = true;
			for(int i=0;i<even.size()&&con;i++)for(int j=i+1;j<even.size()&&con;j++){
				long bi = even.get(i), bj = even.get(j), bk = odd.get(0);
				long g = gcd(bi, bk);
				bi/=g; bk/=g;
				g = gcd(bj, bk);
				bj/=g; bk/=g;
				double r = Math.sqrt(bi*bj/bk);
				long a0 = (long)r;
//				System.out.println("GCD:"+a0);
				if(a0==0)continue;
				long[] a = new long[n];
				boolean f = true;
				List<Long> l = new ArrayList<Long>();
				for(int x=0;x<n;x++){
					long y = even.get(x);
					if(y%a0!=0){
						f = false; break;
					}
					a[x]=even.get(x)/a0;
					l.add(a0*a[x]);
				}
				if(!f)continue;
//				if(a0==18){
//					System.out.println("*************************************");
//					Arrays.sort(a);
//					for(long x:a)System.out.println(x);
//							System.out.println("*************************************");
//				}
				for(int x=0;x<n;x++)for(int y=x+1;y<n;y++)l.add(a[x]*a[y]);
				Collections.sort(l);
				boolean ok = true;
				for(int x=0;x<l.size();x++){
//					if(a0==18){
//						System.out.println("L:"+l.get(x)+" LIST:"+list.get(x));
//					}
					long A = l.get(x), B = list.get(x);
					if(A!=B){
						ok = false; break;
					}
				}
				if(ok){
					Arrays.sort(a);
					System.out.println(a0);
					con = false;
					for(int x=0;x<n;x++)System.out.print(a[x]+(x==n-1?"\n":" "));
				}
			}
		}

	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007
int main()
{
    int A,B,K;
    cin >> A >> B >> K;
    for(int i = A;i <= B;++i)
    {
        if(i <= A + K - 1)
            cout << i << '\n';
        else if(B - K + 1 <= i)
            cout << i << '\n';
    }
}


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

using namespace std;

long long int N;

bool shichigo(long long int a){
  int keta = log10(a);
  keta++;
  
  bool is3 = false, is5 = false, is7 = false;
  for(int i = keta; i >= 0; i--){
    int b;
    b = a / pow(10, i);
    if(b == 3) is3 = true;
    else if(b == 5) is5 = true;
    else if(b == 7) is7 = true;
    a -= b*pow(10, i);
  }
  if(is3 == true && is5 == true && is7 == true) return true;
  else return false;
}

int dfs(int depth, long long int a){
  int counter= 0;
  if(depth == 9) return 0;
  
  if(pow(10,depth) * 3 + a <= N){
    if(shichigo(pow(10,depth) * 3 + a)) counter++;
    counter += dfs(depth+1,pow(10,depth) * 3 + a);
  }
  if(pow(10,depth) * 5 + a <= N){
    if(shichigo(pow(10,depth) * 5 + a))counter++;
    counter += dfs(depth+1,pow(10,depth) * 5 + a);
  }
  if(pow(10,depth) * 7 + a <= N){
    if(shichigo(pow(10,depth) * 7 + a)) counter++;
    counter += dfs(depth+1,pow(10,depth) * 7 + a);
  }
  return counter;
}

int main(){
  cin >> N;
  int ans = 0;
  ans = dfs(0,0LL);
  cout << ans;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;

static int n;
static int m;
static int x;
static int c[16];
static int a[16][16];

static int infinite;
static int status[16];


int backtrack(int i)
{
	int res;

	if (i == n) {
		for (int j = 0; j < m; ++j) {
			if (status[j] < x) {
				return infinite;
			}
		}
		return 0;
	}

	res = backtrack(i + 1);
	for (int j = 0; j < m; ++j) {
		status[j] += a[i][j];
	}
	res = min(res, backtrack(i + 1) + c[i]);
	for (int j = 0; j < m; ++j) {
		status[j] -= a[i][j];
	}

	return res;
}


int main(int argc, char *argv[])
{
	scanf("%d%d%d", &n, &m, &x);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &c[i]);
		for (int j = 0; j < m; ++j) {
			scanf("%d", &a[i][j]);
		}
	}

	for (int j = 0; j < m; ++j) {
		int sum = 0;
		for (int i = 0; i < n; ++i) {
			sum += a[i][j];
		}
		if (sum < x) {
			puts("-1");
			return EXIT_SUCCESS;
		}
	}

	infinite = 1;
	for (int i = 0; i < n; ++i) {
		infinite += c[i];
	}
	memset(status, 0, sizeof(status));
	printf("%d\n", backtrack(0));

	return EXIT_SUCCESS;
}


Measured memory_bytes: 1736
N = int(input())
W = []
flag = 1

for i in range(N):
  w = input()
  W.append(w)
  
  if i != 0:
    if W[i-1][-1] != W[i][0] or W.count(w) >= 2:
      flag = 0
      
if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S, T; 
	cin >> S >> T; 
	int L = S.size(); 
	int M = T.size(); 
	int dp[3010][3010] = {}; // dp[Sのi文字目まで][Tのj文字目まで] = LCS
	for(int i = 1; i <= L; i++){
		for(int j = 1; j <= M; j++){
			if(S.at(i-1) == T.at(j-1)){
				dp[i][j] = dp[i-1][j-1] + 1; 
			}
			else{
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]); 
			}
		}
	}
	int s = L; int t = M; int length = 0; 
	string ans = {}; 
	while((int) ans.size() < dp[L][M]){
		if(S[s-1] == T[t-1]){
			ans.push_back(S[s-1]); s--; t--;
		}
		else if(dp[s][t] > dp[s-1][t]) t--; 
		else s--; 
	}
	reverse(ans.begin(), ans.end()); 
	cout << ans << endl; 
}

Measured memory_bytes: 35712
loops = int(input())
d = {}

# 10^6
for _ in range(loops):
    key = input()
    if key not in d: # ?
        d[key] = 1
    else:
        d[key] += 1

# 10^6
ans = 0
for k,v in d.items():
    if v % 2 != 0:
        ans += 1
print(ans)

Measured memory_bytes: 17884
#include <iostream>
using namespace std;
int krsw[4001][4001];
int main() {
    string s1, s2;
    while(cin >> s1 >> s2) {
        int unco = 0;
        for(int i = 0; i < 4001; i++){
            for(int j = 0; j < 4001; j++) {
                krsw[i][j] = 0;
            }
        }
        for (int i = 1; i <= s1.size(); i++) {
            for (int j = 1; j <= s2.size(); j++) {
                if(s1[i - 1] == s2[j - 1]) {
                    krsw[i][j] = krsw[i - 1][j - 1] + 1;
                    unco = max(unco,krsw[i][j]);
                }
            }
        }
        cout << unco << endl;
    }
    return 0;
}

Measured memory_bytes: 63740
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds; 
using namespace std;
#define int long long
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define mii map<int,int>
#define mp make_pair
#define pb push_back
#define rep(i,b) for(ll (i)=0;i<(b);i++)
#define all(c) (c).begin(), (c).end()
#define F first
#define S second
#define CLR(p) memset(p, 0, sizeof(p))
#define SET(p) memset(p, -1, sizeof(p))
#define DEBUG true
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
//typedef long long int ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
tree_order_statistics_node_update> new_data_set; 
const int MAX=1e6+5;
#define MOD 1000000007
/*std::cout << std::fixed;
std::cout << std::setprecision(6);*/
//(a%mod-b%mod+mod)%mod



/************************************


 
*************************************/

vector<vector<ll>>v;
ll T=0;
ll cnt1=0,cnt0=0;
vector<ll>dep;
bool visited[MAX];
vector<ll>par;
vector<ll>tin,tout;
vector<ll>col;

int countDivisibles(int A, int B, int M) 
{ 
    
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
} 







signed main(){
    int t=1;
    // cin>>t;
    while(t--){
        int x;
        cin>>x;
        for(int i=0;i<=200;i++){
            for(int j=-200;j<=200;j++){
                int a = pow(i,5);
                int b = pow(j,5);
                // cout<<a<<" "<<b<<" ## ";
                if(a-b==x){
                    cout<<i<<" "<<j<<endl;
                    return 0;
                }

            }
        }
    }
    return 0;
}


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

int main() {
  string S;
  cin >> S;

  if((count(S.begin(), S.end(), S[0]) == 2) 
      && (count(S.begin(), S.end(), S[1]) == 2)
      && (count(S.begin(), S.end(), S[2]) == 2)
      && (count(S.begin(), S.end(), S[3]) == 2)){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 384
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var M = one[1];
  var list = new Array(N);
  for(var i = 0; i < N; i++){
    list[i] = nextIntArray();
  }
  var max = 0;
  var p = 3;
  for(var i = 0; i < (1 << p); i++){
    var v = [0,0,0];
    for(var j = 0; j < p; j++){
      if((i & (1 << j)) != 0){
        v[j] = 1;
      }else{
        v[j] = -1;
      }
    }
    var sum = 0;
    var L = 0;
    var C = 0;
    var R = 0;
    list.sort(function(a,b){
      var mae = a[0] * v[0] + a[1] * v[1] + a[2] * v[2];
      var ato = b[0] * v[0] + b[1] * v[1] + b[2] * v[2];
      return ato - mae;
    });
    for(var j = 0; j < M; j++){
      L += list[j][0];
      C += list[j][1];
      R += list[j][2];
    }
    sum = Math.abs(L) + Math.abs(C) + Math.abs(R);
    max = Math.max(max, sum);
  }
  myout(max);
}


Measured memory_bytes: 35208
#include <stdio.h>
#define max(X, Y) ((X) > (Y) ? (X) : (Y))

int sum(int arr[]);

int main()
{
    int a[4];
    int b[4];

    for (int i = 0; i < 4; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < 4; i++) {
        scanf("%d", &b[i]);
    }

    printf("%d\n", max(sum(a), sum(b)));
    
    return 0;
}

int sum(int arr[])
{
    int s = 0;
    for (int i = 0; i < 4; i++) {
        s = s + arr[i];
    }

    return s;
}



Measured memory_bytes: 2052
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.lang.Math;
import java.util.Map;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        String s = fs.next();
        char[] S = s.toCharArray();

        int c = 0;
        boolean rain = false;
        for (int i = 0; i<2; i++) {
            if (S[i] == S[i+1] && S[i] == 'R') {
                c++;

            }
        }
        for (int i = 0; i<3;i++) {
            if (S[i] == 'R') {
                rain = true;
            }
        }
        if (rain) {
            System.out.println(c+1);
        } else {
            System.out.println(0);
        }



    }


    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");

        public String next() {
            while (!st.hasMoreElements())
                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;
        }
    }

}


Measured memory_bytes: 32540
def s()
  gets().chomp
end
def i()
  gets.to_i
end
def li()
  gets.split.map(&:to_i)
end
def ili()
  n = gets.to_i
  as = gets.split.map(&:to_i)
  [n, as]
end
class Array
  def sum
    total = 0
    self.each do |item|
      total += item
    end
    total
  end
end

def barger_p_num(n)
  2**(n+1)-1  
end

def barger_length(n)
  2**(n+2)-3
end

def eat_barger_level(n, x)
  (n+1).times{|i|
    len = 2**(n-i+2)-3
    if x-i >= len
      return n-i
    end
  }
end

def solve(n, x)
  if x <= n 
    return 0
  end
  level = eat_barger_level(n, x)
  eaten = barger_p_num(level)
  if x-barger_length(level)-(n-level) > 0
    eaten+1+solve(level, x-barger_length(level)-(n-level)-1)
  else
    eaten
  end
end

n, x = li()
p solve(n,x)


Measured memory_bytes: 3836
a,b,c,d = gets.split.map {|x| x.to_i}

cd = c.lcm(d)
cdi = b/c - (a-1)/c
ddi = b/d - (a-1)/d
cddi = b/cd - (a-1)/cd

puts (b - a + 1) - cdi - ddi + cddi




Measured memory_bytes: 1788
#include <bits/stdc++.h>
 
using namespace std;
 
#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
 
typedef long long tint;

const int INF = 1e6;
const long double PI = acos(-1);
 
int main() {
	int n; cin >> n;
	set<int> s;
	s.insert(n);
	int cont = 1;
	while(true){
		if(n%2==0){
			n/=2;
		}else{
			n*=3;
			n++;
		}
		if(s.find(n) != s.end()){
			cout << cont+1 << endl;
			return 0;
		}
		s.insert(n);
		cont++;
	}
}


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

using namespace std;
#define int long long
int MOD = 1000000007;

signed main(){
    int A,B,C;
    cin >> A >> B >> C;
    
    int ans = 0;
    if(A+B>=C) ans+= C;
    else ans+= A+B+1;
    
    ans += B;
    
    cout << ans << endl;
    return 0;
}


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

int main(){
  long long int a,b,k;
  cin>>a>>b>>k;
  if (a>k){
    cout<<a-k<<' '<<b<<endl;
    return 0;
  }
  if (a<=k) {
    b=b-(k-a);
    a=0;
  }
  if (b<=0) b=0;
  cout<<a<<' '<<b<<endl;
  return 0;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
void solve(int n, vector<long long> inp){
	vector<pii> v; for (int i=0;i<n;i++) v.PB(MP(inp[i],i));
	sort(v.begin(),v.end());
	vector<int> vans; vans.resize(n);
	for (int i=0;i<n/2;i++) {
		vans[v[i].snd]=v[n/2].fst;
	}
	for (int i=n/2;i<n;i++) {
		vans[v[i].snd]=v[n/2-1].fst;
	}
	for (int i=0;i<n;i++) printf("%d\n",vans[i]);
}

int main(){	
	ios_base::sync_with_stdio(false); cin.tie(0);
	long long N;
	scanf("%lld",&N);
	vector<long long> X(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&X[i]);
	}
	solve(N, X);
	return 0;
}



Measured memory_bytes: 7664
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <bitset>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 310, mod = 998244353;

bitset<N> a[N];
ll p2[N];

int rref(int n, int m);

int main() {
	fast_cin();
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			int temp; cin >> temp;
			a[i][j] = temp;
		}
	}
	p2[0] = 1;
	for (int i = 1; i < N; ++i) {
		p2[i] = (p2[i - 1] * 2) % mod;
	}
	int fvar = rref(n, m);
	ll ans = p2[n - 1] * (p2[m] - p2[fvar] + mod);
	cout << ans % mod << endl;
}

int rref(int n, int m) {
	int sr = 0, pivots = 0;
	for (int j = 0; j < m; ++j) {
		for (int i = sr; i < n; ++i) {
			if (a[i][j]) {
				swap(a[i], a[sr]);
				break;
			}
		}
		if (!a[sr][j]) {
			continue;
		}
		++pivots;
		for (int i = sr + 1; i < n; ++i) {
			if (a[i][j]) {
				a[i] ^= a[sr];
			}
		}
		++sr;
	}
	return m - pivots;
}

Measured memory_bytes: 256
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int a , b ;

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

	cin >> a >> b ;

	if (a <= 0 && 0 <= b) cout << "Zero\n" ;
	else if (a > 0 || !((b - a + 1) & 1)) cout << "Positive\n" ;
	else cout << "Negative\n" ;
}


Measured memory_bytes: 256
'''ika tako
スタートが決められたとき、そこから最も遠いマスは、
幅優先探索で最後に訪れたマスとなる。
よって、道である各マスをスタート地点として全て試し、
最長移動距離の最大値が答え。
H,W  の上限が小さいので、スタート地点候補が最大400、
1回の探索で探索するマスが最大400、あわせて160000回に
比例する計算量で間に合う。
'''
from collections import deque
 
def bfs(field, s):
    MOVE = [(0, 1), (1, 0), (0, -1), (-1, 0)]
    q = deque([(0, s)])
    dist = [[-1] * w for _ in range(h)]
 
    d, i, j = -1, -1, -1
    while q:
        d, (i, j) = q.popleft()
        if dist[i][j] != -1:
            continue
        dist[i][j] = d
        for di, dj in MOVE:
            ni, nj = i + di, j + dj
            if not 0 <= ni < h or not 0 <= nj < w:
                continue
            if field[ni][nj] == '#':
                continue
            if dist[ni][nj] != -1:
                continue
            q.append((d + 1, (ni, nj)))
    return d, i, j

h, w = map(int, input().split())
field = [input() for _ in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if field[i][j] == '.':
            d, i, j = bfs(field, (i, j))
            ans = max(ans, d)
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define int long long
using namespace std;

signed main(){
	int N, M;
	cin >> N >> M;
	cout << (1900 * M + (N - M) * 100) * (1 << M) << endl;
	return 0;
}


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

using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
typedef long long ll;

template <typename T>
bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }

int ope[] = {'*', '-', '+'};
int priority[] = {0, 0, 0};

typedef string::const_iterator State;

ll factor(State &begin);
ll expression(State &begin);


ll calc(ll a, ll b, char c) {
  if (c == '+') return a + b;
  if (c == '-') return a - b;
  return a * b;
}

ll number(State &begin) {
  ll ret = 0;
  while (isdigit(*begin)) {
    ret *= 10;
    ret += *begin - '0';
    begin++;
  }
  return ret;
}

ll term1(State &begin) {
  ll ret = factor(begin);
  for (;;) {
    bool ok = false;
    rep(i, 0, 3) {
      if (priority[i] != 0) continue;
      if (*begin == ope[i]) {
        ok = true;
        begin++;
        ret = calc(ret, factor(begin), ope[i]);
      }
    }
    if (!ok) break;
  }
  return ret;
}

ll term2(State &begin) {
  ll ret = term1(begin);
  for (;;) {
    bool ok = false;
    rep(i, 0, 3) {
      if (priority[i] != 1) continue;
      if (*begin == ope[i]) {
        ok = true;
        begin++;
        ret = calc(ret, term1(begin), ope[i]);
      }
    }
    if (!ok) break;
  }
  return ret;
}

ll factor(State &begin) {
  if (*begin == '(') {
    begin++;
    ll ret = expression(begin);
    begin++;
    return ret;
  } else {
    return number(begin);
  }
}

ll expression(State &begin) {
  ll ret = term2(begin);
  for (;;) {
    bool ok = false;
    rep(i, 0, 3) {
      if (priority[i] != 2) continue;
      if (*begin == ope[i]) {
        ok = true;
        begin++;
        ret = calc(ret, term2(begin), ope[i]);
      }
    }
    if (!ok) break;
  }
  return ret;
}

int main()
{
  string s; cin >> s;
  sort(ope, ope + 3);
  ll ans = LLONG_MIN;
  do {
    // 0, 1, 2
    priority[0] = 0;
    rep(i, 0, 2) rep(j, 0, 2) {
      if (i == 0) priority[1] = priority[0];
      else priority[1] = priority[0] + 1;
      if (j == 0) priority[2] = priority[1];
      else priority[2] = priority[1] + 1;
      State begin = s.begin();
      chmax(ans, expression(begin));
    }
  } while (next_permutation(ope, ope + 3));
  cout << ans << endl;
}


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

using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds; 

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define inf INT_MAX
#define llinf LONG_LONG_MAX

const int MAXN=1e6+3;
const int M=998244353;

ll dp[MAXN];

ll tree[4*MAXN];

void update(int node,int st,int end,int ind,int val){
	if(st==end){
		tree[node]=val;
		return;
	}

	int mid =(st+end)/2;

	if(ind<=mid)
		update(2*node,st,mid,ind,val);
	else
		update(2*node+1,mid+1,end,ind,val);

	tree[node]=max(tree[2*node],tree[2*node+1]);
}

int query(int node,int st,int end,int l,int r)
{
	if(st>r or end<l)
	return 0;
 
	if(st>=l and end<=r)
	return tree[node];
 
	int mid=(st+end)/2;
 
	return max(query(2*node,st,mid,l,r),query(2*node+1,mid+1,end,l,r));
}
 
void solve(){
	int n;
	sfi(n)

	vector<pair<int,int>> v(n);

	vector<int> l(n),diff(n);

	for(int i=0;i<n;i++){
		sfi(v[i].first)
		 sfi(v[i].second)
	}

	sort(v.begin(),v.end());

	f(i,0,n){
		l[i]=v[i].first;
		diff[i]=v[i].second;
	}

	dp[n]=1;

	update(1,0,n,n,n);


	for(int i=n-1;i>=0;i--){
		//cout<<l[i]<<" ";
		auto it=lower_bound(l.begin(),l.end(),l[i]+diff[i]);

		int ind=it-l.begin();

		if(ind>(i+1)){
			ind=max(ind,query(1,0,n,i+1,ind-1));
		}

		update(1,0,n,i,ind);
		
		dp[i]=(dp[i+1]+dp[ind])%M;
	}

	

	pfln(dp[0])


}	

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

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

def Find(x, par):
  if par[x] < 0:
    return x
  else:
    # 経路圧縮
    par[x] = Find(par[x], par)
    return par[x]

def Unite(x, y, par, rank):
  x = Find(x, par)
  y = Find(y, par)
  
  if x != y:
    z = par[x]*par[y]
    # rankの低い方を高い方につなげる
    if rank[x] < rank[y]:
      par[y] += par[x]
      par[x] = y
    else:
      par[x] += par[y]
      par[y] = x
      if rank[x] == rank[y]:
        rank[x] += 1
    return z
  else:
    return 0
    
def Same(x, y, par):
  return Find(x, par) == Find(y, par)
 
def Size(x, par):
  return -par[Find(x)]

n, m = map(int, input().split())
l = [[0, 0] for _ in range(m)]
for i in range(m):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  l[i][0] = a
  l[i][1] = b

par = [-1]*n
rank = [0]*n

ans = [0]*m
ans[0] = n*(n-1)//2
for j in range(m-1):
  ans[j+1] = ans[j]-Unite(l[m-1-j][0], l[m-1-j][1], par, rank)

for i in reversed(range(m)):
  print(ans[i])
  

Measured memory_bytes: 78896
#include<iostream>
#include<cmath>
using namespace std;
long long X;

int main()
{
	cin >> X;
	
	int i = 0;
	long long Y = 100;	
	while (X > Y)
	{
		Y += 0.01 * Y;
		i++;
	}
		
			cout << i << endl;
			
	
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int inf = 1<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

int main () {
  int N; cin >> N;
  vi H(N); rep(i,N) cin >> H.at(i);

  int pre = -999;
  rep(i,N) {
    if (pre <= H[i]-1) {
      pre = H[i]-1;
    }
    else if (pre <= H[i]) {
      pre = H[i];
    }
    else {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}

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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;
    
    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), m = in.ni();
        boolean[] from1 = new boolean[n];
        boolean[] toN = new boolean[n];
        for (int i = 0; i < m; i++) {
            int from = in.ni()-1, to = in.ni()-1;
            if(from == 0){
                from1[to] = true;
            }else if(to == 0){
                from1[from] = true;
            }
            if(from == n-1){
                toN[to] = true;
            }else if(to == n-1){
                toN[from] = true;
            }
        }
        boolean flag = false;
        for (int i = 1; i < n-1; i++) {
            if(from1[i]&&toN[i]) {
                flag= true;
                break;
            }
        }
        out.println(flag?"POSSIBLE":"IMPOSSIBLE");
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 46960
import java.util.Scanner;
 
class Main {
	int n;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
		sc.close();
	}
	Main(Scanner sc){
		n = sc.nextInt();
	}
	void solve(){
		int sum = 0;
		int x = n;
		while(n>0){
			sum += n%10;
			n /= 10;
		}
		if((x%sum)==0){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int A,B;
  cin>>A>>B;
  if(B==1) cout<<0<<endl;
  else{
  for(int i=1; i<1000; ++i){
    if(A+(i-1)*(A-1)>=B){
      cout<<i<<endl;
      return 0;
    }
  }
  }
}


Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
  	public static void main(String[] args) {
    		Scanner sc = new Scanner(System.in);
    		while (true) {
      			String str = sc.next();
      			if (str.equals("-")) {
        			break;
      			}
      			int x = sc.nextInt();
      			for (int i = 0; i < x; i++) {
        			int y = sc.nextInt();
        			str = str.substring(y) + str.substring(0, y);
      			}
      			System.out.println(str);
    		}
  	}
}

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

const int M=2e5+5;

struct SegT
{
	int mx[M*2];
	int P,V;
	void update(int o,int l,int r)
	{
		if(l==r)
		{
			mx[o]=V;
			return;
		}
		int mid=(l+r)>>1;
		int ls=o+1,rs=o+((mid-l+1)<<1);
		if(P<=mid) update(ls,l,mid);
		else update(rs,mid+1,r);
		mx[o]=max(mx[ls],mx[rs]);
	}
	int L,R;
	int query(int o,int l,int r)
	{
		if(L<=l&&r<=R) return mx[o];
		int mid=(l+r)>>1;
		int ls=o+1,rs=o+((mid-l+1)<<1);
		int ans=0;
		if(L<=mid) ans=max(ans,query(ls,l,mid));
		if(mid<R) ans=max(ans,query(rs,mid+1,r));
		return ans;
	}
}segt;

vector<int> g[M];
int a[M];
int dp[M];
int x[M],m;
int find(int v)
{
	return lower_bound(x,x+m,v)-x+1;
}
int pre[M];
int ans[M];

void dfs(int u,int fa)
{
	int preu=pre[a[u]];
	segt.P=a[u];
	segt.L=0; segt.R=a[u]-1;
	pre[a[u]]=segt.V=segt.query(0,0,m)+1;
	segt.update(0,0,m);
	ans[u]=segt.mx[0];
	for(int v:g[u])
	{
		if(v==fa) continue;
		dfs(v,u);
	}
	pre[a[u]]=preu;
	segt.P=a[u];
	segt.V=pre[a[u]];
	segt.update(0,0,m);
}

int main()
{
	int n; scanf("%d",&n);
	int u,v;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		x[i-1]=a[i];
	}
	sort(x,x+n);
	m=unique(x,x+n)-x;
	for(int i=1;i<=n;i++)
		a[i]=find(a[i]);

	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}

	dfs(1,0);

	for(int i=1;i<=n;i++)
		printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 40028
#include <stdio.h>
int n;
double a[1000];
double ans, x;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lf", a + i);
		x = a[i];
		ans += 1.0 / x;
	}
	printf("%lf\n", 1.0 / ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    long long total = 0;
    vector<int> input;
    rrep (i, 0, N) {
        if (i != N) {
            int in; cin >> in;
            input.push_back(in);
            if (i == 0) total += abs(in - 0);
            else total += abs(input[i-1] - input[i]);
        }
        else {
            total += abs(input[i-1] - 0);
        }
    }

    rep (i, 0, N) {
        if (i != N-1) {
            if (i == 0)
                cout << total - (abs(input[i] - 0) + abs(input[i] - input[i+1])) + (abs(0 - input[i+1])) << endl;
            else
                cout << total - (abs(input[i] - input[i-1]) + abs(input[i] - input[i+1])) + (abs(input[i-1] - input[i+1])) << endl;
        }
        else
            cout << total - (abs(input[i] - input[i-1]) + abs(input[i] - 0)) + (abs(input[i-1] - 0)) << endl;
    }
}

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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int main(){
    int N, K;
    cin >> N >> K;
    vector<int64_t> A, Apos, Aneg;
    int z = 0;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        A.push_back(abs(a));
        if(a > 0){
            Apos.push_back(a);
        }else if(a < 0){
            Aneg.push_back(abs(a));
        }else{
            z++;
        }
    }
    sort(Apos.rbegin(), Apos.rend());
    sort(Aneg.rbegin(), Aneg.rend());
    int szp = Apos.size(), szn = Aneg.size();

    int64_t ans = 1;
    if(szp + szn/2*2 >= K && (K%2 == 0 || szp > 0)){
        int pp = 0, pn = 0;
        if(K%2){
            ans = Apos[0];
            pp++;
            K--;
        }
        while(K){
            int64_t v1 = (szp-pp >= 2 ? Apos[pp] * Apos[pp+1] : 0);
            int64_t v2 = (szn-pn >= 2 ? Aneg[pn] * Aneg[pn+1] : 0);
            if(v1 >= v2){
                mul(ans, v1 % MOD);
                pp += 2;
            }else{
                mul(ans, v2 % MOD);
                pn += 2;
            }
            K -= 2;
        }
    }else if(z){
        ans = 0;
    }else{
        sort(A.begin(), A.end());
        for(int i=0; i<K; i++) mul(ans, A[i]);
        ans = (MOD-ans) % MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7636
MOD=10**9+7
s=input()[::-1]
l=len(s)
dp=[[0 for j in range(13)] for i in range(l)]
if s[0] == "?":
    for j in range(10):dp[0][j]=1
else:
    dp[0][int(s[0])]=1
m=1
for i in range(1,l):
    m=10*m%13
    if s[i] == "?":
        for j in range(10):
            for k in range(13):dp[i][(k+j*m)%13]+=dp[i-1][k]%MOD
    else:
        for k in range(13):
            dp[i][(k+int(s[i])*m)%13]+=dp[i-1][k]%MOD
print(dp[-1][5]%MOD)

Measured memory_bytes: 65756
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

#define INF 1e18

int main(){
  long long n, k;
  cin >> n >> k;
  vector<long long> A(n); vector<long long> F(n);
  for(int i = 0; i < n; i++) cin >> A[i];
  for(int i = 0; i < n; i++) cin >> F[i];
  sort(A.begin(), A.end());
  sort(F.begin(), F.end(), greater<int>());
  long long maxi = INF;
  long long mini = -1;
  long long mid, c;
  while(maxi - mini > 1){
    mid = (maxi + mini)/2;
    c = 0;
    for(long long i = 0; i < n; i++){
      if(A[i]*F[i] > mid) c += (A[i]*F[i] - mid)/F[i] + !!((A[i]*F[i] - mid)%F[i]);
    }
    if(c > k) mini = mid;
    else maxi = mid;
  }
  cout << maxi << endl;
}


Measured memory_bytes: 3328
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    static int n;
    static ArrayList<ArrayList<Integer>> arr;
    static int[] FDiff;
    static int[] SDiff;
    static boolean[] visited;

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        arr = new ArrayList<>(n);
        for (int i = 0; i < n; i++) {
            arr.add(new ArrayList<Integer>());
        }

        for (int i = 0; i < n - 1; i++) {
            int from = sc.nextInt() - 1;
            int to = sc.nextInt() - 1;
            arr.get(from).add(to);
            arr.get(to).add(from);
        }

        visited = new boolean[n];
        FDiff = new int[n];
        SDiff = new int[n];
        ArrayDeque<Point> deq = new ArrayDeque<>();

        deq.add(new Point(0, 0));

        while (!deq.isEmpty()) {
            Point p = deq.poll();
            if (visited[p.x]) {
                continue;
            }
            FDiff[p.x] = p.y;
            visited[p.x] = true;
            ArrayList<Integer> Edges = arr.get(p.x);
            for (int i = 0; i < Edges.size(); i++) {
                int to = Edges.get(i);
                if (!visited[to]) {
                    deq.add(new Point(to, p.y + 1));
                }
            }
        }

        deq.clear();
        visited = new boolean[n];
        deq.add(new Point(n - 1, 0));
        while (!deq.isEmpty()) {
            Point p = deq.poll();
            if (visited[p.x]) {
                continue;
            }
            SDiff[p.x] = p.y;
            visited[p.x] = true;
            ArrayList<Integer> Edges = arr.get(p.x);
            for (int i = 0; i < Edges.size(); i++) {
                int to = Edges.get(i);
                if (!visited[to]) {
                    deq.add(new Point(to, p.y + 1));
                }
            }
        }
        int fp = 0, sp = 0;
        for(int i = 0; i < n; i++) {
            if(FDiff[i] <= SDiff[i]) {
                fp++;
            } else {
                sp++;
            }
        }
        System.out.println(fp > sp ? "Fennec" : "Snuke");
//		System.out.println(Arrays.toString(FDiff));
//		System.out.println(Arrays.toString(SDiff));
//		System.out.println(fp+" "+sp);
    }
}


Measured memory_bytes: 105896
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for( int i=a; i<b; i++ )
#define REP(i,n) rep(i,0,n)
using lli = long long int;
using ulli = unsigned long long int;
typedef pair<lli,lli> P;

struct edge{ int u, v, cost; };
struct DirectedGraph
{
  int vertex_num;
  int edge_num;
  vector<edge> edge_list;
  vector< vector<int> > adj_list;
};

void displayVector(vector<lli> v)
{
	lli n = v.size();
	REP(i,n){
		cout << v[i] << " " ;
	}
	cout << endl;
}


int main(){
	int n, k; cin >> n >> k;
	double res = 0.0;
	REP(i, n){
		double tmp = i+1.0; double flip = 0;
		while(tmp < k){
			tmp *= 2; flip+=1.0;
		}

		res += 1.0/(double)n * pow(0.5, flip);
	}
	cout << setprecision(15) << res << endl;
}

Measured memory_bytes: 4140
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
vector<long long> v(n);
for(int i=1;i<=n;i++){
cin>>v[i-1];
}
sort(v.begin(),v.end());
int cnt=1;
for(int i=0;i<n-1;i++){
if(2*v[i]>=v[i+1]) cnt++;
else cnt=1;
v[i+1]+=v[i];

}
cout<<cnt<<endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iomanip>    // setw 控制输出间隔函数
#include <iostream>   // cin, cout, abs
#include <algorithm>  // max, min, swap, sort
#include <cmath>      // pow
#include <cstring>    // strlen, memset
#include <set>        // set 集合
#include <stack>      // stack 栈
#include <queue>      // queue 队列
#include <string>     // string 字(yang)符(rou)串, substr
#include <map>
#include <fstream>
using namespace std;
int main()
{
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    x -= z;
    y += z;
    x /= y;
    printf("%d\n", x);
    return 0;
}


Measured memory_bytes: 256
// D - Coloring Dominoes
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define MOD 1000000007

ll solve(int N, string &S1, string &S2){
	bool isPreVertical;//前回の状態: 縦: true, 横: false
	ll ans = 0;
	rp(i, 0, N){
		ll mulnum = 1;
		if(S1[i] == S2[i]){// 縦
			if(i) mulnum = isPreVertical? 2:1;
			else ans = 3;//init
			isPreVertical = true;
		}
		else{//横
			if(i) mulnum = isPreVertical? 2:3;
			else ans = 6;//init
			isPreVertical = false;
			i++;
		}
		ans = ans * mulnum % MOD;
	}
	return ans;
}

int main(){
	int N; string S1,S2;
	cin>>N>>S1>>S2;
	cout<< solve(N, S1, S2) <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


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

    vi w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    //バッグがある重さのときの、価値の最大値を更新していくマップ
    map<int, int> dp;
    dp[0] = 0;

    int res = 0;

    //この問題ではw[0]からw[0]+3までの重さの物しか存在しないため、
    //重さの総和が同じになる組み合わせが多く存在するはずである。
    //したがって、全ての物について入れるか、入れないかの２通りを試しても、
    //重さの総和の状態数はさほど大きくならない。
    //よって、i-1番目までの全ての物についてバッグに入れる/入れないを試していった際に
    //ありうるすべての重さの総和に対して、i番目の物を入れる/入れないを試していくことができる。

    //物の重さの制約がもう少しでも緩ければ、この方法は用いることが出来ないと考えられる。
    rep(i, N) {
        auto tmp = dp;

        //int cnt = 0;
        for(auto p: tmp) {
            auto x = p.first + w[i];
            auto y = p.second + v[i];
            if(x <= W) res = max(res, dp[x]=max(dp[x], y));
            //cnt++;
        }
        //cout << cnt << endl;
    }

    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}int n;pp a[2010];int dp[2010][2010];
int dfs(int i,int j)
{ 
	if(dp[i][j]!=-1)return dp[i][j];
	int ans=-1e18;
	int x=i+j;
	if(i-1>=0)ans=max(ans,dfs(i-1,j)+a[x-1].first*(abs(a[x-1].second-(i-1))));
	if(j-1>=0)ans=max(ans,dfs(i,j-1)+a[x-1].first*(abs(a[x-1].second-(n-j))));
	return dp[i][j]=ans;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    memset(dp,-1,sizeof(dp));dp[0][0]=0;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
    	cin >> a[i].first;a[i].second=i;
    }
    sort(a,a+n,greater<pp>());
    int ans=0;
    for (int i = 0; i <= n; ++i)
    {
    	ans=max(ans,dfs(i,n-i));
    }
    cout << ans;









}

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

int main(){
    long long int l, r;
    cin >> l >> r;

    if(r-l < 2018 && l%2019 < r%2019){
        int min = 2019;
        for(int i = l%2019; i<r%2019; i++){
            for(int j = i+1; j<=r%2019; j++){
                if(min > i * j % 2019) min = i*j % 2019;
            }
        }
        cout << min << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256