akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007L

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val A = Array(3){ni()}
    val K = ni()
    var k = 0

    for (i in 0 until K) {
      if (A[0] < A[1]) break
      A[1] *= 2
      k++
    }
    for (i in 0 until K - k) {
      if (A[1] < A[2]) break
      A[2] *= 2
      k++
    }
    out.println(if (k <= K && A[0] < A[1] && A[1] < A[2]) "Yes" else "No")
  }













































  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }
  private fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}

Measured memory_bytes: 34752
#include <stdio.h>
#include <string.h>

int main()
{
  char s[11];
  char t[12];

  scanf("%s %s", &s,&t);
  t[strlen(s)] = '\0';
  if(strcmp(s,t) == 0)
    printf("Yes");
  else
    printf("No");

  return 0;
}


Measured memory_bytes: 1708
n = input()
tmp_n = n.split(" ")

a = tmp_n[0]
b = tmp_n[1]
c = tmp_n[2]

flag=0

for i in range(0,100):
    check = int(b)*i+int(c)
    if check%int(a) == 0:
        flag = 1

if flag==1:
    print("YES")
else:
    print("NO")


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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)

using namespace std;

int main ()
{
  int acnum,wanum,tlenum,renum,N;
  string b;

  acnum = 0;
  wanum = 0;
  tlenum = 0;
  renum = 0;

  cin >> N;

  REPI (N)
  {
    cin >> b;
    if (b == "AC")
      acnum++;
    else if (b == "WA")
      wanum++;
    else if (b == "TLE")
      tlenum++;
    else if (b == "RE")
      renum++;
  }
  
  cout << "AC x " << acnum << "\n";
  cout << "WA x " << wanum << "\n";
  cout << "TLE x " << tlenum << "\n";
  cout << "RE x " << renum << "\n";
  
  return 0;
}

Measured memory_bytes: 3512
#include<stdio.h>
int main(void){
	int array[10];
	int N = 10;
	int i,j;
	for(i = 0; i < N; i++){
		scanf("%d",&array[i]);
	}
	for(i = 0;i < N-1;i++){
		for(j=N-1;j>=i+1;j--){
			if(array[j]>array[j-1]){
				int tmp = array[j];
				array[j] = array[j-1];
				array[j-1] = tmp;
			}
		}
	}
	printf("%d\n%d\n%d\n",array[0],array[1],array[2]);
	
	return 0;
}

Measured memory_bytes: 600
N, Y = map(int, input().split())

res10000 = -1
res5000 = -1
res1000 = -1

for a in range(N+1):
    for b in range(N-a+1):
        c = N - a - b
        total = a * 10000 + b * 5000 + c * 1000
        if total == Y:
            res10000 = a
            res5000 = b
            res1000 = c

print('{} {} {}'.format(res10000, res5000, res1000))

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

int main(){
    int sum = 0;
    string num;
    cin >> num;
    for(int i = 0 ; i < 3 ; ++i){
        if(num.at(i) == '7'){
            sum++;
        }
        }
    if(sum > 0) cout << "Yes" << endl;
    else cout << "No" <<endl;
    return 0;
}

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

int main(){
  string s,t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  if(s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            var ab = s.Split(' ').Select(x => int.Parse(x)).ToArray();
            int a = ab[0];
            int b = ab[1];
            bool isOK = false;

            for (int i = a; i <= b; i++)
            {
                if (i % K == 0)
                {
                    isOK = true;
                    break;
                }
            }

            if (isOK)
            {
                Console.WriteLine("OK");
            }
            else
            {
                Console.WriteLine("NG");
            }
        }
    }
}


Measured memory_bytes: 28292
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
long long n,m;
scanf("%lld %lld",&n,&m);
if(n*2<=m){
    LL sum=0;
    sum+=n;
    m-=2*n;
    sum+=m/4;
    cout<<sum;
}
else{
    cout<<m/2;
}



    return 0;
}


Measured memory_bytes: 3752
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        k: usize
    }

    let mut amari = 0;

    let mut count = 1;
    let mut ok = false;

    for i in 1..k + 1 {
        amari = (amari * 10 + 7) % k;
        if amari == 0 {
            ok = true;
            count = i;
            break;
        }

        //println!("{}", amari);
    }

    if ok {
        println!("{}", count);
    } else {
        println!("{}", -1);
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 2264
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
  int x;
  cin>>x;
  if(x==3||x==5||x==7)YES;
  else NO;
}


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

struct pair{
    long int a;
    int b;
};

int compare(const void *x, const void *y)
{
    return ((struct pair *)x)->a - ((struct pair *)y)->a;
}



int main() {
    int i,n,m;
    long int sum=0;//���v���z
    scanf("%d %d\n",&n,&m);
    struct pair AB[n];
    for(i=0;i<n;i++){
        scanf("%ld %d",&AB[i].a,&AB[i].b);
    }


    qsort(AB,n,sizeof(struct pair),compare);// �\�[�g

    struct pair ab = {0,m};
    for (i = 0; i < n; i++) {
        if(ab.b <= AB[i].b){
            ab.a += AB[i].a * ab.b;
            break;
        }
        else{
            ab.a += AB[i].a*AB[i].b;
            ab.b -= AB[i].b;
        }
    }
    printf("%ld\n", ab.a);
    return 0;
}


Measured memory_bytes: 3324
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<stack>

using namespace std;

int main(){
	string st;
	stack<int> sta;
	int a,b;
	
	while(cin>>st){
		if(st[0]=='+'){
			a = sta.top();
			sta.pop();
			b = sta.top();
			sta.pop();
			sta.push(a+b);
		}
		else if(st[0]=='-'){
			a = sta.top();
			sta.pop();
			b = sta.top();
			sta.pop();
			sta.push(b-a);
		}
		else if(st[0]=='*'){
			a = sta.top();
			sta.pop();
			b = sta.top();
			sta.pop();
			sta.push(a*b);
		}
		else if(st[0]=='\n')
		break;
		else{
			sta.push(atoi(st.c_str()));
		}
	}
	printf("%d\n",sta.top());
}

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

typedef std::pair<std::string, int> Process;

int main() {

  std::queue<Process> q;
  int N;
  int ltime;
  std::string name;
  int time;
  int ttime = 0;
  

  std::cin >> N >> ltime;
  for(int i = 0; i < N; ++i) {
    std::cin >> name >> time;
    q.push(Process(name, time));
  }

  while( not q.empty() ) {
    Process pp;
    pp = q.front(); q.pop();
    pp.second -= ltime;
    if( pp.second > 0 ) {
      q.push(pp);
      ttime += ltime;
      continue;
    }
    else {
      ttime += ltime + pp.second;
      std::cout << pp.first << " " << ttime << std::endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 4404
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

num = []
n1 = 0
n2 = 0
n3 = 0
flg_0 = False
flg_1 = False
flg_2 = False
for i in range(x+y):
    if flg_0 is False:
        u = p[min(a-1, n1)]
    else:
        u = 0
    if flg_1 is False:
        uu = q[min(b-1, n2)]
    else:
        uu = 0
    if flg_2 is False:
        uuu = r[min(c-1, n3)]
    else:
        uuu = 0
    if max(u, uu, uuu) == u:
        num.append(u)
        n1 += 1
    elif max(u, uu, uuu) == uu:
        num.append(uu)
        n2 += 1
    else:
        num.append(uuu)
        n3 += 1
    if n1 >= x:
        flg_0 = True
    if n2 >= y:
        flg_1 = True
    if n3 >= c:
        flg_2 = True
    if (n1 + n2 + n3) == (x + y):
        break

print(sum(num))




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


using namespace std;
using ll = long long;

#define pb push_back
#define sz(x) (int)(x).size()

int main () {

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr); cout.tie(nullptr);


  int a, b; cin >> a >> b;
  if (a < 1 || a > 9 || b < 1 || b > 9) {
    cout << -1 << '\n';
  }else {
    cout << a*b << '\n';
  }

  return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
const ll mod = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    vector<int> b(n - 1);
    rep(i, n - 1) cin >> b[i];
    int ans = 0;
    for (int i = n - 2; i > 0; i--)
    {
        ans += min(b[i], b[i - 1]);
    }
    ans += b[0] + b[n - 2];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(v) for (auto itr = v.begin(), itr != v.end(); ++itr)
#define LB(v, x) lower_bound(v.begin(), v.end(), x) - v.begin()
#define UB(v, x) upper_bound(v.begin(), v.end(), x) - v.begin()
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    string N;
    cin >> N;
    int n = N.size();
    vector<vector<int>> dp(n + 1, vector<int>(2, INT_MAX));
    dp[0][0] = 0;
    dp[0][1] = 1;
    REP(i, n) {
        dp[i + 1][0] = min(dp[i][0] + N[i] - '0', dp[i][1] + 10 - (N[i] - '0'));
        dp[i + 1][1] =
            min(dp[i][0] + N[i] + 1 - '0', dp[i][1] + 10 - (N[i] - '0') - 1);
    }
    cout << dp[n][0] << endl;

    return 0;
}


Measured memory_bytes: 55964
#include <cstdio>

using namespace std;

#define rep(i,x) for(int i=0;i<(int)(x);++i)

int nails[5005][5005];

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

	rep(i, M) {
		int A, B, X; scanf("%d%d%d", &A, &B, &X);

		nails[A - 1][B - 1]++;
		nails[A - 1][B]--;
		nails[A + X][B - 1]--;
		nails[A + X][B + X + 1]++;
		nails[A + X + 1][B]++;
		nails[A + X + 1][B + X + 1]--;
	}

	rep(i, N + 2) {
		rep(j, N + 2) {
			nails[i][j + 1] += nails[i][j];
		}
	}

	rep(i, N + 2) {
		rep(j, N + 2) {
			nails[j + 1][i] += nails[j][i];
		}
	}

	rep(i, N + 2) {
		rep(j, N + 2) {
			nails[i + 1][j + 1] += nails[i][j];
		}
	}

	int ans = 0;

	rep(i, N + 2) {
		rep(j, N + 2) {
			ans += nails[i][j] > 0;
		}
	}

    printf("%d\n", ans);
}

Measured memory_bytes: 100568
#include <bits/stdc++.h>
using namespace std;
int main(){
string S;
cin>>S;
if(S[0]!='A'){
cout<<"WA";
return 0;
}
int cntC=0;
for(int i=2;i<(S.size())-1;i++){
    if(S[i]=='C')cntC++;
}
if(cntC!=1){
    cout<<"WA";
    return 0;
}
for(int i=0;i<S.size();i++){
    if(isupper(S[i])){
        if(S[i]!='C'&&S[i]!='A'){
            cout<<"WA";
            return 0;
        }
    }
}
cout<<"AC";
return 0;
}


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

using namespace std;
using ll =long long;
using db = double;

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

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(v) SORT(v);(v).erase(unique((v).begin(),(v).end()),(v).end())
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;

//ここから書き始める
int main()
{
	cout << setprecision(10);
	int n , k, A[100000];
	cin >> n >> k;
	rep(i,n) cin >> A[i];
	vector<ll> dp(n,INF);
	dp[0] = 0;
	For(i,1,n){
		For(j,1,k+1){
			if(i - j >= 0){
				chmin(dp[i],dp[i-j] + abs( A[i] - A[i-j]));
			}
		}
	}
	cout << dp[n-1] << endl;

}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD=1000000007;
using namespace std;
int gcd (int x, int y) {
    if (x < y) swap(x, y);
    if (y == 0) return x;
    return gcd(x % y, y);
}
int main(){
    int n,x;
    cin>>n>>x;
    vector<int> y(n);
    rep(i,0,n) cin>>y.at(i);
    y.push_back(x);
    sort(all(y));
    
    int g=0;
    rep(i,0,n){
        g=gcd(g,abs(y[i]-y[i+1]));
    }
    
    cout<<g<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<list>
#include<algorithm>
#include<cstdio>

using namespace std;


int main()
{
    list<int> D;
    string S;
    int n; cin >> n;
    int a;
    for(int i=0; i< n; i++)
    {
        cin >> S;
        if(S=="insert")
        {
            cin >> a;
            D.push_front(a);
        }
        if(S=="delete")
        {
            cin >> a;
            for(list<int>::iterator it = D.begin();it !=D.end();++it)
            {
                if(*it == a)
                {
                    D.erase(it);
                    break;
                }
            }
        }
        if(S=="deleteFirst")
        {
            D.pop_front();
        }
        if(S=="deleteLast")
        {
            D.pop_back();
        }
    }
    cout << D.front();
    D.pop_front();
    while(!D.empty())
    {
        if(D.begin()!=D.end())cout <<" "<< D.front();
    //    else cout << D.front()<<endl;
        D.pop_front();
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 34400
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define FOR(i,k,n) for(int (i) = (k); (i) < (n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x,y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
template<class T> using vv=vector< vector<T> >;
typedef deque<int> di;
typedef deque< deque<int> > ddi;


int main() {
    map<string,int> M;
    string tmp,rst,rst2;
    int max,maxl;
    while(cin >> tmp) {
        M[tmp] += 1;
        if(max < M[tmp]) {
            max = M[tmp];
            rst = tmp;
        }
        if(tmp.length() > maxl) {
            rst2 = tmp;
            maxl = tmp.length();
        }
    }
    cout << rst << " " << rst2 << endl;
	return 0;
}

Measured memory_bytes: 3152
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int a,b;
    while(~scanf("%d %d",&a,&b))
    {
        a=a-1;
        b=b-1;
        printf("%d\n",a*b);
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int main()
{
	int a, b, c;
	int ans = 1;
	
	std::cin >> a;
	
	std::cin >> b;
	if(a != b) ++ans;
	
	std::cin >> c;
	if(a != c && b != c) ++ans;

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


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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;


signed main(){

	string s;
	cin >> s;
	int ans = 0;
	rep(i, s.size()){
		if (s[i] == '+') ans++;
		else ans--;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import Data.List
import Text.Printf
main :: IO ()
main = do
  [_, pickupDice] <- getInts
  dices <- getInts
  let diceSums = scanl (+) 0 dices
  let maxSum = maximum $ diff pickupDice diceSums
  print . fromRational $ toRational ( maxSum + pickupDice ) / 2

diff diffNum = zipWith subtract <$> id <*> drop diffNum

getInts = do
  x <- getLine
  let y = (map $ read) $ words x :: [Int]
  return y


Measured memory_bytes: 77180
N, K=map(int, input().split())
S=input()
A=[]
tmp=1
for i in range(1,N):
    if S[i-1]==S[i]:
        tmp+=1
    else:
        A.append(tmp)
        tmp=1
A.append(tmp)

ans=sum(A)-len(A)+(K)*2

if ans<N-1:
    print(ans)
else: print(N-1)

Measured memory_bytes: 45296
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1LL << 60;

int main() {
    
    char chara;
    cin >> chara;
    char chara2 = chara+1;

    cout << chara2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll h, w, n;std::cin >> h >> w >> n;
  multiset<vll> s;
  vvi dat = vv(n, 2, 0, int);
  re(i, n){
    std::cin >> dat[i][0] >> dat[i][1];
    s.insert(vll{dat[i][0], dat[i][1]});
  }
  vll ans(10, 0);
  re(i, n){
    vvi mp = vv(5, 5, 0, int);
    ll x = dat[i][0], y = dat[i][1];
    for(int j=-2;j<=2;j++){
      for(int k=-2;k<=2;k++){
        if(s.find(vll{x+j, y+k})!=s.end()) mp[j+2][k+2]=1;
      }
    }
    /*
    std::cout << "now" << i+1 << '\n';
    re(j, 5) {
      re(k, 5) std::cout << mp[j][k] << " ";
      std::cout << '\n';
    }
    */
    for(int j=0;j<=2;j++){
      for(int k=0;k<=2;k++){
        ll S = 0;
        if((x-2)+j<=0||(y-2)+k<=0||x+j>h||y+k>w) continue;
        for(int l=0;l<=2;l++){
          for(int r=0;r<=2;r++){
            S+=mp[j+l][k+r];
          }
        }
        if(S>0) ans[S]++;
        //std::cout << S << '\n';
      }
    }
  }
  ll S = 0;
  rep(i, 1, 10) S+=ans[i]/i;
  std::cout << (h-2)*(w-2) - S << '\n';
  rep(i, 1, 10) std::cout << ans[i]/i << '\n';
  return 0;
}


Measured memory_bytes: 15104
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    string s;
    cin >> s;

    ll count0 = 0;
    ll count1 = 0;
    ll ans = 0;

    for(char c : s){
        if(count0==0 && count1==0){
            if(c=='0'){
                count0++;
            }else{
                count1++;
            }
        }
        // どちらかがカウントあり
        else{
            if(count0>0){
                if(c=='0'){
                    count0++;
                }else{
                    count0--;
                    ans+=2;
                }
            }
            else{
                if(c=='1'){
                    count1++;
                }else{
                    count1--;
                    ans+=2;
                }
            }
        }
    }

    p(ans);
    
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int i,a,b,c,d;
  
  cin >> a >> b >> c >> d;
  
  if (abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d)) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

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

using namespace std;

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

	vector<int> T(N);
	int sum = 0;
	for (auto &e: T) {
		cin >> e;
		sum += e;
	}

	int M;
	cin >> M;

	while (M--) {
		int P, X;
		cin >> P >> X;

		cout << sum - T[P-1] + X << '\n';
	}
}

Measured memory_bytes: 256
if __name__ == '__main__':
	n = int(input())
	R = [int(input()) for i in range(n)]

	minv = R[0]
	maxv = R[1] - R[0]
	for j in range(1, n):
		if (maxv < R[j] - minv):
			maxv = R[j] - minv
		if (R[j] < minv):
			minv = R[j]
	print(maxv)


Measured memory_bytes: 13596
//Think simple yet elegant.
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll  long long
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
const ll maxn=2e5+10;
const ll mod=1e9+7;


int main() {
  	fast;
  	ll a,b,c,k;
  	cin>>a>>b>>c>>k;
  	if(a>=k)
  		cout<<k;
  	else if((a+b)>=k)
  		cout<<a;
  	else{
  		
  		ll ans = 2*a + b - k;
  		cout<<(ans);
	  }
  	
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int& i : a) cin >> i;
    for (int i = k; i < n; ++i)
        cout << (a[i] > a[i - k] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3972
str = int(input())
str2 = input()
str3 = str2.split(" ")
res = 1
isZero = False
# 0があるかチェック

for i in range(0, str):
    if 0 == int(str3[i]):
        isZero = True
        res = 0

if not isZero:
    for i in range(0, str):
        res *= int(str3[i])
        if res > 10 ** 18:
            res = -1
            break

    
print(res)

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

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

int main()
{
    using vi = vector<int>;
    using vvi = vector<vi>;
    using vvvi = vector<vvi>;

    int N;
    cin >> N;
    cout << N * N * N << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);

const LL mod = 998244353;

LL n;

int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif
  cin >> n;
  string ans = "";

  while(n > 0) {
    if (n % 26 == 0) {
      ans += 'z';
      n -= 1;
      n /= 26;
    } else {
      ans += n % 26 - 1 + 'a';
      n /= 26;
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl; 

#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

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

int main(){
	int A, B;
	cin >> A >> B;
	for(int n=1;n<=100000000;n++) {
		int a = (n * 0.08) / 1;
		int b = (n * 0.1) / 1;
		if(a == A and b == B) {
			cout << n << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;
int main(){
    int W;
    int H;
    int x;
    int y;
    int r;
    cin >> W >> H >> x >> y >> r;

    if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
        cout <<"Yes"<<endl;
    }
    else{
        cout << "No"<<endl;
    }
    
}


Measured memory_bytes: 3116
import functools
from math import gcd
n = int(input())
@functools.lru_cache(None)
def main(n):
  g=0
  for i in range (1, n+1):
    for j in range (1, n+1):
      for k in range (1, n+1):
        g  += gcd(gcd(i,j),k)
  return (g)
print(main(n))

Measured memory_bytes: 9572
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

int main(){
    int N;
    cin >> N;
    vector<ll> h(N);
    for(int i = 0; i < N;i++) cin >> h[i];
    ll pre = h[0];
    for(int i = 1; i < N;i++){
        if(pre <= h[i]){
            pre = max(pre,h[i]-1);
        }
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 4060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<int> data(n);
  rep(i, n) cin >> data.at(i);
  int sum = 0;
  rep(i, n) {
    rep(l, n) {
      if (i <= l) continue;
      sum += data.at(i) * data.at(l);
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
int output =0;
vector<int>num(n);
for(int i=0;i<n;i++){
cin >> num.at(i);
}
for(int i=0;i<n;i++){
int p = num.at(i);
if(num.at(p-1)==i+1)
output++;
}
output /= 2;
cout<<output<<endl;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 
//Available in Snips
#define fi(i, x, y)   for (__typeof(x) i = x; i < y; i ++)
#define fir(i, x, y)  for (__typeof(x) i = x; i > y; i --)
#define fv(x)   for (auto itr = x.begin(); itr != x.end(); itr ++)
#define fvr(x)  for (auto itr = x.end() - 1; itr != x.begin() - 1; itr --)

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//code here
	unordered_map<int,int> m;
    int n;cin >>n;
    while(n--){
        int x; cin >> x;
        if(m[x]){
            cout << "NO";
            return 0;
        } else {
            m[x] =1;
        }
    }
    cout << "YES";

}

Measured memory_bytes: 8520
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>

#define REP(i, n) for(int i=0;i<n;i++)

using namespace std;

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

const int maxN = 200000;

ll B[maxN];
int main() {
    ll N;
    cin >> N;
    ll A[N];
    REP(i, N) {
        cin >> A[i];
    }
    REP(i, N) {
        ll r = N / (N - i);//rは，「N-i番目の数の，倍数の個数（自分含む）」
        if (r == 1) {
            B[N - i - 1] = A[N - i - 1];
        } else {
            ll sum = 0;
            for (int m = 2; m < r + 1; m++) {
                sum += B[m * (N - i) - 1];
            }
            if (A[N - i - 1] != sum % 2) {
                B[N - i - 1] = 1;
            }
        }
    }

    ll M = 0;
    REP(i, N) {
        M += B[i];
    }
    cout <<M<<endl;
    REP(i,N){
        if(B[i]==1){
            cout<<i+1;
            cout<<" ";
        }
    }
}





Measured memory_bytes: 3968
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe

ll gcd(ll c, ll d) { return d ? gcd(d, c%d) : c;}
ll lcm(ll c, ll d) { return c / gcd(c,   d) * d;}


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
int r,D,x,ans;
cin >> r >> D >> x;

rep(i,10){
    x = x*r - D;
    cout << x << endl;
}





//////////////////////////////////////////////////////
return 0;}

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

using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
    fast;
    int n;cin>>n;
    int *arr=new int[n+1];

    for(int i=1;i<=n;i++)
        cin>>arr[i];


    vi v(n+1,0);

    for(int i=n;i>=1;i--)
    {
        int sum=0;
        int tmp=i*2;
        while(tmp<=n)
            sum+=v[tmp],tmp+=i;

        sum%=2;
        if(arr[i]==sum)
            v[i]=0;
        else
            v[i]=1;
    }

    vi ans;
    for(int i=1;i<=n;i++)
    {
        if(v[i])
            ans.pb(i);
    }

    cout<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++)
        cout<<ans[i]<<' ';

}

Measured memory_bytes: 5108
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]
ab.sort(key = lambda x:x[0])
ans = 0;check = 0
for i in range(n):
    a = ab[i][0];b = ab[i][1]
    if m > check + b:ans += a*b;check += b
    elif m == check + b:ans += a*b;break
    else:ans += (m-check)*a;break
print(ans)

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	// debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, left, right)  (a).begin()+(left),(a).begin()+(right)	// left to (right-1)

int main() {
	ll n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	ll bn = min({ a, b, c, d, e });
	ll res = (n + bn - 1) / bn + 4;
	pv(res)
	return 0;
}

Measured memory_bytes: 3636
def main():
    H1,M1,H2,M2,K = list(map(int, input().split()))
    from datetime import datetime, timedelta
    time1 = datetime(2019,1,1,H1,M1,0)
    time2 = datetime(2019,1,1,H2,M2,0)
    kmin = timedelta(minutes=K)

    ans = (time2 - kmin) - time1

    print(ans.seconds//60)



if __name__ == '__main__':
    main()

Measured memory_bytes: 9440
#include <bits/stdc++.h>
#define int long long int
#define MOD(x) ((x % MOD_N) + MOD_N) % MOD_N
#define FS first
#define SC second
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,v) for (auto i=v.begin();i!=v.end();++i)
#define REACH(i,v) for (auto i=v.rbegin();i!=v.rend();++i)
#define LB(c,x) distance((c).begin(),lower_bound(ALL(c),x))
#define UB(c,x) distance((c).begin(),upper_bound(ALL(c),x))
#define COUNT(c,x) (lower_bound(ALL(c),x)-upper_bound(ALL(c),x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DEL(v) decltype(v)().swap(v)
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;
#define NL cerr<<endl;
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
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;}
template<typename T>T sum(vector<T>&v){return accumulate(ALL(v),T());}
template<typename T>T sum(vector<T>&v,int a,int b){return accumulate(v.begin()+a,v.begin()+b,T());}
template<typename T>T max(vector<T>&v){return *max_element(ALL(v));}
template<typename T>T min(vector<T>&v){return *max_element(ALL(v));}
template<typename T>T max_index(vector<T>&v){return distance((v).begin(),max_element(ALL(v)));}
template<typename T>T min_index(vector<T>&v){return distance((v).begin(),min_element(ALL(v)));}

struct edge { int to, cost; };

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}

const int INF = 1e18;
const int MOD_N = 1e9+7;

int gcd(int x, int y) {
   if(x < y) swap(x, y);
   if(x % y == 0) return y;
   else return gcd(y, x % y);
}

signed main()
{
   int N; cin >> N;
   V<int> a(N);
   REP(i, N) {
      cin >> a[i];
   }

   int m = a[0];
   REP(i, N-1) {
      m = gcd(m, a[i+1]);
   }
   cout << m << endl;

   return 0;
}


Measured memory_bytes: 1024
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;

vi adj[100005];
 
signed main()
{
    tezz

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

    vi v(n + 1);
    for(int i=1;i<=n;i++) cin>>v[i];

    while(m--){
        int a, b;
        cin>>a>>b;

        adj[a].pb(b);
        adj[b].pb(a);
    }

    int count = 0;
    for(int i=1;i<=n;i++){
        bool flag = true;
        for(int x:adj[i]){
            if(v[x] >= v[i]) flag = false;
        }
        if(flag){
            // cout<<i<<' ';
            count++;
        }
    }
    // cout<<endl;

    cout<<count;
} 

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

#include <vector>

#include <algorithm>

using namespace std;

#define repeat(n) for(int _ = 1; _ <= (n); _++)

int main()
{
	ios::sync_with_stdio(false);
#ifdef CAI_WEI_HAN
	freopen("test.in", "r", stdin);
#endif
	
	int n;
	cin >> n;
	
	vector<int> C;
	for(int _ = 1; _ <= n; _++) {
		int x;
		cin >> x;
		
		if(C.empty() || C.back() != x)
			C.push_back(x);
	}
	
	const int P = 1e9 + 7;
	
	static int sum[200005];
	static int f[200005];
	sum[C[0]] = 1;
	f[0] = 1;
	for(int i = 1; i < C.size(); i++) {
		sum[C[i]] = (sum[C[i]] + f[i-1]) % P;
		f[i] = sum[C[i]];
	}
	
	cout << f[C.size() - 1];
}


Measured memory_bytes: 2676
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 998244353
  #define N 100005
  #define INF 1000000000000
  #define eps 1e-6
  #define int long long

    string s;
    int n,q;

vector<set<int>> v(26);

int query(int l,int r)
{
  int ans =0;


  for(int i = 0; i < 26; i++)
  {
    if(v[i].size() == 0)continue;
    if(v[i].lower_bound(r) == v[i].end())
    {
      if(v[i].lower_bound(l) != v[i].end())ans++;
    }
    else if(v[i].lower_bound(l) != v[i].lower_bound(r))ans++;
    else if(*v[i].lower_bound(r) == r)ans++;
  }
  return ans;
}

void update(int loc,char ch)
{
  v[s[loc]-'a'].erase(loc);
  s[loc] = ch;
  v[s[loc] - 'a'].insert(loc);

}
int32_t main()
{


    cin >> n >> s >> q;

   

    for(int i = 0; i < s.length(); i++)
    {
      v[s[i]-'a'].insert(i);
    }



    // cout << query(0,4);

    // for(auto i : v[1])
    // {
    //   cout << i << " ";
    // }
    //cout <<( v[1].lower_bound(6) == v[1].end()) << endl;
  //  cout << endl;


    for(int i = 1; i <= q; i++)
    {
      int x;
      cin >>x;

      if(x == 1)
      {
        int y;
        char ch;
        cin >> y >> ch;
        y--;
        update(y,ch);
      }
      else
      {
        int l,r;
        cin >> l >> r;
        l--;
        r--;
        cout << query(l,r) << endl;
      }
    }



    return 0;
}

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

#define MAXN (100010)

int n, t;
int a[MAXN];

int main(){
	scanf("%d%d", &n, &t);
	for(int i = 1; i <= n; ++ i){
		scanf("%d", a + i);
	}
	int maxDelta = 0, nowmax = a[n], ans = 0;
	for(int i = n - 1; i; -- i){
		if(nowmax - a[i] > maxDelta){
			maxDelta = nowmax - a[i];
			ans = 1;
		}
		else if(nowmax - a[i] == maxDelta){
			++ ans;
		}
		nowmax = std::max(nowmax, a[i]);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    ll w,h,n;cin>>w>>h>>n;
    vp v(n);
    rep(i,n)cin>>v[i].fi>>v[i].se;
    sort(all(v));
    ll ma=0,ans=inf;
    for(int i=n-1;i>=0;i--){
        chmin(ans,ma+v[i].fi);
        chmax(ma,v[i].se);
    }
    chmin(ans,ma);
    out(ans);
}


Measured memory_bytes: 4376