akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		PrintWriter pw=new PrintWriter(System.out);
		char[] cs=sc.next().toCharArray();
		int ans=0;
		for(char c:cs)if(c=='1')++ans;
		pw.println(ans);
		pw.close();
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public int nextInt() {
    	return Integer.parseInt(next());
    }
    
    public long nextLong() {
    	return Long.parseLong(next());
    }
}

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

int main(){
    int V, E;
    cin >> V >> E;
    vector<vector<int> > edge(10001);
    vector<int> state(V, 0);
    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        edge[s].push_back(t);
        state[t]++;
    }
    vector<int> ans;
    for (int i = 0; i < V; i++) {
        if (state[i] == 0) ans.push_back(i);
    }
    for (int i = 0; i < ans.size(); i++) {
        for (int j = 0; j < edge[ans[i]].size(); j++) {
            int t = edge[ans[i]][j];
            state[t]--;
            if (state[t] == 0) ans.push_back(t);
        }
        cout << ans[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3700
S = input()
for c in range(0, ord('z') - ord('a')+1):
    last_c = -1
    for i,s in enumerate(S):
        if ord(s) - ord('a') == c:
            if last_c == -1:
                last_c = i
                continue
            if i - last_c <= 2:
                print(last_c+1,i+1)
                exit()
            last_c = i
print(-1,-1)

Measured memory_bytes: 41196
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, divisor, modinv, bitSearch, bitList, dfs, bfs//
//dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 9999999999999; ll ans = INF;
vl flag, color, D; vll path;
//***********//
int main() {
	cin >> X >> Y;
	cout << X + Y / 2;
}

Measured memory_bytes: 256
N=int(input())
answer=[]
for i in range(N):
  K,P=map(int,input().split())
  if K<=P:
    answer.append(K)
  elif K%P==0:
    answer.append(P)
  else:
    answer.append(K%P)
for i in range(len(answer)):
  print(answer[i])
    


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

#define endl '\n'

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int INF = (int)1e9;

int AdjMatrix[234][234];

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

    int V, E, r, u, v, w;
    vector <int> R;
    
    cin >> V >> E >> r;
    for(int i = 0; i < r; i++) {
        int foo;
        cin >> foo;
        foo--;
        R.push_back(foo);
    }
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < V; j++)
          AdjMatrix[i][j] = INF;
        AdjMatrix[i][i] = 0;
      }
      for (int i = 0; i < E; i++) {
        cin >> u >> v >> w;
        u--; v--;
        if(AdjMatrix[u][v] != INF) {
            AdjMatrix[u][v] = min(AdjMatrix[u][v], w);
            AdjMatrix[v][u] = min(AdjMatrix[v][u], w);
        }
        else {
            AdjMatrix[u][v] = w; // directed graph
            AdjMatrix[v][u] = w;
        }
      }
    for (int k = 0; k < V; k++) // common error: remember that loop order is k->i->j
      for (int i = 0; i < V; i++)
        for (int j = 0; j < V; j++)
          AdjMatrix[i][j] = min(AdjMatrix[i][j], AdjMatrix[i][k] + AdjMatrix[k][j]);

      sort(R.begin(), R.end());
      int res = INF;
      do {
        int cnt = 0;
        u = R[0];
        for(int i = 1; i < R.size(); i++) {
            v = R[i];
            cnt += AdjMatrix[u][v];
            u = v;
        }

        res = min(res, cnt);
      } while(next_permutation(R.begin(), R.end()));
      cout << res;

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for (auto i : mp) ans += i.first > i.second ? i.second : i.second - i.first;
    cout << ans << endl;
}


Measured memory_bytes: 4736
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
using namespace std;
typedef long long ll;
const int maxn = 10005;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "w", stdout);
#endif
  int n;
  double sum=0;
  double btc = 0;
  cin>>n;
  while(n--){
    double x;
    string y;
    cin>>x>>y;
    if(y[0]=='B')btc+=x;
    else sum+=x;
  }
  printf("%.10f\n",sum+btc*380000.0);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct Random_Number_Generator{
    mt19937_64 mt;

    Random_Number_Generator() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}

    int64_t operator () (int64_t l, int64_t r){
        uniform_int_distribution<int64_t> dist(l, r-1);
        return dist(mt);
    }

    int64_t operator () (int64_t r){ 
        return (*this)(0, r);
    }
};

ll c[27], a[365][27];
ll res = 0, sum = 0;
vector<int> ans(365), now(365);
set<int> s[27];

ll insert(int d, int q){
    ll ret = a[d][q];
    s[q].insert(d);
    set<int>::iterator it1 = s[q].find(d), it2 = it1;
    int l = *--it1, r = *++it2;
    ret += c[q]*(r-l)*(r-l-1)/2;
    ret -= c[q]*((d-l)*(d-l-1)/2 + (r-d)*(r-d-1)/2);
    s[q].erase(d);
    return ret;
}

ll remove(int d, int q){
    ll ret = -a[d][q];
    set<int>::iterator it1 = s[q].find(d), it2 = it1;
    int l = *--it1, r = *++it2;
    ret += c[q]*((d-l)*(d-l-1)/2 + (r-d)*(r-d-1)/2);
    ret -= c[q]*(r-l)*(r-l-1)/2;
    return ret;
}

ll eval(int d, int q){
    return insert(d, q) + remove(d, now[d]);
}

void change(int d, int q){
    s[q].insert(d), s[now[d]].erase(d);
    now[d] = q;
}

int main(){
    int D;
    cin >> D;
    rep(i, 26){
        cin >> c[i];
        s[i].insert(-1), s[i].insert(D);
    }
    c[26] = 0;
    rep2(i, -1, D) s[26].insert(i);
    rep(i, D){
        rep(j, 26) cin >> a[i][j];
        a[i][26] = 0;
    }
    Random_Number_Generator rnd;

    rep(i, D) now[i] = 26;
    copy(all(now), ans.begin());

    int T = 500000;
    double start_temp = 3000, end_temp = 0;
    rep(t, T){
        ll M = -INF;
        int d = rnd(D), q = 0;
        rep(i, 26){
            if(i == now[d]) continue;
            if(chmax(M, eval(d, i))) q = i;
        }
        double temp = start_temp+(end_temp-start_temp)*t/T;
        double p = exp(M/temp);
        if(p > (rnd(INF)%INF)/double(INF)){
            change(d, q);
            sum += M;
            if(chmax(res, sum)) copy(all(now), ans.begin());
        }
    }

    rep(i, D) cout << min(26, ans[i]+1) << endl;
}

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

int main(){
   string s,t;
   int n;
   cin>>n>>s>>t; 
   int ans=2*n;
   for(int i=0;i<n;i++){
       int j;
       for(j=0;i+j<n;j++){
           if(s[i+j]!=t[j]) break;
       }
       if(i+j==n){
           ans-=(n-i);
           break;
       }
   }
   cout<<ans<<endl;
    return 0;
}

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

int main() {
	int n,res=1;
	cin>>n;
	int a[n];
	
	for(int i=0;i<n;i++)
		cin>>a[i];
	int min=a[0];
	for(int j=1;j<n;j++){
		if(a[j]<min)
		res+=1;
		if(a[j]<min)
		min=a[j];
	}
	cout<<res;
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)


int gcc(int a,int b){
    if(a < b)
        swap(a,b);

    if(a % b == 0)
        return b;
    else
        gcc(b,a % b);
}

int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d\n",gcc(a,b));
    return 0;
}

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

int main() {
	// your code goes here
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	int a1[a],b1[b];
	for(int i=0;i<a;i++)
	cin>>a1[i];
	for(int i=0;i<b;i++)
	cin>>b1[i];
	
	vector<int>v;
	int t;
	for(int i=0;i<c;i++)
	{
	   cin>>t;
	   v.push_back(t);
	}
	
	
	sort(a1,a1+a);
	sort(b1,b1+b);
	//sort(c1,c1+c);
	//vector<int>v;
	for(int i=a-1;i>=a-x;i--)
	v.push_back(a1[i]);
	for(int i=b-1;i>=b-y;i--)
	v.push_back(b1[i]);
	
	sort(v.begin(),v.end());
	ll sum=0;
	int n=v.size();
	for(int i=n-1;i>=n-x-y;i--)
	sum+=v[i];
	
	cout<<sum<<"\n";
	
	return 0;
}


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

const int INF = 1000000007;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
typedef pair<int, int> P;

int main()
{
  int H, W; cin >> H >> W;
  string field[H];
  int count = 0;
  int d[H][W];
  for (int i = 0; i < H; i++) {
    cin >> field[i];
    for (int j = 0; j < W; j++) {
      if (field[i][j] == '.') count++;
    }
    fill(d[i], d[i] + W, INF);
  }
  d[0][0] = 1;

  queue<P> que;
  que.push(P(0, 0));
  while (1) {
    if (que.empty()) {
      cout << -1 << endl;
      return 0;
    }
    int y = que.front().first, x = que.front().second;
    if (y == H-1 && x == W-1) break;
    que.pop();
    for (int i = 0; i < 4; i++) {
      int ny = y + dy[i], nx = x + dx[i];
      if (ny < 0 || nx < 0 || ny >= H || nx >= W) continue;
      if (field[ny][nx] == '#' || d[ny][nx] <= d[y][x] + 1) continue;
      que.push(P(ny, nx));
      d[ny][nx] = d[y][x] + 1;
    }
  }

  cout << count - d[H-1][W-1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d,e=0;
    cin>>a>>b>>c;
        d=(a-1)%(b+c);
    if(c-d<2) cout<<(a-1)/(b+c)<<endl;
    else cout<<(a-1)/(b+c)-1<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c;
    cin >>a >> b >> c;
	
	int x = a + b;
	int y = b + c;
	int z = c + a;
	
	int res = min(x, min(y,z));
	
	cout << res <<endl;
	
    return 0;

}


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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int a, b;
  cin >> a >> b;
  cout << a*b << endl;
}


Measured memory_bytes: 3652
use std::io;
use std::collections::HashMap;

const abc: &'static str = "abcdefghijklmnopqrstuvwxyz";

macro_rules! min {
    ($x: expr, $y: expr) => { if $x <= $y { $x } else { $y } };
}

fn f(v: Vec<String>) -> String {
    let to_map = |s: &String| {
        let mut m: HashMap<char, u32> = HashMap::new();
        for c in s.chars() {
            let t = match m.get(&c) { Some(t) => t + 1, None => 1 };
            m.insert(c, t);
        }
        m
    };
    let mut map = to_map(&v[0]);
    for s in v.into_iter().skip(1) {
        let m = to_map(&s);
        for c in abc.chars() {
            let n = min!(*m.get(&c).unwrap_or(&0), *map.get(&c).unwrap_or(&0));
            map.insert(c, n);
        }
    }
    abc.chars().fold(String::new(), |mut s, c| {
        if let Some(n) = map.get(&c) {
            for _ in 0..*n { s.push(c); }
        }
        s
    })
}

#[test]
fn test() {
    assert_eq!(f(vec!["cbaa".to_string(), "daacc".to_string(), "acacac".to_string()]), "aac".to_string());
    assert_eq!(f(vec!["a".to_string(), "aa".to_string(), "b".to_string()]), "".to_string());
}

fn main() {
    let mut n = 0;
    {
        let mut s = String::new();
        io::stdin().read_line(&mut s);
        n = s.trim().parse().unwrap();
    }
    let mut v: Vec<String> = Vec::new();
    for _ in 0..n {
        let mut s = String::new();
        io::stdin().read_line(&mut s);
        v.push(s);
    }
    println!("{}", f(v));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N; 
	cin >> N; 
	pair<long long int, long long int> P[110] = {}; 
	int soeji = 0; 
	for(int i = 0; i < N; i++){
		cin >> P[i].first >> P[i].second; 
		if(P[i].first <= P[soeji].first || (P[i].first == P[soeji].first && P[i].second <= P[soeji].second)){
			soeji = i; 
		}
	}
	vector<int> CH = {};  
	CH.push_back(soeji); 
	long double mx = -2.0; int index = 0;
	long double EPS = 1e-10; 
	for(int i = 0; i < N; i++){
		if(i == index) continue; 
		long long int a = P[soeji].first; 
		long long int b = P[soeji].second; 
		long long int c = P[i].first; 
		long long int d = P[i].second; 
		long double e = (double) (d-b) * pow((c-a) * (c-a) + (d-b) * (d-b), -0.5);
		if(e - mx > -EPS) {
			index = i; mx = e; 
		}
	}
	CH.push_back(index); 
	long double cs[110][110][110] = {}; 
	for(int i = 0; i < N; i++){
		long long int a = P[i].first; 
		long long int b = P[i].second; 
		for(int j = 0; j < N; j++){
			long long int c = P[j].first; 
			long long int d = P[j].second; 
			for(int k = 0; k < N; k++){
				if(i==j || j==k) continue; 
				long long int e = P[k].first; 
				long long int f = P[k].second; 
				long long int g = (c-a)*(e-c) + (d-b)*(f-d); 
				long long int h = (c-a)*(c-a) + (d-b)*(d-b); 
				long long int l = (e-c)*(e-c) + (f-d)*(f-d); 
				cs[i][j][k] = (long double) g * pow(h, -0.5) * pow(l, -0.5); 
			}
		}
	}
	while(CH.at(CH.size() - 1) != soeji){
		int j = CH.at(CH.size() - 1);
		int i = CH.at(CH.size() - 2); 
		long double mx = -2.0; 
		int index = 0; 
		for(int k = 0; k < N; k++){
			if(i == j || j == k) continue;
			if(cs[i][j][k] - mx > -EPS){
				index = k; mx = cs[i][j][k];
			} 
		}
		CH.push_back(index); 
	}
	long double ans[110] = {}; 
	for(int i = 0; i < N; i++){
		ans[i] = 1; 
	}
	cout.precision(15); ans[CH[0]] = cs[CH[CH.size()-2]][CH[0]][CH[1]]; 
	if(ans[CH[0]] < -1.0) ans[CH[0]] = (long double)-1.0;
	if(ans[CH[0]] > 1.0) ans[CH[0]] = (long double) 1.0; 
	for(int i = 1; i < CH.size() - 1; i++){
		ans[CH[i]] = cs[CH[i-1]][CH[i]][CH[i+1]]; 
	if(ans[CH[i]] < -1.0) ans[CH[i]] = (long double)-1.0;
	if(ans[CH[i]] > 1.0) ans[CH[i]] = (long double) 1.0; 
	}
	for(int i = 0; i < N; i++){
		cout << acos(ans[i]) / (2.0 * acos(-1)) << endl; 
	}
}

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

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

  int i = 0;
  vector<int> x(10, 0);
  while( M > 0 ) {
    x.at(i) = M % 10;
    M /= 10;
    i++;
  }

  int sum = 0;
  for( int a : x ) {
    sum += a;
  } 

  if( N % sum == 0 ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

stack<lli> h;
string s;
lli ans = 0;
vll edge;
vll area;
vll area_list;

int main(){
    cin >> s;
    edge = vll(s.size()+1);
    area = vll(s.size()+1);
    for(lli i = 0;i < s.size();i++){
        if(s[i] == '\\'){
            h.push(i);
        }
        else if(s[i] == '/'){
            if(!h.empty()){
                ans += i - h.top();
                edge[h.top()] = i;
                h.pop();

            }
        }
        area[i] = ans;
    }
    cout << ans << endl;
    for(lli i = 0;i < s.size();i++){
        if(edge[i] == 0) continue;
        area_list.push_back(area[edge[i]] - area[i]);
        i = edge[i];
    }
    cout << area_list.size();
    for(lli i = 0;i < area_list.size();i++){
        cout << " " << area_list[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3408
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

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

    ll n,k,s;
    cin>>n>>k>>s;

    if(s!=1&&s!=2)
    {
        for(ll i=0;i<n;++i)
        {
            if(i<k){cout<<s<<" ";}
            else{cout<<s-1<<" ";}
        }
        return 0;
    }
    for(ll i=0;i<n;++i)
    {
        if(i<k){cout<<s<<" ";}
        else{cout<<s+1<<" ";}
    }

    return (0);
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;



signed main() {
	int d, n, ta = 0, mu = 0;
	cin >> d >> n;
	if (d == 0)mu = 1;
	else if (d == 1)mu = 100;
	else mu = 10000;
	for (int i = mu;; i += mu) {
		if (i % (mu * 100) != 0) {
			ta++;
		}
		if (ta == n) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int p,w,g,y=0;
  for(int i=0;i<n;i++){
    string st;
    cin>>st;
    if(st=="P"){
      p+=1;
    }
    else if(st=="W"){
      w+=1;
    }
    else if(st=="G"){
      g+=1;
    }
    else if(st=="Y"){
      y+=1;
    }
  }
  if(y!=0){
    cout<<"Four"<<endl;
  }
  else if(y==0){
    cout<<"Three"<<endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3

from collections import deque

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    N, M = MII()
    l = [[] for _ in range(N+1)]
    for _ in range(M):
        a, b = MII()
        l[a].append(b)
        l[b].append(a)

    ll = [0 for _ in range(N+1)]
    visited = [False for _ in range(N+1)]

    que = deque()
    que.append(1)
    visited[1] = True
    while que:
        now = que.popleft()
        nx = l[now]
        for i in nx:
            if not visited[i]:
                visited[i] = True
                ll[i] = now
                que.append(i)


    if all(visited[1:]):
        print('Yes')
        s = "\n".join(map(str, ll[2:]))
        print(s)
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 42560
n = int(input())
t,a= map(int, input().split())
l = list(map(int, input().split()))

x = t - l[0] * 0.006
tmp = []
for x in l:
    x = t - x * 0.006
    tmp.append(x)

ans = []

for z in tmp:
    y = a - z
    ans.append(abs(y))

print(ans.index(min(ans)) + 1)


Measured memory_bytes: 9088
hist = {'A':0,'B':0,'AB':0,'O':0}
while True:
    try:
        i,b = input().strip().split(',')
        hist[b] += 1
    except EOFError:
        break

print("%d\n%d\n%d\n%d" % (hist['A'],hist['B'],hist['AB'],hist['O']))

Measured memory_bytes: 7356
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<ll,ll>;
using vl = vector<ll>; using vvl = vector<vl>;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<vector<ll>> f(n,vector<ll>(10));
    vector<vector<ll>> p(n,vector<ll>(11));
    rep(i,n) rep(j,10) cin >> f[i][j];
    rep(i,n) rep(j,11) cin >> p[i][j];
    ll ans = -INF;
    for(int bit = 1;bit < (1 << 10);++bit){
        bitset<10> s(bit);
        vector<ll> cnt(n);
        rep(i,n) rep(j,10)
            if(f[i][j] == 1 && s[9-j] == 1) ++cnt[i];
        ll total = 0;
        rep(i,n) total += p[i][cnt[i]];
        ans = max(ans,total); 
    }
    cout << ans << endl;
}

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

ll value(ll v){
    return (ll)(-1 + sqrt(1 + 8*v))/2;
}


ll solve(ll n){
    ll res = 0;
    
    // Calculate the prime factors first
    map<ll, ll >m;
    //set<ll>primefactors;
    while(n%2 == 0){
        m[2]++;
        n = n/2;
    }
    for(int i = 3; i <= sqrt(n); i++){
        while(n%i == 0){
            m[i]++;
            n /= i;
        }
    }
    if(n > 2){
        m[n] = 1;
    }
    
    for(auto mm : m){
        res += value(mm.second);
    }
    
    return res;
}


int main(){
    ll N;
    cin >> N;
    
    cout << solve(N) << endl;
    return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

const int N=21;

char str[1<<N];
int ans,len,n,req,f[N][1<<N],g[N][1<<N];

inline int mask(int x){ return (1<<x)-1; }

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin);
	freopen("my.out","w",stdout);
#endif
	scanf("%d%d",&n,&req); 	
	rep(i,0,n){
		scanf("%s",str); 
		lop(s,0,(1<<i)){
			f[i][s]=str[s]-'0';
		}
	}
	g[0][0]=-1;
	rep(i,1,n){
		lop(s,0,(1<<i)){
			int b=s>>(i-1)&1,p=i;
			for(;p>=1&&(s>>(p-1)&1)==b;--p);
			g[i][s]=p;
		}	
	}
	rep(i,0,n){
		for(int j=1;i+j<=n;++j){
			int all=(1<<(i+j))-1;
			lop(s,0,all){
				f[i][s>>j]+=f[i+j][s];
				int p=g[j][s&mask(j)];
				if(p)f[i+p][((s>>j)<<p)+(s&mask(p))]+=f[i+j][s];
			}
		}
		dec(s,(1<<i)-1,0){
			if(f[i][s]>=req){
				len=i;
				ans=s;
			}
		}
	}
	dec(i,len-1,0)putchar((ans>>i&1)+'0'); 
	puts(""); 
	return 0;
}


Measured memory_bytes: 98560
#include <bits/stdc++.h>
using namespace std ;
const int N = 2e5 + 10 ;
typedef long long ll ;
const int INF = 0x3f3f3f3f ;
constexpr int mod = 998244353 ;
struct Node{

  int x , d ;
}a[N] ;
bool cmp(Node c  ,Node b)
{
  return c.x < b.x ;
}
int main()
{
  int n  ;
  scanf("%d" , &n) ;
  for(int i = 1; i <= n ;i ++)
  scanf("%d%d" , &a[i].x , &a[i].d) ;
  sort(a + 1 , a + n + 1 , cmp) ;
  ll dp = 1 ;
  vector<pair<int , ll>> v ;
  v.push_back({INF , 1}) ;
  for(int i = n ;i >= 1; i --)
   {
     while(a[i].x + a[i].d > v.back().first) v.pop_back() ;
     dp += v.back().second , dp %= mod ;
     v.push_back({a[i].x , dp}) ;
   }
  cout << dp << endl ;
  return 0 ;
}


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

int main(){ 
    string s;
    cin>> s;
    if((s.at(0)=='0'&&s.at(1)!='0'||(s.at(0)=='1'&&(s.at(1)=='0'||s.at(1)=='1'||s.at(1)=='2')))&&(s.at(2)=='0'&&s.at(3)!='0'||(s.at(2)=='1'&&(s.at(3)=='0'||s.at(3)=='1'||s.at(3)=='2'))))
    cout<<"AMBIGUOUS"<<endl;
   if(!(s.at(0)=='0'&&s.at(1)!='0'||(s.at(0)=='1'&&(s.at(1)=='0'||s.at(1)=='1'||s.at(1)=='2')))&&(s.at(2)=='0'&&s.at(3)!='0'||(s.at(2)=='1'&&(s.at(3)=='0'||s.at(3)=='1'||s.at(3)=='2'))))
   cout<<"YYMM"<<endl;
if((s.at(0)=='0'&&s.at(1)!='0'||(s.at(0)=='1'&&(s.at(1)=='0'||s.at(1)=='1'||s.at(1)=='2')))&&!(s.at(2)=='0'&&s.at(3)!='0'||(s.at(2)=='1'&&(s.at(3)=='0'||s.at(3)=='1'||s.at(3)=='2'))))
cout<<"MMYY"<<endl;
if(!(s.at(0)=='0'&&s.at(1)!='0'||(s.at(0)=='1'&&(s.at(1)=='0'||s.at(1)=='1'||s.at(1)=='2')))&&!(s.at(2)=='0'&&s.at(3)!='0'||(s.at(2)=='1'&&(s.at(3)=='0'||s.at(3)=='1'||s.at(3)=='2'))))
cout<< "NA" << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
const int INF = 12;

int dnum(ll n) {
    int ans = 0;
    while (n > 0) {
        ans++;
        n /= 10;
    }

    return ans;
}

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

    int ans = INF;
    for (ll i = 1; i*i <= N; i++) {
        if (!(N%i)) ans = min(ans, max(dnum(i), dnum(N/i)));
    }

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

Measured memory_bytes: 256
import sys
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]

def main():
    N,K = LI()
    H = LI()

    H.sort()

    if(N<=K):
        print(0)
        return
    
    print(sum(H[:N-K]))

if __name__ == "__main__":
    main()


Measured memory_bytes: 80332
import numpy as np
N, M = map(int, input().split())

H = np.array(list(map(int, input().split())))
# print(H)

good = np.ones(N)
for _ in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    if H[A] == H[B]:
        good[A] = 0
        good[B] = 0
    elif H[A] > H[B]:
        good[B] = 0
    else:
        good[A] = 0
        
    # print(A, B)
    # print(good)
print(int(sum(good)))
# print(good)

Measured memory_bytes: 38372
package main

import "fmt"

func main() {
	// Code for B - Choose Integers
	var A, B, C int
	fmt.Scanf("%d %d %d", &A, &B, &C)

	//fmt.Println(A, B, C)
	var flag int = 0
	for i := 1; i <= 100; i++ {
		temp := (i * A) % B
		//fmt.Println(A)
		if temp == C {
			flag = 1
		}
	}
	if flag == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


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

int main(void)
{
        char A[11], B[11], C[11];
        int  i, j;

        scanf("%s%s%s",A ,B ,C);

        i=strlen(A);
        j=strlen(B);
        if(A[i-1]==B[0]&&B[j-1]==C[0])
                printf("YES\n");

        else
                printf("NO\n");
        return 0;
}


Measured memory_bytes: 128
// Vicfred
// https://atcoder.jp/contests/abc166/tasks/abc166_c
use std::io;

fn main() {
    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let words: Vec<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let n = words[0];
    let m = words[1];

    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let h: Vec<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();


    let mut graph = [0;100005];

    for _ in 0..m {
        let mut line = String::new();

        io::stdin()
            .read_line(&mut line)
            .unwrap();

        let words: Vec<usize> =
            line
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect();

        let a = words[0]-1;
        let b = words[1]-1;

        if h[a] < h[b] {
            graph[a] = 1;
        } else if h[b] < h[a] {
            graph[b] = 1;
        } else {
            graph[a] = 1;
            graph[b] = 1;
        }
    }

    let mut answer = 0;
    for item in 0..n as usize {
        if graph[item] == 0 {
            answer += 1;
        }
    }

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



Measured memory_bytes: 4284
import java.util.Scanner;


public class Main {


//	final int MOD = 1000000007;

//	public static int min = 3000000;

	public static void main(String[] args) {

		int ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

//		long k = sc.nextLong();
		int x = sc.nextInt();
		int y = sc.nextInt();


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

		for(int i = 0; i <= 100; i++) {
			for(int j = 0; j <= 100; j++) {
				if((i * 2) + (j * 4) == y) {
					if(i+j == x)
						f = true;
				}
			}
		}

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

		if(f) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

//		System.out.println(ans);

		sc.close();
	}



}

Measured memory_bytes: 35804
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Magic 2
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  while (a >= b) b *= 2, k--;
  while (b >= c) c *= 2, k--;

  if (k >= 0) puts("Yes");
  else puts("No");
  return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  while (true) {
    int n;
    cin >> n;
    if (n == 0) return 0;
    
    int ans = 0, cnt = 0;
    vector<string> f(n);
    for (int i = 0; i < n; i++) {
      cin >> f.at(i);
      if (f.at(i).at(1) == 'u') cnt++;
      else cnt--;
      if (abs(cnt) == 2) {
        ans++;
        cnt = 0;
      }
    }
    
    cout << ans << '\n';
  }
}


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

using namespace std;
using ll = long long;

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

int main() {
  int n;
  cin >> n;
  int a[n + 1], b[n];
  rep(i, n + 1) cin >> a[i];
  rep(i, n) cin >> b[i];

  ll ans = 0;
  rep(i, n) {
    int k = min(a[i], b[i]);
    a[i] -= k;
    ans += k;
    int s = min(a[i + 1], b[i] - k);
    a[i + 1] -= s;
    ans += s;
  }

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


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

int main (){
  string T;

  cin >> T ;

  int len = T.size();
  for (int i =len-1;i>=0;i--){
    if(T[i] == '?'){
      if(i==len-1) T[i]='D';
      else{
	if(T[i+1] =='P') T[i]='D';
        else if(i != 0 && T[i-1]=='P') T[i]='D';
        else if(i != 0 && T[i-1]=='D') T[i]='P';
	else T[i]= 'P';
      }
    }  
  }

  for(int i = 0; i<len; i++){
    cout << T[i];
  }
  cout << endl;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a ;
  int b = a / 100 ;
  int c = (a - 100 * b) / 10;
  int d = a - 100 * b - 10 * c;
    cout << b + c + d << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static long bignum = 1000000000+7;

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();

		int[] c = new int[n];
		int[][] a = new int[n][m];

		int[] sumR = new int[m];
		for(int i =0;i<m;i++) {
			sumR[i] =0;
		}

		for(int i=0;i<n;i++) {
			c[i]=sc.nextInt();
			for(int j=0;j<m;j++) {
				a[i][j]=sc.nextInt();
				sumR[j]+=a[i][j];
			}
		}
		boolean flag = true;
		for(int i =0;i<m;i++) {
			if(sumR[i]<x) {
				flag = false;
				break;
			}
		}
		if(flag) {
			int minCost = 100000000;

			for(int i=0;i<(1<<n);i++) {
				boolean[] bits = new boolean[n];
				int cost = 0;
				for(int j=0;j<m;j++) {
					sumR[j]=0;
				}
				for(int j=0;j<n;j++) {
					if ((1 & i>>j) == 1) {
						bits[j]=true;
						cost+=c[j];
						for(int k=0;k<m;k++) {
							sumR[k]+=a[j][k];
						}
					}else {
						bits[j]=false;
					}
				}
				boolean check = true;
				for(int j=0;j<m;j++) {
					if(x>sumR[j]) {
						check = false;
						break;
					}
				}
				if(check) {
					if(minCost>cost) {
						minCost = cost;
					}
				}
			}
			System.out.println(minCost);

		}else {
			System.out.println(-1);
		}




	}

	static long divn(int target, int times) {//10_9+7のあまり累乗版
		int sqtimes = (int)Math.sqrt(times);
		long ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		long holder = ans;
		ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans*holder)%(1000000000+7);
		}
		for(int i=0;i<times - sqtimes*sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		return ans;
	}

	static long div(long a) {//10_9+7のあまり
		if(a<0)a+=1000000000+7;
		return a%(1000000000+7);
	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 37788
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int mod=2019;
ll l,r,tmp,Min=0x3f3f3f3f;
int main()
{
	scanf("%lld%lld",&l,&r);//i<j
	if(l+2018<=r)
		printf("0\n");
	else
	{
		for(ll i=l;i<r;i++)
			for(ll j=i+1;j<=r;j++)
				Min=min(Min,(i*j)%mod);
		printf("%lld\n",Min);
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
int main(){
	int n,m,k, cnt = 0;
	cin >>n >> m >> k;
	rep(i, n){
		if(n % (n-i) == 0 && m % (n-i) == 0) {
        	cnt++;
          	if (cnt == k) { 
            	cout << n-i << endl;
              	return 0;
            }
        }
    }	
}


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

int main() {
 
  int N;
  cin >> N;
  
  int ans=100000;
  for(int i=1; i<N; i++){
    int A = i;
    int B = N - A;
    int total=0;
    
    for(int j=0; j<5; j++){
      total += A%10 + B%10;
      A /= 10;
      B /= 10;
    }
    
    if(ans > total){
      ans = total;
    }
  
  }
  
 cout << ans << endl;
  
}


Measured memory_bytes: 3628
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  double L; cin >> L;
  cout << setprecision(16) << (L / 3) * (L / 3) * (L / 3) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <list>
#include <climits>
#include <bitset>
#include <fstream>
#include <algorithm>
#include <functional>
#include <stack>
#include <string>
#include <cmath>
#define fi first
#define se second
#define re register
#define ls i << 1
#define rs i << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007

//#define endl puts("")
#define int long long

using namespace std;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double pi = acos(-1.0);

inline int rd(){
    re int res = 0,flag = 0;char ch;
    if ((ch = getchar()) == '-')flag = 1;
 	else if(ch >= '0' && ch <= '9')res = ch - '0';
	while ((ch = getchar()) >= '0' && ch <= '9')res = (res<<1) + (res<<3) + (ch - '0');
    return flag ? -res : res;
}

void out(int a) {
    if (a < 0) {
        putchar('-');a = -a;
    }
    if (a >= 10) out(a / 10);
    putchar(a % 10 + '0');
}

int n, m, k, t;
const int maxn = 2e5+10;

int a[maxn], b[maxn]; 

signed main(){
//int main() {
	n = rd(), m = rd(), k = rd();
	for (int i = 1; i <= n; i++) a[i] = rd(),a[i]+=a[i-1];
	for (int i = 1; i <= m; i++) b[i] = rd(),b[i]+=b[i-1];
	int ans = 0;
	for (int i = 0; i <= n; i++) {
		if (a[i] > k) break;
		int l = 0, r = m;
		while (l <= r) {
			int mid = l + r + 1 >> 1;
			if (a[i] + b[mid] <= k) {
				ans = max(ans, i + mid);
				l = mid + 1;
			} else r = mid - 1;
		}
	}
	out(ans);
	return 0;
}

Measured memory_bytes: 6672
import sys
N = int(input())
A = [int(input()) for i in range(N)]

if A[0]!=0:
    print(-1)
    sys.exit()
for i in range(N-1):
    if A[i+1]-A[i]>1:
        print(-1)
        sys.exit()

num = 0
for i in range(N-1):
    if A[i]>=A[i+1]:
        num += A[i]
num += A[-1]
print(num)

Measured memory_bytes: 11048
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author IncubatorMan
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define long long long
typedef pair < long , long > pii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
class AABCSwap {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int a,b,c;
	    in>>a>>b>>c;
	    swap(a,b);
	    swap(a,c);
	    out<<a<<" "<<b<<" "<<c<<endl;

	}
};


int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
	AABCSwap solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define EQ(a,b) (abs((a)-(b))<EPS)
using namespace std;
typedef long double D;
const D EPS = 1e-8;

inline D getTime(D dx, D dy, D v, D fpx, D fpy, D fvx, D fvy){
  D px = fpx-dx, py = fpy-dy;
  D a = fvx*fvx + fvy*fvy - v*v;
  D b = 2*fvx*px + 2*fvy*py;
  D c = px*px + py*py;

  if(EQ(a,0)){
    if(EQ(b,0))return EQ(c,0)?0:-1;
    else return (-c/b<-EPS)?-1:-c/b;
  }else{
    D d = b*b - 4*a*c;
    if(d < -EPS)return -1;
    if(EQ(d,0))return (-b/2/a<-EPS)?-1:-b/2/a;
    D t1 = (-b-sqrt(d))/2/a, t2 = (-b+sqrt(d))/2/a;
    if(t1<-EPS)return (t2<-EPS)?-1:t2;
    return t1;
  }
}

int main(){
  int n,m;
  D dx[10], dy[10], v[10], t[10];
  int cnt[10];
  while(scanf("%d%d",&n,&m),n){
    rep(i,n)scanf("%Lf%Lf%Lf",dx+i,dy+i,v+i);

    memset(cnt,0,sizeof(cnt));
    rep(i,m){
      D fpx, fpy, fvx, fvy;
      scanf("%Lf%Lf%Lf%Lf",&fpx,&fpy,&fvx,&fvy);
      
      D minT = 1e10;
      int minID = -1;
      rep(i,n){
	t[i] = getTime(dx[i],dy[i],v[i], fpx,fpy,fvx,fvy);
	if(t[i]>-EPS && minT > t[i] + EPS){
	  minT = t[i]; minID = i;
	}
      }

      cnt[minID]++;
      rep(i,n){
	if(t[i]>-EPS){
	  D sx = fpx+fvx*t[i] - dx[i], sy = fpy+fvy*t[i] - dy[i];
	  D absS = sqrt(sx*sx + sy*sy);
	  if(EQ(absS,0))continue;
	  sx /= absS; sy /= absS;
	  dx[i] += sx * v[i] * minT; dy[i] += sy * v[i] * minT;
	}
      }
    }
    rep(i,n)printf("%d%c",cnt[i],i==n-1?'\n':' ');
  }
}

Measured memory_bytes: 1228
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N; R(N);
    int ma=0;
    int an=0;
    FOR(i,1,N){
        int x;
        R(x);
        an+=x>=ma;
        ma=max(ma,x);
    }
    W(an);
    return 0;
}


Measured memory_bytes: 256
n,t[999],a;
int main(i){
  for(;n*=scanf("%d",&n);puts("")){
    for(i=999;t[i]=i--;);
    for(;n--;t[a]=*t)scanf(" %c %c",&a,t);
    for(scanf("%d", &n);n--;putchar(t[a]))scanf(" %c",&a);
  }
}

Measured memory_bytes: 592
from math import factorial,sqrt,ceil,gcd,floor
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
A,B,N = map(int,input().split())

def yosiki(x):
    return floor(A*x/B)-A*floor(x/B)
if B == 1:
    print(0)
    exit()
elif A == B:
    x = min(N,B-1)
    print(yosiki(x))
    exit()
elif A>B:
    x = min(N,B-1)
    print(yosiki(x))
    exit()
elif A<B:
    x = min(N,B-1)
    print(yosiki(x))
    exit()
# print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
typedef float fl;
typedef long long ll;
int A,B,K;

int main(){
    cin >> K;
    cin >> A >> B;
    for(int i = A; i<=B;i++){
        if(i%K==0){ 
            cout << "OK" << endl;
            return 0;
            }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>

using namespace std;

int main(void) {
	string ans;
	string A, B;
	char a, b;
	cin >> A >> B;
	if (A.size() > B.size()) {
		ans = "GREATER";
	}
	else if (A.size() < B.size()) {
		ans = "LESS";
	}
	else {
		a = A[0];
		b = B[0];
		if (a > b) {
			ans = "GREATER";
		}
		else if (a < b) {
			ans = "LESS";
		}
		else {
			ans = "EQUAL";
		}
	}
	cout << ans << endl;
	return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>

using namespace std;

string S;
int n,m,N,A[100001]={0};

int main()
{
  cin >> S;
  int i,j,k;
  
  N=S.length();
  n=0;
  k=0;
  m=0;
  for(i=0;i<N;i++)
  {
    if(m==0)
    {
      if(S[i]=='R')
      {
        n++;  
      }
      else
     {

        for(j=i-n;j<i-1;j++)
        {
          A[j]=0;        
        }
      
        if(n%2==0)
        {
          A[i-1]+=n/2;
          A[i]+=n/2;
        }
        else
        {
          A[i-1]+=n/2+1;
          A[i]+=n/2;
        }
        n=0;
        m=1;
      
      }
    }
    
    if(m==1)
    {
      if(S[i]=='L')
      {
        k++;
      }
      else if(S[i]=='R')
      {
        for(j=i-1;j>i-k;j--)
      {
        A[j]=0;        
      }
      
      if(k%2==0)
      {
        A[i-k-1]+=k/2;
        A[i-k]+=k/2;
      }
      else
      {
        A[i-k-1]+=k/2;
        A[i-k]+=k/2+1;
      }
      k=0;
      m=0;
        n++;
      }
    }

  }
  i=N;
  for(j=i-1;j>i-k;j--)
      {
        A[j]=0;        
      }
      
      if(k%2==0)
      {
        A[i-k-1]+=k/2;
        A[i-k]+=k/2;
      }
      else
      {
        A[i-k-1]+=k/2;
        A[i-k]+=k/2+1;
      }
  
  for(i=0;i<N;i++)
  {
    cout << A[i] << " " ;
  }
  
  
}

Measured memory_bytes: 1024