akhauriyash/Code-Regression huggingface dataset:
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


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

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, std::vector<long long> a){

    i64 ans = -INF;
    vector<vector<i64>> dp(n, vector<i64>(10, -INF));
    dp[0][0] = a[0];
    dp[1][0] = a[1];
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < 10; ++j){
            int perf = (i / 2) + 1;
            int cnt = perf - j;
            if(cnt == 0)
                chmax(dp[i][j], 0LL);
            if(cnt == 1)
                chmax(dp[i][j], a[i]);
            if(cnt == n / 2)
                chmax(ans, dp[i][j]);
            for(int nex = 2; nex < 10 && i + nex < n; ++nex){
                int nex_idx = i + nex;
                int nex_perf = (i + nex) / 2 + 1;
                int diff = nex_perf - (cnt + 1);
                if(diff >= 10)
                    continue;
                chmax(dp[nex_idx][diff], dp[i][j] + a[nex_idx]);
            }
        }
    }
    cout << ans << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 28344
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
string st1,st2;
int n,m,f[3004][3004];
string res;
void truyvet()
{
    if (m*n==0) return;
    if (st1[n]==st2[m])
    {
        res=st1[n]+res;
        n--;
        m--;
    } else if (f[n-1][m]==f[n][m]) n--; else m--;
    truyvet();
}
int main()
{
    cin>>st1>>st2;
    n=st1.size();
    m=st2.size();
    st1=" "+st1;
    st2=" "+st2;
    for (int i=1;i<=n;++i)
        for (int j=1;j<=m;++j)
        {
            if (st1[i]==st2[j])
            {
                f[i][j]=f[i-1][j-1]+1;
            } else f[i][j]=max(f[i-1][j],f[i][j-1]);
        }
    res="";
    truyvet();
    cout<<res;
    return 0;
}

Measured memory_bytes: 39140
#ifdef __LOCAL
  #define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define intmax numeric_limits<int>::max()
#define llmax numeric_limits<ll>::max()
#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 rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;
const ll lnf=1ll<<60;

int main(){
  itn n; cin >> n;
  cout << 1-n << endl;
  
}

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



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

  int a,b,c; cin >> a >> b >> c;
  if(a != b || b != c || c != a){
    cout << "No" << endl;
  }
  else cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 764
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

a, b, c, d = LI()
if abs(a - c) <= d or (abs(a - b) <= d and abs(b - c) <= d):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3896
use std::io::*;
use std::collections::HashMap;
use std::cmp;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn main() {
    let n = read::<usize>();
    let mut hm: HashMap<String,i32> = HashMap::new();
    for i in 0..n {
        let s = read::<String>();
        if let Some(&v) = hm.get(&s) {
            hm.insert(s,v+1);
        } else {
            hm.insert(s,1);
        }
    }
    let m = read::<usize>();
    for i in 0..m {
        let t = read::<String>();
        if let Some(&v) = hm.get(&t) {
            hm.insert(t,v-1);
        } else {
            hm.insert(t,-1);
        }
    }
    let mut ans = 0;
    for &v in hm.values() {
        ans = cmp::max(ans,v);
    }
    println!("{}",ans);
}


Measured memory_bytes: 4352
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int a,b,c,yn;
        a=sc.nextInt();
        b=sc.nextInt();
        c=sc.nextInt();
        yn= c-(a+b);
        if(yn<=0) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 21844
n = int(input())
a_list = list(map(int, input().split()))

cnt_multiple_2 = 0
cnt_multiple_4 = 0
cnt_others     = 0

for i in range(len(a_list)):
    if a_list[i] % 4 == 0:
        cnt_multiple_4 += 1
        continue
    if a_list[i] % 2 == 0:
        cnt_multiple_2 += 1
        continue
    cnt_others += 1

if cnt_multiple_2 > 0:
    if cnt_others > cnt_multiple_4:
        print('No')
    else:
        print('Yes')
else:
    if cnt_others-1 > cnt_multiple_4:
        print('No')
    else:
        print('Yes')





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

int main() {

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

  vector< long long int > v;
  for ( long long int i = 0; i < n; i++ ) {
    v.push_back( 0 );
  }

  for ( long long int i = 0; i < m; i++ ) {

    long long int a, l;
    cin >> a >> l;

    for ( long long int j = 0; j < l; j++ ) {
      v[ ( a + j ) % n ] = 1;
    }

  }

  long long int st = -1;

  for ( long long int i = 0; i < n; i++ ) {
    if ( v[i] == 0 ) {
      st = i;
      break;
    }
  }
  if ( st == -1 ) {
    cout << n << " " << 1 << endl;
    return 0;
  }

  long long int ans[101] = {};

  long long int cnt = 0;
  for ( long long int i = 0; i <= n; i++ ) {
    long long int k = ( st + i ) % n;
    if ( v[k] == 0 ) {
      ans[cnt]++;
      cnt = 0;
    }else {
      cnt++;
    }
  }
  for ( long long int i = n; i > 0; i-- ) {
    if ( ans[i] > 0 ) {
      cout << i << " " << ans[i] << endl;
    }
  }
  return 0;

}


Measured memory_bytes: 1220
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

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

int main() {
  int n, x, flag, flag2 = 1;
  cin >> n;
  vector<int> a(n);
  set<int> s;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n && flag2 == 1; i++) {
    x = a[i];
    for (int j = 2; j <= 1000 && x != 1; j++) {
      flag = 0;
      while (x % j == 0) {
        x /= j;
        flag = 1;
      }
      if (flag && s.find(j) == s.end()) {
        s.insert(j);
      } else if (flag) {
        flag2 = 0;
        break;
      }
    }
    if (x != 1 && s.find(x) == s.end()) {
      s.insert(x);
    } else if (x != 1) {
      flag2 = 0;
      break;
    }
  }
  if (flag2 == 1) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
  int g = a[0];
  for (int i = 0; i < n; i++) {
    g = gcd(g, a[i]);
  }
  cout << (g == 1 ? "setwise coprime" : "not coprime") << endl;
}

Measured memory_bytes: 7272
var input = require('fs').readFileSync( '/dev/stdin', 'utf8' );
var arr = input.split(" ");
var a = arr[0] - 0;
var b = arr[1] - 0;
var c = arr[2] - 0;
var str = "";
a < b && b < c ? str = "Yes" : str = "No";
console.log(str);


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
typedef unsigned long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 300 + 5;
const int MAX_N = 1e5 + 5;

// factorization O(sqrt(n))
map<int, int> prime_factor(int n) {
    map<int, int> res;
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

int MOD = 1e9 + 7;

long modpow(long m, long p) {
    if (p == 0) return 1;
    if (p % 2)
        return m * modpow(m, p - 1) % MOD;
    else {
        long res = modpow(m, p / 2);
        return res * res % MOD;
    }
}

long calcComb(int a, int b) {
    if (b > a - b) return calcComb(a, a - b);
    long mul = 1;
    long div = 1;
    for (int i = 0; i < b; i++) {
        mul *= (a - i);
        div *= (i + 1);
        mul %= MOD;
        div %= MOD;
    }
    long res = mul * modpow(div, MOD - 2) % MOD;
    return res;
}

int n, l, r;
bool is_not_prime[MAX_N];
int concat[MAX_N];
int main() {
    is_not_prime[0] = is_not_prime[1] = true;
    for (int i = 2; i < MAX_N; i++) {
        if (!is_not_prime[i]) {
            for (int j = i + i; j < MAX_N; j += i) {
                is_not_prime[j] = true;
            }
        }
    }
    for (int i = 3; i < MAX_N; i += 2) {
        if (!is_not_prime[i] && !is_not_prime[(i + 1) / 2]) {
            concat[i]++;
        }
    }
    for (int i = 3; i < MAX_N; i++)
        concat[i] += concat[i - 1];
    cin >> n;
    while (n--) {
        cin >> l >> r;
        cout << concat[r] - concat[l - 1] << endl;
    }
}


Measured memory_bytes: 1152
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	t := []string{"dream", "dreamer", "erase", "eraser"}
	idx := len(s)
Loop:
	for idx > 0 {
		for _, word := range t {
			l, r := idx-len(word), idx
			if l >= 0 && s[l:r] == word {
				idx -= len(word)
				continue Loop
			}
		}
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")
}

Measured memory_bytes: 1280
import math

def dist(x,y,N,M):
    sum = 0
    for n in range(N):
        sum += abs(x[n]-y[n])**M
    sum = sum**(1/M)
    
    return sum
    
def dist_inf(x,y,N):
    return max([abs(x[n]-y[n]) for n in range(N)])


N = int(input())
x = [int(i) for i in input().split()]
y = [int(j) for j in input().split()]

print(dist(x,y,N,1))
print(dist(x,y,N,2))
print(dist(x,y,N,3))
print(dist_inf(x,y,N))


Measured memory_bytes: 5700
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i=1;i<=n;i++){
			if(i%3==0)System.out.printf(" %d",i);
			else{
				int x=i;
				while(true){
					if(x%10==3){
						System.out.printf(" %d",i);
						break;
					}
					x/=10;
					if(x==0)break;
				}
			}
		}
		System.out.print("\n");
	}
}



Measured memory_bytes: 36232
use std::io::Read;
use std::str::{SplitWhitespace, FromStr};

struct InputReader<'a> {
    iterator: SplitWhitespace<'a>,
}

impl <'a> InputReader<'a> {
    fn from(input: &'a str) -> Self {
        InputReader {
            iterator: input.split_whitespace()
        }
    }

    fn next<T: FromStr>(&mut self) -> T
        where <T as std::str::FromStr>::Err: std::fmt::Debug
    {
        self.iterator.next().unwrap().parse::<T>().unwrap()
    }
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut reader = InputReader::from(input);

    let n: usize = reader.next();

    let mut prepre: usize = 0;
    let mut pre: usize = 0;
    for _i in 0..n {
        let mut current: usize = reader.next();
        if prepre > current {
            return String::from("No")
        }
        if pre > current {
            return String::from("No")
        }
        if current > pre {
            current -= 1;
        }
        prepre = pre;
        pre = current;
    }

    return String::from("Yes");
}

#[test]
fn test() {
    let cases: Vec<(&str, &str)> = vec![
        (
            r"5
1 2 1 1 3",
            "Yes"
        ),
        (
            r"4
1 3 2 1",
            "No"
        ),
        (
            r"5
1 2 3 4 5",
            "Yes"
        ),
        (
            r"1
1000000000",
            "Yes"
        ),
    ];

    let mut all_ok = true;
    for (i, case) in cases.iter().enumerate() {
        print!("case {} : ", i);

        let expected = case.1;
        let actual = solve(case.0);

        if expected == actual {
            println!("OK");
        } else {
            println!("NG");
            println!("    Expected: {}", expected);
            println!("    Actual  : {}", actual);

            all_ok = false;
        }
    }

    assert_eq!(all_ok, true);
}


Measured memory_bytes: 6396
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(Math.abs(a-b) % 2 == 0)System.out.println("Alice");
        else System.out.println("Borys");
        sc.close();

    }

}


Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <float.h>
#include <stdlib.h>
#include <functional>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <fstream>
#include <bitset>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)
#define sort1(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> p;
bool paircom (pair<int,int> p,pair<int,int> q){
return p.second<q.second;
}

void count(vector<int> v,vector<int>& ans){
    sort1(v);
    int n=v.size();
  int k=1;
  int i=1;
  bool bl=true;
    while(true){
    while(bl){
        if(v[i-1]==v[i]){
        k++;    
      }else{
          bl=false;
      }
      i++;
      }
      ans.push_back(k);
      if(i>=(n-1))break;
      k=1;
      bl=true;
    }
    }




int main() {
    int a;
    cin >> a;
    if(a>=30){cout <<"Yes";}else{cout <<"No";}
    
}

    

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
int rest=1000000007;

int main(){
  ll n;
  cin>>n;
  vector<ll> a(n+1,0);
  vector<ll> memo(n+1,0);
  rep1(i,n)cin>>a[i];
  ll ans=1;
  int memo0=0;
  rep1(i,n){
    if(a[i]==0){
      if(memo0==0)ans*=3;
      if(memo0==1)ans*=2;
      else ans*=1;
      memo0++;
    }
    else{
      ans*=memo[a[i]-1];
      memo[a[i]-1]--;
    }
    if(memo0==4)ans*=0;
    memo[a[i]]++;
    ans=ans%rest;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
const int nmax=40,abmax=10,inf = 1000000;
int a[nmax],b[nmax],c[nmax];
int dp[nmax+1][nmax*abmax+1][nmax*abmax+1];
int main(void){
  int n,ma,mb;
  cin>>n>>ma>>mb;
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i]>>c[i];
  }
  for(int i=0;i<=n;i++){
    for(int ca=0;ca<=nmax*abmax;ca++){
      for(int cb=0;cb<=nmax*abmax;cb++){
        dp[i][ca][cb]=inf;
      }
    }
  }
  dp[0][0][0]=0;
  for(int i=0;i<n;i++){
    for(int ca=0;ca<=nmax*abmax;ca++){
      for(int cb=0;cb<=nmax*abmax;cb++){
        if(dp[i][ca][cb]==inf)
          continue;
        dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb]);
        dp[i+1][ca+a[i]][cb+b[i]]=min(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i]);
      }
    }
  }
  int ans=inf;
  for(int ca=1;ca<=nmax*abmax;ca++){
    for(int cb=1;cb<=nmax*abmax;cb++){
      if(ca*mb==cb*ma)
        ans=min(ans,dp[n][ca][cb]);
    }
  }
  if(ans==inf)
    ans=-1;
  cout<<ans<<endl;
}

Measured memory_bytes: 25984
list1 = list(map(int, input().split()))
N = list1[0]
M = list1[1]
list2 = list(map(int, input().split()))
if list1[0] - list1[1] >= 0:
    print(0)
    exit(0)
list2 = sorted(list2, reverse=True)
# print(list2)
list3 = []
for i in range(len(list2) - 1):
    list3.append(list2[i] - list2[i + 1])
list3 = sorted(list3, reverse=True)
# print(list3)
sum = 0
for i in range(N - 1):
    sum = sum + list3.pop(0)
ans = list2[0] - list2[-1] - sum
print(ans)


Measured memory_bytes: 13960
from math import ceil
t1,t2,a1,a2,b1,b2=map(int,open(0).read().split())
w,x,y,z=t1*a1,t2*a2,t1*b1,t2*b2
if w+x==y+z:
	print("infinity")
	exit()
if (w-y)*(w+x-y-z)>0:
	print(0)
	exit()
a1=min(w,y)
b1=max(w,y)
c1=max(w+x,y+z)
c2=min(w+x,y+z)
print(2*int((b1-a1)//(c1-c2))+int((b1-a1)%(c1-c2)>0))

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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

// template from zscoder

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int n,ans(0);
    cin >> n;
    vi a(2*n);
    for(int i = 0 ; i < (2*n); i++)
    {
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    for(int i = 0; i < (2*n); i+=2)
    {
        ans += a[i];
    }
    cout << ans << endl;
}


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

long long absdif(long long a, long long b){
	return ( a > b ) ? a-b: b-a;
}

int main(){
	int N, K;
	std::vector<long long> h, dp;
	std::cin >> N >> K;
	h.resize(N);
	dp.resize(N+1);
	for(int i=0; i<N; i++){
		std::cin >> h[i];
	}

	dp[0] = 0;
	for(int i=1; i<N; i++){
		dp[i] = 1e9+9;
		for(int j=1; j<=K && i-j >= 0; j++){
			dp[i] = std::min(dp[i], dp[i-j] + absdif(h[i], h[i-j]) );
		}
	}
	std::cout << dp[N-1] << '\n';
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int N, M;
    cin >> N >> M;
    map<pair<int, int>, int> ma;
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        pair<int, int> p, pp;
        p = {a, b};
        pp = {b, a};
        ma[p] = 1, ma[pp] = 1;
    }

    deque<int> A;
    for (int i = 1; i < N; i++) {
        A.push_back(i);
    }

    int res = 0;
    do {
        deque<int> AA = A;
        AA.push_front(0);
        bool judge = 1;
        rep(i, N - 1) {
            int a = A[i], b = A[i + 1];
            if (ma[{a, b}] != 1)
                judge = 0;
        }
        if (judge)
            res++;

    } while (next_permutation(all(A)));

    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define int long long

signed main(){
  int n,m;
  bool disable[100006]={};
  int cnt[100006]={};
  cin >> n >> m; // System.in 的なの
  for(int i=0;i < m; i++){
    int a;
    cin >> a;
    disable[a]=true; // a番目に印をつける、という方法で i 番目の床に穴があいているかどうかがわかる。
  }
  cnt[1] = !disable[1];
  cnt[2] = ((!disable[2])? 1 + cnt[1] : 0);
  for(int i=3; i<=n; i++){
    if(disable[i]==false){
      cnt[i]=cnt[i-1]+cnt[i-2];
      cnt[i]%=1000000007;
    }
  }
  cout << cnt[n] << endl;
}

Measured memory_bytes: 1152
n,m=map(int,input().split())
a=[]
for i in range(n):
    a.append(list(map(int,input().split())))
b=[]
for i in range(m):
    b.append(int(input()))
for i in range(n):
    ans=0
    for j in range(m):
        ans += a[i][j]*b[j]
    print(ans)





Measured memory_bytes: 6012
#include<stdio.h>
#include<iostream>

using namespace std;
int  main(void) {
	//A
	int num;
	cin >> num;
	if (num == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int a;
		int b;
		cin >> a;
		cin >> b;
		cout << a + b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define maxn 100010
#define ll long long
#define db double
#define vi vector<int>
#define pb push_back
#define mod 998244353
#define fi first
#define pi pair<int, int>
#define se second
#define mp make_pair
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
// head
int n;
vector<pi> r;
int cal(int a, int b) {
	a = min(a, b);
	return 2 * a;
}
int main() {
	cin >> n;
	r.pb(mp(0, 0));
	for (int i = 1; i <= n; i++) {
		int l, rs;
		scanf("%d%d", &l, &rs);
		r.pb(mp(l, 1)), r.pb(mp(rs, 2));
	}
	sort(r.begin(), r.end());
	ll ans = 0;
	int tot[3] = {0};
	for (int i = 0; i < r.size() - 1; i++) {
		ll ndis = r[i + 1].fi - r[i].fi;
		tot[r[i].se]++;
		int nr = 0;
		if (tot[0]) nr = cal(tot[2] + 1, n - tot[1]);
		else nr = cal(n - tot[1] + 1, tot[2]);
		ans += ndis * nr;
	}
	cout << ans << endl;
	return 0;
}


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

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

  int n, x, d;
  cin >> n >> x >> d;

  if (x == 0 && d == 0) {
    cout << 1 << '\n';
    return 0;
  } 
  if (d == 0) {
    cout << n + 1 << '\n';
    return 0;
  }
  
  if (d < 0) x *= -1, d *= -1;
  map<int, vector<pair<int, int>>> m;
  int mn = 0, mx = 0;
  
  m[0].emplace_back(0, 0);
  for (int i = 0; i < n; ++i) {
    mn += i; mx += n-i-1;
    int l = (i+1)*x + mn * d, r = (i+1)*x + mx * d;
    m[((i+1)*x)%d].emplace_back(l, r);
  }

  int ans = 0;
  for (auto segs : m) {
    auto seg = segs.second;
    sort(seg.begin(), seg.end());
    int l = seg[0].first, r = seg[0].second;
    for (int i = 1; i < (int)seg.size(); ++i) {
      if (seg[i].first <= r) r = max(r, seg[i].second);
      else {
        ans += (r - l + d) / d;
        l = seg[i].first;
        r = seg[i].second;
      }
    }
    ans += (r - l + d) / d;
  }

  cout << ans << '\n';
}


Measured memory_bytes: 25492
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let v : Vec<String> = get_vec();
    let s = v[0].to_string();
    let t = v[1].to_string();
    println!("{}", t + &s);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
// lint mod = 1000000007;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

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

  string s;
  cin>>s;

  vector<int> rc(n+1);
  rc[0]=0;
  rep(i,n){
    rc[i+1]=rc[i]+(s[i]=='R');
  }

  int minscore=n;
  rep(k,n+1){
    chmin(minscore, max(k-rc[k],rc[n]-rc[k]));
  }

  return minscore;
}

int main(){cout<<app()<<endl;return 0;}


Measured memory_bytes: 4448
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i=0;
	char s[101],p[101],cat[201];
	scanf("%s",s);
	scanf("%s",p);
	strcpy(cat,s);
	strcat(cat,s);
	if(strstr(cat,p)){printf("Yes\n");}
	else{printf("No\n");}

	return 0;
}

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

#define ll long long

int main() {
    std::ios::sync_with_stdio(false);
    using namespace std;
    int n;
    cin >> n;
    vector< vector< pair<ll, ll> > > A(n);
    for(int i = 0; i < n; i++)
        A[i].resize(n, {0, 0});

    for(int i = 0; i < n; i++)
        cin >> A[0][i].first;

    const ll max_v = 1'000'000'000;

    for(int i = 1; i < n; i++)
        for(int j = 0; j < n - i; j++) {
            ll res = max_v * max_v + 1;
            for(int k = 0; k < i; k++)
                res = min(res, A[k][j].second + A[i - k - 1][j + k + 1].second);
            ll weight = A[0][j].first + A[i - 1][j + 1].first;
            A[i][j].first = weight;
            A[i][j].second = res + weight;
        }

    cout << A[n - 1][0].second << "\n";

    return 0;
}


Measured memory_bytes: 2816
/* به نام یزدان */
#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 100 * 1000 + 3, MOD = 1e9 + 7;
vector<int> adj[MAX_N];
int n, dp[MAX_N][2];

void read_input() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

void dfs(int v, int pr = -1) {
	dp[v][0] = dp[v][1] = 1;
	for (int u: adj[v])
		if (u != pr) {
			dfs(u, v);
			dp[v][0] = (1LL * dp[v][0] * (dp[u][0] + dp[u][1])) % MOD;
			dp[v][1] = (1LL	* dp[v][1] * dp[u][0]) % MOD;
		}
}

void solve() {
	dfs(0);
}

void print_output() {
	cout << (dp[0][0] + dp[0][1]) % MOD;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	read_input();
	solve();
	print_output();
}


Measured memory_bytes: 13440
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
  // input
    int n;cin >> n;
    vector<long> a(n + 1);
    for(int i = 1; i < n + 1; i++) cin >> a[i];

  // compute
    int counter_o = 0;
    int counter4 = 0;

    for(int i = 1; i < n + 1; i++) {
        if(a[i] % 2 != 0){
            counter_o += 1;
        }
        if(a[i] % 4 == 0){
            counter4 += 1;
    }
    }

    if(counter4 == 0 && counter_o > 0){
        cout << "No" << endl;
        return 0;
    }

    if(counter_o <= counter4){
        cout << "Yes" << endl;
        return 0;
    }else if(counter_o == counter4 + 1 && counter_o + counter4 == n){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }   

  // output  

}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  ll N; cin >> N;

  ll ok = N;  // compare(ok) is always true
  ll ng = 0;    // compare(ng) is always false

  auto compare = [&](ll X) {
    // X = max in S
    ll Y = N - X; // 和で作るべき値

    // X 未満の数字を使って、Y以上を作ることが出来るか
    ll x = X;
    return x * (x - 1) / 2 >= Y;

    // X 未満の数字を使って、ちょうどYを作ることが出来るか

  };
  
  while(abs(ok-ng) > 1) { // ng極限の隣がokとなるまで
    ll mid = (ok + ng) / 2LL;
    (compare(mid) ? ok : ng) = mid;
  }

  ll sum = 0;
  for(int i = min(ok - 1, N - ok); i>=1; i--) {
    if(sum == N - ok) break;
    if(sum + i > N - ok) continue;
    printf("%d\n", i);
    sum += i;
  }

  cout << ok << endl;

  
  return 0;
}

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

int a[100003];

int main()
{
    int N;
    cin >> N;
    while (N--)
    {
        int t;
        cin >> t;
        a[t]++;
        a[t + 1]++;
        a[t + 2]++;
    }
    cout << *max_element(a + 2, a + 100000) << endl;
    return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
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;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;
}

Measured memory_bytes: 3616
#include<stdio.h>
int main(void){
    int x1,x2;
    scanf("%d %d",&x1,&x2);
    if(x1>x2){
        printf("%d\n",x1-x2);
    }else{
        printf("%d\n",x2-x1);
    }
    return 0;
}


Measured memory_bytes: 2072
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll N,M,F;
    //cin>>N>>M>>F;
    string S;
    cin>>S;
    REP(i,S.length()){
        cout<<((S[i]=='?')?'D':S[i]);
    }
    //ll t=N*M;
    //cout<<fixed<<setprecision(20)<<N*M<<endl;
    //cout<<fixed<<setprecision(0)<<floor(t);
    //N-=F;
    //cout<<N/(M+F);
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3732
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    numbers=[]
    n = int(input())
    numbers= list(map(int,input().split()))
    dp=[0]*n

    dp[0]=numbers[0]
    dp[-1]=numbers[-1]

    for i in range(1,n-1):
        dp[i]=min(numbers[i-1],numbers[i])
    print(sum(dp))

if __name__=="__main__":
    main()

Measured memory_bytes: 9036
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 105;

int n, m, q, ans = 0;
int a[N], b[N], c[N], d[N];
int cur[N];

void gen(int idx)
{
	if(idx > n)
	{
		int val = 0;
		for(int i = 1; i <= q; i++)
		{
			if(cur[b[i]] - cur[a[i]] == c[i])
				val += d[i];
		}
		ans = max(ans, val);
		return;
	}
	for(int i = cur[idx - 1]; i <= m; i++)
	{
		cur[idx] = i;
		gen(idx + 1);
	}
}

int32_t main()
{
	IOS;
	cin >> n >> m >> q;
	for(int i = 1; i <= q; i++)
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	cur[0] = 1;
	gen(1);
	cout << ans;
	return 0;
}

Measured memory_bytes: 3648
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};//RDLU
int f(int a,int b){
	if(a>=0)return b;
	if(b<=0)return -a;
	if(abs(a)<abs(b))return -a-a+b;
	return b+b-a;
}
int main(){
	int n,m;
	cin>>n>>m;
	vi in(n);
	rep(i,n)cin>>in[i];
	int out=inf;
	rep(i,n-m+1)out=min(out,f(in[i],in[i+m-1]));
	cout<<out<<endl;
}



Measured memory_bytes: 1024
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;

void main(){

    real x,h;
    while(true){
	x = to!real(chomp(readln()));
	h = to!real(chomp(readln()));
	if(x==0&&h==0) break;
	real h1 = sqrt(x*x/4 + h*h);
	real ans = x*x + 2 * h1 * x;
	writef("%.5f\n",ans);
    }
}

Measured memory_bytes: 2384
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

int main(){
  string S; cin>>S;
  for(int i=0; i<S.size(); i++){
    cout<<"x";
  }
  cout<<endl;
}

Measured memory_bytes: 256
n, k = map(int, raw_input().split())
w = [int(raw_input()) for _ in xrange(n)]

def check(P):
    i = 0
    for j in range(k):
        s = 0
        while s + w[i] <= P:
            s += w[i]
            i += 1
            if i == n:
                return True
    return False


def solver():
    left, right = 0, 100000 * 10000

    while left < right:
        mid = int((left + right) / 2)

        if check(mid):
            right = mid
        else:
            left = mid + 1
    
    return right


print solver()

Measured memory_bytes: 10152
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const int mod=1e9+7;
const int nax=22;
vector<vector<ll>> dp(1<<nax,vector<ll>(nax,-1));

ll calc(int index,int mask,int& size,vector<vector<int>>& pairs,int& n){
  if(mask==size){
    return 1;
  }
   if(index>=n) return 0;
   if(dp[mask][index]!=-1) return dp[mask][index];
   ll res=0;
   for(int i=0;i<n;i++){
     int val=(mask>>i)&1;
     if(!val && pairs[index][i]){
        res+=calc(index+1,mask|(1<<i),size,pairs,n);
         if(res>mod)
            res-=mod;
     }
   }
   dp[mask][index]=res;
   return res;
}

int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;cin>>n;
    vector<vector<int>> pairs(n,vector<int>(n));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)
            cin>>pairs[i][j];
    }
    int size=(1<<n)-1;
    cout<<calc(0,0,size,pairs,n);

}


Measured memory_bytes: 887716
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

using namespace std;

#ifdef LDEBUG
#define debug(x) cout << #x << ":" << x << endl
#else
#define debug(...)
#endif

#define bzero(m)  memset(m,0,sizeof(m))
#define REP(i,n) for(u64 i=0, i##_len=(n); i<i##_len; ++i)

typedef unsigned long long u64;
typedef long long i64;

u64 n,m;
u64 a[100005];
u64 b[100005];

u64 c[100005];
u64 aaa[100005];
u64 g[100005];


u64 par(u64 x) {
        if (c[x] == x) return x;

        return (c[x] = par(c[x]));
}
void merge(u64 x, u64 y) {
        x = par(x); y = par(y);

        if (x == y)
                return;

        c[y] = x;

        g[x] = g[x] + g[y];
}


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

        cin >> n >> m;

        REP(i,n) {
                c[i] = i;
                g[i] = 1;
        }
        REP(i,m)
                cin >> a[i] >> b[i];

        aaa[m] = n * (n-1) /2;
        REP(i,m) {
                u64 j = m-1 -i;

                if (par(a[j]) == par(b[j]))
                        aaa[j] = aaa[j+1];
                else
                        aaa[j] = aaa[j+1] - g[par(a[j])]*g[par(b[j])];

                merge(a[j], b[j]);
        }

        REP(i,m+1) {
                if (i==0)continue;
                cout << aaa[i] << endl;
        }

        return 0;
}


Measured memory_bytes: 5248
n, m, x = map(int, input().split())
book = [list(map(int, input().split())) for i in range(n)]
ans = 10**18

for i in range(2**n):
    i = format(i, "0{}b".format(n))
    algo = [10**18] + [0]*m
    money = 0
    for j in range(n):
        if i[j] == "1":
            money += book[j][0]
            for k in range(m):
                algo[k+1] += book[j][k+1]
    if min(algo) >= x:
        ans = min(ans, money)

if ans == 10**18:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 74296
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

a,b = gs
n = (a+b).to_i
ns = pr n
jd = true
ns.each do |nn|
jd = false if nn[1] % 2 != 0
end
puts jd ? 'Yes' : 'No'


Measured memory_bytes: 2300
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
 
typedef long long int int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
 
void run(void){
  int n;
  scanf("%d",&n);
  int x[100];
  int y[100];
  int h[100];
  int i;
  for(i=0;i<n;i++)
    scanf("%d%d%d",x+i,y+i,h+i);
  int j;
  for(i=0;i<=100;i++){
    for(j=0;j<=100;j++){
      int k;
      for(k=0; k<n && h[k]==0; k++);
      int height = h[k] + ABS(x[k]-i) + ABS(y[k]-j);
      for(k=0; k<n; k++){
    	if(MAX(height-ABS(x[k]-i)-ABS(y[k]-j),0)!=h[k])
	        break;
      }
      if(k==n){
	    printf("%d %d %d\n",i,j,height);
    	return;
      }
    }
  }
}
 
int main(void){
  run();

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define	foreach( gg,itit )	for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define	mp make_pair
#define	pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

ll dis[305][305], curr[305][305];
vector<pair<ll,pii> > dists; 
int main(){
	int n;
	scanf("%d",&n);
	REP(i,n) REP(j,n) scanf("%lld",&dis[i][j]);
	REP(i,n) REP(j,n) curr[i][j]=mod*(i!=j);		
	REP(i,n) REP(j,n) if(i<j) dists.pb(mp(dis[i][j],mp(i,j)));
	sort(all(dists));
	bool bad = false;
	ll tot = 0;
	REP(i,dists.size()){
		int v1 = dists[i].Y.X,v2 = dists[i].Y.Y;
		ll d = dists[i].X;
		if(curr[v1][v2] < d) {
			bad = true;
			break;
		}
		if(curr[v1][v2] > d) {
			tot += d;
			curr[v1][v2] = d;
			curr[v2][v1] = d;
		}
		REP(j,n) {
			curr[v1][j] = curr[j][v1]=min(curr[v1][j],curr[v1][v2]+curr[v2][j]);
			curr[v2][j] = curr[j][v2]=min(curr[v2][j],curr[v1][v2]+curr[v1][j]);
		}
	}
	if(bad) tot = -1;
	printf("%lld\n",tot);
	return 0;
}


Measured memory_bytes: 2808
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll diff = a - b;

  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  
  ll l = -1, r = 1000000001;
  while (l + 1 < r) {
    ll middle = (l + r) / 2;

    auto ok = [&] {
      ll base = middle * b;
      ll cnt = middle;
      rep(i, n) {
       cnt -= max(0LL, (h[i] - base + diff - 1) / diff);
      }
      return cnt < 0;
    }();
    ll cnt = 0;

    if(ok) l = middle;
    else r = middle;
  }
  cout << r << endl;
}

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

bool check (string s){
  int n = s.length();
  if (n%2==1){
    return false;
  }
  else {
    return (s.substr(0,n/2-1)==s.substr(n/2));
  }
}

int choise_sort (int n, int a[]){
  int index;
  for (int i=0; i<n-1; i++){
    int min = a[i], num;
    for (int j=i; j<n-1; j++){
      if (a[j+1]<min){
        min = a[j+1];
        num = j+1;
      }
    }
    index = a[i];
    a[i] = min;
    a[num] = index;
  }
}

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

  vector<int> a(n), b(200100);
  for (int i=0; i<=200000; i++){
    b.at(i) = 0;
  }
  for (int i=0; i<n; i++){
    cin >> a.at(i);
    b.at(a.at(i))++;
  }

  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());

  int sum = 0;
  for (int i=0; i<k; i++){
    sum += b.at(i);
  }

  cout << n - sum << endl;
}


Measured memory_bytes: 1792
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
#include <bitset>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define SZ(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define pi acos(-1)
#define mod 998244353 //1000000007
#define inf 1000000007
#define ll long long
#define ull unsigned long long
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
#define N 200005
#define _DEBUG
template <class U,class T> void Max(U &x, T y){if(x<y)x=y;}
template <class U,class T> void Min(U &x, T y){if(x>y)x=y;}
template <class T> void add(int &a,T b){a=(a+b)%mod;}
inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%mod;
        a=1LL*a*a%mod;b>>=1;
    }
    return ans;
}
int pow(int a,int b,int c){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%c;
        a=1LL*a*a%c;b>>=1;
    }
    return ans;
}

vi g[N];
int d[N];
int bfs(int s, int n){
    queue<int>q;q.push(s);
    memset(d, -1, sizeof(d));
    d[s] = 0;
    while(!q.empty()){
        int u = q.front(); q.pop();
        for(auto &v : g[u]){
            if(d[v] == -1){
                d[v] = d[u] + 1;
                q.push(v);
            }
        }
    }
    rep(i, 0, n)if(d[i] > d[s]) s = i;
    return s;
}
int main(){
    //srand(time(NULL)+clock());
    int T,ca=0,k,i,j,m=0, K, n;
    scanf("%d", &n);
    rep(i, 1, n){
        scanf("%d %d", &j, &k);
        j--, k--;
        g[j].pb(k);
        g[k].pb(j);
    }
    int s = bfs(0, n);
    int t = bfs(s, n);
    K = d[t] + 1;
    if(K % 3 < 2){
        puts("First");
    }
    else{
        puts("Second");
    }
    //cerr<<(1.*clock()-start)/CLOCKS_PER_SEC<<"\n";
}



Measured memory_bytes: 13556
"""
https://atcoder.jp/contests/abc118/tasks/abc118_a
"""


def parse():
    A, B = list(map(int, input().split()))
    return A, B


def solve(A, B):
    if B % A == 0:
        print(A + B)
    else:
        print(B - A)


if __name__ == '__main__':
    inputs = parse()
    solve(*inputs)


Measured memory_bytes: 2940
# ARC069D - Menagerie (ABC055D)
def check(a: int, b: int) -> list:
    ret, cur, prev = [], a, b
    for i in S:
        ret += [cur]
        if cur ^ (i == "o"):  # oSo or oWx
            prev, cur = cur, prev ^ 1  # both neighbors are different
        else:  # oSx or oWo
            prev, cur = cur, prev  # both are the same
    flg = cur == a and prev == b  # check the consistency of input and result
    return ret if flg else []


def main():
    global S
    N = int(input())
    S = input().rstrip()
    for a in range(2):
        for b in range(2):
            ans = check(a, b)
            if ans:
                print("".join("S" if i else "W" for i in ans))
                return
    print(-1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{
    bool flag = 0;
    int n;
    cin >> n;
    for (int i = 1; i<=9; i++)
        for (int j = 1; j<=9; j++)
            if (n == i*j) 
                flag = 1;
    cout << (flag?"Yes\n":"No\n");
}

Measured memory_bytes: 256