akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define sz(a) ((int)(a).size())

typedef long long ll;

const int INF = 1e9;

struct UFnode
{
  int value_;
  int rank_, p_, index_, size_, weight_;
  UFnode(int value) : value_(value), rank_(0), p_(-1), size_(1), weight_(0) {}
  int size() const { return size_; }
};

struct UF
{
  vector<UFnode> ufnodes_;
  map<int, int> value_to_index_;
  int size_;

  UF() : size_(0) {}
  int size() const { return size_; }
  int tree_size(int value)
  {
    if (value_to_index_.count(value) == 0) { return 0; }
    int pix = ufnodes_[value_to_index_[value]].p_;
    return ufnodes_[pix].size();
  }

  void make_set(int value)
  {
    UFnode node(value);
    ufnodes_.push_back(node);
    int ix = ufnodes_.size() - 1;
    ufnodes_[ix].index_ = ufnodes_[ix].p_ = value_to_index_[value] = ix;
    ++size_;
  }

  int find_set(int value, int index = -1)
  {
    pair<int, int> p = find_set2(value, index);
    return p.first;
  }

  pair<int, int> find_set2(int value, int index = -1)
  {
    if (index == -1) {
      if (value_to_index_.count(value) == 0) { return make_pair(-1, -1); }
      index = value_to_index_[value];
    }
    if (ufnodes_[index].p_ != index) {
      pair<int, int> p = find_set2(ufnodes_[ufnodes_[index].p_].value_, ufnodes_[index].p_);
      ufnodes_[index].p_ = p.first;
      ufnodes_[index].weight_ += p.second;
    }
    return make_pair(ufnodes_[index].p_, ufnodes_[index].weight_);
  }

  int find_weight(int value)
  {
    pair<int, int> p = find_set2(value);
    if (p.first == -1) { return -1; }
    return p.second;
  }

  // w[y] - w[x] = weight
  void unite(int x, int y, int weight)
  {
    pair<int, int> p1 = find_set2(x), p2 = find_set2(y);
    int s1 = p1.first, s2 = p2.first;
    int w = weight + p1.second - p2.second;
    if ((s1 == s2) || (s1 == -1) || (s2 == -1)) { return; }
    if (ufnodes_[s1].rank_ > ufnodes_[s2].rank_) {
      ufnodes_[s2].p_ = s1;
      ufnodes_[s2].weight_ = w;
      ufnodes_[s1].size_ += ufnodes_[s2].size_;
    }
    else {
      ufnodes_[s1].p_ = s2;
      ufnodes_[s1].weight_ = -w;
      ufnodes_[s2].size_ += ufnodes_[s1].size_;
      if (ufnodes_[s1].rank_ == ufnodes_[s2].rank_) { ++ufnodes_[s2].rank_; }
    }
    --size_;
  }

  bool is_connected(int x, int y) { return find_set(x) == find_set(y); }
};

int main()
{
  while (true) {
    int n = 0, m = 0;
    fscanf(stdin, "%d %d", &n, &m);
    if (n == 0 && m == 0) { break; }
    UF uf;
    for (int i = 1; i <= n; ++i) {
      uf.make_set(i);
    }
    for (int i = 0; i < m; ++i) {
      char ch;
      int a, b, d;
      fscanf(stdin, " %c", &ch);
      if (ch == '!') {
        fscanf(stdin, " %d %d %d", &a, &b, &d);
        uf.unite(a, b, d);
      }
      else if (ch == '?') {
        fscanf(stdin, " %d %d", &a, &b);
        if (uf.is_connected(a, b)) {
          int wb = uf.find_weight(b);
          int wa = uf.find_weight(a);
          fprintf(stdout, "%d\n", wb - wa);
        }
        else {
          fprintf(stdout, "UNKNOWN\n");
        }
      }
      else {
        return -1;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 9956
#include <iostream>
#include <cstdio>

using namespace std;

int n,t0,t1,tmp;

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
        scanf("%d",&tmp);
        if (tmp%2) t1++;
        else t0++;
    }
    if (t1%2 and n>1)
        cout << "NO";
    else
        cout << "YES";
    cout << "\n";
}


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

int n,m;
char tmp,ch[310];

int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>tmp;
			ch[tmp]++;
		}
	}
	if(n%2==0&&m%2==0){
		for(int i='a';i<='z';i++){
			if(ch[i]%4!=0){
				puts("No");
				return 0;
			}
		}
	}else if(n%2==0&&m%2!=0){
		int cnt=0;
		for(int i='a';i<='z';i++){
			if(ch[i]%4==0)continue;
			else if(ch[i]%2==0)cnt++;
			else{
				puts("No");
				return 0;
			}
		}
		if(cnt>n/2){
			puts("No");
			return 0;
		}
	}else if(m%2==0&&n%2!=0){
		int cnt=0;
		for(int i='a';i<='z';i++){
			if(ch[i]%4==0)continue;
			else if(ch[i]%2==0)cnt++;
			else{
				puts("No");
				return 0;
			}
		}
		if(cnt>m/2){
			puts("No");
			return 0;
		}
	}else{
		int cnt1=0,cnt2=0;
		for(int i='a';i<='z';i++){
			if(ch[i]%4==0)continue;
			else if(ch[i]%2==0)cnt1++;
			else if(cnt2==0)cnt2++;
			else{
				puts("No");
				return 0;
			}
		}
		if(cnt1>n/2+m/2){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;


  if(a == b && a != c) {
    cout << "Yes" << endl;
    return 0;
  }

  if(a == c && b != c) {
    cout << "Yes" << endl;
    return 0;
  }

  if(b == c && a != c) {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;

  return 0;
}


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

int main(void){
    int r = 0; 

    scanf("%d", &r);

    if(r < 1200){
        printf("ABC\n");
    }else if(r < 2800){
        printf("ARC\n");
    }else{
        printf("AGC\n");
    }

    return 0;

} 


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

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println((b + a + 1) / 2);
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 21716
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[][] h = new int[N][3];
    h[0][0] = sc.nextInt();
    h[0][1] = sc.nextInt();
    h[0][2] = sc.nextInt();
    for (int i = 1; i < N; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      h[i][0] = a+Math.max(h[i-1][1], h[i-1][2]);
      h[i][1] = b+Math.max(h[i-1][2], h[i-1][0]);
      h[i][2] = c+Math.max(h[i-1][0], h[i-1][1]);
    }
    System.out.println(Math.max(Math.max(h[N-1][0],h[N-1][1]),h[N-1][2]));
  }
}

Measured memory_bytes: 95048
N = int(input())
flag = 0
ans = 0
for _ in range(N):
    D1, D2 = (int(x) for x in input().split())
    if D1 == D2:
        flag += 1
    else:
        flag = 0
    if flag == 3:
        ans = 1
if ans == 1:
    print('Yes')
else:
    print('No')


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

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

	int a=in(),b=in();
	
	
	cout << (b<a ? a-1 : a) << endl;
	return 0;
}


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

#define infi            5e9
#define infl            5e18
#define MX              100005
#define pi              2*acos(0.0)
#define ll              long long int
#define rr              read()
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define ms(a,b)         memset(a, b, sizeof(a))
#define loop(i,n)       for(register int i=0;i<n;i++)
#define pool(i,n)       for(register int i=n-1;i>=0;i--)
#define loop1(i,n)      for(register int i=1;i<=n;i++)
#define pool1(i,n)      for(register int i=n;i>0;i--)

using namespace std;

inline ll read(){char c=getchar();ll num,sign=1;for(;c<'0'||c>'9';c=getchar())if(c=='-')sign=-1;for(num=0;c>='0'&&c<='9';){c-='0';num=num*10+c;c=getchar();}return num*sign;}
inline ll pw(ll b, ll p){ll ans=1;while(p>0){if(p&1)ans*=b;p>>=1;b*=b;}return ans;}
inline bool isPrime(ll n){if(n==1)return false;if(n==2)return true;if(!(n%2))return false;for(ll i=3;i<=sqrt(n);i+=2)if(!(n%i))return false;return true;}
inline ll gcd(ll a, ll b){if(a==0)return b;return gcd(b%a,a);}

// //*************************************  Bitmask Opereations  **********************************//
// int Set(int N,int pos){return N=N | (1<<pos);}
// int reset(int N,int pos){return N= N & ~(1<<pos);}
// bool check(int N,int pos){return (bool)(N & (1<<pos));}
// //********************************************************************************************//

// vector<pll>vec[30005];
// ll ans;

// ll DFS(int u, int v){
//     ll cur,prev=0;

//     loop(i,vec[v].size()){
//         if(vec[v][i].ff!=u){
//             cur = DFS(v, vec[v][i].ff)+vec[v][i].ss;
//             ans = max(ans, cur+prev);
//             prev = max(prev, cur);
//         }
//     }
//     return prev;
// }

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    //#ifdef rid.dle//freopen("in.txt", "r", stdin);//#endif
    //freopen("in.txt", "r", stdin);

    // int tt=rr;
    // int x,y,n;
    // ll w;
    // loop1(t,tt){
    
    
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;

    int a=1,b=0,c=0;
    char cc=s1[0];
    while(1){
        if(cc=='a'){
            cc=s1[a];
            a++;
            if(a>s1.length()){
                cout << "A" << endl;
                return 0;
            }
        }else if(cc=='b'){
            cc=s2[b];
            b++;
            if(b>s2.length()){
                cout << "B" << endl;
                return 0;
            }
        }else if(cc=='c'){
            cc=s3[c];
            c++;
            if(c>s3.length()){
                cout << "C" << endl;
                return 0;
            }
        }
       
    }
     
    
    
    // }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void trace(int A[], int N) {
    for (int j = 0; j < N; ++j) {
        if (j > 0) printf(" ");
        printf("%d", A[j]);
    }
    printf("\n");
}

void insertion_sort(int A[], int N) {
    int key, j;
    for (int i = 0; i < N; ++i) {
        key = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > key) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = key;
        trace(A, N);
    }
}

int main() {
    int N;
    scanf("%d", &N);
    int A[N];
    for (int i = 0; i < N; ++i) {
        scanf("%d", &A[i]);
    }
    insertion_sort(A, N);

    return 0;
}




Measured memory_bytes: 2104
#include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;
 
int main(){
    string S;
    cin >> S;

    int count = 0;
    for(int i = 0; i < S.length(); i++){
        if(S[i] == 'x'){
            count++;
        }
    }
    string ans = "YES";
    if (count >= 8)
    {
        ans = "NO";
    }

    cout << ans << endl;

    return 0;
}

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

const int N = 200005;

int n;
int k[N], l[N], r[N];

int lft[N];
int getLft(int u) {
  if (u == -1 || lft[u] == u) return u;
  return lft[u] = getLft(lft[u]);
}

void add(int u) {
  lft[getLft(u)] = getLft(getLft(u) - 1);
}

long long count(vector<pair<int, int>> camels, vector<int> k) {
  sort(camels.begin(), camels.end(), greater<pair<int, int>>());
  for (int i = 0; i < n; ++i) lft[i] = i;

  long long tot = 0;
  for (int i = 0; i < camels.size(); ++i) {
    int idx = camels[i].second;
    if (getLft(k[idx]) == -1) {
      add(n-1);
    } else {
      add(k[idx]);
      tot += camels[i].first;
    }
  }

  return tot;
}

int solve() {
  scanf("%d", &n);

  vector<pair<int, int>> pos, neg;
  vector<int> k1, k2;

  long long tot = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d %d %d", &k[i], &l[i], &r[i]);
    --k[i];
    k1.push_back(k[i]);
    k2.push_back(n - k[i] - 2);

    if (l[i] >= r[i]) {
      pos.emplace_back(l[i] - r[i], i);
      tot += r[i];
    } else {
      neg.emplace_back(r[i] - l[i], i);
      tot += l[i];
    }
  }

  tot += count(pos, k1) + count(neg, k2);

  printf("%lld\n", tot);
  return 0;
}

int main() {
  int t = 1;
  scanf("%d", &t);
  while (t--) solve();
  return 0;
}


Measured memory_bytes: 12760
from math import sqrt
from sys import stdin
N, D = [int(_) for _ in stdin.readline().rstrip().split()]
XY = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]
ans = 0
for x, y in XY:
    if sqrt(x**2+y**2) <= D:
        ans += 1
print(ans)

Measured memory_bytes: 45268
package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	"strings"
)

func main() {

	body, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		log.Println(err)
	}
	scanner := bufio.NewScanner(strings.NewReader(string(body)))
	scanner.Split(bufio.ScanWords)
	if err := scanner.Err(); err != nil {
		fmt.Fprintln(os.Stderr, "reading input:", err)
	}
	inputs := make([]int, 0)
	for scanner.Scan() {
		word, _ := strconv.Atoi(scanner.Text())
		inputs = append(inputs, word)
	}

	cards := inputs[1:]

	fmt.Println(len(removeDuplicates(cards)))
}

func removeDuplicates(elements []int) []int {
	encountered := map[int]bool{}
	result := []int{}

	for v := range elements {
		if encountered[elements[v]] == true {
		} else {
			encountered[elements[v]] = true
			result = append(result, elements[v])
		}
	}
	return result
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string s;
    cin>>s;
    int len=s.length();
    int index=-1;
    for(int i=0;i<len-1;i++){
        if(s[i]==s[i+1]){
            index=i;
            break;
        }
    }
    if(index!=-1)
    cout<<index+1<<" "<<index+2;
    else{
        for(int i=1;i<len-1;i++){
            if(s[i-1]==s[i+1]){
                index=i;
                break;
            }
        }
        if(index==-1)cout<<"-1 -1";
        else cout<<index<<" "<<index+2;
    }
}

Measured memory_bytes: 512
N = list(map(int,input().split()))[0]
lis = [[] for i in range(N)]

for a_i,b_i in [ map(int,input().split()) for _ in range(N-1) ]:
	lis[a_i-1].append(b_i-1)
	lis[b_i-1].append(a_i-1)

while True:

	sumsum = 0
	for x in lis:
		sumsum += sum(x)
	if sumsum == 0:
		print("Second")
		quit()

	for i in range(len(lis)):

		if len(lis[i]) == 1:
			b = lis[i][0]
			lis[i].remove(b)
			lis[b].remove(i)
			for c in lis[b]:
				lis[c].remove(b)
				if len(lis[c]) == 0:
					print("First")
					quit()
			lis[b] = []

Measured memory_bytes: 56016
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
mod = 998244353

N, K = map(int, input().split())
LR = tuple(tuple(map(int, input().split())) for _ in range(K))

dist = [0] * (N + 1)
dist[1] = 1
for i in range(1, N + 1):
    dist[i] += dist[i - 1]
    dist[i] %= mod
    for l, r in LR:
        if i + l <= N:
            dist[i + l] += dist[i]
        if i + r + 1 <= N:
            dist[i + r + 1] -= dist[i]
    if i == 1:
        dist[i] = 0

print(dist[N])

Measured memory_bytes: 16924
use io::*;
use proconio::{fastout, input};
use std::*;

#[fastout]
fn main() {
    input! {
        r: i32,
        mut g: i32,
        mut b: i32,
        mut k: i32,
    }
    while k > 0 && g <= r {
        g *= 2;
        k -= 1;
    }
    while k > 0 && b <= g {
        b *= 2;
        k -= 1;
    }
    let res = if k >= 0 && b > g && g > r {
        "Yes"
    } else {
        "No"
    };
    println!("{}", res);
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define DIM 100007
#define DIMM 100007
#define INF 1000000009.0
#define X 500007
#define epc 0.0000001
#define pi 3.14159265358979323846
#define MAX 25
#define MODULO 10009
const long double gr=(1+sqrt(5))/2;

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

typedef pair<I,I> pII;
typedef pair<ll,ll> pllll;
typedef pair<ld,ld> pldld;

typedef vector<I> vI;
typedef vector<ll> vll;
typedef vector<pllll> vpllll;

typedef char cr;
typedef string str;

typedef tree<
I,
null_type,
less<I>,
rb_tree_tag,
tree_order_statistics_node_update> mset;

ll n,m,v1,v2,vis[DIM],res;
vector<ll>a[DIM];

void dfs(ll v){
  if(vis[v]!=0)return;
  ll maxv=0;
  for(auto to:a[v]){
   dfs(to);
   maxv=max(maxv,vis[to]);
  }
  vis[v]=maxv+1;
}

int main()
{
    //freopen("suffarray.in", "r", stdin);
    //freopen("suffarray.out", "w", stdout);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //cout<<"ops"<<endl;

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

    //ll x1,y1,xs,ys,y1,y2,x3,x4,y3,y4;

    cin>>n>>m;
    for(int i=1;i<=m;i++){
     cin>>v1>>v2;
     a[v1].push_back(v2);
    }
    for(int i=1;i<=n;i++){
     if(vis[i]==0)dfs(i);
     res=max(res,vis[i]);
    }
    cout<<res-1<<endl;
}


Measured memory_bytes: 8576
#include <stdio.h>
int main(void){
int a;
scanf("%d",&a);
if(a>888)
printf("999");
else if(a>777)
printf("888");
else if(a>666)
printf("777");
else if(a>555)
printf("666");
else if(a>444)
printf("555");
else if(a>333)
printf("444");
else if(a>222)
printf("333");
else if(a>111)
printf("222");
else
printf("111");
return 0;
}

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

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

	vector<int> a(n), b(n);

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

	sort(a.begin(), a.end(), greater<int>());
	sort(b.begin(), b.end(), greater<int>());

	int b_use_index;
	for (int i = 0; i < n; i++) {
		if (a[0] < b[i]) b_use_index = i;
	}
	
	int ans = 0;
	int tmp_h = h;

	for (int i = 0; i <= b_use_index; i++) {
		tmp_h -= b[i];
		ans++;
		if (tmp_h <= 0) {
			cout << ans << endl;
			return 0;
		}
	}

	while (0 < tmp_h) {
		tmp_h -= a[0];
		ans++;	
	}

	cout << ans << endl;
    return 0;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define avg(a,b) ((a)+(b))/2
#define push push_back
#define pop pop_back
#define mp make_pair
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;
ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll mymod(ll a,ll b=num)
{
    return ((a%b)+b)%b;
}
bool prime[200000];
vll v;
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=200000; p++) 
    { 
        if (prime[p] == true) 
        { 
            v.push(p);
            for (int i=p*p; i<=200000; i += p) 
                prime[i] = false; 
        } 
    } 
}
ll powe[60];
void power()
{
    powe[0]=1;
    REP(i,1,15)
    {
        powe[i]=2*powe[i-1];
    }
}
ll gcdExtended(ll,ll,ll *,ll *);
ll modInverse(ll a, ll m=num) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
        ll res = (x%m + m) % m;
        return res;
} 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
} 
ll fact[100005];
void factorial()
{
    fact[0]=1;
    REP(i,1,100002)
    {
        fact[i]=mymod(i*fact[i-1], num);
    }
}
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
bool my(pll p1,pll p2)
{
    if(p1.f<p2.f) return true;
    if(p1.f==p2.f && p1.s<p2.s) return true;
    return false;
}
bool isprime(ll n)
{
    REP(i,2,sqrt(n))
    {
        if(n%i==0)
        return false;
    }
    return true;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll h,n,a,b;
    cin>>h>>n;
    map<ll,ll> m;
    
    REP(i,0,n)
    {
        cin>>a>>b;
        if(m[a]==0) m[a]=b;
        else assmin(m[a],b);
    }
    ll dp[h+1];
    dp[0]=0;
    REP(i,1,h+1)
    {
        dp[i]=num;
        REP(j,1,i/2+1)
        {
            assmin(dp[i],dp[j]+dp[i-j]);
        }
       // cout<<dp[i]<<endl;
        for(auto itr=m.rbegin();itr!=m.rend();itr++)
        {
            if(itr->first<i) break;
            else
            { assmin(dp[i],itr->second);
              //  cout<<"here for "<<i<<" "<<itr->first<<" "<<itr->second<<"\n";
            }
        }
    }
    cout<<dp[h]<<"\n";
	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

bool is_ok(int l, int m, int r) {
    if (l < m && m < r)
        return true;
    else if (l > m && m > r)
        return true;
    else
        return false;
}

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    int n;
    std::vector<int> a;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int m1;
        cin >> m1;
        if (i != 0) {
            int prev = a[a.size() - 1];
            if (prev != m1) {
                a.push_back(m1);
            }
        } else {
            a.push_back(m1);
        }
    }
    int res = 1;
    for (int i = 1; i < a.size() - 1; i++) {
        if (!is_ok(a[i - 1], a[i], a[i + 1])) {
            res++;
            i++;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 892
from itertools import product
N = int( input())
ans = 0
for i in range(3,10):
    for x in product("357", repeat = i):
        z = ""
        V = [0]*10
        for l in x:
            z += l
            V[ int( l)] = 1
        if int(z) <= N and sum(V) == 3:
            ans += 1
print(ans)

Measured memory_bytes: 3064
S = input()

p1 = int(S[:2])
p2 = int(S[2:])
# print(p1, p2)

if (1 <= p1 <= 12) or (1 <= p2 <= 12):
    if (1 <= p1 <= 12) and (1 <= p2 <= 12):
        print('AMBIGUOUS')
    elif 1 <= p1 <= 12:
        print('MMYY')
    else:
        print('YYMM')
else:
    print('NA')


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

struct MinimumCostFlow {
	using Flow = int;
	using Cost = int;
	struct Edge {
		int to, rev;
		Flow cap;
		Cost cost;
		Edge() {}
		Edge(int to, int rev, Flow cap, Cost cost) :to(to), rev(rev), cap(cap), cost(cost) {}
	};
	int n;
	vector<vector<Edge>> g;
	vector<int> dist;
	vector<int> prevv, preve;
	MinimumCostFlow(int n) :n(n), g(n), dist(n), prevv(n), preve(n) {}
	void addArc(int from, int to, Flow cap, Cost cost) {
		g[from].emplace_back(to, (int)g[to].size(), cap, cost);
		g[to].emplace_back(from, (int)g[from].size() - 1, 0, -cost);
	}
	// s??????t????????????f???????°??????¨???
	// ??????????????´?????? -1
	Cost minimumCostFlow(int s, int t, Flow f) {
		Cost total = 0;
		while (f > 0) {
			// Bellman-Ford
			fill(dist.begin(), dist.end(), INF);
			dist[s] = 0;
			bool update = true;
			while (update) {
				update = false;
				for (int v = 0; v < n; v++) {
					if (dist[v] == INF)continue;
					for (int i = 0; i < g[v].size(); i++) {
						Edge &e = g[v][i];
						if (e.cap > 0 && dist[e.to] > dist[v] + e.cost) {
							dist[e.to] = dist[v] + e.cost;
							prevv[e.to] = v;
							preve[e.to] = i;
							update = true;
						}
					}
				}
			}
			// ????????\???????????????
			if (dist[t] == INF)
				return -1;
			// ?????????????????£??????????????????
			int d = f;
			for (int v = t; v != s; v = prevv[v])
				d = min(d, g[prevv[v]][preve[v]].cap);
			f -= d;
			total += d*dist[t];
			for (int v = t; v != s; v = prevv[v]) {
				Edge &e = g[prevv[v]][preve[v]];
				e.cap -= d;
				g[v][e.rev].cap += d;
			}
		}
		return total;
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (int n; cin >> n&&n;) {
		MinimumCostFlow mcf(365 + 1);
		rep(i, 0, 365) {
			mcf.addArc(i, i + 1, 2, 0);
		}
		rep(i, 0, n) {
			int a, b, w; cin >> a >> b >> w;
			a--;
			mcf.addArc(a, b, 1, -w);
		}
		cout << -mcf.minimumCostFlow(0, 365, 2) << endl;
	}
	return 0;
}

Measured memory_bytes: 3344
x=int(input())
A=[]
C=[]
for i in range(100000):
    A.append((i)**5)
    C.append((-(i))**5)
for i in range(len(A)):
    for j in range(len(A)):
        if x==A[i]-A[j]:
            print(i,j)
            #print(A[i],A[j])
            #print(A)
            exit()
        elif x==A[i]-C[j]:
            print(i,-(j))
            #print(A[i],C[j])
            #print(C)
            exit()

Measured memory_bytes: 97388
from collections import deque

n, m = map(int, input().split())
edges = [[]for _ in range(n)]
for _ in range(m):
    a, b = map(lambda x: int(x)-1, input().split())
    edges[a].append(b)
    edges[b].append(a)

next_v = deque([0])
history = [-1]*n
INF = 10**18
dist = [INF]*n
dist[0] = 0
while next_v:
    v = next_v.popleft()

    for v2 in edges[v]:
        if dist[v2] <= dist[v]+1:
            continue
        dist[v2] = dist[v]+1
        history[v2] = v
        next_v.append(v2)


print('Yes')
for x in history[1:]:
    print(x+1)


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


int N, M;
vector<int> s, c;


void input() {
    cin >> N >> M;
    s = c = vector<int>(M);
    rep(i, M) cin >> s[i] >> c[i];
}


int main() {
    input();
    map<int, int> w;
    rep(i, M) {
        if (w.count(s[i] - 1)) {
            if (w[s[i] - 1] != c[i]) {
                cout << -1 << endl;
                return 0;
            }
        } else {
            w[s[i] - 1] = c[i];
        }
    }
    vector<int> ans(N, 10);
    for (auto p : w) {
        ans[p.first] = p.second;
    }
    if (N > 1 && ans[0] == 0) {
        cout << -1 << endl;
        return 0;
    }
    if (ans[0] == 10) {
        if (N == 1) {
            ans[0] = 0;
        } else {
            ans[0] = 1;
        }
    }
    for (int i = 1; i < N; i++) {
        if (ans[i] == 10) ans[i] = 0;
    }
    rep(i, N) cout << ans[i];
    cout << endl;
}


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

#define pb push_back
#define mp make_pair
#define f first
#define s second

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef long long ll;

int main(){

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

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

    if(n == m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;
const int MOD = 1000000007,MAX = 510000;
long int pow107 = (int)pow(10, 9) + 7,llimit = LONG_MAX,fac[MAX], finv[MAX], inv[MAX];
int ilimit = INT_MAX;

// テーブルを作る前処理
void COMinit() {
    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 int COM(long int n,long int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool comp(pair<int, int> a, pair<int, int> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

long int Func2(long int n,long int m){
    long int s2 = 1,
        r = 1;
    for(long int i = 1; i <= m; ++i){
        s2 = (s2*(n - (i - 1))/i) % (pow107);
    }
    return s2;
}

bool secsort(pair<int, int> a, pair<int, int> b){
    if(a.second == b.second)return a.first > b.first;
    else return a.second > b.second;
}

//long intの最大llimit
//intの最大ilimit
//10^9+7    pow107
//素数pn
//n乗jou
//階乗factorial
//コンビネーションFunc2
//コンビネーションCOMinit(),COM(n,m)

int main(){
    long int n,cc[3] = {};
    cin >> n;
    for(int i = 0 ; i < n ; i++){
        long int a,c = 0;
        cin >> a;
        while(a % 2 == 0 && c != 2){
            c++;
            a/=2;
            if(c == 2)
                break;
        }
        cc[c]++;
        //cout << c << endl;
    }
    //cout << cc[0] << " " << cc[1] << " " << cc[2] << endl;
    if((cc[1] == 0 && cc[0] <= cc[2] + 1) || (cc[1] != 0 && cc[1] % 2 == 0 && cc[0] <= cc[1]/2 + cc[2]) || (cc[1] != 0 && cc[1] % 2 == 1 && cc[0] + cc[1] - cc[1]/2 <= cc[1]/2 + cc[2] + 1)){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

bool ansflg=1;

vector<int> dfs(vector<int> a){
    int m=a.size();
    if(m==0){
        ansflg=0;
        return {};
    }
    vector<int> ret;
    vector<int> tmp=a;
    for(int i=m-1;i>=0;i--){
        if(i+1==tmp[i]){
            tmp.erase(tmp.begin()+i);
            ret=dfs(tmp);
            ret.push_back(i+1);
            break;
        }
    }
    return ret;
}

int main(){
    int n; cin>>n;
    vector<int> b(n); rep(i,n) cin>>b[i];
    vector<int> ans=dfs(b);
    if(ansflg){
        cout<<-1<<endl;
        return 0;
    }
    for(int i:ans){
        cout<<i<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>

using namespace std;
// using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<double,double> pd;
typedef priority_queue<int, vector<int>, greater<int>> min_heap;

// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const double PI = 4*atan(1);
const ll INF = 1e18;
const int MX = 100001;

string s;
int n;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> s;
    n = s.size();
    if (n % 2 == 1) {
        cout << "No\n";
        return 0;
    }
    string ans = "Yes";
    for (int i = 0; i < n; i += 2) {
        if (s[i] != 'h') {
            ans = "No";
        }
    }
    for (int i = 1; i < n; i += 2) {
        if (s[i] != 'i') {
            ans = "No";
        }
    }
    cout << ans << "\n";
}

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

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if(A == B || A == C || B == C){
        if(A != B || A != C || B != C){
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;
    }
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
/*Arnab's Code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define vii vector<int>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define take(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define takes(a,n,st) for(ll i=st;i<n+st;i++)cin>>a[i]
ll sum(ll a[],ll n,ll s){ for(ll i=0;i<n;i++)s+=a[i]; return s;}
#define mod 1000000009
ll power(ll x, ll y, ll p)  {  
    ll res = 1;  
    x = x % p;   
    if (x == 0) return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
ll a[100017];
void solve(){
	ll n,su,cur,i;
	cin>>n;
	take(a,n);
	sort(a,a+n);
	su=a[0];
	cur=1;
	for(i=1;i<n;i++){
		if(su*2 >= a[i]){
			cur++;
			su+=a[i];
		}
		else{
//			cout<<su<<" "<<a[i]<<endl;
			su+=a[i];
			cur=1;
		}
	}
	cout<<cur;
	return;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ll t,T;
//	cin>>T;
	T=1;
	for(t=1;t<=T;t++){
//		cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 4276
#include <stdio.h>
#define MAX 100100100
int Min(int a,int b){
    return a<b?a:b;
}
int main()
{   int n,m;

    scanf("%d%d",&n,&m);
    int a[m],b[m],c,key[1001]={0};
    for(int i=0;i<m;i++){
        scanf("%d%d",&a[i],&b[i]);
        for(int j=0;j<b[i];j++){
            scanf("%d",&c);
            key[i]+=(1<<(c-1));
        }
    }
    int dp[100000];
    for(int i=0;i<(1<<n);i++)dp[i]=MAX;
    dp[0]=0;
    for(int i=0;i<(1<<n);i++){
        if(dp[i]<MAX){
            for(int j=0;j<m;j++){
                dp[i|key[j]]=Min(dp[i|key[j]],dp[i]+a[j]);
            }
        }
    }
    if(dp[(1<<n)-1]==MAX)printf("-1");
    else printf("%d",dp[(1<<n)-1]);

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>


int A[100000],n;

int partition(int, int);

int main(){
  
  int n,i,x;

  scanf("%d",&n);
  for(i = 0; i < n; i++)
    scanf("%d",&A[i]);

  x = partition(0, n - 1);

  for(i = 0; i < n; i++){
    if(i)printf(" ");
    if(i == x)printf("[");
    printf("%d",A[i]);
    if(i == x)printf("]");
  }
  printf("\n");

}

int partition(int p, int r){
  int x,i,j,t;

  x = A[r];
  i = p - 1;
  for( j = p; j < r; j++){
    if(A[j] <= x){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i + 1];
  A[i + 1] = A[r];
  A[r] = t;
  return i + 1;
}



Measured memory_bytes: 2156
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = a; i <= b; ++i)
#define PER(i, a, b) for (int i = a; i >= b; --i)
#define RVC(i, S) for (int i = 0; i < S.size(); ++i)
#define mp make_pair
#define pb push_back
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> VI;

int main(){
	LL n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	LL dist = b - a;
	REP(i, 0, n - 1){
		int j = n - 1 - i;
		// err << i << ' ' << j << endl;
		LL l = c * i - d * j, r = d * i - c * j;
		// cerr << l << ' ' << r << endl;
		if (l <= dist && dist <= r) return puts("YES"), 0;
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    double n = sc.nextDouble();

    double odd = 0;
    double notOdd = 0;
    for (int i = 1; i <= n; i++) {
      if (i % 2 == 0) {
        notOdd++;
      } else {
        odd++;
      }
    }
    System.out.println(odd / n);
  }
}


Measured memory_bytes: 23252
#GRL_3_C
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

def scc():
    order = []
    visited = [False]*N
    
    def dfs(v):
        visited[v] = True
        
        for nv in G[v]:
            if not visited[nv]:
                dfs(nv)
        
        order.append(v)
    
    for i in range(N):
        if not visited[i]:
            dfs(i)
    
    visited = [False]*N
    group = [-1]*N
    label = 0
    
    def rdfs(v, label):
        group[v] = label
        visited[v] = True
        
        for nv in RG[v]:
            if not visited[nv]:
                rdfs(nv, label)
    
    for v in reversed(order):
        if not visited[v]:
            rdfs(v, label)
            label += 1
            
    return label, group

N, M = map(int, input().split())
G = [[] for _ in range(N)]
RG = [[] for _ in range(N)]

for _ in range(M):
    s, t = map(int, input().split())
    G[s].append(t)
    RG[t].append(s)
    
_, group = scc()

Q = int(input())

for _ in range(Q):
    u, v = map(int, input().split())
    
    if group[u]==group[v]:
        print(1)
    else:
        print(0)


Measured memory_bytes: 21608
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    vector<long> a(n), b(n);
    long i;
    ll suma=0, sumb=0; 
    for(i=0; i<n; i++) {
        scanf("%ld", &a[i]);
        suma += a[i];
    }
    for(i=0; i<n; i++) {
        scanf("%ld", &b[i]);
        sumb += b[i];
    }
    if(suma>sumb) {
        printf("No\n"); return 0;
    }

    ll m = sumb-suma;
    ll cnt=0;
    for(i=0; i<n; i++) {
        if(b[i]>a[i]) {
            cnt += (b[i]-a[i]+1)/2;
        }
    }
    if(cnt>m) {
        printf("No\n"); return 0;
    }
    else {
        printf("Yes\n"); return 0;
    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 200011;
int N;
LL A[MAX];

int main(void) {
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }

    const LL sum = accumulate(A, A + N, 0LL);
    LL ans = LLINF;
    LL tmp = 0;
    REP(i, N - 1) {
        tmp += A[i];
        const LL left = tmp;
        const LL right = sum - left;
        chmin(ans, llabs(left - right));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
# include<stdio.h>
# include<string.h>
int main()
{
	char str[10];
	gets(str);
	if(strcmp(str,"Sunny")==0)
		printf("Cloudy\n");
	else if(strcmp(str,"Cloudy")==0)
		printf("Rainy\n");
	else
		printf("Sunny\n");
	return 0;
}

Measured memory_bytes: 128
def is_prime(n):
  if n == 2: return True
  if n < 2 or n % 2 == 0: return False
  return pow(2, n - 1, n) == 1

count = 0
for i in range(int(input())):
  if is_prime(int(input())) : count += 1
print(count)

Measured memory_bytes: 7700
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, M;
    cin >> N >> M;

    vector<vector<int>> S;
    REP(i, M)
    {
        int k;
        cin >> k;
        S.PB(vector<int>(k));
        REP(j, k)
        cin >> S[i][j];
    }

    vector<int> P(M);
    REP(i, M)
    cin >> P[i];

    int ans = 0;
    REP(i, 1 << N)
    {
        int count = 0;
        REP(j, M)
        {
            int on = 0;
            REP(k, SIZE(S[j]))
            {
                //オンになっているスイッチの数を数え上げる
                if (i >> (S[j][k] - 1) & 1)
                    on++;
            }
            //オンになっているスイッチの数と条件を照らし合わせて電球がつくかどうか判定
            if (on % 2 == P[j])
                count++;
        }

        //すべての電球がついているか確認
        if (count == M)
            ans++;
    }

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


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

int main()
{
    int n, m;

    while( cin >> n >> m )
    {
        if( n + m == 0 )
            break;

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

        for( int i = 0; i < n - 1; i++ )
            for( int j = i + 1; j < n; j++ )
                if( a[i] + a[j] > max && a[i] + a[j] <= m )
                    max = a[i] + a[j];

        if( !max )
            cout << "NONE" << endl;
        else
            cout << max << endl;
    }

    return 0;
}



Measured memory_bytes: 3068
namespace VainZero.Procon.FSharp

open System
open System.Collections.Generic

[<AutoOpen>]
module Operators =
  let read f = Console.ReadLine().Split([|' '|]) |> Array.map f

module Program =
  [<EntryPoint>]
  let main _ =
    let _ = Console.ReadLine()
    let source = Console.ReadLine()

    let calc () =
      let (depth, minDepth) =
        // 括弧の深さ
        let mutable d = 0
        // 括弧の深さの最小値
        let mutable minDepth = Int32.MaxValue
        for i in 0..(source.Length  - 1) do
          d <- d + (if source.[i] = '(' then 1 else -1)
          minDepth <- minDepth |> min d
        (d, minDepth)
      
      // minDepth が負なら括弧列の一部に「閉じすぎ」な部分があるので、
      // 必要なだけ開き括弧を補う。
      // 左端に挿入すれば辞書順最小になる。
      let leftParenthesis =
        if minDepth < 0 then String('(', -minDepth) else ""
      // 左括弧の挿入により、全体の深さが (-minDepth) 増加する。
      let depth =
        if minDepth < 0 then depth - minDepth else depth

      // NOTE: 左括弧の挿入により、全体の深さは 0 以上になる。

      // 右端の深さが 0 より大きいなら、「開きすぎ」なので、閉じ括弧を挿入する。
      // 右端に挿入すれば辞書順最小になる。
      let rightParenthesis =
        if depth > 0 then String(')', depth) else ""

      leftParenthesis + source + rightParenthesis

    printfn "%s" (calc ())

    0


Measured memory_bytes: 13916
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

points n ws = runSTArray $ do
    arr <- newArray (1,n) 0
    forM ws $ \[ai,bi,ap,bp] -> do
        when (ap>bp) $ readArray arr ai >>= writeArray arr ai . (+3)
        when (ap<bp) $ readArray arr bi >>= writeArray arr bi . (+3)
        when (ap==bp) $ readArray arr ai >>= writeArray arr ai . (+1) >> readArray arr bi >>= writeArray arr bi . (+1)
    return arr

rank :: Int -> [[(Int,Int)]] -> [(Int,Int)]
rank _ [] = []
rank r (xs:xss) = map ((r<$) . swap) xs ++ rank (r+length xs) xss

main = do
    n <- getInt
    ws <- replicateM (n*(n-1)`div`2) getInts
    mapM_ print $ map snd $ sort $ rank 1 $ groupBy (on (==) fst) $ sort $ map (swap .(negate<$>)) $ assocs $ points n ws

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

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

    long long n, a, b;
    cin >> n >> a >> b;

    if(a > b){
        cout << 0 << endl;
        return 0;
    }
    if(n == 1){
        if(a == b) cout << 1 << endl;
        else cout << 0 << endl;
        return 0;
    }
    cout << (b - a) * (n - 2) + 1 << endl;

    return 0;
}

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

int main() {
  int N,M;
  std::cin >> N >> M;
  std::map<int,int> love_cnt;
  for(int i=0;i<N;i++){
    int K;
    std::cin >> K;
    for(int k=0;k<K;k++){
      int M;
      std::cin >> M;
      love_cnt[M]++;
    }
  }
  int cnt = 0;
  for(auto &l:love_cnt){
    if(l.second == N)
      cnt++;
  }
  std::cout << cnt << std::endl;
  return 0;
}


Measured memory_bytes: 256