akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define inf 1000000000
#define eps (1e-11)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;

class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}

  Point operator+(Point p){ return Point(x+p.x,y+p.y);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y);}
  Point operator*(double k){ return Point(x*k,y*k);}
  Point operator/(double k){ return Point(x/k,y/k);}
  bool operator<(Point p)const{ return (x!=p.x ? x<p.x : y<p.y);}
  bool operator==(Point p)const{ return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}

  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

class Segment{
public:
  Point p1,p2;
  Segment(Point p1,Point p2):p1(p1),p2(p2){}
};
typedef Segment Line;

class Circle{
public:
  Point c;
  double r;
  Circle(Point c=Point(),double r=0.0):c(c),r(r){}
};

double norm(Vector a){ return (a.x*a.x+a.y*a.y);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){ return (a.x*b.y-a.y*b.x);}

Point median_Point(Point a,Point b){
  Vector v=a-b;
  return b+(v/2);
}

Point PointRotation(Point base,Point a,double r){
  Point b=a-base;
  a.x=b.x*cos((r/180)*M_PI)-b.y*sin((r/180)*M_PI);
  a.y=b.x*sin((r/180)*M_PI)+b.y*cos((r/180)*M_PI);
  a=a+base;
  return a;
}

vector<Point> vp;
int ans;
int n;

pair<Circle,Circle> makeCircle(Point a,Point b){
  Point m=median_Point(a,b);
  double d=sqrt(1-abs(m-b)*abs(m-b));
  Vector v=(PointRotation(m,a,90)-m)*(d/abs(m-a));
  Point A=m+v,B=m-v;
  return mp(Circle(A,1),Circle(B,1));
}

int PointsInCircle(Circle C)
{
  int num=0;
  for(int i=0;i<n;i++){
    if(abs(vp[i]-C.c)<=1+eps)num++;
  }
  return num;
}

int main()
{
  while(1){
    cin>>n;
    if(n==0)break;
    vp.clear();
    vp.resize(n);
    for(int i=0;i<n;i++)cin>>vp[i].x>>vp[i].y;
    ans=1;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(i==j)continue;
	if(2<abs(vp[i]-vp[j]))continue;
	pair<Circle,Circle> pc=makeCircle(vp[i],vp[j]);
	ans=max(ans,PointsInCircle(pc.f));
	ans=max(ans,PointsInCircle(pc.s));
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1248
using System;
using System.Linq;

namespace _0074
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (x.Min() == -1 && x.Max() == -1) break;
                TimeSpan video = new TimeSpan(2,0,0);
                TimeSpan time = new TimeSpan(x[0],x[1],x[2]);
                Console.WriteLine(video - time);
                TimeSpan three = video - time;
                three = new TimeSpan(three.Hours * 3,three.Minutes * 3,three.Seconds * 3);
                Console.WriteLine(three);
            }
        }
    }
}


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

using namespace std;

int main()
{
    char op;
    int a, b;
    while(true)
    {
        scanf("%d %c %d", &a, &op, &b);
        if(op=='?') break;
        switch(op)
        {
        case '+':
            cout << a+b << '\n';
            break;
        case '-':
            cout << a-b << '\n';
            break;
        case '*':
            cout << a*b << '\n';
            break;
        case '/':
            cout << a/b << '\n';
            break;
        }
    }
}


Measured memory_bytes: 3168
#include <stdio.h>
#include <math.h>

int main(void) {
	double x1,x2,y1,y2;
	double x,y;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	x=pow(x1-x2,2.0);
	y=pow(y1-y2,2.0);
	printf("%lf\n",sqrt(x+y));
	return 0;
}



Measured memory_bytes: 2104
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int X = sc.nextInt();
        int t = sc.nextInt();
        _out.println(Math.max(0, X - t));
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#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 FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    FOR(x,l,r) if (x % d == 0) ans++;
    cout << ans << endl;

    return 0;
}


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

using namespace std;

const int maxn = 1e5 + 5;

int par[maxn];
int r[maxn];

void init(int n)
{
    for (int i = 0; i < n;i++)
    {
        par[i] = i;
        r[i] = 0;
    }
}
int find(int x)
{
    if(par[x] == x)
    {
        return x;
    }
    else
    {
        return par[x] = find(par[x]);
    }
}
void unite(int x, int y)
{
    x = find(x);
    y = find(y);
    if (r[x] < r[y])
    {
        par[x] = y;
    }
    else
    {
        par[y] = x;
        if(r[x] == r[y])
        {
            r[x]++;
        }
    }
}
bool same(int x, int y)
{
    return find(x) == find(y);
}
int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> p;
    init(N);
    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        a--;
        p.push_back(a);
    }
    for (int i = 0; i < M;i++)
    {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        unite(x, y);
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if(p[i] == i || same(i, p[i]) == true)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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



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

  ll n = (b - 1 + ( a - 2)) / (a - 1);
  cout << n << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

ll n, m, d;

int main()
{
  scanf( "%lld%lld%lld", &n, &m, &d );

  printf( "%.10f\n", (m-1)*(d ? 2.0*(n-d)/n/n : 1.0/n) );

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=300005,p=1000000007;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,ans,a[N],s[N][2];
bool check(int mid){
	int las=0;
	for (int i=2;i<=n;i+=2)
	if (s[i-1][1]-s[i-1][0]-las>=mid) las=min(las,s[i][1]-s[i][0]);
	return (s[n][1]-s[n][0]-las>=mid);
}
int main(){
	n=read();
	for (int i=1;i<=n;i++){
		a[i]=read();
		s[i][0]=s[i-1][0];
		s[i][1]=s[i-1][1];
		s[i][i&1]+=a[i];
	}
	if (n&1){
		int l=0,r=s[n][0]+s[n][1],mid;
		while (l<r){
			mid=(l+r+1)>>1;
			if (check(mid)) l=mid;
			else r=mid-1;
		}
		printf("%d %d\n",s[n][0]+l,s[n][1]-l);
	}
	else printf("%d %d\n",max(s[n][0],s[n][1]),min(s[n][0],s[n][1]));
	return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;

int main() {
	int a;
	cin >> a;
	cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3588
#include <stdio.h>

int solve(int, int);

int n, A[20];

int main(){
  int q, m, a;
  
  scanf("%d",&n);
  for(a = 0; a < n; a++){
    scanf("%d",&A[a]);
  }

  scanf("%d",&q);
  for(a = 0; a < q; a++){
    scanf("%d",&m);
    if(solve(0,m) == 1) printf("yes\n");
    else printf("no\n");
  }

  return 0;
  
}

int solve(int a, int m){
  int res;
  if(m == 0) return 1;
  if(a >= n) return 0;
  res = solve(a+1,m) || solve(a+1,m-A[a]);
  return res;
}



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

public class Main {

   private static final String INPUT_FILE_PATH = "";

   static final int MAX = (int) 1e5;

   static void solve(InputReader in, PrintWriter out) {
      int n = in.nextInt();
      long[] counts = new long[MAX + 1];
      long sum = 0;
      for (int i = 0; i < n; i++) {
         int a = in.nextInt();
         counts[a]++;
         sum += a;
      }
      int q = in.nextInt();
      for (int i = 0; i < q; i++) {
         int b = in.nextInt();
         int c = in.nextInt();

         sum -= counts[b] * b;
         sum += counts[b] * c;
         counts[c] += counts[b];
         counts[b] = 0;

         out.println(sum);
      }
   }

   private static class InputReader {
      private BufferedReader br;
      private StringTokenizer st;

      public InputReader(InputStream inputStream) {
         this.br = new BufferedReader(new InputStreamReader(inputStream), 32768);
         this.st = null;
      }

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

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

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

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

   public static void main(String[] args) throws Exception {
      InputStream inputStream = INPUT_FILE_PATH.isEmpty()
         ? System.in
         : new FileInputStream(new File(INPUT_FILE_PATH));
      OutputStream outputStream = System.out;

      InputReader inputReader = new InputReader(inputStream);
      PrintWriter printWriter = new PrintWriter(outputStream);

      solve(inputReader, printWriter);

      printWriter.close();
   }

}


Measured memory_bytes: 56604
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;
int main()
{
    int n, m, x, y;
    cin >> n >> m;
    vector<int> h(n);
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    vector<bool> v(n, true);
    for (int i = 0; i < m; i++)
    {
        cin >> x >> y;
        x--;
        y--;
        if (x == y)
            continue;
        if (h[x] <= h[y])
        {
            v[x] = false;
        }
        if (h[y] <= h[x])
            v[y] = false;
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (v[i])
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
        int x, y, z;
        cin >> x >> y >> z;

        cout << z << " " << x << " " << y << endl;

        return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int a = sc.nextInt();
		int b = sc.nextInt();

		
		if (b == 100) {
			for (int i = 10; i < 400; i++) {
				if (Math.sqrt(a * 1000 + b) == i) {
					System.out.println("Yes");
					return;
				}
			}
		}
			else if (b >= 10) {
			for (int i = 10; i < 400; i++) {
				if (Math.sqrt(a * 100 + b) == i) {
					System.out.println("Yes");
					return;
				}
			}
		} else {
			for (int i = 3; i < 40; i++) {
				if (Math.sqrt(a * 10 + b) == i) {
					System.out.println("Yes");
					return;
				}
			}
		}

		System.out.println("No");
	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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


Measured memory_bytes: 20692
import numpy as np

n,m,x = map(int, input().split())
c = []
a = []
s =  np.zeros(m)
for i in range(n):
    temp = list(map(int, input().split()))
    c.append(temp[0])
    a.append(temp[1:])
    s+=np.array(temp[1:])

a = np.array(a)

if (min(s) < x):
    print(-1)
else:
    ans = np.inf
    for i in range(0, 2 ** n):
        ct = bin(i)[2:].zfill(n)
        price = 0
        score = np.zeros(m)
        for j in range(n):
            score += int(ct[j]) * a[j]
            price += int(ct[j]) * c[j]
        if (min(score) >= x):
            ans = min(price,ans)
    print(ans)


Measured memory_bytes: 27244
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let mut A: i64 = sc.get();
    let B: i64 = sc.get();
    let mut C: i64 = sc.get();
    let D: i64 = sc.get();
    loop {
        C -= B;
        if C <= 0 {
            println!("Yes");
            return;
        }
        A -= D;
        if A <= 0 {
            println!("No");
            return;
        }
    }
}


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

string S;
int main(){
	cin >> S;
	int n = S.size();
	bool judge = true;
	if(S[n-1]=='1') judge = false;
	if(S[0]=='0') judge = false;
	for(int i=0;i<n/2;i++){
		if(S[i]=='1' && S[n-2-i]!='1') judge = false;
		if(S[n-2-i]=='1' && S[i]!='1') judge = false;
	}
	if(!judge){
		cout << -1 << endl;
		return 0;
	}
	vector<pair<int,int>> v;
	int t = 1;
	for(int i=2;i<=n;i++){
		if(S[i-1]=='1'){
			for(int j=t;j<i;j++){
				v.push_back({j,i});
			}
			t = i;
		}
		if(i==n){
			for(int j=t;j<i;j++){
				v.push_back({j,i});
			}
		}
	}
	for(int i=0;i<n-1;i++){
		cout << v[i].first << " " << v[i].second << endl;
	}
}

Measured memory_bytes: 2548
program am
integer::H,W
integer,allocatable,dimension(:,:)::maze,DP
character(100)::S
integer::dx(2)=[-1,0],dy(2)=[0,-1]
integer::i,j,k
read*,H,W
allocate(maze(H,W))
maze=0
do i=1,H
    read*,S
    do j=1,W
        if(S(j:j)=="#")maze(i,j)=1
    end do
end do
allocate(DP(H,W))
DP=huge(i)/2
DP(1,1)=maze(1,1)
do i=1,H
    do j=1,W
        do k=1,2
            DP(i,j)=min(DP(i,j),&
            DP(max(1,i+dx(k)),max(1,j+dy(k)))+merge(1,0,maze(max(1,i+dx(k)),max(1,j+dy(k)))==0.and.maze(i,j)==1))
        end do
    end do
end do
print"(I0)",DP(H,W)
end program am

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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 1e6 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int n;
int f[N];
int a[N], d[N];
void upd (int pos, int x) {
	for (int i = pos; i <= n; i = (i | (i + 1)))
		f[i] += x;
}

int get (int r) {
	int res = 0;
	while (r >= 0) {
		res += f[r];
		r = (r & (r + 1)) - 1;
	}
	return res;
}
int main () {
	int x, y;
	cin >> x >> y;
	if (x % y == 0) {
		cout << -1;
	} else cout << x;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100006
using namespace std;
struct arr{int x,i;}a[4][N];
int x,y,R,C,n,top,t[4],g[N],s[N];bool f[N];
inline int read()
{
	int x=0,c=getchar(),f=1LL;while(c<'0'||c>'9')f=(c=='-'?-f:f),c=getchar();
	while(c>='0'&&c<='9')x=(x<<1LL)+(x<<3)+c-48,c=getchar();return f>0?x:-x;
}
void print(int x)
{
	if(x>9)print(x/10);putchar(x%10+48);
}
inline bool cmp1(arr x,arr y)
{
	return x.x<y.x;
}
inline bool cmp2(arr x,arr y)
{
	return x.x>y.x;
}
int main()
{
	R=read();C=read();n=read();
	for(int i=1;i<=n;i++){
		bool f1=0,f2=0;
		x=read();y=read();
		if(x==0)a[0][++t[0]]=arr{y,i},f1=1;
		else if(x==R)a[2][++t[2]]=arr{y,i},f1=1;
		else if(y==0)a[1][++t[1]]=arr{x,i},f1=1;
		else if(y==C)a[3][++t[3]]=arr{x,i},f1=1;
		x=read();y=read();
		if(x==0)a[0][++t[0]]=arr{y,i},f2=1;
		else if(x==R)a[2][++t[2]]=arr{y,i},f2=1;
		else if(y==0)a[1][++t[1]]=arr{x,i},f2=1;
		else if(y==C)a[3][++t[3]]=arr{x,i},f2=1;
		if(f1&&f2)f[i]=1;
	}
	sort(a[0]+1,a[0]+t[0]+1,cmp2);sort(a[3]+1,a[3]+t[3]+1,cmp2);
	sort(a[1]+1,a[1]+t[1]+1,cmp1);sort(a[2]+1,a[2]+t[2]+1,cmp1);
	for(int i=0;i<4;i++)
		for(int j=1;j<=t[i];j++){
			int id=a[i][j].i;if(!f[id])continue;
			if(!g[id])s[++top]=id,g[id]=1;
			else if(s[top]==id)top--;else return puts("NO"),0;
		}
	puts("YES");
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, k, n) for (int i = k; i < n; ++i)
#define fore(i,a) for (auto &i : a)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

signed main (int argc, char *argv[]) {
    int n;
    cin >> n;
    vector<int> A(n);
    rep(i, n) cin >> A[i];

    priority_queue<int> divisers;
    for (int i = 1; i * i <= A[0]; ++i) {
        if (A[0] % i == 0) divisers.push(i), divisers.push(A[0] / i);
    }
    for (int i = 1; i * i <= A[1]; ++i) {
        if (A[1] % i == 0) divisers.push(i), divisers.push(A[1] / i);
    }
    
    int divi;
    while(! divisers.empty()){
        divi = divisers.top();
        int cnt = 0;
        rep(i, n) {
            if (A[i] % divi) ++cnt;
        }
        if (cnt == 0 || cnt == 1) break;
        divisers.pop(); 
    }

    cout << divi << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PI;
typedef pair<LL, LL> PLL;
const LL MOD = 1000000007LL;
const int inf = 1e9;
const LL INF = 1e18;
int a[100], b[100];
int c[100], d[100];
vector<int> G[200];
int matchTo[200];
bool vis[200];
bool dfs(int v) {
	if (v < 0) return 1;
	for (int to : G[v]) {
		if (vis[to]) continue;
		vis[to] = 1;
		if (dfs(matchTo[to])) {
			matchTo[v] = to;
			matchTo[to] = v;
			return 1;
		}
	}
	return 0;
}
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> a[i] >> b[i];
	for (int i = 0; i < N; i++) cin >> c[i] >> d[i];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (a[i] < c[j] && b[i] < d[j]) {
				G[i].push_back(j + N);
				G[j + N].push_back(i);
			}
		}
	}
	memset(matchTo, -1, sizeof(matchTo));
	int match = 0;
	for (int i = 0; i < N; i++) {
		memset(vis, 0, sizeof(vis));
		if (dfs(i)) match++;
	}
	cout << match << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int n[] = {13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
int a, b;

int main(){
    scanf("%d %d", &a, &b);

    a--; b--;

    if(n[a] > n[b]){
        printf("Alice\n");
    }else if(n[b] > n[a]){
        printf("Bob\n");
    }else{
        printf("Draw\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
typedef unsigned long long ull;
int main()
{
	int n; std::cin >> n;
	ull sum = 0;
	for (int i=0; i<n; i++) {
		ull v; std::cin >> v;
		sum += v;
	}
	std::cout << sum / (ull)n << std::endl;
	
	return 0;
}




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

int main(){
    string a,b,c;
    cin>>a>>b>>c;
    int ac,bc,cc;
    char ne,win;
    ac=bc=cc=0; ne ='a';
    while(1){
        if(ne=='a') {
            if(ac>=a.size()){ win='A'; break;}
            else ne =a[ac++];
        }
        else if(ne=='b'){
            if(bc>=b.size()){ win='B'; break;}
            else ne =b[bc++];
        }        
        else {
            if(cc>=c.size()){ win='C'; break;}
            else ne = c[cc++];
        }
    }
    cout<<win<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
//const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
typedef pair<ll,ll> PLL;

const int N=1010000;
const int M=201000;
int n,m,mod,q,u,v,w,dep[M],s,t,vis[N];
vector<PII> e[M];
int f[N];
ll hv1[M],hv2[M],pw[M],ipw[M],pww[4][M];
PLL cc[M];

int find(int x) {
	return f[x]==x?x:f[x]=find(f[x]);
}

void dfs(int u,ll hs1,ll hs2,int d) {
	vis[u]=1;
	dep[u]=d;
	hv1[u]=hs1;
	hv2[u]=hs2;
	for (auto p:e[u]) {
		int v=p.fi;
		int w=p.se;
		if (vis[v]) continue;
		dfs(v,(hs1*2+w)%mod,(hs2+w*pw[d])%mod,d+1);
	}
}

void divi(PLL &a,PLL b) {
	int t=a.fi/b.fi;
	if (t==0) return;
	b.se=b.se*pww[b.fi][t-1]%mod;
	b.fi=t*b.fi;
	a.se=(a.se-b.se+mod)%mod;
	a.se=(a.se*ipw[b.fi])%mod;
	a.fi-=b.fi;
}
int main() {
	scanf("%d%d%d%d",&n,&m,&q,&mod);
	pw[0]=1;
	rep(i,1,2*m+1) pw[i]=pw[i-1]*2%mod;
	ipw[0]=1;
	rep(i,1,2*m+1) ipw[i]=ipw[i-1]*(mod+1)/2%mod;
	pww[1][0]=1;
	rep(i,1,2*m+1) pww[1][i]=(pww[1][i-1]*2+1)%mod;
	pww[2][0]=1;
	rep(i,1,2*m+1) pww[2][i]=(pww[2][i-1]*4+1)%mod;
	rep(i,0,m) {
		scanf("%d%d%d",&u,&v,&w);
		e[u].pb(mp(v,w));
		e[v].pb(mp(u,w));
	}
	dfs(1,0,0,0);
	rep(u,1,n+1) {
		for (auto p:e[u]) {
			int v=p.fi,w=p.se;
			cc[t++]=mp(dep[u]+dep[v]+1,(hv1[u]*pw[dep[v]+1]+w*pw[dep[v]]+hv2[v])%mod);
//			printf("%d %d %lld %lld\n",u,v,cc[t-1].fi,cc[t-1].se);
		}
	}
	rep(rd,0,3) {
		int posp=-1;
		rep(i,0,t) if (cc[i].fi>0&&(posp==-1||cc[i].fi<cc[posp].fi)) {
			posp=i;
		}
		if (posp==-1) continue;
		rep(i,0,t) if (i!=posp) divi(cc[i],cc[posp]);
	}
	int w=mod;
	rep(i,0,t) if (cc[i].fi==0) {
		w=gcd(w,cc[i].se);
	}
	rep(i,0,mod) f[i]=i;
	rep(i,0,mod) f[find(i)]=find((i+w)%mod);
//	puts("faq");
//	rep(i,0,t) printf("%lld %lld\n",cc[i].fi,cc[i].se);
	rep(i,0,t) if (cc[i].fi!=0) {
		rep(j,0,mod) f[find(j)]=find(((j<<cc[i].fi)+cc[i].se)%mod);
	}
	rep(i,0,q) {
		scanf("%d%d%d",&s,&t,&w);
		ll p=hv2[t];
		ll q=(w-hv1[s])*ipw[dep[s]]%mod;
		if (q<0) q+=mod;
		puts(find(p)==find(q)?"YES":"NO");
	}
}


Measured memory_bytes: 27136
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdlib>
#include<cstdio>
#include<utility>
#include<list>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;

	int small=0,large=0;
	small = min(a, b);
	large = max(a, b);
	if(small<=0 && large>=0){
		cout<< "Zero" <<endl;
		return 0;
	}
	if(small<0 && large<0){
		if((small+large)%2 == 0)cout<< "Negative" <<endl;
		else cout<< "Positive" <<endl;
	}
	if(small>0 && large>0)cout<< "Positive" <<endl;

	return 0;
}


Measured memory_bytes: 256
import sys
# A,B,C = [int(n) for n in input().split()]
# N = int(input())
S = str(input())
# T = str(input())

t = {}
for s in S:
    if not(s in t):
        t[s] = 1
    else:
        t[s]+=1

ans = [n % 2 for n in t.values()]
print("Yes" if 1 not in ans else "No")


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <functional>
#include <algorithm>
#include <complex>
#include <map>
#include <cmath>
#include <string>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <istream>
//-----------------------------------------------------define--------------------------------------------------------------------//
#define PB push_buck
#define MP make_pair
#define MAX 100000
//-------------------------------------------------------typedef----------------------------------------------------------------//
typedef long long ll;

using namespace std;

int h, w;
char a[100][100];
//------------------------------------------------------------------------------------------------------------------------------//
int main() {
	cin >> h >> w;
	for (int i = 0; i < h ; i++) {
		for (int j = 0; j < w ; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < 2 * h; i++) {
		for (int j = 0; j < w; j++) {
			if (j % w == w-1 ) {
				cout << a[i/2][j] << endl;
			}
			else if (j%w !=w-1  ) {
				cout << a[i/2][j];
			}
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  int x,y,z;
  cin>>x>>y>>z;
  int i=0;
  while(1){
    
    if(y*i+z*(i+1)<=x)i++;
    else break;
  }
  cout<<i-1<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
using namespace std;

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


ll popcount(ll n) {
	ll p = 0;
	for (int i = 0; i < 64; i++) {
		if (((n >> i) & 1) == 1) {
			p++;
		}
	}
	return p;
}

ll func(ll n) {
	int cnt = 0;
	int num = n;
	while (num > 0)
	{
		num = num % popcount(num);
		cnt++;
	}
	
	return cnt;

}

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

	string s;
	cin >> s;
	
	int pop0 = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == '1') {
			pop0++;
		}
	}


	vector<vector<ll>> pow(2,vector<ll>(n + 1));
	pow[0][n] = pow[1][n] = 1;
	
	
	for (int i = n; i > 0; i--) {
		pow[0][i - 1] = (2 * pow[0][i]) % (pop0 + 1);
		if (pop0 > 1) {
			pow[1][i - 1] = (2 * pow[1][i]) % (pop0 - 1);
		}
	}

	
	vector<ll> sum(2);
	for (int i = 0; i < n; i++) {

		if (s[i] == '1') {
			sum[0] = (sum[0] + pow[0][i + 1]) % (pop0 + 1);
			if (pop0 > 1) {
				sum[1] = (sum[1] + pow[1][i + 1]) % (pop0 - 1);
			}
		}
	}

	


	for (int i = 0; i < n; i++) {
		int j = s[i] - '0';

		ll su = sum[j];
		ll pop1 = pop0;
		if (j == 0) {
			su += pow[j][i + 1];
			pop1++;
		}
		else {
			su -= pow[j][i + 1];
			pop1--;
		}
		if (pop1 == 0) {
			cout << 0 << endl;
			continue;
		}

		ll p = (su + pop1) % pop1;

		cout << (func(p) + 1) << endl;
	}
}

Measured memory_bytes: 7660
import java.util.Scanner;

class Main{

    static int N;
    static long A,B;
    static long[] S;

    static int findIndex(long s){
        int left=0,right=N+1;
        while(right-left>1){
            int center=(left+right)/2;
            if(s-S[center]>=B)left=center;
            else right=center;
        }
        return left;
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        N = scan.nextInt();
        A = scan.nextLong();
        B = scan.nextLong();
        S = new long[N+1];
        long[] sum=new long[N+1];
        sum[0]=1;
        S[0] = -B;
        for(int i=1;i<=N;++i)S[i]=scan.nextLong();
        int lindex=-1;
        long mod = (long)1e9+7;
        if(A>B){
            long a = A;
            A=B;
            B=a;
        }
        for(int i=2;i<=N;++i)if(S[i]-S[i-2]<A){
            System.out.println(0);
            return;
        }

        for(int i=1;i<=N;++i){
            if(S[i]-S[i-1]<A){
                //怪しい findindexがlindexに対して小さかったら？
                int index = findIndex(S[i]);
                long dp = (index >= lindex ? (sum[findIndex(S[i])] - (lindex>=0 ? sum[lindex]:0)+mod)%mod : 0);
                sum[i]=(sum[i-1]+dp)%mod;
                lindex=i-2;
            }else if(S[i]-S[i-1]<B){
                int index = findIndex(S[i]);
                long dp = (index >= lindex ? (sum[findIndex(S[i])] - (lindex>=0 ? sum[lindex]:0)+mod)%mod : 0);
                sum[i]=(sum[i-1]+dp)%mod;
            }else{
                long dp = (sum[i-1] - (lindex>=0 ? sum[lindex]:0)+mod)%mod;
                sum[i]=(sum[i-1]+dp)%mod;
            }
        }
        System.out.println(((sum[N]-(lindex>=0 ? sum[lindex]:0)+mod)%mod));
    }
}

Measured memory_bytes: 63060
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0151&lang=jp

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break
        data = [list(map(int, list(input().strip('\n')))) for _ in range(n)]

        if n == 1:              #  ????????????1?????????????????????
            print(data[0][0])
            continue

        # ???(North)??????(West)?????????(NorthWest)?????????(NorthEast) ????????????????????????1???????????£?¶???????????????????????????????
        N = [[0] * n for _ in range(n)]
        W = [[0] * n for _ in range(n)]
        NW = [[0] * n for _ in range(n)]
        NE = [[0] * n for _ in range(n)]
        N_max = 0               #  ???????????????????????§?????£?¶???????1????????§?????°
        W_max = 0
        NW_max = 0
        NE_max = 0

        for i in range(n):
            for j in range(n):
                c = data[i][j]  #  ????????????data[i][j]?????????????????§???????????§?????????????¨???¶

                # North??????
                ni = i - 1
                if ni < 0:
                    N[i][j] = c
                    if N[i][j] > N_max:
                        N_max = N[i][j]
                else:
                    if c == 1:
                        N[i][j] = N[ni][j] + 1
                        if N[i][j] > N_max:
                            N_max = N[i][j]
                    else:
                        N[i][j] = 0

                # West??????
                nj = j - 1
                if nj < 0:
                    W[i][j] = c
                    if W[i][j] > W_max:
                        W_max = W[i][j]
                else:
                    if c == 1:
                        W[i][j] = W[i][nj] + 1
                        if W[i][j] > W_max:
                            W_max = W[i][j]
                    else:
                        W[i][j] = 0

                # North West??????
                ni = i - 1
                nj = j - 1
                if ni < 0 or nj < 0:
                    NW[i][j] = c
                    if NW[i][j] > NW_max:
                        NW_max = NW[i][j]
                else:
                    if c == 1:
                        NW[i][j] = NW[ni][nj] + 1
                        if NW[i][j] > NW_max:
                            NW_max = NW[i][j]
                    else:
                        NW[i][j] = 0

                # North East??????
                ni = i - 1
                nj = j + 1
                if ni < 0 or nj >= n:
                    NE[i][j] = c
                    if NE[i][j] > NE_max:
                        NE_max = NE[i][j]
                else:
                    if c == 1:
                        NE[i][j] = NE[ni][nj] + 1
                        if NE[i][j] > NE_max:
                            NE_max = NE[i][j]
                    else:
                        NE[i][j] = 0

        print(max(N_max, W_max, NW_max, NE_max))



if __name__ == '__main__':
    main(sys.argv[1:])
    

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

int main()
{
  long long n, a, b;
  cin >> n >> a >> b;
  if(a == b)
    cout << 0 << endl;
  else
  {
    long long temp = abs(a - b);
    if(temp & 1)
    {
      long long x = min(a - 1LL, b - 1LL);
      long long y = min(n - a, n - b);
      cout << min(x, y) + 1 + (abs(b - a) >> 1) << endl;
    }
    else
    {
      cout << (temp >> 1) << endl;
    }
  }
  return 0;
}

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

int main()
{
  string a, b;
  
  cin >> a >> b;
  if (a.size() < b.size())
    cout << "LESS" << endl;
  else if (b.size() < a.size())
    cout << "GREATER" << endl;
  else
  {
    if (a.compare(b) < 0)
      cout << "LESS" << endl;
    else if (a.compare(b) > 0)
      cout << "GREATER" << endl;
    else
      cout << "EQUAL" << endl;
  }
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define foru(i, a, b) for(int i = a; i <= b; i++)
#define ford(i, a, b) for(int i = a; i >= b; i--)
#define endl "\n"
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define com(a, b) a ## b
#define scv(a, b, c) #a#b#c
#define db(x) cerr << "[" << #x << ": " << (x) << "] " << endl;
#define run cerr << 1 << endl; 
template<class T> void printvec(vector<T>& x, int a, int b) {foru (i, a, b) cout << x[i] << " "; cout << endl;}

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vii;
typedef vector<pll> v2l;
typedef pair<char, int> pci;
typedef vector<pci> vci;

const ld PI = acos((ld) -1);
const ld EPS = 1e-6;
const int N = 1e6 + 1;
const int NN = 1e3 + 1;
const ll MOD = 1e9 + 7;
const ll oo = 1e18 + 7;
const int BASE = 10000;

void solve() {
    int n, m;
    cin >> n >> m;
    int s = 0;
    for (int i = 1; i <= m; i++) {
        int x;
        cin >> x;
        s += x;
    }
    cout << max(-1, n - s);
}

int main() {
    #ifdef DEBUG
        com(fre, open) (scv(solve, ., inp), "r", stdin);
        com(fre, open) (scv(solve, ., out), "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    solve();
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
} 

Measured memory_bytes: 3804
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int n = in.nextInt();
		int[] t = new int[n];
		int sum = 0;
		for (int i=0; i<n; i++) {
			t[i]= in.nextInt();
			sum += t[i];
		}
		
		int m = in.nextInt();
		int[] p = new int[m];
		int[] x = new int[m];
		for (int i=0; i<m; i++) {
			p[i] = in.nextInt() - 1;
			x[i] = in.nextInt();
		}
		
		for (int i=0; i<m; i++) {
			out.println((sum - t[p[i]] + x[i]));
		}
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

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

#define ll long long
#define ld long double
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define ppb pop_back
#define vll vector<ll>
#define vi vector<int>
#define endl "\n"

const ll INF = 1000000007;

/*
const int max_size = 100001;
int parent[max_size];
int Size[max_size];

int root(int x){
	while(x!=parent[x]){
		parent[x] = parent[parent[x]];
		x = parent[x];
	}
	return x;
}

void sunion(int x,int y){
	int rx = root(x);
	int ry = root(y);
	if(rx != ry){
		if(Size[rx] > Size[ry]){
			parent[ry] = parent[rx];
			Size[rx] += Size[ry];
		}
		else{
			parent[rx] = parent[ry];
			Size[ry] += Size[rx];
		}
	}
}
*/

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tc=1;
	//cin >> tc;
	while(tc--){
		string s,t;
		cin >> s >> t;
		int ans=(int)t.size();
		for (int i=0;i<(int)s.size();i++) {
			if ((int)s.size()-i < (int)t.size()) continue;
			int k=0;
			for (int j=0;j<(int)t.size();j++) {
				if (s[i+j] != t[j]) k++;
			}
			ans = min(ans,k);
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

ll n,x,m;
map<int,int> visited;
ll S[100010];

void solve(){
    cin >> n >> x >> m;
    ll a=x;visited[x]=1;S[1]=a;
    int sta=-1,T;
    rep(i,n-1){
        a*=a;a%=m;
        //cout << a << endl;
        if(visited[a]){
            sta=i+2;
            T=i+2-visited[a];
            break;
        }
        visited[a]=i+2;
        S[i+2]=S[i+1]+a;
    }
    //cout << sta << " " << T << endl;
    if(sta==-1) cout << S[n] << endl;
    else{
        ll V=S[sta-1]-S[sta-1-T];//cout << V << endl;
        ll p=(n-sta+1)%T,q=(n-sta+1)/T;
        ll ans=0;
        ans+=S[sta-1];
        ans+=q*V;
        ans+=S[sta-T-1+p]-S[sta-T-1];
        cout << ans << endl;
    }
}

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

Measured memory_bytes: 6372
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

////////// 繰り返し二乗法 //////////

ll power(ll a,ll b){
  ll res=1;
  while(b>0){
    if(b&1) res=res*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return res;
}

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

int main(){
  ll N,K;
  cin>>N>>K;
  
  vector<ll> DIV;
  for(ll i=1; i<=sqrt(N); ++i){
    if(N%i==0){
      if(i*i==N) DIV.PB(i);
      else{
        DIV.PB(i);
        DIV.PB(N/i);
      }
    }
  }
  SORT(DIV);
  
  vector<ll> NUM(DIV.size(),0);
  
  for(ll i=0; i<(ll)DIV.size(); ++i){
    NUM[i]=power(K,(DIV[i]+1)/2);
    for(ll j=0; j<i; ++j){
      if(DIV[i]%DIV[j]==0) NUM[i]-=NUM[j];
    }
    NUM[i]=(NUM[i]%MOD+MOD)%MOD;
  }
  
  ll ans=0;
  for(ll i=0; i<(ll)DIV.size(); ++i){
    if(DIV[i]%2==1) ans+=NUM[i]*DIV[i]%MOD;
    else ans+=NUM[i]*DIV[i]/2%MOD;
    ans%=MOD;
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3732
#include<stdio.h>
       int main()
       {
        int a,b,c,x,y,z;
        scanf("%d%d%d",&a,&b,&c);
        x=a+b;
        y=c+b;
        z=a+c;

         if (x<=y&&x<=z)
            printf("%d",x);

         else if(y<=x&&y<=z)
                     printf("%d",y);
         else
              printf("%d",z);









       }


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
using ll = long long;
using namespace std;

int main(){
    ll n,t,a,b,ans=10000;
    cin >> n >> t;
    for(ll i=0;i<n;i++){
        cin >> a >> b;
        if(t>=b) ans = min(ans,a);
    }
    if(ans==10000)  cout << "TLE\n";
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256