akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

ll xorSum(ll a){
    int d = (int)log2(a);
    ll res = (a%4 == 1 || a%4 == 2) ? 1 : 0;
    for(int i=1; i<=d; i++){
        ll q = 1LL << (i+1);
        ll r = a % q;
        if(r < (q / 2)){
            continue;
        }else{
            res += ((r+1 - q/2)%2) << i;
        }
    }
    return res;
}

int main(){
    ll a, b;
    cin >> a >> b;
    a = max(a-1, 0LL);
    cout << (xorSum(a) ^ xorSum(b)) << endl;

    return 0;
}

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

int a[8][8], f[8], b[8], c[15], d[15];
string mapp[8] = {
        "........",
        "........",
        "........",
        "........",
        "........",
        "........",
        "........",
        "........"
};



void search(int n){
    if (n >= 8){
        for(int k = 0; k < 8; ++k){
            for(int j = 0; j < 8; ++j){
                if (a[k][j]) mapp[k][j] = 'Q';

            }
        }
    }
    else{
        if (f[n]) search(n + 1);
        else{
            for(int i = 0; i < 8; ++i){
                if (!b[i] && !c[i + n] && !d[n - i + 7]) {
                    b[i] = 1;
                    c[i + n] = 1;
                    d[n - i + 7] = 1;
                    a[n][i] = 1;
                    search(n + 1);
                    b[i] = 0;
                    c[i + n] = 0;
                    a[n][i] = 0;
                    d[n - i + 7] = 0;
                }
            }
        }
    }
}

int main(){
    int n;
    cin >> n;
    while (n--)
    {
        int v, c1;
        cin >> v >> c1;
        a[v][c1] = 1;
        b[c1] = 1;
        f[v] = 1;
        c[v + c1] = 1;
        d[v - c1 + 7] = 1;
    }
    search(0);
    for(int i = 0; i < 8; i++){
        cout << mapp[i] << endl;
    }
}




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

int main(void){
   string s;
   cin>>s;
   map<char,int> dict;
   for(char c='a';c<='z';c++){
      dict[c]=1;
   }
   for(int i=0;i<s.size();i++){
      dict[s[i]]++;
   }
   for(auto C:dict){
      if(C.second==1){
         cout<<C.first<<endl;
         return 0;
      }
   }
   cout<<"None"<<endl;
   return 0;
}



Measured memory_bytes: 512
#include<stdio.h>
int G[100][100] = { 0 };
int main(){
    int n, u, k, v;
    int i, j;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &u);
        scanf("%d", &k);
        for (j = 0; j < k; j++) {
            scanf("%d", &v);
            G[u - 1][v - 1] = 1;
        }
    }
    // ??????
    for (i = 0; i < n; i++) {
        printf("%d", G[i][0]);
        for (j = 1; j < n; j++) {
            printf(" %d", G[i][j]);
        }
        printf("\n", G[i][0]);
    }
    return 0;
}

Measured memory_bytes: 632
<?php

class IO {

	//input
	private $buf = [];
	private $count = 0;
	private $pointer = 0;

	public function nextLine() {
		$ret = '';
		if($this->hasNext()){
			while($this->hasNext()){
				$ret .= $this->next();
			}
		}else{
			$ret = trim(fgets(STDIN));
		}

		return $ret;
	}

	public function next() {
		if(!$this->hasNext()) {
			$str = trim(fgets(STDIN));
			$this->buf = explode(' ',$str);
			$this->count = count($this->buf);
			$this->pointer = 0;
		}

		return $this->buf[$this->pointer++];
	}

	public function hasNext() {
		return $this->pointer < $this->count;
	}

	public function nextInt() {
		return (int)$this->next();
	}

	public function nextDouble() {
		return (double)$this->next();
	}

	//output
	public function println($str = '') {
		echo $str . PHP_EOL;
	}
}

class Math {
	public static function gcd($x,$y) {
		if ($y === 0)return $x;
		else return Math::gcd($y,$x % $y);
	}

	public static function lcm($x,$y) {
		return $x / Math::gcd($x,$y) * $y;
	}
}

$io = new IO();


$N = $io->nextInt();

$T = array();
for($i = 0;$i < $N;$i++) {
	$T[] = $io->nextInt();
}

$ans = 1;
for($i = 0;$i < $N;$i++) {
	$ans = Math::lcm($ans,$T[$i]);
}

$io->println($ans);

?>


Measured memory_bytes: 4984
s[3][51];char c[51];n,m;j;M,t;main(i){
	for(scanf("%d%d\n",&n,&m);gets(c);i++)for(j=0;j<m;j<3?s[j][i]+=s[j][i-1]:0,j++)s[(c[j]==66)+2*(c[j]==82)][i]++;
	for(;--i;)for(j=i;++j<n;M=M<t?t:M)t=s[0][i]+s[1][j]-s[1][i]+s[2][n]-s[2][j];
	n=!printf("%d\n",n*m-M);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
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;}

int main() {
  int n;
  cin >> n;
  int l = n / 100;
  int r = n % 100;
  if (1 <= l && l <= 12) {
    if (1 <= r && r <= 12) cout << "AMBIGUOUS" << endl;
    else cout << "MMYY" << endl;
  } else {
    if (1 <= r && r <= 12) cout << "YYMM" << endl;
    else cout << "NA" << endl;
  }
}


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

using ll = long long;
const int N = 2e5+10;
int n, a[N], ans[N], org[N];
vector<int> d[N], id;

int main() {
	for(int i = 1; i < N; i++) {
		for(int j = i; j < N; j += i)
			d[j].push_back(i);
	}

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

	for(int i = n; i > 0; i--) if(a[i]) {
		ans[i] = 1;
		for(int x : d[i]) 
			a[x] ^= 1;
	}
	for(int i = 1; i <= n; i++) {
		int par = 0;
		for(int j = i; j <= n; j += i)
			par ^= ans[j];
		if(par != org[i]) {
			puts("-1");
			return 0;
		}
	}
	for(int i = 1; i <= n; i++) if(ans[i]) 
		id.push_back(i);
	printf("%d\n", (int)id.size());
	for(int x : id) printf("%d ", x);
	return 0;
}

Measured memory_bytes: 25340
import Control.Applicative

main :: IO ()
main = solve <$> f >>= print
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> Int
solve [h1, m1, h2, m2, k] = h2 * 60 + m2 - h1 * 60 - m1 - k


Measured memory_bytes: 3892
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    map<char,int>hoge;
    int n;cin>>n;
    rep(i,n){
        char saho;cin>>saho;
        hoge[saho]++;
    }
    cout<<(hoge.size()==4?"Four":"Three")<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int min = Integer.MAX_VALUE;
    for (int i = 1; i <= (N / 2); i++) {
      int a_sum = digitSum(i);
      int b_sum = digitSum(N - i);
      if (a_sum + b_sum < min) {
        min = a_sum + b_sum;
      }
    }
    System.out.println(min);
  }

  public static int digitSum(int num) {
    int tmp = num;
    int sum = 0;
    while (tmp > 0) {
      sum += (tmp % 10);
      tmp /= 10;
    }
    return sum;
  }
}

Measured memory_bytes: 23124
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		ArrayList<String> list = new ArrayList<>();
		String newWord;

		for (int i = 0; i < N; i++) {
			newWord = sc.next();
			if (list.contains(newWord)
					|| (!list.isEmpty() && !(list.get(list.size() - 1)).endsWith(String.valueOf(newWord.charAt(0))))) {
				System.out.println("No");
				return;
			} else {
				list.add(newWord);
			}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

long long GCD(long long m, long long n){
    if(n == 0) return m;
    else return GCD(n, m % n);
}

long long LCM(long long m, long long n){
    long long g = GCD(m, n);
    return m / g * n;
}

signed main(){
    int n;
    ll m;
    cin >> n >> m;
    ll a[n];
    REP(i,n){
        cin >> a[i];
    }
    bool odd = false, even = false;
    REP(i,n){
        a[i] /= 2;
    }
    ll l = 1;
    REP(i,n){
        l = LCM(l, a[i]);
    }
    REP(i,n){
        if((l / a[i]) % 2 == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << m / l  - m / (2 * l) << endl; 
    return 0;
}

Measured memory_bytes: 1024
n=int(input())
bricks=list(map(int,input().split()))
st=1
b=0
i=0
f=-1
while(i<n):
    if bricks[i]==st:
        st+=1
        f=1
    else:
        b+=1
    i+=1
if f==-1:
    print(f)
else:
    print(b)

Measured memory_bytes: 77644
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
const ll MAX = 2e5;
const ll INF = 1e18;
vector<vector<ll>> G(MAX);
ll d[MAX];
ll ans[MAX];
signed main(){
  init_io();
  ll n,m;
  cin >> n >> m;
  fill(d,d+MAX,INF);
  fill(ans,ans+MAX,-1);
  vector<ll> a(m),b(m);
  priority_queue<P,vector<P>,greater<P>> que;
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }
  d[0] = 0;
  que.push(P(0,0));
  while(!que.empty()){
    P tmp = que.top();
    que.pop();
    ll di = tmp.first,v=tmp.second;
    if(di>d[v]){
      continue;
    }
    for(auto nv:G[v]){
      if(di+1<d[nv]){
        d[nv] = di+1;
        ans[nv] = v;
        que.push(P(d[nv],nv));
      }
    }
  }
  cout <<"Yes\n";
  for(int i=1;i<n;i++){
    cout << ans[i]+1<<endl;
  }
}


Measured memory_bytes: 22024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>=(int)b;--i)
using ll=long long;
static const ll mod = 1e9;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int n;
	cin >> n;
	int i = 0;
	vector<int>ans;
	if (n == 0)ans.push_back(0);
	else {
		while (n != 0) {
			ans.push_back(n % (-2));
			n /= (-2);
			if (ans[i] < 0) {
				ans[i] = -ans[i];
				n++;
			}
			i++;
		}
	}
	repm(i, ans.size() - 1, 0)cout << ans[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n; cin >> n;
  int L=100,R=0;
  int ans = INF;
  int sum;
  vector<int> tmp(n);
  REP(i,n){
    cin >> tmp[i];
    L = min(tmp[i],L);
    R = max(tmp[i],R);
  }
  for(int i = L; i <= R;i++){
    sum = 0;
    REP(j,n){
      sum += (tmp[j] - i)*(tmp[j] - i);
    }
    ans = min(ans,sum);
  }
  cout << ans << endl;
}

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

int main(int argc, char** argv){
	int k,x;
	cin >> k >> x;
	int min_ = max(-1000000,x-k+1);
	int max_ = min(1000000,x+k);
	for(int i = min_; i < max_; i++){
		cout << i << endl;
	}
	return 0;
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] d = new int[n];
		for(int i=0;i<n;i++) d[i] = in.nextInt();
		Arrays.sort(d);
		int l = d[n/2-1];
		int u = d[n/2];
		System.out.println(u-l);
		in.close();

	}

}


Measured memory_bytes: 50056
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdlib>
#include<string>
#include <bitset>

#define SIZE 100001
typedef long long ll;
using namespace std;

int main(){

    int N=0;
    string S;
    cin>>S;
    for(int i = 0 ; i < S.size() ; i++){
        N += S[i] - '0';
    }
    if(N % 9 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define NL endl
#define pi 2.0*acos(0.0)
#define INTM 1e18
#define mod 1e9+7
#define FOR(i,j,n)    for(ull i=j;i<n;i++)
#define RFOR(i,j,n)    for(ll i=j;i>=n;i--)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

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

int main(){
    fastIO;
    ll a,n,sum = 0,c;
    cin>>a>>n;
    while(n--){
        cin>>c;
        sum += c;
    }
    if(sum >= a) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import heapq
from collections import deque

N, M=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(N)]
AB.sort(key=lambda x:x[0])
d=deque(AB)
h=[]
ans=0
for i in range(M+1):
    while d and d[0][0]<=i:
        heapq.heappush(h, -d.popleft()[1])
    if h:
        ans-=heapq.heappop(h)
print(ans)

Measured memory_bytes: 77912
// C - X: Yet Another Die Game

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	ll a = x / 11;
	int b = x % 11;

	ll ans;
	if (b == 0) ans = a * 2;
	else if (b <= 6) ans = a * 2 + 1;
	else ans = a * 2 + 2;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int H,W,a,d;
    while(1){
        cin>>H>>W;
        d=0;
        if (H==0 && W==0) break;
        else{
            for (int c=0;c<H;c++){
                if (d%2==0){
                    for (int b=0;b<W;b++){
                        if (a%2==0){
                            cout<<"#";
                            a+=1;
                        }
                        else {
                            cout<<".";
                            a+=1;
                        }
                    }
                    cout<<endl;
                    d+=1;
                    a=0;
                }else{
                    for (int b=0;b<W;b++){
                        if (a%2==0){
                            cout<<".";
                            a+=1;
                        }
                        else {
                            cout<<"#";
                            a+=1;
                        }
                    }
                    cout<<endl;
                    d+=1;
                    a=0;
                }    
            }
                
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3032
#include <stdio.h>

int min(int a,int b){
  if (a>b) return b;
  else return a;
}

int main(){
  int i,j,k,n,p[101],m[101][101],s,z;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d%d",&p[i],&s);
  p[n]=s;

  for(i=1;i<=n;i++) m[i][i]=0;
  
  for(j=2;j<=n;j++){
    for(i=1;i<=n-j+1;i++){
      z=i+j-1;
      m[i][z]=1000000000;
      for(k=i;k<=z-1;k++){
	m[i][z]=min(m[i][z],m[i][k]+m[k+1][z]+p[i-1]*p[k]*p[z]);
      }
    }
  }

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

  return 0;
}



Measured memory_bytes: 2056
s = input()
word = [0] * 26
for i in s:
    word[ord(i) - ord('a')] = 1

if sum(word) != 26:
    for i in range(26):
        if word[i] == 0:
            c = chr(i + ord('a'))
            break
    print(s + c)
else:
    if s == 'zyxwvutsrqponmlkjihgfedcba':
        print(-1)
    else:
        for i in range(25, -1, -1):
            if s[i] == 'z':
                pass
            else:
                now = ord(s[i]) + 1
                for j in range(now, ord('z')+1):
                    if chr(j) in s[0:i]:
                        pass
                    else:
                        print(s[0:i] + chr(j))
                        exit()


Measured memory_bytes: 3064
from queue import Queue
def bfs(target, graph, scores):
    visited = [False]*len(graph)
    que = Queue()
    que.put(target)
    visited[target] = True
    while not que.empty():
        root = que.get()
        for dst in graph[root]:
            if visited[dst] is False:
                visited[dst] = True
                que.put(dst)
                scores[dst] += scores[root] 
    return scores 
n, q = map(int, input().split())
graph = {i:[] for i in range(0, n)}
for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

scores = [0]*n
for _ in range(q):
    t, s = map(int, input().split())
    t -= 1
    scores[t] += s

ans = bfs(0, graph, scores)
for a in ans:
    print(a)

Measured memory_bytes: 70208
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
#define ar array
const ll maxN=1e5+1 , N=1e2+5;
vector<ll> adj[maxN];
ll dp[maxN];
ll n , m ,a, b;
ll dfs(ll u , ll p=-1){
	if(!dp[u]){
	for(auto v : adj[u]){
		dp[u]=max(dfs(v),dp[u]);
	}
	dp[u]++;
}
	return dp[u];
}
void solve(){
	cin>> n >> m ;
	for(ll i=0;i<m ; i++){
		cin>>a>> b ;
		adj[a].pb(b);
	}
	ll ans=0;
	for(ll i=1;i<=n ; i++){
			ans=max(ans,dfs(i));
		
	}
	// ll ans=0;
	// for(ll i=0;i<=n ; i++){
	// 	ans=max(ans , dp[i]);
	// }
	cout<<ans-1<<endl;
}
int main(){
	//mahakal(),fast;
	ll t=1;
	// cin>> t ;
	while(t--)solve();

	return 0;
}

Measured memory_bytes: 11836
#include<stdio.h>
int main()
{
    int tab[100][100];
int r,c,i,j,sum,sum1;
scanf("%d %d",&r,&c);
for(i=0;i<r;i++)
    {
for(j=0;j<c;j++)
{
            scanf("%d",&tab[i][j]);
        }
    }

    sum1=0;
    for(i=0;i<r;i++)
    {
        sum=0;
        for(j=0;j<c;j++)
        {
            sum += tab[i][j];
            printf("%d ",tab[i][j]);
        }
        sum1+=sum;
        printf("%d\n",sum);
    }

    for(i=0;i<c;i++)
    {
        sum=0;
        for(j=0;j<r;j++)
            sum+=tab[j][i];
        printf("%d ",sum);
    }
    printf("%d\n",sum1);
    return 0;
}



Measured memory_bytes: 2056
#include<iostream>
#include<vector>

using namespace std;

int bs(vector<int> arr, int x, int a, int b) {
  if(a == b) return a;
  else {
    int c = (a+b)/2;
    if(arr[c] < x && arr[c+1] >= x) return c+1;
    else if(arr[c] >= x) return bs(arr, x, a, c);
    else return bs(arr, x, c, b);
  }
}

int main() {
  int N, len, a_i;
  cin >> N;
  vector<int> arr(N), lis;
  for(int i = 0; i < N; i++) cin >> arr[i];
  lis.push_back(arr[0]);
  len = 1;
  for(int i = 1; i < N; i++) {
    if(lis[len-1] < arr[i]) {
      lis.push_back(arr[i]);
      len++;
    }
    else {
      lis[bs(lis, arr[i], 0, len-1)] = arr[i];
    }
  }
  cout << len << endl;
  return 0;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

const int MAX = 510000;

ll fac[MAX], finv[MAX], inv[MAX];

void init_com() {
  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;
  }
}

ll com(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;
}

ll _fact[MAX];

void init_fact() {
  _fact[0] = 1;
  ll num = 1;
  for (ll i = 1; i < MAX; i++) {
    num = num * i % MOD;
    _fact[i] = num;
  }
}
ll fact(ll num) {
  // cout << "num:" << num << endl;
  if (num <= 1) {
    return 1;
  }
  return _fact[num];
}

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

ll nPr(ll val1, ll val2) {
  ll c = com(val1, val2);
  return c * fact(val2) % MOD;
}

int main() {
  init_com();
  init_fact();

  ll N, M;
  scanf("%lld %lld", &N, &M);

  ll ans = 0;

  for (ll i = 0; i <= N; i++) {
    ll c = com(N, i);
    ll p = nPr(M - i, (N - i));

    ll val = c;
    val = val * p % MOD;

    if (i % 2 == 0) {
      ans += val;
      ans = ans % MOD;
    } else {
      ans -= val;
      ans = (ans + MOD) % MOD;
    }
  }
  ll patterns = nPr(M, N);
  ans = ans * patterns % MOD;
  cout << ans << endl;
}


Measured memory_bytes: 19676
from collections import defaultdict
cnt=defaultdict(int)
S=input()
for s in S:
    cnt[s]+=1
X=[cnt["a"],cnt["b"],cnt["c"]]
X.sort()
ans=False
if X[0]==X[1]==X[2]:
    ans=True
elif X[0]==X[1]:
    if X[0]+1==X[2]:
        ans=True
elif X[1]==X[2]:
    if X[2]-1==X[0]:
        ans=True
if ans:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3444
package main

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

var sc = bufio.NewScanner(os.Stdin)

type Stack struct {
	Stack [1000]int
	Top int
}

func getStack() *Stack {
	s := &Stack{}
	return s
}

func (s *Stack) isEmpty() bool {
	return s.Top == 0
}

func (s *Stack) Push(n int) {
	s.Top++
	s.Stack[s.Top] = n
}

func (s *Stack) Pop() int {
	s.Top--
	return s.Stack[s.Top + 1]
}

func main() {
	sc.Split(bufio.ScanWords)
	stack := getStack()
	for {
		if ok := sc.Scan(); !ok {
			break
		}
		token := sc.Text()
		switch token {
		case "+":
			n1, n2 := stack.Pop(), stack.Pop()
			stack.Push(n1 + n2)
		case "-":
			n1, n2 := stack.Pop(), stack.Pop()
			stack.Push(n2 - n1)
		case "*":
			n1, n2 := stack.Pop(), stack.Pop()
			stack.Push(n1 * n2)
		default:
			num, _ := strconv.Atoi(token)
			stack.Push(num)
		}
	}
	fmt.Println(stack.Pop())
}


Measured memory_bytes: 1160
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;
			int result = 0;
			for (int i = 1; i < n; i++) {
				int sum = 0;
				for (int j = i; j < n; j++) {
					sum += j;
					if (sum > n)
						break;
					if (sum == n) {
						result++;
						break;
					}
				}
			}
			System.out.println(result);
		}
		sc.close();
	}
}

Measured memory_bytes: 19896
package main

import (
	"fmt"
	"sort"
)

type byAbc []rune

func (a byAbc) Len() int           { return len(a) }
func (a byAbc) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a byAbc) Less(i, j int) bool { return a[i] < a[j] }

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	ss := byAbc(s)
	ts := byAbc(t)
	sort.Sort(ss)
	sort.Sort(sort.Reverse(ts))

	s = string(ss)
	t = string(ts)

	var ans string
	if s < t {
		ans = "Yes"
	} else {
		ans = "No"
	}

	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 512
def main():
    import sys
    from bisect import bisect_right

    N,M,K=list(map(int,sys.stdin.readline().split()))
    A=list(map(int,sys.stdin.readline().split()))
    B=list(map(int,sys.stdin.readline().split()))

    AS=[0]*N
    BS=[0]*M
    for i,a in enumerate(A):
        if i:
            AS[i]=AS[i-1]+a
        else:
            AS[i]=a

    for i,b in enumerate(B):
        if i:
            BS[i]=BS[i-1]+b
        else:
            BS[i]=b

    mx=bisect_right(BS,K)
    for i,sa in enumerate(AS):
        if K-sa>=0:
            p=bisect_right(BS,K-sa)
            mx=max(mx,i+p+1)

    print(mx)


main()

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

int n;
vector<long long int> v;
int main(){
	cin >> n;
	long long int rest = 0;
	for (int i = 0; i < n; i++){
		long long int a;
		scanf("%lld", &a);
		v.push_back(a);
		rest += a;
	}
	long long int ans = LLONG_MAX;
	long long int sum = 0;
	for (int i = 0; i+1 < n; i++){
		sum += v[i];
		rest -= v[i];
		ans = min(ans, max(sum - rest, rest - sum));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2420
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define sz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int n, m;
bitset <310> B[310];

ll pw[1010];
const ll mod =  998244353;

int main() {
	pw[0] = 1;
	for(int i=1;i<1010;i++) pw[i] = pw[i-1] * 2 % mod;
	scanf("%d%d", &n, &m);
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=m;j++) {
			int x; scanf("%d", &x);
			if(x & 1) B[i][j] = 1;
		}
	}
	int t = 1;
	for(int i=1;i<=m;i++) {
		int f = -1;
		for(int j=t;j<=n;j++) if(B[j][i]) {
			f = j; break;
		}
		if(f == -1) continue;
		swap(B[t], B[f]);
		for(int j=t+1;j<=n;j++) {
			if(B[j][i]) B[j] ^= B[t];
		}
		++t;
	}
	int r = t - 1;
	ll ans = (pw[n+m-1] - pw[n+m-1-r] + mod) % mod;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#!/mnt/c/Users/moiki/bash/env/bin/python
# N,M = map(int, input().split())
N = int(input())
if N == 0:
    print(0)
    exit(0)

if N >= 0:
    b = bin(N)[2:]

    lst = [0 for _ in range(len(b)+10)]

    for e,s in enumerate(reversed(b)):
        if e % 2 == 0:
            lst[e] += int(s)
        elif e % 2 == 1:
            lst[e] += int(s)
            lst[e+1] += int(s)

    for e,s in enumerate(lst):
        if s >= 2:
            # if e % 2 == 0:
            while lst[e] > 1:
                lst[e] -= 2
                if lst[e+1] > 0:
                    lst[e+1] -= 1
                else:
                    lst[e+1] += 1
                    lst[e+2] += 1
            # else:
            #     while lst[e] > 1:
            #         lst[e] -= 2
            #         if lst[e+1] > 0:
            #             lst[e+1] -= 1
            #         else:
            #             lst[e+1] += 1
            #             lst[e+2] += 1

    flag = False
    for s in "".join(map(str, reversed(lst))):
        if not flag and s=="0":
            continue
        else:
            flag = True
            print(s, end="")
    print()
else:
    b = bin(N)[3:]
    lst = [0 for _ in range(100)]
    for e,s in enumerate(reversed(b)):
        if e % 2 == 0:
            lst[e] += int(s)
            lst[e+1] += int(s)
        else:
            lst[e] += int(s)


    for e,s in enumerate(lst):
        if s >= 2:
            while lst[e] > 1:
                lst[e] -= 2
                if lst[e+1] > 0:
                    lst[e+1] -= 1
                else:
                    lst[e+1] += 1
                    lst[e+2] += 1

    flag = False


    for s in "".join(map(str, reversed(lst))):
        if not flag and s == "0":
            continue
        else:
            flag = True
            print(s, end="")
    print()

# print("".join(map(str, reversed(lst))))
        
        



Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string S, T;
    cin >> S >> T;
    int lenS = S.size(), lenT = T.size();
    int res = -1;
    for (int i = lenS - lenT; i >= 0; i--) {
        bool same = true;
        for (int j = 0; j < lenT; j++) {
            if (S[i+j] != '?' && S[i+j] != T[j]) same = false;
        }
        if (same) {
            res = i;
            break;
        }
    }
    if (res == -1) cout << "UNRESTORABLE" << '\n';
    else {
        for (int i = res; i < res + lenT; i++) S[i] = T[i - res];
        for (char c : S) cout << (c == '?' ? 'a' : c);
        cout << '\n';
    }

}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h, w;
  cin >> h >> w;
  vector<string> t(h);
  for(int i = 0; i < h; ++i) cin >> t[i];
  int all = 0;
  for(int i = 0; i < h; ++i) for(int j = 0; j < w; ++j) if(t[i][j] == '#') all++;
  cout <<  (h + w - 1 == all ? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n;
	cin>>n;
	vvi in(n,vi(3));
	rep(i,n)rep(j,3)cin>>in[i][j];
	vi dp(400);
	rep(i,n)rep(j,400)loop(k,in[i][0],in[i][1]+1)if(j+k<400){
		dp[j+k]=max(dp[j+k],dp[j]+in[i][2]);
	}
	int q;
	cin>>q;
	vi out(q);
	bool h=true;
	rep(i,q){
		int a;cin>>a;
		out[i]=dp[a];
		if(out[i]==0)h=false;
	}
	if(!h)cout<<-1<<endl;
	else rep(i,q)cout<<out[i]<<endl;
}
 
 

Measured memory_bytes: 1236
x,y = (int(_) for _ in input().split())
minX = minY = dir = 0
maxX = maxY = 1

while 1:
    if minX <= x and x < maxX and minY <= y and y < maxY:
        break
    if dir % 4 == 0:
	    maxX += max(maxX - minX,maxY - minY)
    elif dir % 4 == 1:
        maxY += max(maxX - minX, maxY - minY)
    elif dir % 4 == 2:
        minX -= max(maxX - minX, maxY - minY)
    else:
        minY -= max(maxX - minX, maxY - minY)
    dir += 1
print((dir % 3) + 1)


Measured memory_bytes: 5604
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll roundd(ll n,ll x){
  if(0<=x&&x<n){return x;}
  else if(x<0){return x+n;}
  else{return x%n;}
}
int main(){
  ll n;cin>>n;
  vll a(n),ans(n);
  ll sum=0;
  rep(i,0,n){
    cin>>a[i];
    sum+=a[i];
  }
  
  ans[0]=2*a[roundd(n,-1)];ll kari=ans[0];
  rep(i,1,n){
    ans[i]=2*a[roundd(n,i-1)]-ans[i-1];
    kari+=ans[i];
  }
  ll x=kari-sum;
  rep(i,0,n){
    if(i%2){cout<<ans[i]+x<<" ";}
    else{cout<<ans[i]-x<<" ";}
    
  }


}



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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, x[11], y[11];
double ans;
bool b[11];
void dfs(double c, i64 t, int nx, int ny){
	if(t == n){
		ans += c;
		return;
	}
	for(int i = 0; i < n; i++){
		if(b[i]) continue;
		b[i] = 1;
		dfs(c+sqrt(pow(nx-x[i],2)+pow(ny-y[i],2)), t+1, x[i], y[i]);
		b[i] = 0;
	}
}
int kai(int a){
	int c = 1;
	for(int i = a; i > 1; i--){
		c *= i;
	}
	return c;
}
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> x[i] >> y[i];
	}
	
	for(int i = 0; i < n; i++){
		b[i] = 1;
		dfs(0, 1, x[i],y[i]);
		b[i] = 0;
	}
	printf("%.10f\n", ans/kai(n));
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
a, b, c, x, y = map(int,input().split())
c2 = c*2
if c2 <= a+b and c2 <= a and c2 <= b:
  sums = c * 2 * max(x,y)
elif c2 > a+b:
  sums = a*x+b*y
elif c2 <= a+b and x >= y and a <= c2:
  sums = c*2*y+a*(x-y)
elif c2 <= a+b and x >= y and a > c2:
  sums = c*2*x
elif c2 <= a+b and x <= y and b <= c2:
  sums = c*2*x+b*(y-x)
else:
  sums = c*2*y
print(sums)

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

typedef pair<int,int> P;

#define fr first
#define sc second

int n;
int x[10002],y[10002];

bitset<20002> G[20002];
bitset<20002> rG[20002];

vector<int> vs;
bitset<20002> alive;
bitset<20002> nex;
void dfs(int v){
	if(!alive[v])return;
	alive[v] = false;
	while(1){
		nex = alive & G[v];
		int x = nex._Find_first();
		if(x == 20002)break;
		dfs(x);
	}
	vs.push_back(v);
}

bitset<20002> c;
void scc(int v){
	if(!alive[v])return;
	alive[v] = false;
	while(1){
		nex = alive & rG[v];
		int x = nex._Find_first();
		if(x == 20002)break;
		scc(x);
	}
	c[v] = true;
}

bitset<20002> mask;

bool f(int d){
	vector<P> vec;
	for(int i = 0 ; i < n ; i ++){
		vec.push_back(P(x[i],2*i));
		vec.push_back(P(y[i],2*i+1));
	}
	sort(vec.begin(),vec.end());
	
	/*for(P p: vec){
		cout << p.fr << " " << p.sc << endl;
	}*/
	
	bitset<20002> a,b;
	int l = 0, r = 0;
	for(int i = 0 ; i < vec.size() ; i ++){
		while(r < vec.size() && vec[r].fr < vec[i].fr+d){
			a[vec[r].sc^1] = true;
			b[vec[r].sc] = true;
			r ++;
		}
		while(l < vec.size() && vec[l].fr <= vec[i].fr-d){
			a[vec[l].sc^1] = false;
			b[vec[l].sc] = false;
			l ++;
		}
		G[vec[i].sc] = a;
		G[vec[i].sc][vec[i].sc^1] = false;
		rG[vec[i].sc^1] = b;
		rG[vec[i].sc^1][vec[i].sc] = false;
		/*for(int j = 0 ; j < 2*n ; j ++){
			if(a[j])printf("1");
			else printf("0");
		}
		cout << endl;*/
	}
	//puts("=======");
	
	/*for(int i = 0 ; i < 2*n ; i ++){
		for(int j = 0 ; j < 2*n ; j ++){
			if(G[i][j])printf("1");
			else printf("0");
		}
		cout << endl;
	}
	puts("======");
	for(int i = 0 ; i < 2*n ; i ++){
		for(int j = 0 ; j < 2*n ; j ++){
			if(rG[i][j])printf("1");
			else printf("0");
		}
		cout << endl;
	}
	puts("======");*/
	
	vs.clear();
	alive.set();
	for(int i = 0 ; i < 2*n ; i ++){
		if(alive[i])dfs(i);
	}
	reverse(vs.begin(),vs.end());
	alive.set();
	for(int i = 0 ; i < vs.size() ; i ++){
		c.reset();
		scc(vs[i]);
		/*for(int j = 0 ; j < 2*n ; j ++){
			if(c[j])printf("1");
			else printf("0");
		}
		cout << endl;*/
		c &= c>>1;
		c &= mask;
		if(c.any())return false;
	}
	return true;
}

int main(){
	mask.reset();
	for(int i = 0 ; i < 10000 ; i ++){
		mask[2*i] = true;
	}
	
	scanf("%d",&n);
	for(int i = 0 ; i < n ; i ++){
		scanf("%d%d",&x[i],&y[i]);
	}
	
	//f(2);
	//return 0;
	
	int l = 0, r = 1000000000;
	while(l < r){
		int m = (l+r+1)/2;
		if(f(m))l = m;
		else r = m-1;
	}
	cout << l << endl;
}



Measured memory_bytes: 148956
import numpy


d = int(input())
c = numpy.array(list(map(int, input().split())))
s = []
for i in range(d):
    s.append(list(map(int, input().split())))

result = []
past = numpy.array([0] * 26)
ans = 0
for i in range(d):
    past += 1
    t = int(input())
    past[t-1] = 0
    ans += sum(past * -c) + s[i][t-1]
    print(ans)


Measured memory_bytes: 27280
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> x(m,vector<int>());
    rep(i,n){
        int y;
        cin >> y;
        x[y%m].push_back(y);
    }
    vector<int> cnt(m);
    rep(i,m){
        sort(x[i].begin(),x[i].end());
        int c = 0;
        int now = -1;
        int se = 0;
        rep(j,x[i].size()){
            if(now==x[i][j]){
                ++se;
            }
            else{
                c += se/2;
                se=1;
                now=x[i][j];
            }
        }
        c+=se/2;
        cnt[i]=c;
    }
    /*
    rep(i,m){
        cout << cnt[i] << " ";
        rep(j,x[i].size()){
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
    cout << endl;
    */
    vector<int> use(m,0);
    int ans = 0;
    ans += (int)(x[0].size())/2;
    for(int i=1;2*i<=m;++i){
        if(2*i==m){
            ans+=(int)(x[i].size())/2;
            continue;
        }
        ans += min((int)x[i].size(),(int)(x[m-i].size()));
        use[i] = min((int)x[i].size(),(int)(x[m-i].size()));
        ans += min(((int)(x[i].size())-use[i])/2,cnt[i]);
        ans += min(((int)(x[m-i].size())-use[i])/2,cnt[m-i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9436
//https://beta.atcoder.jp/contests/abc112/tasks/abc112_a
#include<bits/stdc++.h>

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};


int main() {
    int n;
    cin>>n;
    if(n==1)cout<<"Hello World"<<endl;
    else {
        int a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

constexpr char BR = '\n';


///////////////////////////////////////////////////

constexpr int CONTEST_SIZE = 26;
constexpr int DAY_MAXSIZE = 365;

int calc_score(int *r, const int c[CONTEST_SIZE], const int s[DAY_MAXSIZE][CONTEST_SIZE], int t[DAY_MAXSIZE], int D = DAY_MAXSIZE)
{
    int score = 0;
    int last[CONTEST_SIZE] = {};
    for (int d = 0; d < D; d++)
    {
        int con = t[d];
        score += s[d][con];
        last[con] = d+1;
        for (int i = 0; i < CONTEST_SIZE; i++)
        {
            score -= c[i] * (d+1 - last[i]);
        }
        r[d] = score;
    }
    return D;
}

int main()
{
    int D; io >> D;
    int c[CONTEST_SIZE];
    int s[DAY_MAXSIZE][CONTEST_SIZE];
    for (int i = 0; i < CONTEST_SIZE; i++)
        io >> c[i];
    for (int d = 0; d < D; d++)
        for (int c = 0; c < CONTEST_SIZE; c++)
            io >> s[d][c];
    
    int t[DAY_MAXSIZE];
    for (int d = 0; d < D; d++)
    {
        cin >> t[d];
        --t[d];
    }

    int scores[DAY_MAXSIZE];
    calc_score(scores, c, s, t, D);
    for (int d = 0; d < D; d++)
        io << scores[d] << BR;
}

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

int main() {
    string S;
    cin >> S;
    
    long long sum = 0;
    for (int bit = 0; bit < (1 << (S.size() - 1)); bit++) {
        vector<int> B;
        for (int i = 0; i < S.size() - 1; i++) {
            if (bit & (1 << i)) {
                B.push_back(i);
            }
        }
        B.push_back(S.size() - 1);

        int str = 0;
        for (int i = 0; i < B.size(); i++) {
            if (i == 0) sum += stoll(S.substr(str, B[i] + 1));
            else sum += stoll(S.substr(str, B[i] - B[i - 1]));
            str = B[i] + 1;
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
dist = 0
for i in range(1,N+1):
    dist += abs(A[i]-A[i-1])
dist += abs(A[0]-A[N])
for i in range(1,N):
    if A[i-1]<=A[i]<=A[i+1] or A[i+1]<=A[i]<=A[i-1]:
        print(dist)
    elif A[i-1]<=A[i+1]<=A[i] or A[i]<=A[i+1]<=A[i-1]:
        print(dist-abs(A[i+1]-A[i])*2)
    elif A[i]<=A[i-1]<=A[i+1] or A[i+1]<=A[i-1]<=A[i]:
        print(dist-abs(A[i]-A[i-1])*2)
if A[N-1]<=A[N]<=A[0] or A[0]<=A[N]<=A[N-1]:
        print(dist)
elif A[N-1]<=A[0]<=A[N] or A[N]<=A[0]<=A[N-1]:
    print(dist-abs(A[0]-A[N])*2)
elif A[N]<=A[N-1]<=A[0] or A[0]<=A[N-1]<=A[N]:
    print(dist-abs(A[N]-A[N-1])*2)

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


const int MAX_N = 2010;
string s[MAX_N];
int len[MAX_N][MAX_N][4];

int main2() {
  CLR(len, 0);
  int H, W; cin >> H >> W;
  REP(i, H) cin >> s[i];

  REP(i, H) {
    int l = 0;
    REP(j, W) {
      if (s[i][j] == '.') { l++; } else { l = 0; }
      len[i][j][0] = l;
    }
    l = 0;
    for (int j = W - 1; j >= 0; j--) {
      if (s[i][j] == '.') { l++; } else { l = 0; }
      len[i][j][1] = l;
    }
  }

  REP(j, W) {
    int l = 0;
    REP(i, H) {
      if (s[i][j] == '.') { l++; } else { l = 0; }
      len[i][j][2] = l;
    }
    l = 0;
    for (int i = H - 1; i >= 0; i--) {
      if (s[i][j] == '.') { l++; } else { l = 0; }
      len[i][j][3] = l;
    }
  }

  int ans = 0;
  REP(i, H) REP(j, W) if (s[i][j] == '.') {
    int total = len[i][j][0]
              + len[i][j][1]
              + len[i][j][2]
              + len[i][j][3] - 3;
    chmax(ans, total);
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 67456
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <sstream>
#include <cctype>
using namespace std;

#define PQ priority_queue
#define P pair<int,int>
#define CLA(array) memset(array,0,sizeof array)
#define CLINF(array) memset(array,0x3f,sizeof array)
#define CLF(array) memset(array,-1,sizeof array)
#define DB(a) cout << "DEBUG " << a << endl;
typedef long long LL;
typedef unsigned long long ULL;
const int MAXN = 200000 + 50;
const int INF = 1 << 30;
int n, m;
int a1[MAXN], b1[MAXN];

int main(){
    //ios_base::sync_with_stdio(false);
	while(~scanf("%d%d", &n ,&m)){
		memset(a1, 0, sizeof a1);
		CLA(b1);
		int tot1 = 0, tot2 = 0, a, b;
		for(int i = 0; i < m; i++){
			scanf("%d%d", &a, &b);
			if(a == 1) a1[b] = 1;
			else if(b == n) b1[a] = 1;
		}
		for(int i = 0; i < MAXN; i++){
			if(a1[i] && b1[i]) {
				printf("POSSIBLE\n");
				tot1 = 1;
				break;
			}
		}
		if(!tot1) printf("IMPOSSIBLE\n");
	}


    return 0;
}


Measured memory_bytes: 1792
def f(n):
  D={}
  A=[]
  for _ in range(n):
    a,b,c=map(int,raw_input().split(' '))
    try: D[a]+=b*c
    except:
      D[a]=b*c
      A.append(a)
  B=[i for i in A if D[i]>=1e6]
  if B==[]: B=["NA"]
  return B

while 1:
  n=input()
  if n==0:break
  for e in f(n): print e

Measured memory_bytes: 4360
#include <bits/stdc++.h>
#define MAX (ll)(2e1)
#define INF (ll)(1e18)
#define MOD (ll)(1e9)

using namespace std;
using ll = long long;
using cd = complex<double>;

ll cc[20][20];
ll gcd (ll a, ll b) {
 if (!a || !b) {
  return max (a, b);
 }
 ll r = a % b;
 while (r) {
  a = b;
  b = r;
  r = a % b;
 }
 return b;
}

map<ll, ll> ma;

int main () {
 ll n;
 cin >> n;
 ll ar[n];
 vector<pair<ll, ll>> vp;
 for (ll i = 0; i < n; i++) {
  double v;
  cin >> v;
  ll xx = gcd (llround(v * MOD), INF);
  ll pt = 0, pf = 0;
  while (xx % 2 == 0) {
   xx /= 2;
   pt++;
  }
  while (xx % 5 == 0) {
   xx /= 5;
   pf++;
  }
  cc[pt][pf]++;
  vp.push_back (make_pair (pt, pf));
 }
 ll ans = 0;
 for (auto v : vp) {
  ll x = 18 - v.first, y = 18 - v.second;
  for (ll i = x; i <= 18; i++)  {
   for (ll j = y; j <= 18; j++) {
    ans += cc[i][j];
   }
  }
  if (v.first * 2  >= 18 && 2 * v.second >= 18) {
   ans--;
  }
 }
 cout << ans / 2 << "\n";
}



Measured memory_bytes: 7512
#include <stdio.h>
int main(void){
	int a, b;
	char op;
	for(;;){
		scanf("%d %c %d", &a, &op, &b);
		if(op=='?') break;
		printf("%d\n", op == '+' ? a+b : op == '-' ? a-b : op == '*' ? a*b : a/b);
	}
	return 0;
}




Measured memory_bytes: 2100