akhauriyash/Code-Regression huggingface dataset:
#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++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int a, b, k;
  cin >> a >> b >> k;
  int g = __gcd(a, b);
  vi can;
  for(int i = 1; i*i <= g; i++) {
    if(g%i == 0) {
      can.push_back(i);
      if(i != g/i)can.push_back(g/i);
    }
  }
  sort(rall(can));
  int ans = can[k-1];
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input().strip())
a = []
for i in range(0, N):
    ak = int(input().strip())
    a.append(ak)

ME = 'first'
RUN = 'second'

me_win = True
all_even = True
for ai in a:
    all_even &= ai%2 == 0
me_win = not all_even

print(ME if me_win else RUN)

Measured memory_bytes: 7072
#include<stdio.h>
main()
{
    int A,B;
    scanf("%d%d",&A,&B);
    if ((A==1 && B==2)||(A==2 && B==1))
        printf("3");
    else if ((A==2 && B==3)||(A==3 && B==2))
        printf("1");
    else
        printf("2");

}


Measured memory_bytes: 128
ans i 1 = i
ans i n =
  if (n `mod` 2) == 0
  then ans (i+1) (n `div` 2)
  else ans (i+1) (n*3 + 1)

main = do
  c <- getContents
  let i = takeWhile (/= 0) $ map read $ lines c :: [Int]
      o = map (ans 0) i
  mapM_ print o

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

using namespace std;
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define NULL 0
#define pi 3.14159265358979323846
#define d0(x) cout<<x<<" ";
#define d1(x) cout<<x<<"\n";
#define d2(x,y) cout<<x<<" "<<y<<"\n";
#define d3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n";
#define d4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<"\n";
 
template<typename T, typename U> static inline void amin(T &x, U y){if (y < x)x = y;} 
template<typename T, typename U> static inline void amax(T &x, U y){if (y > x)x = y;} 
 
typedef long long int ll;
typedef unsigned long long int ull;
const  ll mod=(1000000007); 
const long long inf = (ll)1e18+17;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

    ll n,m,x;
    ll c[13];ll a[13][13],op[20],ind=0,ans=inf;

void dfs(int pos){
    if(pos==n){
        ll d[13]={0},cc=0;
        for(int i=0;i<ind;i++){
            cc+=c[op[i]];
        for(int j=0;j<m;j++){
            d[j]+=a[op[i]][j];
        }
        }
        
        for(int i=0;i<m;i++){
            if(d[i]<x)return;
        }//d0(cc)
        amin(ans,cc);
        return;
    }
    dfs(pos+1);
    op[ind++]=pos;
    dfs(pos+1);
    ind--;
}

void solve(){
    cin>>n>>m>>x;
    for(int i=0;i<n;i++){
        cin>>c[i];
        for(int j=0;j<m;j++)cin>>a[i][j];
    }
    dfs(0);
    if(ans==inf)cout<<"-1\n";
    else cout<<ans<<endl;

}
 
int main()
{  
    clock_t tt;tt = clock(); 
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    //pre();
    for(int i=1;i<=t;i++){
       //cout<<"Case #"<<i<<": ";
       solve();
    }
    tt = clock() - tt; double time_taken = ((double)tt)/CLOCKS_PER_SEC;   
    //printf("code took %f seconds to execute \n", time_taken); 
    return 0;
}

// ============== Notes =============== //
// common bugs
// - fastio
// - int overflow (especially intermediate expressionns)
// - array bounds (indices bigger than MAXN?)
// - special cases (n=1? graph not connected?)
// - re-initialize efficiently between test cases


Measured memory_bytes: 3664
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    int c=a*b;
     if(c%2==0){
        cout<<"Even";
    }else if(c%2==1){
        cout<<"Odd";
    }
    
    
    
    
    
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi 3.14159265
using namespace std;
int main(void){
    int a,b,x;
    double y,ans;
    cin>>a>>b>>x;
    if(2*x<=a*a*b){
        y=2.0*x/(a*b);
        ans=atan(b/y)*360/(2*pi);
        printf("%6f\n",ans);
    }
    else{
        y=2.0*(a*a*b-x)/(a*a);
        ans=atan(y/a)*360/(2*pi);
        printf("%6f\n",ans);
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();
		int b[] = new int[m];
		int a[][] = new int[n][m];
		for (int i = 0; i < m; i++) {
			b[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			for (int o = 0; o < m; o++) {
				a[i][o] = sc.nextInt();
			}
		}
		int kei = 0;
		int ans = 0;
		for (int i = 0; i < n; i++) {
			kei = 0;
			for (int o = 0; o < m; o++) {
				kei += b[o] * a[i][o];
			}
			kei += c;
			if (kei > 0) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 24532
n,m,k = map(int,input().split())

#mod = 998244353

ans = 0

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353 #出力の制限
N = n
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

#a = cmb(n,r,mod)


#p = 998244353
#N = 10 ** 6  # N は必要分だけ用意する
"""
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
"""
ans = 0#(pow(2,n)-1)%p
#print(ans)
#exit()
#print(cmb(n, a, p) , cmb(n, b, p))
#print(ans,cmb(n, a, p),cmb(n, b, p))

for i in range(k+1):
    ans += m*cmb(n-1,i,mod)*pow(m-1,n-1-i,mod)
    ans %= mod
    #print(ans)
    #print(ans,i)

print(ans%mod)
#ans -= (cmb(n, a, p) + cmb(n, b, p))

Measured memory_bytes: 112600
import java.util.*;

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

    while(true){
      int n = sc.nextInt();
      if(n == 0) break;

      ArrayList<HashSet<Integer>> set = new ArrayList<HashSet<Integer>>();
      boolean[][] flg = new boolean[n][32];

      for(int i=0;i<n;i++){
        set.add(new HashSet<Integer>());
        set.get(i).add(i);

        int m = sc.nextInt();

        for(int j=0;j<m;j++){
          int x = sc.nextInt();
          flg[i][x-1] = true;
        }
      }

      int ans = 0;
      for(;ans<30;ans++){
        HashSet<Integer> tmp = new HashSet<Integer>();
        for(int j=0;j<n;j++){
          if(flg[j][ans]){
            tmp.addAll(set.get(j));
          }
        }
        if(tmp.size() == n) break;

        for(int j=0;j<n;j++){
          if(flg[j][ans]){
            set.get(j).addAll(tmp);
          }
        }
      }

      System.out.println(ans==30 ? -1 : ans+1);
    }
  }
}

Measured memory_bytes: 98752
#include <iostream>
#include <map>

using namespace std;

const long long int MOD=1e9+7;

long long int modinv(long long int a, long long int m) {
    long long int b = m, u = 1, v = 0;
    while (b) {
        long long int t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

long long int cmb(long long int i, long long int j) {
    if(i-j<j) j=i-j;
    long long int ret=1;
    for(int k=1; k<=j; k++) {
        ret *= (i-k+1);
        ret %= MOD;
        ret *= modinv(k, MOD);
        ret %= MOD;
    }
    return ret;
}

int main() {
    long long int N, A, B;
    cin >> N >> A >> B;
    
    map<long long int, long long int> mp;
    long long int pow=1;
    long long int cur=2;
    mp[pow]=cur;
    while(pow<N) {
        pow*=2;
        cur *= cur;
        cur %= MOD;
        mp[pow]=cur;
    }
    
    long long int ans=1;
    long long int cnt=0;
    for(auto itr=mp.begin(); itr!=mp.end(); itr++) {
        if(N & (1<<cnt)) {
            ans *= itr->second;
            ans %= MOD;
        }
        cnt++;
    }
    ans--;
    
    long long int tmp=0;
    tmp += cmb(N, A);
    tmp += cmb(N, B);
    tmp %= MOD;
    ans -= tmp;
    
    while(ans<0) {
        ans += MOD;
    }
    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <functional>
#include <iomanip>

#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using ll = mp::cpp_int;

using namespace std;
// using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
const int MOD = 1e9+7;
const int INF = 1e9;
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; }

// debug
template<class T>ostream& operator<<(ostream& os, vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& out,const pair<T1,T2>& rhs){out<<"("<<rhs.first<<", "<<rhs.second<<")";return out;}
#include<type_traits>
template<typename T,size_t SIZE,enable_if_t<!is_same<remove_cv_t<T>,char>::value,nullptr_t> = nullptr>ostream& operator<<(ostream& os,T(&arr)[SIZE]){os<<"{";for(size_t i=0;i<SIZE;++i)os<<(i?", ":"")<<arr[i];os<<"}";return os;}
#ifdef LOCAL
    #define debug(v) cerr<<v<<"\n"
#else
    #define debug(...) 42
#endif


const int MAX = 2e5+1;
long long fac[MAX], finv[MAX], inv[MAX];

void comb_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long comb(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


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

  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  sort(A.begin(), A.end());

  ll sum[N+1];
  sum[0] = 0;
  rep(i, N)
    sum[i+1] = sum[i] + A[i];

  ll ans = 0;
  if (K == 1) {
    cout << 0 << endl;
    return 0;
  }
  rep(l, K, N+1) {
    ans += (((sum[N] - sum[l-1]) - sum[N - l + 1]) * comb(l-2, K-2));
  }
  ans %= MOD;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11136
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b>c+d) cout<<"Left";
	if(a+b<c+d) cout<<"Right";
	if(a+b==c+d) cout<<"Balanced";
	return 0;
 } 

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};
int key = 0;
int N;
ll ma=0;
ll ans;
ll n;

void saiki(int idx,ll num) {
	if (idx == N) {
		if (ma < min(abs(n - num), (ll)pow(10, N) - abs(n - num))) {
			ma = max(ma, min(abs(n - num), (ll)pow(10, N) - abs(n - num)));
			ans = num;
		}
		else if (ma == min(abs(n - num), (ll)pow(10, N) - abs(n - num))) {
			ans = min(ans,num);
		}
		return;
	}
	REP(i, 10) {
		if (!(key&(1 << i))) {
			key |= (1 << i);
			saiki(idx + 1, num * 10 + i);
			key &= ~(1 << i);
		}
	}
}
int main() {
	string s;
	cin >> s;
	n = atol(s.c_str());
	ans = n;
	N = s.length();
	saiki(0, 0);
	REP(i,N)
	cout <<ans/(ll)pow(10,N-i-1)%10;
	cout << endl;
}

Measured memory_bytes: 3336
t = input()
ans  = ''
for i in range(len(t)):
    if i == 0:
        if t[i] == '?':
            ans += 'D'
        else:
            ans += t[i]
    else:
        if t[i] =='?':
            if ans[i-1] == 'P':
                ans += 'D'
            else:
                ans += 'D'
        else:
            ans += t[i]
print(ans)

Measured memory_bytes: 9396
import itertools, math

n, k = input().split()
nums = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} - {x for x in input().split()}
length = len(n)
coms = itertools.product(nums, repeat=length)
n = int(n)
ans = float("inf")
for com in coms:
    tmp = "".join(com)
    if n <= int(tmp) < ans:
        ans = int(tmp)

coms = itertools.product(nums, repeat=length+1)
for com in coms:
    tmp = "".join(com)
    if n <= int(tmp) < ans:
        ans = int(tmp)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

class Node
{
public:
	Node* prev;
	Node* next;
	int key;
};

Node* nil;

void init()
{
	nil->key = 0;
	nil->prev = nil;
	nil->next = nil;
}

void print()
{
	Node* cur = nil->next;
	int isf = 0;
	while (true)
	{
		if (cur == nil)
		{
			break;
		}
		if (isf++ > 0)
		{
			cout << " ";
		}
		cout << cur->key;
		cur = cur->next;
	}
	cout << endl;
}

void insert(int key)
{
	Node* node = new Node;
	node->key = key;
	node->next = nil->next;
	nil->next->prev = node;
	nil->next = node;
	node->prev = nil;
}

Node* listSearch(int key)
{
	Node* cur = nil->next;
	while (cur != nil && cur->key != key)
	{
		cur = cur->next;
	}
	return(cur);
}

void deleteNode(Node* t)
{
	if (t == nil)
	{
		return;
	}
	t->prev->next = t->next;
	t->next->prev = t->prev;
	delete(t);
}

void deleteKey(int key)
{
	deleteNode(listSearch(key));
}

void deleteFirst()
{
	deleteNode(nil->next);
}

void deleteLast()
{
	deleteNode(nil->prev);
}

void solve()
{
	int n;
	cin >> n;
	nil = new Node;
	init();
	for (int i = 0; i < n; ++i)
	{
		char command[12];
		scanf("%s", command);
		if (command[6] == 'F')
		{
			deleteFirst();
		}
		else if (command[6] == 'L')
		{
			deleteLast();
		}
		else
		{
			int key;
			scanf("%d", &key);
			if (command[0] == 'i')
			{
				insert(key);
			}
			else if (command[0] == 'd')
			{
				deleteKey(key);
			}
		}
	}
	print();
	delete nil;
}

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

Measured memory_bytes: 32420
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        char[][] c = new char[h][w];
        for (int i = 0; i < h; i++) {
            c[i] = sc.next().toCharArray();
        }
        sc.close();

        // 主処理
        int result = 0;

        List<List<Integer>> lineCombinationList = combinationList(h);
        List<List<Integer>> columnCombinationList = combinationList(w);

        for (List<Integer> lineList : lineCombinationList) {
            char[][] grid = cloneArray(c, h, w);
            for (int lineNum : lineList) {
                for (int i = 0; i < w; i++) {
                    grid[lineNum][i] = '.';
                }
            }
            for (List<Integer> columnList : columnCombinationList) {
                char[][] grid2 = cloneArray(grid, h, w);
                for (int columnNum : columnList) {
                    for (int i = 0; i < h; i++) {
                        grid2[i][columnNum] = '.';
                    }
                }
                if (countBlack(grid2) == k) {
                    result++;
                }
            }
        }

        // 出力
        System.out.println(result);

    }

    public static List<List<Integer>> combinationList(int n) {
        List<List<Integer>> combinationList = new ArrayList<>();
        for (int i = 0; i < Math.pow(2, n); i++) {
            List<Integer> list = new ArrayList<>();
            for (int j = 0; j < n; j++) {
                if ((1 & i >> j) == 1) {
                    list.add(j);
                }
            }
            combinationList.add(list);
        }
        return combinationList;
    }

    public static int countBlack(char c[][]) {
        int count = 0;
        for (int i = 0; i < c.length; i++) {
            for (int j = 0; j < c[i].length; j++) {
                if (c[i][j] == '#') {
                    count++;
                }
            }
        }
        return count;
    }

    public static char[][] cloneArray(char[][] array, int h, int w) {
        char[][] grid = new char[h][w];
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                grid[i][j] = array[i][j];
            }
        }
        return grid;
    }
}


Measured memory_bytes: 36836
import numpy as np

N, D = map(int, input().split())
X = [ list(map(int,input().split())) for i in range(N)]
sum = 0
count = 0
for i in range(N):
  for j in range(i+1,N):
    d = 0
    sum = 0
    for k in range(D):
      sum += (X[i][k] - X[j][k])**2
    d = np.sqrt(sum)
    if d // 1 == d:
      count +=1
print(count)
    



Measured memory_bytes: 14472
S,T=input(),input()
l,m=len(S),len(T)

for i in range(l-m+1):
  if all(c in"?"+d for c,d in zip(S[-i-m:],T)):
    S=S.replace("?","a")
    print(S[:-i-m]+T+S[l-i:])
    quit()

print("UNRESTORABLE")

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

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

    for(int v = 1; v <= n; ++v){
        int price = v * 1.08;
        if(price == n){
            cout << v << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < int(n); i++)
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >>b >> c;
  d = c - (a - b);
  if(d < 0) d = 0;
  cout << d <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}

ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}

int main(){
    ll n;
    cin >> n;
    ll a[n];
    bool x=true;
    for (ll i=0;i<n;i++){
        cin >> a[i];
        if (a[i]==0)x=false;
    }
    ll ans=1;
    for (ll i=0;i<n;i++){
        ll s=ans;
        ans*=a[i];
        if (ans>1000000000000000000 or ans<s){
            if (x){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

 


Measured memory_bytes: 4420
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"

#define rep(i,n) for (int i = 0; i < n; i++)
#define repd(i,n) for (int i = n-1; i >= 0; i--)
#define fo(i,a,b) for (int i = a; i < b; i++)
#define fod(i,a,b) for (int i = a; i >= b; i--)
#define umap unordered_map<int,int>
#define mii map<int,int>
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define pqMin priority_queue<int,vector<int>,greater<int>>
#define pqMax priority_queue<int>
#define pqpii priority_queue<pii>
#define all(v) v.begin(),v.end()
#define sortall(v) sort(all(v))
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define w(t) int t; cin>>t; while (t--)
#define out(x, y) cout << x << " " << y << endl
#define print(x) cout << x << endl
#define ps(x,y) fixed<<setprecision(y)<<x
#define pprint cout<<"Case #"<<tt<<": ";
const int mod = 1e9+7;
const int N = 2e5;
const int inf = 1e18;

int add(int a,int b){int res=(a+b)%mod;return (res<0)?res+mod:res;}
int mul(int a,int b){int res=(a*1LL*b)%mod;return (res<0)?res+mod:res;}
bool compare (int x, int y) { return x > y;}

struct Compare {
    bool operator () (pii A, pii B) {
        return A.first > B.first;
    }
};
 struct tri{
   int x,y,z;
 };
 struct cmp{
bool operator ()(tri a,tri b){
    if(a.x==b.x)
        return a.y>b.y;
    return a.x<b.x;

}};
bool comp(pii a,pii b){
    if(a.first>b.first) return true;
    else if(a.first==b.first) return a.second<b.second;
    else return false;

}
int binarySearch(vector<int>nums, int lo, int hi, int target) {
        while (lo < hi) {
            int mid = (lo + hi)/2;
            if (nums[mid] <= target) {
                lo = mid + 1;
            } else {
                hi = mid;
            }
        }
        return lo;
    }
void solve() {

    int t = 1;
    //cin >> t;
   while(t--){
     int x;
     cin>>x;
     if(x>=30) cout<<"Yes";
     else cout<<"No";

    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

   /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/

    solve();

    return 0;
}


Measured memory_bytes: 3644
function Main(input) {
	input = input.trim().split(" ").map((a)=>Number(a));
  if(input[0] % 2 == 0 || input[1] % 2 == 0) {
     console.log("No");
     }else{
      console.log("Yes"); 
     }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21192
#pragma optimization_level 3
#include <bits/stdc++.h>
#define  f               first
#define  s               second
#define  sym(s)          s = "#" + s + "#";
#define  all(x)          (x).begin(), (x).end()
#define  alll(x,n)       x+1, x+n+1
#define  newl            cout<<"\n";
#define  foo(i,a,n)      for(ll i = (a); i <= n; i++)
#define  deb1(a)         cout<<a<<"\n";
#define  deb2(a,b)       cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)     cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)   cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  debp(a)         cout<<a.f<<" "<<a.s<<"\n";
#define  debv(a)         for(auto it: a)cout<<it<<" ";newl;
#define  debm(a)         for(auto it: a)cout<<"{"<<it.f<<","<<it.s<<"}, ";newl;
#define  deb1d(a,n)      foo(i,1,n)cout<<a[i]<<" ";newl;
#define  deb2d(a,n,m)    foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}

using namespace std;
using ll              =  long long;
using ld              =  long double;
const ll   MOD        =  1e+9 + 7;
const ll   INF        =  LLONG_MAX;
const int  N          =  (int)2e+5 + 8;

ll n, x, y, res[N];
struct point {
    ll x, y, i;
};
vector<point> v;
map<pair<ll, ll>, ll> m;

ll par[N], sz[N];
void make() {
    foo(v, 1, N - 1)
    par[v] = v, sz[v] = 1;
}

ll find(ll v) {
    return  (v == par[v]) ? v : par[v] = find(par[v]);
}

ll merge(ll x, ll y) {
    ll a = find(x);
    ll b = find(y);
    if (a != b) {
        if (sz[a] < sz[b])
            swap(a, b);
        par[b] = a;
        sz[a] += sz[b];
        return 0;
    }
    return 1;
}
void MAIN(int tc) {
    make();
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> x >> y;
        v.push_back({x, y, i});
        m[ {x, y}] = i;
    }

    {
        set<pair<ll, ll>> bag;
        bag.insert({INF, INF});
        for(auto z: v)bag.insert({z.y, z.x});
        sort(all(v), [&](point p1, point p2) {return p1.x < p2.x;});
        for (auto z : v) {
            ll x = z.x, y = z.y, i = z.i;
            bag.erase({y, x});
            pair<ll, ll> p = *bag.upper_bound({y, INF});
            while (p.f != INF) {
                ll v = merge(i, m[ {p.s, p.f}]);
                if (v == 1) break;
                p = *bag.upper_bound({p.f, INF});
            }
        }
    }
    {
        set<pair<ll, ll>, greater<pair<ll,ll>>> bag;
        bag.insert({-INF, -INF});
        for(auto z: v)bag.insert({z.y, z.x});
        sort(all(v), [&](point p1, point p2) {return p1.x > p2.x;});
        for (auto z : v) {
            ll x = z.x, y = z.y, i = z.i;
            bag.erase({y, x});
            pair<ll, ll> p = *bag.upper_bound({y, -INF});
            while (p.f != -INF) {
                ll v = merge(i, m[ {p.s, p.f}]);
                if (v == 1) break;
                p = *bag.upper_bound({p.f, INF});
            }
        }
    }

    for (int i = 1; i <= n; i++) {
        deb1(sz[find(i)]);
    }
}

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

    int test_cases = 1;
    //cin>>test_cases;
    for (int i = 1; i <= test_cases; i++) {
        MAIN(i);
    }
}

Measured memory_bytes: 35988
/*
AizuOnline A2020
Title Princess's Japanese
@kankichi573
*/
#include <stdio.h>
#include <string.h>
//char buf[101]="hottokouhii";
//char flag[101]={0,0,0,0,1,0,0,0,0,0,0};
char buf[102];
char flag[101];
//
int is_musei(char c)
{
        return(c=='k'||c=='s'||c=='h'||c=='t'||c=='p');
}
int is_boin(char c)
{
        return(c=='a'||c=='e'||c=='i'||c=='o'||c=='u');
}
int is_sokuon(char * s)
{
        if(!*s)
                return(0);
        return(!is_boin(*s) && *s==*(s+1));
}
char next_boin(char * s)
{
        int i;
        char c;

        for(i=1;i<4;i++)
        {
                if(!s[i])
                        return(0);
                if(is_boin(c=s[i]))
                return(c);
        }
        return(0);
}
int prev_boin_museika(char * s)
{
        s--;
        while(s >= buf)
        {
                if(is_boin(*s))
                        return(flag[s-buf]);
                s--;
        }
        return(0);
}
int is_musei_prev(char *s)
{
        if(s > buf && is_musei(s[-1]))
                return(1);
        if(s > buf+1 && is_musei(s[-2]) && (s[-1]=='y'))
                return(1);
        return(0);
}
int is_musei_next(char *s)
{
        if(!s[1])
                return(1);
        if(is_musei(s[1]))
                return(1);
}
int is_musei_hasami(char *s)
{
        return(is_musei_prev(s) && is_musei_next(s));
}
void solve()
{
        char *p,*f,c;
        p=buf+1;f=flag+1;

        while((c=*p))
        {
                //printf("C= %c\n",c);

                if(c=='i'||c=='u')
                         if(is_musei_hasami(p) &&
                           !prev_boin_museika(p))
                                *f=1;
                if(c=='a'||c=='o')
                {
                         if(is_musei_hasami(p) &&
                            !prev_boin_museika(p) &&
                            !is_sokuon(p+1))
                                if(c==next_boin(p))
                                        *f=1;
                }
                p++;f++;
        }
}
void write_result()
{
        char *p,*q,c;

        p=buf;q=flag;

        while(c=*p)
        {
                if(*q)
                        printf("(%c)",c);
                else
                        printf("%c",c);
                p++;q++;
        }
        printf("\n");
}

main()
{
        while(EOF!=scanf("%s",buf) && buf[0]!='#')
        {
                
                memset(flag,0,102);
                solve();
                write_result();
        }
        return(0);
}

Measured memory_bytes: 544
import java.util.*;
public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);

		//ツエツδ可トツスツテツネツスツづ個づ督づゥツつ「
		final int MAX = 10000000;
		boolean [] prime = new boolean[MAX + 1];
		for(int i=3; i <= MAX; i+= 2){
			prime[i] = true;
		}
		for(int i=3; i * i <= MAX; i+= 2){
			if(prime[i]){
				for(int j = i*3; j <= MAX; j += i*2){
					prime[j] = false;
				}
			}
		}
		int n = sc.nextInt();
		while(n!=0){
			if(n % 2 == 0) n--;
			for(int i=n;i >= 13; i-= 2){
				if(prime[i] && prime[i-2] &&prime[i-6] &&prime[i-8]){
					System.out.println(i);
					break;
				}
			}
			n = sc.nextInt();
		}

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

	}

}

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

int main(){


	vector<double> v;
	int N;
	cin >> N;
	double x;
	string u;

	for (int i = 0; i < N; i++){
		cin >> x >> u;
		if (u=="BTC"){
			x *= 380000.0;
		}else{

		}
		v.push_back(x);
	}
	double sum = 0;
	for (int i = 0; i < N; i++){
		
		sum += v[i];
	}



	cout << sum << endl;

	
	return 0;
}



Measured memory_bytes: 256
use strict;
use warnings;

my ($a, $b, $c, $d) = split(" ", <STDIN>);
my $L = $a + $b;
my $R = $c + $d;

if ($L > $R) {
    print "Left\n";
} elsif ($L < $R) {
    print "Right\n";
} else {
    print "Balanced\n";
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		long x = scan.nextLong();
		long k = scan.nextLong();
		long d = scan.nextLong();
		
		x = Math.abs(x);
		
		long near = (x/d);
		long stop = k - near;
		if(stop < 0) {
			stop = 0;
		}
		/*
		System.out.println(near);
		System.out.println(stop);  
		*/
		
		
		
		if(k < near) {
			x -= k * d;
			System.out.print(Math.abs(x));
			return;
		}
		
		
		
		if( stop % 2 == 0) {
			x -= near * d;
			System.out.print(Math.abs(x));
			return;
		}
		else {
			x -= near * d;
			
			if(Math.abs(x+d) < Math.abs(x-d)) {
				System.out.print(Math.abs(x+d) );
				return;
			}
			else if(Math.abs(x+d) > Math.abs(x-d)) {
				System.out.print(Math.abs(x-d));
				return;
			}
			else {
				
				System.out.print(Math.abs(x+d) );
				return;
			}
		}
	}

}


Measured memory_bytes: 35600
n=int(input())
s=[input() for _ in range(n)]
ac,wa,tle,re=0,0,0,0

for i in s:
    if i=="AC":
        ac+=1

    elif i=="WA":
        wa+=1

    elif i=="TLE":
        tle+=1

    else:
        re+=1

print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))

Measured memory_bytes: 16228
from math import log2,ceil
N,K = map(int,input().split())
A = list(map(int,input().split()))

minL = 1
maxL = max(A)

while True:
    if minL >= maxL:
        break
    midL = (minL + maxL) // 2
    cut = 0
    for elem in A:
        cut += elem // midL
        if elem % midL == 0:
            cut -= 1
    if cut <= K:
        maxL = midL
    else:
        minL = midL + 1
print(maxL)


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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)
#define cube(x) (x) * (x) * (x)

const int INF = 1e9;

using namespace std;

int main() {
    int n;
    ostringstream os;
    cin >> n;
    set<string> dict;
    REP(i, n){
        string order, str;
        cin >> order >> str;
        if(order == "insert")
            dict.insert(str);
        else if(order == "find"){
            if(dict.count(str))
                os << "yes" << endl;
            else
                os << "no" << endl;
        }
    }
    cout << os.str();
    return 0;
}

Measured memory_bytes: 32984
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <climits>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <unordered_map>
#include <numeric>
#include <random>
#include <memory>
#include <chrono>
#include <functional>
#include <unordered_set>
#include <cstring>
#include <cassert>
#include <bitset>
#ifdef LOCAL
#include "debug.h"
#else
#define debug(x...)
#endif
//#define int ll
//#pragma GCC optimize("Ofast")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
#define sz(x) int((x).size())

#ifndef LOCAL
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#else
	mt19937 rng(228);
#endif

const int N = 5e3 + 7;
const int inf = INT_MAX / 2;
const ll INF = LLONG_MAX / 3;
const int MOD = 998244353;
const ld eps = 1e-6;
const string cars[] = {"🚗", "🚕", "🚙"};



signed main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(9);
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

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

	int c[n], a[n][m];
	for (int i = 0; i < n; i++) {
		cin >> c[i];

		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}

	int ans = 1e9;
	for (int i = 0; i < (1 << n); i++) {
		int cur[m] = {0}, cost = 0;
		for (int j = 0; j < n; j++) {
			if (i & (1 << j)) {
				for (int k = 0; k < m; k++) {
					cur[k] += a[j][k];
				}
				cost += c[j];
			}
		}

		bool flag = true;
		for (int j = 0; j < m; j++) {
			flag &= (cur[j] >= x);
		}

		if (flag) {
			ans = min(ans, cost);
		}
	}

	cout << (ans == 1e9 ? -1 : ans) << endl;

	return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  int n; cin >>n;
  int res = 0;
  rep(i, n){
    int a; cin >>a; res += a % 2;
  }
  res %= 2;
  cout <<(res == 0 ? "YES" : "NO") <<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
int A[128],N;
int main() {
  A[0] = 1;
  for(int i=1; i<=32; i++) {
    A[i] = A[i-1];
    if (i >= 2) {
      A[i] += A[i-2];
    }
    if (i >= 3) {
      A[i] += A[i-3];
    }
  }
  while (cin >> N && N) {
    cout << ((A[N]+9)/10 + 364)/365 << endl;
  }
}

Measured memory_bytes: 1160
S = list(input())
K = int(input())


def solve(S, K):
    T = S * K
    ans = 0
    for i in range(len(T) - 1):
        if T[i] == T[i + 1]:
            ans += 1
            T[i + 1] = "*"
    return ans


A = [solve(S, i) for i in range(6)]
if K <= 5:
    print(A[K])
else:
    if K % 2 == 1:
        d = A[5] - A[3]
        print(A[5] + (K - 5) // 2 * d)
    else:
        d = A[4] - A[2]
        print(A[4] + (K - 4) // 2 * d)


Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	elems, err := nextInts(n, sc)
	if err != nil {
		panic(err)
	}
	sorted, count := mergeSort(elems)
	fmt.Println(strings.Join(isToAs(sorted), " "))
	fmt.Println(count)
}

func mergeSort(elems []int) ([]int, int) {
	length := len(elems)
	if length == 1 {
		return elems, 0
	}
	mid := length / 2
	left, countL := mergeSort(elems[:mid])
	right, countR := mergeSort(elems[mid:])
	sorted, countS := merge(left, right)
	return sorted, (countL + countR + countS)
}

func merge(xs, ys []int) ([]int, int) {
	sorted := make([]int, 0)
	count := 0
	for len(xs) > 0 && len(ys) > 0 {
		if xs[0] < ys[0] {
			sorted = append(sorted, xs[0])
			xs = xs[1:]
		} else {
			sorted = append(sorted, ys[0])
			ys = ys[1:]
		}
		count++
	}
	if len(xs) > 0 {
		sorted = append(sorted, xs...)
		count += len(xs)
	} else if len(ys) > 0 {
		sorted = append(sorted, ys...)
		count += len(ys)
	}
	return sorted, count
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

func nextInts(n int, sc *bufio.Scanner) ([]int, error) {
	ns := make([]int, n)
	for i, _ := range ns {
		x, err := nextInt(sc)
		if err != nil {
			return nil, err
		}
		ns[i] = x
	}
	return ns, nil
}

func isToAs(is []int) []string {
	as := make([]string, len(is))
	for i, _ := range as {
		as[i] = strconv.Itoa(is[i])
	}
	return as
}



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

int main(){
    int n, k;
    cin >> n >> k;
    double result = 0;
    double p[n];
    for(int i=0; i<n; i++){
        cin >> p[i];
        if(i < k) result += p[i];
    }
    double temp = result;
    for(int i=k; i<n; i++){
        temp += p[i] - p[i-k];
        result = max(temp, result);
    }
    printf("%.7f", (result+(double)k)/2.0);
    return 0;
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	if n % sum(n) == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func sum(num int) int {
	var sum int
	for num != 0 {
		sum += num % 10
		num /= 10
	}
	return sum
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
 
int main(){
  ll n, k;
  cin >> n >> k;
  
  ll nn;
  nn = n%k;
  if(nn*2 > k) nn = k-nn;
  cout << nn  << endl;
  
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int A = scanner.nextInt();
        int B = scanner.nextInt();

        int total = 0;
        for (int s=1; s <= N; s++) {
            String value = String.valueOf(s);
            int length = value.length();

            int sum = 0;
            for (int t=0; t < length; t++) {
                sum += value.charAt(t) - '0';
            }

            if (sum >= A && sum <= B) {
                total += s;
            }
        }
        System.out.println(total);
    }
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
typedef long long ll;

int main(){
    fastio;
    int n, m;
    cin >> n >> m;
    if(n % 2 == 1){
        for(int i = 1; i <= m; ++i){
            cout << i << " " << n - i << "\n";
        }
    }
    else{
        int num = (m + 1) / 2;
        for(int i = 1; i <= num; ++i){
            cout << i << " " << n - i + 1 << "\n";
        }
        for(int i = num + 1; i <= m; ++i){
            cout << i << " " << n - i << "\n";
        }
    }
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int n,m,d[60][60];
char a[60][60];
int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};

int bfs(){
    queue<pii> p;
    rep(i,n)rep(j,m)d[i][j]=1e9;
    p.push(MP(0,0));
    d[0][0]=0;
    while(!p.empty()){
        pii q=p.front();
        p.pop();
        if(q.F==n-1&&q.S==m-1)break;
        rep(i,4){
            int x=q.F+dx[i],y=q.S+dy[i];
            if(0<=x&&x<=n-1&&0<=y&&y<=m-1&&d[x][y]==1e9&&a[x][y]!='#'){
                p.push(MP(x,y));
                d[x][y]=d[q.F][q.S]+1;
            }
        }
    }
    return d[n-1][m-1];
}

int main(){
    cin>>n>>m;
    rep(i,n)rep(j,m)cin>>a[i][j];
    int cnt=0;
    rep(i,n)rep(j,m)if(a[i][j]=='#')cnt++;
    int ans=bfs();
    if(ans==1e9){
        cout<<-1<<endl;
        return 0;
    }
    cout<<(n*m-ans-1-cnt)<<endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
par = [i for i in range(N)]
rank = [0 for i in range(N)]
def root(x):
  if par[x] == x:
    return x
  else:
    par[x] = root(par[x])
    return par[x]
def unite(x, y):
  x, y = root(x), root(y)
  if x != y:
    if rank[x] < rank[y]:
      par[x] = y
    else:
      par[y] = x
      if rank[x] == rank[y]:
        rank[x] += 1

for i in range(M):
  X, Y, Z = map(int, input().split())
  unite(X-1, Y-1)
for i in range(N):
  root(i)
print(len(set(par)))

Measured memory_bytes: 13984
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

int W, H;
int N;    
std::vector<int> X1, X2, Y1, Y2;
bool board[6005][6005];

int compress(std::vector<int> &v1, std::vector<int> &v2, int w){
    std::vector<int> v;

    REP(i, N){
        int s = v1[i], t = v2[i];
        FOR(j, -1, 2){
            int ns = s + j, nt = t + j;
            if(0 <= ns && ns < w){
                v.push_back(ns);
            }
            if(0 <= nt && nt < w){
                v.push_back(nt);
            }
        }
    }

    std::sort(v.begin(), v.end());
    v.erase(std::unique(v.begin(), v.end()), v.end());

    REP(i, N){
        v1[i] = std::find(v.begin(), v.end(), v1[i]) - v.begin();
        v2[i] = std::find(v.begin(), v.end(), v2[i]) - v.begin();
    }

    return v.size();
}

int main(){
    while(std::cin >> W >> H, W){
        X1.clear();
        Y1.clear();
        X2.clear();
        Y2.clear();

        std::cin >> N;

        REP(i, N){
            int x1, y1, x2, y2;
            std::cin >> x1 >> y1 >> x2 >> y2;

            X1.push_back(x1);
            Y1.push_back(y1);
            X2.push_back(x2);
            Y2.push_back(y2);
        }

        int wx = compress(X1, X2, W),
            wy = compress(Y1, Y2, H);

        REP(i, wx){
            REP(j, wy){
                board[i][j] = 0;
            }
        }

        REP(i, N){
            int x1 = X1[i], y1 = Y1[i], x2 = X2[i], y2 = Y2[i];
            //std::cout << x1 << " " << y1 << " " << x2 << " " << y2 << std::endl;

            FOR(j, x1, x2){
                FOR(k, y1, y2){
                    board[j][k] = 1;
                }
            }
        }

        // REP(i, wy){
        //     REP(j, wx){
        //         printf("%d, ", board[j][i]);
        //     }
        //     puts("");
        // }

        int res = 0;
        REP(i, wy){
            REP(j, wx){
                if(!board[j][i]){
                    res++;

                    std::queue<P> q;
                    q.push(mp(j, i));
                    board[j][i] = 1;
                 
                    while(!q.empty()){
                        P p = q.front(); q.pop();

                        REP(k, 4){
                            int nx = p.first + dx[k], ny = p.second + dy[k];
                            if(0 <= nx && nx < wx && 0 <= ny && ny < wy && !board[nx][ny]){
                                q.push(mp(nx, ny));
                                board[nx][ny] = 1;
                            }
                        }
                    }
                }
            }
        }

        std::cout << res << std::endl;
    }
}

Measured memory_bytes: 9236
// #define _GLIBCXX_DEBUG
#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 Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    ll sum = 0;
    rep(i, N) {
        cin >> A[i];
        sum += A[i];
    }
    
    B[0] = sum;
    for(int i = 1; i < N; i += 2) B[0] -= 2 * A[i];
    
    for(int i = 1; i < N; i++){
        B[i] = 2 * A[i - 1] - B[i - 1];
    }

    rep(i, N) cout << B[i] << ' ';
    cout << endl;

}

Measured memory_bytes: 2944