akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - 105
            int n = int.Parse(Console.ReadLine());
            int divisors = 0;

            if (n >= 195)
            {
                divisors = 5;
            }
            else if (n >= 189)
            {
                divisors = 4;
            }
            else if (n >= 165)
            {
                divisors = 3;
            }
            else if (n >= 135)
            {
                divisors = 2;
            }
            else if (n >= 105)
            {
                divisors = 1;
            }

            Console.WriteLine(divisors);
        }
    }
}

Measured memory_bytes: 11092
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int[] ABC = in.nextIntArray(3);
            Arrays.sort(ABC);
            out.println(ABC[2] * 10 + ABC[1] + ABC[0]);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

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

    }
}



Measured memory_bytes: 21460
#include<stdio.h>
#define MAX 100000
int parent(int i) {return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}

int main(){
  int H,i,A[MAX+1];
  scanf("%d",&H);
  for(i = 1;i<=H;i++)
    scanf("%d",&A[i]);
  for(i = 1;i<=H;i++){
    printf("node %d",i);
    printf(": key = %d",A[i]);
    printf(", ");
    if(parent(i)>=1){
      printf("parent key = %d",A[parent(i)]);
      printf(", ");
    }
    if(left(i)<=H){
      printf("left key = %d",A[left(i)]);
      printf(", ");
    }
    if(right(i)<=H){
      printf("right key = %d",A[right(i)]);
      printf(", ");}
    printf("\n");
  }

  return 0;
}



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

int main(){
	int N;
	cin >> N;
	double x[N];
	string u[N];
	
	int i;
	for(i=0; i<N; i++){
		cin >> x[i] >> u[i];
	}

	double ans = 0;
	for(i=0; i<N; i++){
		if(u[i]=="BTC")	x[i] *= 380000.00000000;
		ans += x[i];
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
n =int(input())

cupper=n//4
dupper = n//7
flag = False

for x in range(cupper+1):
    for y in range(dupper+1):
        if (4 * x + 7 * y == n):
            flag = True
            break
if flag:
    print ("Yes")
else:
    print ("No")

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

void solve() {
    ll n;
    cin >> n;
    vector<ll> v;
    for (int i = 0; i < n; i++) {
        ll x;
        cin >> x;
        v.push_back(x);
    } 
    vector<ll> dp(n, 0);
    dp[0] = 0;
    dp[1] = abs(v[1] - v[0]);
    for (ll i = 2; i < n; i++) 
        dp[i] = min(dp[i - 2] + abs(v[i] - v[i - 2]),
                    dp[i - 1] + abs(v[i] - v[i - 1]));
    cout << dp[n - 1] << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 5060
fn main() {
    let n: usize = readln();
    let a: Vec<i64> = readln();
    let b: Vec<i64> = readln();
    let ans = (0..n)
        .map(|i| a[0..i + 1].iter().sum::<i64>() + b[i..n].iter().sum::<i64>())
        .max()
        .unwrap();
    println!("{}", ans);
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 4352
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AStationAndBus solver = new AStationAndBus();
        solver.solve(1, in, out);
        out.close();
    }

    static class AStationAndBus {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String x = in.next();
            for (int i = 0; i < 3; i++) {
                if (x.charAt(i) != x.charAt((i + 1) % 3)) {
                    out.println("Yes");
                    return;
                }
            }
            out.println("No");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 21460
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	static PrintWriter out;
	static Scanner sc;
	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		int a = sc.nextInt(),b = sc.nextInt(), c = sc.nextInt();
		boolean f = (a == b && a != c) || (a == c && a != b) || (c == b && a != c);
		out.println(f?"Yes":"No");
		out.close();
	}
	static class Scanner{
		BufferedReader br;
		StringTokenizer st;
		public Scanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));			
		}
		private String next() throws IOException{
			while(st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}
		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
	}
}


Measured memory_bytes: 21204
//13-4 暑い日々
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<math.h>
#include<time.h>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<set>
#include<stack>
#include<queue>
#include<cstdlib>
#include<algorithm>
#include<random>
#include<cassert>
using namespace std;
#define LL long long
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while(true)

int D,N;
int T[200];
int A[200];
int B[200];
int C[200];
vector<int> s[61];//o度の日に着られる服一覧

int dp[200][101];

int cul(int now, int before){
    if(dp[now][before]!=INT_MIN) return dp[now][before];
    if(now==D-1){
        int tmp = 0;
        for(int i=0; i<s[T[now]].size(); i++) tmp = max(tmp, abs(before-s[T[now]].at(i)));
        dp[now][before] = tmp;
        return tmp;
    }
    int re = 0;
    for(int i=0; i<s[T[now]].size(); i++){
        re = max(re, cul(now+1, s[T[now]].at(i)) + abs(before-s[T[now]].at(i)) );
    }
    dp[now][before] = re;
    return re;
}

int main(){
    cin >> D >> N;
    for(int i=0; i<D; i++){
        cin >> T[i];
        for(int j=0; j<101; j++){
            dp[i][j] = INT_MIN;
        }
    }
    for(int i=0; i<N; i++){
        cin >> A[i] >> B[i] >> C[i];
        for(int j=A[i]; j<=B[i]; j++){
            s[j].push_back(C[i]);
        }
    }
    int ans = 0;
    for(int i=0; i<s[T[0]].size(); i++){
        ans = max(ans, cul(1,s[T[0]].at(i)));
    }
    cout << ans << endl;
    
    return 0;
}



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

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

int H, W;
vector<string> field;

int seen[30][30];
void dfs(int h, int w, int k) {
	if (h >= H || h < 0 || w >= W || w < 0)
		return ;
	if (field[h][w] == '#')
		return ;
	if (seen[h][w] <= k)
		return ;
	else
		seen[h][w] = k;
	REP(i, 4)
		dfs(h + dx[i], w + dy[i], k + 1);
}

int main() {
	cin >> H >> W;
	field.resize(H);
	REP(i, H) cin >> field[i];

	int maxi = 0;
	REP(i, H) REP(j, W) {
		if (field[i][j] == '.') {
			memset(seen, 0x40, sizeof(seen));
			dfs(i, j, 0);
			REP(h, H) REP(w, W) {
				if (seen[h][w] != seen[29][29])
					maxi = max(maxi, seen[h][w]);
			}
		}
	}
	cout << maxi << '\n';
    return 0;
}


Measured memory_bytes: 3644
def agc030_a():
  a, b, c = map(int, input().split())
  # a+b+1枚まではcを食べられる (最後の1枚をcにする)
  c_max = min(c, a+b+1)
  ans = b + c_max
  print(ans)

agc030_a()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 8010
#define INF 1000000005
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000005;
const int MOD = 998244353;
bool dpx[N][N];
bool dpy[N][N];
int main(){
    string s;
    int x,y;
    cin>>s>>x>>y;
    int t=0;
    int tmp=0;
    s.push_back('T');
    vector<int>a,b;
    REP(i,SZ(s)){
        if(s[i]=='F')tmp++;
        else{
            if(t%2==0){
                if(t==0)x-=tmp;
                else a.push_back(tmp);
            }
            else b.push_back(tmp);
            t++;
            tmp=0;
        }
    }
    x=abs(x);
    y=abs(y);
    dpx[0][0]=dpy[0][0]=true;
    REP(i,SZ(a)){
        REP(j,N){
            if(!dpx[i][j])continue;
            if(j-a[i]>=0)dpx[i+1][j-a[i]]=true;
            if(j+a[i]<N)dpx[i+1][j+a[i]]=true;
        }
    }
    REP(i,SZ(b)){
        REP(j,N){
            if(!dpy[i][j])continue;
            if(j-b[i]>=0)dpy[i+1][j-b[i]]=true;
            if(j+b[i]<N)dpy[i+1][j+b[i]]=true;
        }
    }
    if(x<N&&dpx[SZ(a)][x]&&dpy[SZ(b)][y])OUT("Yes");
    else OUT("No");
    return 0;
}

Measured memory_bytes: 64768
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int dp[400]={};
  dp[0]=1;
  for(int i=1;i<18;i++){
    for(int j=0;j+i*i<400;j++){
      dp[j+i*i]+=dp[j];
    }
  }
  int n;
  while(cin>>n,n) cout<<dp[n]<<endl;
  return 0;
}

Measured memory_bytes: 3008
# -*- coding: utf-8 -*-


N,M = map(int, input().split())
graph = [set() for _ in range(N)]
for _ in range(M):
  a,b = map(int, input().split())
  graph[a-1].add(b-1)
  graph[b-1].add(a-1)

ans = 0

def dfs(p, visited):
  global ans
  if len(visited) == N:
    ans += 1
  else:
    for q in graph[p]:
      if q not in visited:
        dfs(q, visited+[q])

dfs(0,[0])
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    string s;
    cin >> s;
    if(s == "RRR") {
        cout << 3 << endl;
    } else if(s == "SRR") {
        cout << 2 << endl;
    } else if(s == "RRS") {
        cout << 2 << endl;
    } else if(s == "SSS") {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define maxn 1005
const lli inf = 1e16;

struct box{
	int w,s;
	lli v;
};

lli dp[maxn][10006][2];
vector<box> order;
int n;

bool cmp(box a, box b){
	return (a.w + a.s) > (b.w + b.s);
}

lli solve(int pos, int str, int f){
	if(str < 0) return -inf;
	if(pos == n){
		return 0ll;
	}

	lli &ans = dp[pos][str][f];
	if(ans != -1) return ans;
	ans = 0;
	
	ans = max(ans, solve(pos+1,str,f));
	int val = min(str-order[pos].w, order[pos].s);
	if(!f) val = order[pos].s;
	ans = max(ans, solve(pos+1,val,1) + order[pos].v);
	return ans;
}

int main(){__
	cin >> n;
	order.resize(n);
	for(int i=0; i <n; i++){
		cin >> order[i].w >> order[i].s >> order[i].v;
	}
	sort(order.begin(),order.end(),cmp);
	memset(dp,-1,sizeof(dp));
	cout << solve(0,1e4+5,0) << endl;
	return 0;
}


Measured memory_bytes: 160844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 要素の入力、格納
		int N = sc.nextInt();
		int a[][] = new int[2][N];
		for (int i = 0; i < N; i++) {
			a[0][i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			a[1][i] = sc.nextInt();
		}
		int x = 0;
		int ans = 0;

		for (int i = 0; i < N; i++) {
			x = 0;
			for (int j = 0; j < N; j++) {
				if (j < i) {
					x += a[0][j];
				} else if (j == i) {
					x += a[0][j];
					x += a[1][j];
				} else {
					x += a[1][j];
				}
			}
			if (ans < x) {
				ans = x;
			}
		}

		// 出力
		System.out.println(ans);
	}
}


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

bool check(string S) {
  if (S[0] != 'A') {
    return false;
  }

  int counter = 0;
  for (int i = 2; i < S.length() - 1; i++) {
    if (S[i] == 'C') {
      counter++;
    }
  }

  if (counter == 0) {
    return false;
  }

  int upper = 0;
  for (int i = 0; i < S.length(); i++) {
    if (S[i] >= 'A' && S[i] <= 'Z') {
      upper++;
    }
  }

  if (upper != 2) {
    return false;
  }
  return true;
}

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

  if (check(S)) {
    cout << "AC" << endl;
  } else {
    cout << "WA" << endl;
  }

  return 0;
}

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

int main(){
    string S;
    cin >> S;
    size_t K;
    cin >> K;
    size_t N{S.size()};
    vector<vector<vector<int>>> dp(N, vector<vector<int>>(N, vector<int>(K + 1)));
    for(size_t i = 0; i < N; ++i)for(size_t j = 0; j <= K; ++j)dp[i][i][j] = 1;
    for(size_t j = 0; j <= K; ++j)for(size_t k = 1; k < N; ++k)for(size_t i = 0; i + k < N; ++i)
        dp[i][i + k][j] = max({dp[i][i + k - 1][j], dp[i + 1][i + k][j], (S[i] == S[i + k]) * (dp[i + 1][i + k - 1][j] + 2), (j != 0) * (dp[i + 1][i + k - 1][j - 1] + 2)});
    cout << dp[0][N - 1][K] << endl;
}

Measured memory_bytes: 109568
n=int(input())
l=sorted(map(int,input().split()))[::-1]
def f(x):
  t=n+1
  for i in l[x::2]:
    if t-2!=i: return 0
    t=i
  return 1
print(pow(2,n//2,10**9+7)*f(0)*f(1))

Measured memory_bytes: 13880
#include <stdio.h>
#include <stdlib.h>

 int compare(const void *a, const void *b){
    return *(int*)a-*(int*)b;
}

int main(void){
    int i, j, k, n, ans = 0;
    scanf("%d", &n);
    int l[n];
    for(i = 0; i < n; ++i){
        scanf("%d", &l[i]);
    }
    qsort(l, n, sizeof(int), compare);
    for(i = 0; i < n-2; ++i){
            for(j = i+1; j < n-1; ++j){
                for(k = j+1; k < n; ++k){
                    if( l[k] < l[i] + l[j] ){ ans++; }
                    else{ break; }
                }
            }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W, &H, &x, &y, &r);
	if (W >= x + r){
		if (x >= r){
			if (H >= y + r){
				if (y >= r)
					printf("Yes\n");
				else
					printf("No\n");
			}
			else
				printf("No\n");
		}
		else
			printf("No\n");
	}
	else
		printf("No\n");
		
	
	return 0;
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
 
int main(){
  int n;
  cin >> n;
  VI p(n);
  rep(i,n){
  cin >> p.at(i);
  }
  int sum=0;
  int mx=n+100;
  rep(i,n){
    mx=min(mx,p.at(i));
    if(p.at(i)<=mx)sum++;
  }
  cout << sum << endl;
    
}
  

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

int main( void )
{
    int a, b;
    cin >> a >> b;
    int t, h, k;
    t = a + b;
    h = a - b;
    k = a * b;
    if ( (t >= h) && (t >= k) )
    {
        cout << t << endl;
    }
    else if ( (h >= t) && (h >= k) )
    {
        cout << h << endl;
    }
    else
    {
        cout << k << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

if N == 0 and A[0] != 1:                            # N=0なら葉は1
    ans = -1
elif N != 0 and A[0] != 0:                          # N>0ならd=0の葉は0
    ans = -1
else:
    ans = 1                                         # 頂点合計
    node = 1                                        # 深さdでの頂点
    lateFolia = sum(A)                              # 残りの葉
    preFolia = 0                                    # 深さd-1の葉

    for d in range(1, N+1):                         # d=0は初期値固定なのでd=1以降の計算
        folia = A[d]                                # 深さdの葉
        node = min((node-preFolia)*2, lateFolia)    # 深さdの頂点

        if node < folia:                            # 頂点<葉はありえない
            ans = -1
            break

        ans += node                                 # 頂点合計を更新
        lateFolia -= folia                          # 残りの葉の数を更新
        preFolia = folia                            # 深さd-1の葉を記憶

print(ans)


Measured memory_bytes: 20128
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

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

  cout << (a+b > c+d ? "Left" : a+b < c+d ? "Right" : "Balanced") << endl;
  return 0;
} 

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mp make_pair

void solve(int N, vector<pii> &A) {
    vector<int> hana(N);
    for(int i = 0; i < N; i++) {
        hana[i] = N - i - 1;
    }
    for(int i = 0; i < A.size(); i++) {
        int p = A[i].first;
        int c = A[i].second;
        vector<int> newhana(N);
        for(int j = p; j < p + c; j++) {
            newhana[j - p] = hana[j];
        }
        for(int j = 0; j < p; j++) {
            newhana[c + j] = hana[j];
        }
        for(int j = 0; j < p + c; j++) {
            hana[j] = newhana[j];
        }
    }
    cout << hana[0] + 1 << endl;
}

int main() {
    int N, R;
    while(cin >> N >> R, R) {
        vector<pii> A(R);
        for(int i = 0; i < R; i++) {
            int p, c;
            cin >> p >> c;
            p -= 1;
            A[i] = mp(p, c);
        }
        solve(N, A);
    }
    return 0;
}



Measured memory_bytes: 3044
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<int,int> point;
#define rep(i,n) for(i,0,n)

string abc = "abcdefghijklmnopqrstuvwxyz";

int main() {
	// 入力
	string S ;
	cin >> S;
	
	// 解法
	bool ans = true;
	if (S.substr(0,1)!="A") ans = false;
	int count = 0;
	int idx;
	for (int i = 2; i < S.size()-1; ++i) {
		if (S.substr(i,1)=="C"){
			 count++;
			 idx = i;
		}
	}
	if (count!=1) ans = false;
	if (ans){
		S = S.substr(1,idx-1)+S.substr(idx+1);
		// cout << S <<endl;
		for (int i = 0; i < S.size(); ++i) {
			string c = S.substr(i,1);
			bool judge = false;
			for (int k = 0; k < abc.size(); ++k) {
				if (c==abc.substr(k,1)) judge = true;
			}
			if (judge==false) ans = false;
		}
	}

	//出力
	if (ans) printf("AC\n");
	else printf("WA\n");
}
 


Measured memory_bytes: 256
//I̲n̲ ̲t̲h̲e̲ ̲N̲a̲m̲e̲ ̲o̲f̲ ̲G̲o̲d̲
#define pb push_back
#define F first
#define S second
#define sz size()
#define ll long long

#include <bits/stdc++.h>

using namespace std;

ll n, k;
pair <ll , ll> a[100001];
int main()
{
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++)
    {
        ll x,y;
        cin >> x >> y;
        a[i].F = x;
        a[i].S = y;
    }
    sort(a,a+n);
    for (int i = 0; i < n; i++)
    {
        if (a[i].S >= k)
            return cout << a[i].F, 0;
        else
            k-= a[i].S;
    }
}


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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

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

	vi v;
	int a, b, k;
	cin >> a >> b >> k;
	for(int i = 1; i <= 101; i++){
		if(a % i == 0 && b % i == 0) v.push_back(i);
	}
	cout << v[v.size() - k];
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    string s,t;
    cin >> s >> t;
    bool ok = true;
    bool flag = false;

    for(ll i=s.size()-t.size();i>=0;i--){
        ok = true;
        for(ll j=0;j<t.size();j++){
            if(s[i+j] == '?') continue;
            if(s[i+j] == t[j]) continue;
            ok = false;
        }

        if(ok){
            for(ll j=0;j<t.size();j++) s[i+j] = t[j];
            flag = true;
            break;
        }
    }

    if(!flag){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    for(ll i=0;i<s.size();i++){
        if(s[i] == '?') s[i] = 'a';
    }

    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3660
N = int(input())
A = [int(i) for i in input().split()] 

total = sum(A)
node = 1
ans = 0
for i in range(N+1):
  ans += node
  total -= A[i]
  #print(node, total)
  node = min(total, (node - A[i]) * 2)
  
  if node < 0:
    print(-1)
    exit()
      
print(ans)

Measured memory_bytes: 20116
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
A = sorted(map(int, readline().split()))

def main(A):
    N = len(A)
    if A[0] == A[-1]:
        x = A[0]
        return x == N - 1 or 2 * x <= N
    if A[0] + 1 != A[-1]:
        return False
    a, b = A[0], A[-1]
    full = b
    unique = A.count(a)
    people, color = N - unique, A[-1] - unique
    return color > 0 and 2 * color <= people

print('Yes' if main(A) else 'No')

Measured memory_bytes: 18344
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <cmath>
#include <bitset>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
  ll D, T, S;
  cin >> D >> T >> S;
  
 
    if((D-T*S)<=0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  
}

Measured memory_bytes: 3672
s = input()
a = 100
for i in s:
    c = 0
    s_t = s
    s_ = s
    while i * len(s_t) != s_:
        c += 1
        s_ = ""
        for j in range(len(s_t) - 1):
            if s_t[j] == i or s_t[j+1] == i: s_ += i
            else: s_ += s_t[j]
        s_t = s_
    a = min(a, c)
print(a)


Measured memory_bytes: 3060
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int N;
  char S[10010];
  cin >> N >> S;

  int len = strlen(S);

  rep(i, len) {
    int x = S[i] - 'A';
    x = (x + N) % 26;
    putchar('A' + x);
  }
  cout << endl;
}


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> a(M);
  vector<int> b(M);
  vector<int> count(N,0);
  
  for(int i = 0; i<M; i++){
    cin >> a.at(i) >> b.at(i);
    for(int j = 0; j<N; j++){
      if(a.at(i)==j+1){
        count.at(j)++;
      }
      if(b.at(i)==j+1){
        count.at(j)++;
      }
    }
  }
  
  for(int i=0; i<N; i++){
    cout << count.at(i) << endl;
  }    
}

Measured memory_bytes: 256
def main():
    s = input()
    t = input()
    for i in reversed(range(len(s)-len(t)+1)):
        for j, c in enumerate(s[i:i+len(t)]):
            if c!='?' and c!=t[j]:
                break
        else:
            ans = s[:i] + t + s[i+len(t):]
            print(ans.replace('?', 'a'))
            return
    print('UNRESTORABLE')

if __name__=='__main__':
    main()

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

int n;

int main()
{
    cin >> n;

    for (int i = 0; i < n; i++) {
        string s, t, w;

        cin >> s;
        t = "NA";

        int m = s.size();

        if (m > 4 && m % 2 == 0) {
            string u(m - 4, '=');
            u.insert(u.begin() + m / 2 - 2, '#');
            if (s == ">'" + u + '~')
                t = "A";

            for (int j = 0; j < (m / 2 - 2); j++)
                w += "Q=";

            if (s == ">^" + w + "~~")
                t = "B";            
        }

        cout << t << endl;
    }

    return 0;
}



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

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
    ifstream t("/proc/self/status");
    cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;

const int MAXN = 700;

int n, m;

int A[MAXN + 5][MAXN + 5];

inline void input()
{
	n = read<int>(), m = read<int>();
	for(int i = 1; i <= m; ++i)
	{
		int u = read<int>(), v = read<int>();
		A[u][v] = A[v][u] = 1;
	}
}

int cnt[2], fg;
int col[MAXN + 5];

inline void color(int u, int c0)
{
	++cnt[col[u] = c0];
	for(int v = 1; v <= n; ++v) if(A[u][v])
	{
		if(col[v] == col[u]) { fg = 1; return; }
		else if(col[v] == -1) color(v, !c0);
	}
}

inline void solve()
{
	int edge_cnt = 0;
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= n; ++j)
			if(i != j) edge_cnt += (A[i][j] ^= 1) == 1;
	edge_cnt /= 2;

	static vector<int> V;
	memset(col, -1, sizeof col);
	for(int i = 1; i <= n; ++i) if(col[i] == -1)
	{
		cnt[0] = cnt[1] = fg = 0;
		color(i, 0);
		if(fg) { puts("-1"); return; }
		V.push_back(abs(cnt[0] - cnt[1]));
	}

	static bool f[MAXN + 5][MAXN * 2 + 5];

	f[1][ V[0] + n] = 1;
	f[1][-V[0] + n] = 1;
	for(int k = 2; k <= SZ(V); ++k)
		for(int i = -n; i <= n; ++i) if(f[k - 1][i + n])
		{
			if(i - V[k - 1] >= -n) f[k][i - V[k - 1] + n] = 1;
			if(i + V[k - 1] <=  n) f[k][i + V[k - 1] + n] = 1;
		}

	for(int i = 0; i <= n; ++i) if(f[SZ(V)][i + n])
	{
		int p = (n + i) / 2, q = (n - i) / 2;
		printf("%d\n", p * (p - 1) / 2 + q * (q - 1) / 2);
		return;
	}
}

int main()
{
//	freopen("E.in", "r", stdin);
//	freopen("E.out", "w", stdout);

	input();
	solve();

	return 0;
}



Measured memory_bytes: 3200
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
    }
    if n == 0 {
        println!("2");
    } else if n == 1 {
        println!("1");
    } else {
        let mut l0: u64=2;
        let mut l1: u64=1;
        for i in 0..n {
            if i % 2 == 0 {
                l0 += l1.clone();
            } else {
                l1 += l0.clone();
            }
        }
        if n % 2 == 0 {
            println!("{}", l0);
        } else {
            println!("{}", l1);
        }
    }
}

Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		X = new int[N];
		Y = new int[N];
		H = new int[N];
	}

	int[] X;
	int[] Y;
	int[] H;

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		String[] strArr = str.split(" ");
		X[cnt] = Integer.parseInt(strArr[0]);
		Y[cnt] = Integer.parseInt(strArr[1]);
		H[cnt] = Integer.parseInt(strArr[2]);
		cnt++;
	}

	public void solve() {
		int ok = 1;
		for (int cx = 0; ok == 1 && cx <= 100; cx++) {
			for (int cy = 0; ok == 1 && cy <= 100; cy++) {
				ok = 0;
				int h = 0;
				for (int i = 0; i < N; i++) {
					if (H[i] != 0) {
						h = Math.abs(cx - X[i]) + Math.abs(cy - Y[i]) + H[i];
						break;
					}
				}
				for (int i = 0; i < N; i++) {
					if (H[i] == 0) {
						if (h > Math.abs(cx - X[i]) + Math.abs(cy - Y[i]))
							ok = 1;
					} else {
						if (h != Math.abs(cx - X[i]) + Math.abs(cy - Y[i]) + H[i])
							ok = 1;
					}
				}
				if (ok == 0) {
					System.out.println(cx + " " + cy + " " + h);
					return;
				}
			}
		}

	}
}


Measured memory_bytes: 22356
#include <stdio.h>

typedef struct{char kigou,number;}Card;

void Bsort(Card *,int);
void Ssort(Card *,int);
void print(Card *,int);
int hantei(Card *,Card *,int);

int main(){
  Card C1[100],C2[100];
  int N,i;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf(" %c",&C1[i].kigou);
    scanf(" %c",&C1[i].number);
  }
  for(i=0;i<N;i++){
    C2[i]=C1[i];
  }

  Bsort(C1,N);
  Ssort(C2,N);
  print(C1,N);

  printf("Stable\n");

  print(C2,N);
  if(hantei(C1,C2,N)==1){
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }

  return 0;
}

void Bsort(Card *C ,int N){
  int i,j;
  Card a;
  for(i=0;i<N;i++){
    for(j=N-1;j>=i+1;j--){
      if(C[j].number<C[j-1].number){
        a=C[j];
        C[j]=C[j-1];
        C[j-1]=a;
      }
    }
  }
}

void Ssort(Card *C,int N){
  int i,j,minj;
  Card a;
  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(C[j].number<C[minj].number)minj=j;
    }
    a=C[i];
    C[i]=C[minj];
    C[minj]=a;
  }
}

void print(Card *C,int N){
  int i;
  for(i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%c%c",C[i].kigou,C[i].number);
  }
  printf("\n");
}

int hantei(Card *C1,Card *C2,int N){
  int i;
  for(i=0;i<N;i++){
    if(C1[i].kigou != C2[i].kigou)return 0;
  }
  return 1;
}



Measured memory_bytes: 2072
#include <iostream>
#include <bits/stdc++.h>
#define US unsigned short
#define UI unsigned int
#define UC unsigned char
using namespace std;

int main(int argc, char const *argv[])
{
    US n;
    cin >> n;
    if (n > 81)
        cout << "No" << endl;
    else
    {
        for (UC i = 1; i < 10; i++)
            if (n % i == 0 && n / i < 10)
            {
                cout << "Yes" << endl;
                return 0;
            }
        cout << "No" << endl;
    }

    return 0;
}


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

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

    int N, Z, W;
    cin >> N >> Z >> W;

    vector<int> a(N);

    vector<int> x(N, 1000000005);
    vector<int> y(N);

    for(int i = 0; i < N; i++) cin >> a[i];

    for(int i = N - 2; i >= 0; i--) {
        for(int j = i + 1; j < N - 1; j++) {
            x[i] = min(x[i], y[j]);
        }
        x[i] = min(x[i], abs(a[i] - a[N - 1]));

        for(int j = i + 1; j < N - 1; j++) {
            y[i] = max(y[i], x[j]);
        }
        y[i] = max(y[i], abs(a[i] - a[N - 1]));
    }

    x[N - 1] = abs(a[N - 1] - W);

    cout << *max_element(x.begin(), x.end()) << endl;
}

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

int main() {
  int n;
  cin >> n;
  pair<int, int> P[n];
  for (int i = 0; i < n; i ++) {
    cin >> P[i].first >> P[i].second;
  }
  sort(P, P + n);
  reverse(P, P + n);
  cout << P[0].first + P[0].second << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <functional>
#include <queue>
#include <regex>
#include <cassert>
#include <map>
// #include "bits/stdc++.h"

using namespace std;
//debug

#define rep(i, N, M) for (ll i = N; i < M; ++i)
#define rrep(i, N, M) for (ll i = N; i < M; --i)
#define pb push_back


typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef priority_queue<ll> pqll;
typedef priority_queue<pll, vector<pll>> pqpll;
typedef priority_queue<ll, vll, greater<ll>> pqll_greater;
typedef priority_queue<pll, vector<pll>, greater<pll>> pqpll_greater;


#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define vec(a) vector<a>
#define _CRT_SECURE_NO_WARNINGS

template<class T, class S>
T atbit(T n, S i) {
	return (n >> i) % i;
}

template<class T>
T getbit(T i) {
	return 1LL << i;
}

//#define TRANSFORM(v,w,func) decltype(v) w ; transform((v).begin(),(v).end(),back_inserter(w),func);

using namespace std;


int main() {
	ll N, K;
	cin >> N >> K;
	ll n = N / K;
	
	
	if (K == 2) {
		cout << n * n*n + (N - n)*(N - n)*(N - n);
	}
	else if (K % 2 == 1) {
		cout << n * n*n;
	}
	else {
		ll m = N / (K / 2);
		ll n1, n2;
		if (m % 2 == 0) {
			n1 = m / 2;
			n2 = m / 2;
		}
		else {
			n1 = m / 2+1;
			n2 = m / 2;
		}
		cout << n1 * n1*n1 + n2 * n2*n2;
	}
}
//ll N;
//cin >> N;
//vll a(N);
//rep(i,0, N) cin >> a[i];

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    int a,b,c,d,e,k,x;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    scanf("%d",&e);
    scanf("%d",&k);
    x=e-a;
    if(x<=k){
        printf("Yay!\n");
    }
    else{
        printf(":(\n");
    }
    return 0;
}

	

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {

  long N,M;
  cin >> N >> M;

  long s,a,i;

  s = 0;
  for (i=0;i<M;i++) {
    cin >> a;
    s += a;
  }

  if (s > N) {
    cout << "-1";
  }
  else cout << N-s;

  return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
 
        int matrix[][] = new int[n][m];
        for(int i=0; i<=n-1; i++){
            for(int j=0; j<=m-1; j++){
                matrix[i][j] = sc.nextInt();
            }
        }
 
        int vector[] = new int [m];
        for(int k=0; k<=m-1; k++){
            vector[k] = sc.nextInt();
        }
 
        for(int i=0; i<=n-1; i++){
            int ans = 0;
            for(int j=0; j<=m-1; j++){
                ans += matrix[i][j] * vector[j];
            }
            System.out.println(ans);
        }
    }
}



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

typedef long long ll;
typedef pair<int,int> pii;

ll mod = 998244353;

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

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

  sort(a.begin(),a.end());
  
  double ret = a[0];
  for(int i = 1;i < n;i++){
    ret = (ret + a[i]) / 2;
  }

  cout << fixed << setprecision(10);
  cout << ret << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));

using namespace std;
using P = pair<long long, long long>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

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


struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

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

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i-1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

int main() {
	string S;
	cin >> S;
	
	int ans = 1;
	if (S == "SUN")ans = 7;
	else if (S == "MON")ans = 6;
	else if (S == "TUE")ans = 5;
	else if (S == "WED")ans = 4;
	else if (S == "THU")ans = 3;
	else if (S == "FRI")ans = 2;

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int N;
    scanf("%d",&N);

    if(N==1 || N==2|| N==3|| N==4|| N==5|| N==6|| N==7|| N==8|| N==9|| N==10|| N==12|| N==14|| N==15|| N==16|| N==18|| N==20|| N==21|| N==24|| N==25|| N==27|| N==28|| N==30|| N==32|| N==35|| N==36|| N==40|| N==42|| N==45|| N==48|| N==49|| N==54|| N==56|| N==63|| N==64|| N==72|| N==81){
        printf("Yes");
    }

    else{
        printf("No");
    }
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int main(){
    cin.sync_with_stdio(false);
    string a, b, c;
    cin >> a >> b >> c;

    cout << 'A' << b[0] << 'C' << endl;


    return 0;
}

Measured memory_bytes: 256
using System;

namespace ALDS1_5_B
{
    public static class Algorithm
    {
        public static int Count;

        public static void MergeSort<T>(this T[] a) where T : IComparable<T>
        {
            Count = 0;
            MergeSort(a, 0, a.Length);
        }

        private static void Merge<T>(this T[] a, int l, int m, int r) where T : IComparable<T>
        {
            int n1 = m - l, n2 = r - m;
            T[] a1 = new T[n1], a2 = new T[n2];
            for (int i = 0; i < n1; i++) a1[i] = a[l + i];
            for (int i = 0; i < n2; i++) a2[i] = a[m + i];
            int i1 = 0, i2 = 0, k = l;
            while (i1 < n1 && i2 < n2)
            {
                if (a1[i1].CompareTo(a2[i2]) <= 0) a[k++] = a1[i1++];
                else a[k++] = a2[i2++];
                Count++;
            }
            Count += n1 - i1 + n2 - i2;
            while (i1 < n1) a[k++] = a1[i1++];
            while (i2 < n2) a[k++] = a2[i2++];
        }
        private static void MergeSort<T>(this T[] a, int s, int t) where T : IComparable<T>
        {
            if (s + 1 < t)
            {
                var mid = (s + t) >> 1;
                MergeSort(a, s, mid);
                MergeSort(a, mid, t);
                Merge(a, s, mid, t);
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            a.MergeSort();
            Console.WriteLine(string.Join(" ", Array.ConvertAll(a, (s) => s.ToString())));
            Console.WriteLine(Algorithm.Count);
        }
    }
}

Measured memory_bytes: 97152