akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<string> vec(N);
  for(int i = 0;i < N;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int C = 0;
  string save;
  int max = 0;
  for(int i = 0;i < N;i++){
    if(i == 0){
      save = vec.at(i);
      C++;
    }else{
      if(save == vec.at(i)){
        C++;
        if(max < C){
          max = C;
        }
      }else{
        if(max < C){
          max = C;
        }
        C = 1;
        save = vec.at(i);
      }
    }
  }
  C = 0;
  for(int i = 0;i < N;i++){
    if(max == 1){
      cout << vec.at(i) << endl;
    }else if(i == 0){
      save = vec.at(i);
      C++;
      if(max == 1){
        cout << vec.at(i) << endl;
      }
    }else{
      if(save == vec.at(i)){
        C++;
        if(max == C){
          cout << save << endl;
        }
      }else{
        C = 1;
        save = vec.at(i);
      }
    }
  }
}


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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

ll MAX_X = 1000000000;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string S;
    cin >> S;

    ll sumW = 0;
    ll numW = 0;
    ll snum = 0;

    for (int i=0;i<S.length();i++) {
        if (S[i] == 'W') {
            sumW += i;
            snum += numW;
            numW++;
        }
    }

    cout << sumW - snum << endl;

    return 0;
}

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

int main(){
  std::string s1;
  std::cin >> s1;
  std::string s2(s1);
  std::reverse(s2.begin(), s2.end());
  if(s1 == s2)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
  return 0;
}

  

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

int main(){
  int K, X;
  cin >> K >> X;
  int left, right;
  left = X-K+1;
  right = X+K-1;
  repi(i, left, right){
    cout << i << " ";
  }
  cout << right << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll          long long int
#define ld          double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         1000000000000000000
#define MAXN        200005
#define LOG         20
#define mod         1000000007
using namespace std;
 
ll dp[MAXN];
ll a[MAXN];
 
ll solve(ll n,ll k){
    if(n==0){
        return 0;
    }
    if(dp[n]!=-1){
        return dp[n];
    }
    ll x=MAX;
    ll p=0;
    for(ll i=n-1;i>=max(n-k,p);i--){
        x=min(x,abs(a[n]-a[i])+solve(i,k));
    }
    dp[n]=x;
    return dp[n];
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(dp,-1,sizeof(dp));
    ll n,k,i;
    cin>>n>>k;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    solve(n-1,k);
    // for(i=0;i<n;i++){
    //     cout<<dp[i]<<" ";
    // }
    // cout<<endl;
    cout<<dp[n-1];
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<int,int>;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
vector<long long> calc_divisor(long long n) {
    vector<long long> res;
    for (long long i = 1LL; i*i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            long long j = n / i;
            if (j != i) res.push_back(j);
        }
    }
    sort(res.begin(), res.end());
    return res;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  ll n;
  cin >> n;
  vector<long long> div1 = calc_divisor(n);
  vector<long long> div2 = calc_divisor(n-1);
  int ans=div2.size()-1;
  rep(i,div1.size()){
    ll m=n;
    if(div1[i]!=1){
      while(m%div1[i]==0){
        m/=div1[i];
      }
      if(m%div1[i]==1)ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
#define MOD 1000000007
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	int N,M;
	cin >> N >> M ;
	if ((N % 3 == 0 || M % 3 == 0) || (N + M) % 3 == 0)
		cout << "Possible";
	else
		cout << "Impossible";
}

Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

a = inpll(3)
n = inp()
B = inplm(n)

tmp = np.zeros((3,3),dtype=np.int)

for b in B:
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                tmp[i][j] = 1

ans = 'No'
if np.any(np.all(tmp == 1,axis=0) == True) or np.any(np.all(tmp == 1,axis=1) == True) or (tmp[0][0] == 1 and tmp[1][1] == 1 and tmp[2][2] == 1) or (tmp[0][2] == 1 and tmp[1][1] == 1 and tmp[2][0] == 1):
    ans = 'Yes'

print(ans)

Measured memory_bytes: 31452
import numpy as np

def input_numbers():
    temp = list(map(int, input().split()))
    return temp

def GCD(a, b):
    if(a < b):
        temp = a
        a = b
        b = temp
    a = a % b
    if(a == 0):
        return b
    else:
        return GCD(a, b)

n = int(input())
a = input_numbers()

g = a[0]
for i in range(1, n):
    g = GCD(g, a[i])

print(g)


Measured memory_bytes: 23072
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647;
const LL mod = 1000000007ll;
 
int N;
string S;
 
int ans = 0;
 
void solve(){
	//iからとjから始めた時に一致する、最大の長さをdp[i][j]とする
	vector<vector<int>> dp(N,vector<int>(N,0));
	for(int i=N-2;i>=0;i--){
		dp[i][N-1] = (S[i]==S[N-1]);
	}
	for(int j=N-2;j>=1;j--){
		for(int i=j-1;i>=0;i--){
			if(S[i]==S[j]){
				dp[i][j] = dp[i+1][j+1] + 1;
			}
			else dp[i][j] = 0;
		}
	}
	for(int j=N-1;j>=1;j--){
		for(int i=j-1;i>=0;i--){
			ans = max(ans,min(dp[i][j],j-i));
		}
	}
}
 
int main(){
	cin >> N;
	cin >> S;
 
	solve();
 
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find algo with array
// Find()
int findpar(int curr, int arr[])
{
  while(arr[curr] != curr) curr = arr[curr];
  return curr;
}
// Union()
void Union(int b, int spa, int arr[])
{
  while(arr[b] != b)
  {
    int c = arr[b];
    arr[b] = spa;
    b = c;
  }
  arr[b] = spa;
}

// Main Code
int n, w;
pair<int, int> p[101];
map<pair<int, int>, ll> mp;
map<pair<int, int>, ll> stor;

ll findans(int curr, int weight)
{
  ll aa, bb;
  aa = bb = 0;
  if(curr == n) return 0;
  if(stor[{curr, weight}]) return mp[{curr, weight}];
  if(p[curr].f <= weight)
  {
    aa = findans(curr+1, weight - p[curr].f) + p[curr].s;
  }
  bb = findans(curr+1, weight);
  stor[{curr, weight}] = 1;
  return mp[{curr, weight}] = max(aa, bb);
}

int main()
{

  cin>>n>>w;
  rep(i, 0, n)
  {
    cin>>p[i].f>>p[i].s;
  }
  ll ans = findans(0, w);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 24192
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 処理対象個数の入力
		Scanner sc = new Scanner(System.in);
		int inputNumSize = sc.nextInt();
		HashMap<Integer,Integer> inputNumMap = new HashMap<>();
		for(int i=1;i <= inputNumSize;i++) {
			inputNumMap.put(sc.nextInt(), i);
		}

		sc.close();

		// 出力
		System.out.println(inputNumMap.size());

	}

}

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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (b <= c || d <= a) {
		cout << 0 << endl;
	}
	else {
		if (a < c) {
			cout << min(b - c, d - c) << endl;
		}
		else {
			cout << min(d - a, b - a) << endl;
		}
	}
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

vvll cnt;

void dfs(int now, int prev, const vvi &g) {
  for(int i=0;i<SZ(g[now]);++i) {
    int nxt = g[now][i];
    if(nxt == prev) continue;
    dfs(nxt, now, g);
  }

  for(int i=0;i<SZ(g[now]);++i) {
    int nxt = g[now][i];
    if(nxt == prev) continue;
    cnt[now][0] *= (cnt[nxt][0] + cnt[nxt][1]);
    cnt[now][0] %= MOD;
    cnt[now][1] *= cnt[nxt][0];
    cnt[now][1] %= MOD;
  }
  
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  cnt.resize(n, vll(2, 1));
  vvi g(n);
  for(int i=0;i<n-1;++i) {
    int a, b; cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  dfs(0, -1, g);

  cout << (cnt[0][0] + cnt[0][1]) % MOD << endl;

}


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

typedef vector <int> VI;

int main( void )
{
    int n, s;
    while ( cin >> n && n )
    {
        VI v(n);
        for ( int i = 0; i < n; i++ )
        {
            cin >> v[i];
        }
        sort( v.begin(), v.end() );
        
        double sum = 0.0;
        for ( int i = 1; i + 1 < n; i++ )
        {
            sum += v[i];
        }

        int score = (int)floor( sum / ( n - 2 ) );
        cout << score << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include <iostream>

int main()
{
	long long int k, n = 50, a[60];
	std::cin >> k;
	
	for (int i = 0; i < n; ++i)
		a[i] = k / n + (n - i - 1);
	
	for (int i = 0; i < k % n; ++i)
		++a[i];
	
	std::cout << n << "\n";
	
	for (int i = 0; i < n; ++i)
		std::cout << a[i] << " ";
}

Measured memory_bytes: 256
string = ''
while True:
    hoge = input().strip()
    if hoge == '-':
        print (string)
        break
    if hoge.isalpha():
        if string:
            print (string)
        string = hoge
        count = 0
    else:
        if count == 0:
            count = hoge
            continue
        else:    
            string = string[int(hoge):] + string[:int(hoge)]


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

#define MX 100050
int a[MX];

int main() {
	int n, k; scanf("%d%d", &n, &k);
	for(int i = 0; i < n; i++) scanf("%d", a + i);
	int mn = n + 10, pos;
	for(int i = 0; i < n; i++)
		if(mn > a[i]) {
			mn = a[i]; pos = i;
		}
	int res = n + 10;
	for(int i = 0; i < k; i++) {
		int val = (max(pos - i, 0) + k - 2) / (k-1) + (n - 1 - min(pos + k - 1 - i, n - 1) + k - 2) / (k-1) + 1;
		res = min(res, val);
	}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 640
import Data.List
import Control.Monad
import Data.Maybe

maxNum :: [Int] -> Int
maxNum = foldr1 (\x acc -> if x > acc then x else acc)

foo :: [Int] -> (Int,Int) -> (Int,Int)
foo [] tup = tup
foo (n:ns) (big,sndBig)
  | n > big = foo ns (n,sndBig)
  | n > sndBig = foo ns (big,n)
  | otherwise = foo ns (big,sndBig)

bar :: [Int] -> Int -> Int -> [Int]
bar ints big sndBig = map (\n -> if n == big then sndBig else big) ints

printList :: [Int] -> IO ()
printList ints = mapM_ putStrLn $ lines $ intercalate "\n" $ map show ints

main = do
  n <- read <$> getLine :: IO Int
  ints <- replicateM n (read <$> getLine) :: IO [Int]
  let (i,j) = foo ints (0,0)
  printList $ bar ints i j


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

int main(){
    int n, ans, a, b;
    cin >> n;
    int c[n];
    ans = a = b = 0;
    for(int i = 0; i < n; i++){
        cin >> c[i];
    }
    sort(c, c+n);
    for(int i = 1; i <= n; i++){
        if(i % 2 == 1) a += c[n-i];
        else b += c[n-i];
    }
    ans = a - b;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;
typedef long long ll;

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

int main(){
    int n,k;
    cin>>n>>k;
    cout<<n-k+1<<endl;
    
    
    return 0;
}



Measured memory_bytes: 764
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let d = read::<usize>();
    let c = read_vec::<i64>();
    let mut s = vec![vec![]; d];
    for i in 0..d {
        s[i] = read_vec::<i64>();
    }

    let mut answers = vec![];

    for i in 0..d {
        let mut max_idx = 0;
        for j in 0..26 {
            if s[i][j] > s[i][max_idx] {
                max_idx = j;
            }
        }
        answers.push(max_idx);
    }

    for ans in answers {
        println!("{}", ans + 1);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, k;
	cin >> n >> m >> k;
	vvi v(n, vi(n, -INF));
	REP(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		chmax(v[a][b], c);
	}
	vector<vvi> d;
	d.push_back(v);
	while (1) {
		vvi t = d.back(), a = d.back();
		REP(i, n)REP(j, n)REP(k, n) {
			if (t[i][k] != -INF && t[k][j] != -INF && t[i][k] + t[k][j] > a[i][j]) {
				a[i][j] = t[i][k] + t[k][j];
			}
		}
		int m = 0;
		REP(i, n)REP(j, n)chmax(m, a[i][j]);

		if (d.back() == a)break;
		d.push_back(a);
		if (m >= k)break;
	}
	{
		int m = 0;
		REP(i, n)REP(j, n)chmax(m, d.back()[i][j]);
		if (m < k) {
			cout << -1 << endl;
			return 0;
		}
	}
	int l = -1, r = (1 << (d.size() + 1)) - 1;
	while (r - l > 1) {
		int mid = (r + l) / 2;
		vvi a(n, vi(n, -INF));
		REP(i, n)a[i][i] = 0;
		REP(f, d.size()) {
			if (mid&(1 << f)) {
				vvi t = d[f], next = a;
				REP(k, n)REP(i, n)REP(j, n) {
					if (a[i][k] != -INF && t[k][j] != -INF && a[i][k] + t[k][j] > next[i][j]) {
						next[i][j] = a[i][k] + t[k][j];
					}
				}
				a = next;
			}
		}
		int m = 0;
		REP(i, n)REP(j, n)chmax(m, a[i][j]);
		if (m >= k)r = mid;
		else l = mid;
	}

	cout << r << endl;

	if (r <= 100) {
		vector<vvi> p;
		{
			vvi tmp(n, vi(n, -INF));
			REP(i, n)tmp[i][i] = 0;
			p.push_back(tmp);
		}
		REP(i, r) {
			vvi t = p.back(), a(n, vi(n, -INF));
			REP(i, n)a[i][i] = 0;
			REP(i, n)REP(j, n)REP(k, n) {
				if (t[i][k] != -INF && v[k][j] != -INF && t[i][k] + v[k][j] > a[i][j]) {
					a[i][j] = t[i][k] + v[k][j];
				}
			}
			p.push_back(a);
		}
		vi ans;
		int x = -1, y = -1;
		int t = 0;
		REP(i, n)REP(j, n)if (p.back()[i][j] >= t) {
			x = i;
			y = j;
			t = p.back()[i][j];
		}

		REP(f, r) {
			REP(k, n) {
				if (v[x][k] + p[r - f - 1][k][y] == p[r - f][x][y]) {
					ans.push_back(x);
					x = k;
					break;
				}



			}
		}
		ans.push_back(y);
		REP(i, r + 1)cout << ans[i] << " \n"[i == r];
	}
}


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

int main(){
  string str;
  cin>>str;
  int flag=1;
  for(int i=0;i<str.size();i++)
    for(int j=i+1;j<str.size();j++)
      if(str[i]==str[j]){
	flag=0;
	break;
      }

  if(flag)
    cout<<"yes"<<endl;
  else
    cout<<"no"<<endl;
}

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

int main(void) {
    string ipt;
    int n, cnt = 0;
    cin >> n >> ipt;
    for (int i = 0; i < n; i ++) {
        if (ipt.at(i) == 'R')
            cnt ++;
    }
    if (cnt > n - cnt)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    for i in range(N):
        if i%2 == 0:
            if A[i]%2 != 0:
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9172
func = lambda x: x if x != 0 else 10 

ct_list = [int(input()) for _ in range(5)]
ct_surp = [func(ct%10) for ct in ct_list]

argmin = sorted(list(enumerate(ct_surp)),key=lambda x:x[1])[0][0]

total_time = 0

for i,ct in enumerate(ct_list):
  if i == argmin:
    continue
  total_time += ct + (10-ct_surp[i]) if ct_surp[i] < 10 else ct

total_time += ct_list[argmin]

print(total_time)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
    string s;
    int res = 0;

    cin >> s;

    for(int i=0;i<3;i++){
        if(s[i] == '1'){
            res++;
        }
    }
    cout << res <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}
#define MX (200005)
char s[MX];
int L,f[26];
ll S;
int main(void){
    scanf("%s",s),L=strlen(s),S=L*(L+1ll)/2+1;
    F(L)++f[s[i]-97];
    F(26)S-=f[i]*(f[i]+1ll)/2;
    printf("%lld\n",S);
    return 0;
}


Measured memory_bytes: 384
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  [m1, _] <- getIntList
  [m2, _] <- getIntList
  print (m2 - m1)

Measured memory_bytes: 380
N,M = [int(x) for x in input().split()]
mini = 0 
maxi = 1.1e+5
for i in range(M):
    l,r = [int(x) for x in input().split()]
    mini = max(mini,l)
    maxi = min(maxi,r)

if maxi - mini +1< 0:
    print(0)
else:
    print(maxi-mini+1)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1234567890

int main(){
    ll i,j;
    ll n;
    cin>>n;
    double v[n];
    for(i=0;i<n;i++) cin>>v[i];
    sort(v,v+n);
    double ans=v[0];
    for(i=1;i<n;i++){
        ans=(ans+v[i])/2.0;
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
S = input()
count = 0
max_count = 0
for s_char in S:
    if s_char == 'A' or s_char == 'C' or s_char == 'G' or s_char == 'T':
        count += 1
    else:
        max_count = max(max_count, count)
        count = 0
max_count = max(max_count, count)
print(max_count)


Measured memory_bytes: 2940
import java.io.PrintStream;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	static void exec(Scanner in, PrintStream out) {
		String N = in.next();
		if (N.length() == 1) {
			out.println(N);
			return;
		}
		if (N.substring(0, 2).equals("10")) {
			int sum = 10;
			if (N.length() > 2) {
				sum += Stream.of(N.substring(2).split(""))
						.mapToInt(Integer::valueOf).sum();
			}
			out.println(sum);
		} else {
			int sum = Stream.of(N.split("")).mapToInt(Integer::valueOf).sum();
			out.println(sum);
		}
	}

	public static void main(String[] args) {
		exec(new Scanner(System.in), System.out);
	}

}


Measured memory_bytes: 26836
import math
import sys
def input():
    return sys.stdin.readline().rstrip('\n')

def get_e(x):
    l = []
    i = 2
    m = math.floor(math.sqrt(x))
    while i <= m and i <= x:
        if x % i == 0:
            x = x // i
            l += [i]
        else:
            i += 1
    if x != 1:
        l += [x]
    return l

def calc(N):
    d = {}
    for i in get_e(N):
        d[i] = 1 + (d[i] if i in d else 0)
    result = 0
    for i in d:
        result += math.floor((math.sqrt(1 + 8 * d[i]) - 1) / 2)
    return result
    

N = int(input())
print(calc(N))

Measured memory_bytes: 63044
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("1_23.txt","r",stdin);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
using namespace std;

ll n,m,ar[N],sum,t;

vector<int> v[N];

int f(int ind,int back)
{
	int k=0;
	for(int i=0;i<v[ind].size();i++)
		k=max(k,f(v[ind][i],ind));
	// cout<<ind<<sp<<k<<endl;
	if(k==m-1 && ind!=1 && back!=1)
	{
		sum++;
		return 0;
	}
	// if(back==1 && k==m && ind!=1)
	// {
	// 	sum++;
	// 	return 0;
	// }
	return k+1;

}

int main()
{
	fast;
	cin>>n>>m;
	fs(ar,n);
	if(ar[1]!=1)
		sum++;
	fo(i,2,n)
		v[ar[i]].pb(i);
	f(1,1);
	cout<<sum<<endl;
}



/*     cd onedrive\desktop\kod
cls

Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/

Measured memory_bytes: 34176
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<stack>
#include<queue>
#include<map>
#include<cstring>
#include<functional>

using namespace std;

int group[200001];

int uf(int a)
{
	if (group[a] == a)
	{
		return a;
	}

	return group[a] = uf(group[a]);
}

void disj(int a, int b)
{
	const int ga = uf(a);
	const int gb = uf(b);

	if (gb < ga)
	{
		group[ga] = gb;

		uf(a);
	}

	else
	{
		group[gb] = ga;

		uf(b);
	}
}

int main()
{
	//freopen("input.txt", "r", stdin);

	int n, m;

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

	for (int i = 1; i <= n; i++)
	{
		group[i] = i;
	}

	for (int i = 0; i < m; i++)
	{
		int u, v;

		scanf("%d %d", &u, &v);

		disj(u, v);
	}

	int cnt[200001] = { 0, };

	int lmax = 0;

	for (int i = 1; i <= n; i++)
	{
		const int g = uf(group[i]);

		if (++cnt[g] > lmax)
		{
			lmax = cnt[g];
		}
	}

	printf("%d\n", lmax);

	return 0;
}

Measured memory_bytes: 3292
#include<bits/stdc++.h>
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

enum PosiNega {
  POSITIVE = 0,
  NEGATIVE = 1
};

void _main() {
  int N;
  cin >> N;

  ll a[N];
  rep(i, 0, N) cin >> a[i];

  ll ans = 0;
  ll sum = 0;
  PosiNega posi_nega = POSITIVE;
  rep(i, 0, N) {
    sum += a[i];
    if (POSITIVE == posi_nega) {
      if (0 >= sum) {
        ans += 1-sum;
        sum = 1;
      }
      posi_nega = NEGATIVE;
    } else {
      if (0 <= sum) {
        ans += 1+sum;
        sum = -1;
      }
      posi_nega = POSITIVE;
    }
  }

  ll _ans = 0;
  ll _sum = 0;
  posi_nega = NEGATIVE;
  rep(i, 0, N) {
    _sum += a[i];
    if (POSITIVE == posi_nega) {
      if (0 >= _sum) {
        _ans += 1-_sum;
        _sum = 1;
      }
      posi_nega = NEGATIVE;
    } else {
      if (0 <= _sum) {
        _ans += 1+_sum;
        _sum = -1;
      }
      posi_nega = POSITIVE;
    }
  }

  chmin(ans, _ans);

  cout << ans << "\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!


void solve(){
    
    int n;
    cin>>n;
    
    int odd=0,even=0;
    int ans=pow(3,n);
    
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        if(x&1){
            odd++;
        }
        else{
            even++;
        }
    }
    int rem=pow(2,even);
    cout<<ans-rem<<endl;
}

int main() {
    faster;
    int t=1;
    // cin>>t;
    while(t-->0){
        solve();
    }
	return 0;
}

Measured memory_bytes: 4096
N = input()
tmp = len(N) - 1
NL = list(N)
if len(N) == 1:
    print(int(N))
elif all(x == "9" for x in NL[1:]):
    print(int(N[0]) + tmp * 9)
else:
    print(int(N[0]) - 1 + tmp * 9)

Measured memory_bytes: 9060
h, w = map(int, input().split())
mat = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    mat[i] = list(input())

row = []
col = []
for y in range(h):
    cnt = 0
    for x in range(w):
        if mat[y][x] == ".":
            cnt += 1
    if cnt == w:
        row.append(y)

for x in range(w):
    cnt = 0
    for y in range(h):
        if mat[y][x] == ".":
            cnt += 1
    if cnt == h:
        col.append(x)

for y in range(h):
    tmp = ""
    for x in range(w):
        if x not in col and y not in row:
            tmp += mat[y][x]
    if tmp != "":
        print(tmp)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ss second
#define ff first
#define pii pair <int,int>
#define vi vector <int>
#define vvi vector <vector <int> >
#define vpii vector <pair <int,int> >
#define ll long long
#define ld long double
#define rep(x,a,b) for(x=a;x<b;x++)
#define db double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define pb push_back
#define mii map <int,int>
#define mod 1000000007


int main()
{
	IOS
	
	int n,i,j;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	int ans=0;
	for(i=0;i<n;)
	{
		j=i;
		while(j<n-1 && a[j]>=a[j+1])
		j++;
		
		
		ans=max(ans,j-i);
		i=j+1;
	}
	
	cout<<ans;
}

Measured memory_bytes: 4040
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

int main(){
	int n,k;cin>>n>>k;
	double ans = 0;
	if(n >= k){
		ans += (double)(n-k+1)/(double)n;
	}
	//cout<<ans<<endl;
	double kiso = 1.0/(double)n;
	for(int i=1;i<min(n+1,k);i++){
		long long tmp = i;
		int cnt =0;
		while(tmp < k){
			tmp *= 2;
			cnt++;
		}
		double tmp2 = 1.0;
		while(cnt--){
			tmp2*=0.5;
		}
		ans += tmp2*kiso;
	}
	printf("%.12f\n",ans);
	return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef pair<int, int>pii;
typedef pair<int, pii>pi3;
int m[1000][1000];
bool flag[1000][1000];
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
int main()
{
	int mx, my, k;
	scanf("%d%d%d", &mx, &my, &k);
	int sx, sy;
	for (int i = 0; i < mx; i++)
	{
		for (int j = 0; j < my; j++)
		{
			char z;
			scanf(" %c", &z);
			if (z != '#')m[i][j] = 1;
			if (z == 'S')sx = i, sy = j;
		}
	}
	queue<pi3>que;
	que.push(make_pair(0, make_pair(sx, sy)));
	int mini = 1000000000;
	for (;;)
	{
		if (que.empty())break;
		pi3 z = que.front();
		que.pop();
		int d = z.first, x = z.second.first, y = z.second.second;
		if (flag[x][y])continue;
		flag[x][y] = true;
		mini = min(mini, (x + k - 1) / k);
		mini = min(mini, (y + k - 1) / k);
		mini = min(mini, (mx - x - 1 + k - 1) / k);
		mini = min(mini, (my - y - 1 + k - 1) / k);
		if (d == k)continue;
		for (int i = 0; i < 4; i++)if (m[x + dx[i]][y + dy[i]] == 1)que.push(make_pair(d + 1, make_pair(x + dx[i], y + dy[i])));
	}
	printf("%d\n", mini + 1);
}

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

int main(){
  vector<int> a;
  int s,t;
  for(int i=0;i<3;i++){
    cin>>s;
    a.push_back(s);
  }
  
  s=count(a.begin(),a.end(),5);
  t=count(a.begin(),a.end(),7);
  if(s==2 and t==1){
    cout<<"YES";
  }
  else{
	cout<<"NO";
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

int main() {
	int h,n;
	cin >> h >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	int sum=0;
	rep(i,n) sum+=a[i];
	if(sum>=h)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 640
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toLong() }
    println(problem069c(n, a))
}

fun problem069c(n: Int, a: List<Long>): String {
    val fours = a.count { it % 4 == 0L }
    val odds = a.count { it % 2 != 0L }
    val twoCount = a.count { it % 2 == 0L && it % 4 != 0L }
    // 4の倍数
    val tmp = (n - fours) - (fours + 1)
    // 2の倍数
    val tmp2 = tmp - if (twoCount > 1) twoCount - 1 else 0
    return if (tmp2 <= 0) "Yes" else "No"
}

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

int main()
{
   int a,b;
   a = b = 0;
   cin >> a >> b;

   if ( a == b )
   {
      cout << "a == b" << endl;
      return 0;
   }
   if ( a < b ) cout << "a < b" << endl;
   else cout << "a > b" << endl;

   return 0;
}

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

using namespace std;

int main() {
  int N;
  
  cin >> N;
  
  vector<long long> A;
  long long sum = 0, sum2 = 0;
  
  for (int i = 0; i < N; i++) {
    long long inA;
    
    cin >> inA;
    
    sum += inA * (i % 2 == 0 ? 1 : -1);
    
    A.push_back(inA);
  }
  
  long long X = sum;
  
  cout << X;
  
  for (int i = 0; i < N - 1; i++) {
    X = 2 * A[i] - X;
    
    cout << " " << X;
  }
  
  return 0;
}

Measured memory_bytes: 4300
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{template<class U>static auto c(U v)->decltype(v.begin(),v.end(),std::true_type());static std::false_type c(...);public:const static bool value=decltype(c(std::declval<T>()))::value;};
template<class T,typename enable_if<iterable<T>::value, nullptr_t>::type=nullptr>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    int isl=1;
    REP(i,1,n){
        isl+=s[i-1]!=s[i];
    }
    dprint("first island:", isl);
    isl-=k*2;
    chmax(isl,1);
    cout<<n-isl<<endl;
    /*int rp=n-2;
    REP(i,1,n){
        if(a[i-1]!=a[i]){
            while(rp)
        }
    }*/
}


Measured memory_bytes: 512
//by xiqiao
#include<bits/stdc++.h>
#define maxn 100005
using namespace std;
typedef long long ll;
int n;
vector <int> v[maxn];
map <pair<int,int> ,int> mp,vis;
int fa[maxn];
queue <pair<int,int> > q;
set <int> s[maxn];
int find(int x){
	if(fa[x]==x)return x;
	return fa[x]=find(fa[x]);
}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)fa[i]=i;
	for(int i=1;i<n+n-1;i++){
		int x,y;scanf("%d%d",&x,&y);if(x>y)swap(x,y);
		s[x].insert(y);s[y].insert(x);
		mp[make_pair(x,y)]++;
		if(mp[make_pair(x,y)]==2){
			vis[make_pair(x,y)]=1;q.push(make_pair(x,y));
		}
	}
	for(int i=1;i<n;i++){
		int x,y;
		while(1){
			if(q.empty()){
				puts("NO");return 0;
			}
			x=q.front().first,y=q.front().second;q.pop();
			x=find(x);y=find(y);//cout<<x<<" "<<y<<endl;
			if(x!=y)break;
		}
		if(s[x].size()>s[y].size())swap(x,y);
		fa[x]=y;
		for(set <int> :: iterator it=s[x].begin();it!=s[x].end();it++){
			int v=find(*it);
			if(v==y)continue;
			s[v].insert(y);s[y].insert(v);int tt=0;
			if(v>y)tt=1,swap(v,y);
			mp[make_pair(v,y)]++;
			if(mp[make_pair(v,y)]>1 && !vis[make_pair(v,y)]){
				vis[make_pair(v,y)]=1;
				q.push(make_pair(v,y));
			}
			if(tt)y=v;
		}
		s[y].erase(x);s[x].clear();
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 45312
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int i=1;
        do{
            int x=i;
            if(x%3==0){
                System.out.print(" "+i);
            }
            else{
                while(true){
                    if(x%10==3){
                        System.out.print(" "+i);
                        break;
                    }
                    x/=10;
                    if(x!=0) continue;
                    else break;
                }
            }
        }while(++i<=n);
        System.out.println();
    }
}


Measured memory_bytes: 28436
#include<iostream>

using namespace std;

int main(){
  int q;
  cin >> q;
  int sosu[100001] = {};
  int rui[100001] = {};
  int l[100001] = {};
  int r[100001] = {};
  for(int i = 0; i < q ; i++){
    scanf("%d %d", &l[i], &r[i]);
  }
  sosu[1] = 0;
  for(int i = 2; i <= 100000; i++){
    if(sosu[i] == 0 && sosu[(i+1) / 2] == 0 && i % 2 == 1) rui[i] = rui[i - 1] + 1;
    else rui[i] = rui[i - 1];
    if(sosu[i] == 1 || i > 100000 / 2) continue;
    int j = 2;
    while(i * j <= 100000){
      sosu[i * j] = 1;
      j++;
    }
  }
  for(int i = 0; i < q; i++){
    printf("%d\n", rui[r[i]] - rui[l[i]-1]);
    //printf("%d %d %d\n",rui[l[i]], rui[r[i]], rui[r[i]] - rui[l[i]-1]);
  }

}


Measured memory_bytes: 2684
#include <stdio.h>

int main(void)
{
	int n,b,f,r,v,a[4][3][10]={0},i,j,k;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d%d",&b,&f,&r,&v);
		a[b-1][f-1][r-1]+=v;
	}
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++)printf(" %d",a[i][j][k]);
			puts("");
		}
		if(i!=3)printf("####################\n");
	}
	return 0;
}


Measured memory_bytes: 2072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
  int n;
  cin >> n;
  n=n%10;
  if(n==2||n==4||n==5||n==7||n==9)
    cout << "hon" << endl;
  if(n==0||n==1||n==6||n==8)
    cout << "pon" << endl;
  if(n==3)
    cout << "bon" << endl;  
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int n, y;
  cin >> n >> y;
  int x[n];
  for(int i=0; i<n; i++){
    cin >> x[i];
  }

  x[n]=y;
  sort(x, x+n+1);

  int dif[n];
  
  for(int i=0; i<n; i++){
    dif[i] = x[i+1]-x[i];
  }

  int mini = 1000000000;
  for(int i=0; i<n; i++){
    mini = min(dif[i], mini);
  }

  int flg=0, ans=0;

  for(int i=mini; i>0; i=i-1){
    flg = 0;
    for(int j=0; j<n; j++){
      if(dif[j]%i!=0){
	flg=1;
      }
    }
    if(flg==0){
      ans = i;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

        int n = in.nextInt();
        int x = in.nextInt();
        int[] arr = in.nextIntArray(n);


        for (int i=0; i<n; i++) {
            arr[i] -= x;
        }
        int gcd = Math.abs(arr[0]);
        for (int i=1; i<n; i++) {
            gcd = Math.abs(gcd(gcd, arr[i]));
        }
        out.println(gcd);
        out.close();
        //INT OVERFLOW -> USE LONG
        //ARR OUT OF BOUNDS
    }

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

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        public double[] nextDoubleArray(int n) {
            double[] arr = new double[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextDouble();
            }
            return arr;
        }

        public long[] nextLongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }

        public char[] nextCharArray(int n) {
            char[] arr = nextLine().trim().replaceAll("\\s", "").toCharArray();
            return arr;
        }

        public String[] nextStringArray(int n) {
            String[] arr = new String[n];
            for (int i = 0; i < n; i++) {
                arr[i] = next();
            }
            return arr;
        }
    }
}


Measured memory_bytes: 36364
#include<bits/stdc++.h>
 
using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
const long long lim = 3e5+100;
typedef long long int lld;
typedef long long ll;

#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define mset(a, v) memset(a, v, sizeof(a))
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }
 
 
#define popcount __builtin_popcountll
 
ll powP(ll x, ll y) {
    ll ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}

vector<ll> Ans, Adj[lim];
ll Array[lim], Vis[lim];
pair<ll,ll> P[lim];

ll dfs(ll node,ll Vis[]) {
    Vis[node]=1;
    for(auto i:Adj[node]) {
        if(!Vis[i]) dfs(i,Vis); 
    }

    return 0;
}

int main(){

    ios::sync_with_stdio(0);
    cin.tie(0);

    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    
    lld T,i,p,j,l,e,r,b,c,k,m,q,a,d,w,x,y,u,v,z,t,curr,prev,sum=0,val,countA=0,indicator=0,pos,h,minA,maxA,type,n,ans=0,left,right;
    string A,B;
    A = "Yes", B="No";
    cin>>A>>B;
    ans = INT_MAX;
    rep(i,0,A.size()-B.size()) {
        val=0;
        rep(j,0,B.size()-1) {
            if(B[j]!=A[i+j]) val++;
        }

        ans = min(ans,val);
    }

    cout<<ans<<endl;
    return 0;
}
    

Measured memory_bytes: 10684
#include <bits/stdc++.h>
using namespace std;
long long mod=pow(10,9)+7;

long long dp[500][500];
long long solve (int i,int j,int*arr,long long*pre)
{
	 if(i>=j)
	  return 0;
	  if(dp[i][j]!=-1)
	   return dp[i][j];
	   long long ans=1e18;
	  for(int k=i;k<j;k++)
	  {
	  	  long long a=solve(i,k,arr,pre);
		  long long b=solve(k+1,j,arr,pre);
		  ans=min(ans,a+b+pre[j+1]-pre[i]);
	  }
	  
	  return dp[i][j]=ans;
	  
}
int main() {	
	int t=1;
	//cin >> t;
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	while (t--) {
	     int n;
	     cin>>n;
	     int*arr=new int[n];
	     memset(dp,-1,sizeof(dp));
	     for(int i=0;i<n;i++)
	     {
	     	cin>>arr[i];
		 }
		 long long*pre=new long long[n+1];
		 pre[0]=0;
		 for(int i=1;i<=n;i++)
	    {
	    	pre[i]=pre[i-1]+arr[i-1];
		}
		 
		 long long temp=solve(0,n-1,arr,pre);
		 cout<<dp[0][n-1];
		 
	 
      }
	} 
	
	
	

Measured memory_bytes: 5620
#include<iostream>
using namespace std; //or std::cin et al.

int main() {
	int i,count = 1;
	while (1) {
		cin >> i;
		if ( i == 0 ) {
			break;
		}
		cout << "Case " << count << ": " << i << endl;
                count++;
	}
	
	return 0;
}


Measured memory_bytes: 3108