akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}
void sorti(vi &a) {sort(a.begin(), a.end());}
void sortll(vll &a) {sort(a.begin(), a.end());}
void sorts(vs &a) {sort(a.begin(), a.end());}

int main() {
  string s;
  ll k;
  cin >> s >> k;
  ll m = s.size();
  if (m < k) {
    cout << 0 << endl;
    return 0;
  }
  if (k == 1) {
    ll ans = s[0] - '0';
    ans += 9 * (m - 1);
    cout << ans << endl;
  }
  else if (k == 2) {
    ll cnt = 0, memo = -1;
    for (ll i = 0; i < m; i++) {
      if (s[i] != '0') {
        cnt++;
        if (cnt == 2) {
          memo = i;
          break;
        }
      }
    }
    ll a, b;
    if (memo == -1) {
      if (s[0] == '1') {
        a = 9;
        b = 9;
        m--;
        memo = 1;
      }
      else {
        a = s[0] - '0' - 1;
        b = 9;
        memo = 1;
      }
    }
    else {
      a = s[0] - '0';
      b = s[memo] - '0';
    }
    ll ans = (m - 1) * (m - 2) / 2 * 81;
    ans += 9 * (m - 1) * (a - 1);
    ans += 9 * (m - memo - 1);
    ans += b;
    cout << ans << endl;
  }
  else {
    string ss;
    for (ll i = 0; i < m; i++) ss.push_back('0');
    ll ans = 243 * (m - 3) * (m - 2) / 2 * (m - 1);
    for (ll a = 1; a <= s[0] - '0'; a++) {
      for (ll b = 1; b < 10; b++) {
        for (ll c = 1; c < 10; c++) {
          for (ll y = 1; y < m - 1; y++) {
            for (ll z = y + 1; z < m; z++) {
              string sss = ss;
              sss[0] = a + '0';
              sss[y] = b + '0';
              sss[z] = c + '0';
              if (sss <= s) {
                ans++;
              }
            }
          }
        }
      }
    }
    cout << ans << endl;
  }
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;

	int val1 = 0;
	if (A > B){
		val1 = A;
		A--;
	} else {
		val1 = B;
		B--;		
	}

	int ans = val1 + max(A, B);

	cout << ans << "\n";


	return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()

r = 0
g = 0
b = 0

for i in S:
  if i == 'R':
    r += 1
  elif i == 'G':
    g += 1
  elif i == 'B':
    b += 1

res = r * g * b

for i in range(N - 1):
  for j in range(i, N - 1):
    k = j + j - i
    if k >= N:
      break
    if S[i] != S[j] and S[i] != S[k] and S[k] != S[j]:
      res -= 1
print(res)

Measured memory_bytes: 9220
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;
 
#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  ll x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  ll n,m;
  std::cin>>n>>m;

  std::vector<std::vector<ll>> graph(n);

  rep(i,0,m){
    ll a,b;
    std::cin>>a>>b;
    a--;b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  std::vector<ll> color(n,-1);

  std::stack<ll> que;

  color[0]=0;
  que.push(0);

  while(!que.empty()){
    ll now=que.top();que.pop();
    for(ll next:graph[now]){
      if(color[next]==-1){
        color[next]=color[now]^1;
        que.push(next);
      }else{
        if(color[next]==color[now]){
          std::cout<<n*(n-1)/2-m<<"\n";
          return 0;
        }
      }
    }
  }

  ll black=0;
  rep(i,0,n)if(color[i]==0)black++;

  std::cout<<black*(n-black)-m<<"\n";

  return 0;
}


Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100505;
ll a[N], sum[N];
map<ll, ll>mp;
ll n, m;
ll ans = 0;
int main(){
    mp.clear();
    scanf("%lld%lld", &n, &m);
    sum[0] = 0;
    for(int i = 1; i <= n; ++i){
        scanf("%lld", a+i);
        sum[i] = (sum[i-1] + a[i]) % m;
    }
    //for(int i = 1; i <= n; ++i) sum[i] %= m;
    mp[0] = 1;
    for(int i = 1; i <= n; ++i){
            /*
        if(mp.count(sum[i])){
            ans = ans + mp[sum[i]];
            mp[sum[i]] += 1;
        }else{
            mp[sum[i]] = 1;
        }
        */
        ans = ans + mp[sum[i]];
        mp[sum[i]] += 1;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 5760
#include <stdio.h>

int main(void){
    int D,N,i,X,ans;
    scanf("%d %d",&D,&N);
    
    ans = 0;
    X = 1;
    for(i = 0;i < D;i++){
        X *= 100;
    }
    if(N <= 99){
        printf("%d\n",X * N);
    }else{
        printf("%d\n",X * 101);
    }
}

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

int main(){
	ll N;
	cin >> N;
	vector<ll> a(N);
	vector<ll> b(N);
	rep(i,N){
		cin >> a[i];
	}
	rep(i,N){
		cin >> b[i];
	}
	ll suma = 0;
	ll sumb = 0;
	rep(i,N){
		suma += a[i];
		sumb += b[i];
	}
	if(suma > sumb){
		cout << "No" << endl;
		return 0;
	}
	
	ll time = sumb - suma;
	
	ll count1 = 0;
	ll count2 = 0;
	rep(i,N){
		if (a[i] > b[i]) {
			count1 += a[i] - b[i];
		}
		if (a[i] < b[i]) {
			count2 += (b[i] - a[i] + 1) / 2;
		}
	}
	
	if(count1 <= time && count2 <= time){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
const int MAXN = 505;
int C[MAXN], F[MAXN], S[MAXN];
int N;

int main()
{
	scanf("%d", &N);
	for(int i = 1; i < N; ++i)
		scanf("%d%d%d", &C[i], &S[i], &F[i]);
	for(int i = 1; i <= N; ++i)
	{
		int time = 0;
		for(int j = i; j < N; ++j)
		{
			time  = std::max(S[j], time);
			int R = (time-S[j]) % F[j];
			if(R) time += F[j]-R;
			time += C[j];
		}
		printf("%d\n", time);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

llint WarshallFloyd(int N, vector< vector<int> > &G){
    llint ans = 0;
    vector< vector<int> > G_str(G);
    REP(i, N) REP(j,N) REP(k, N){
        if(i == j || i == k) continue;
        if(G[j][k] > G[j][i] + G[i][k]){
            return -1;
        }else if(G[j][k] == G[j][i] + G[i][k]){
            G_str[j][k] = 0;
        }
    }
    // REP(i, N){
    //     REP(j, N){
    //     cout << G_str[i][j] << " ";
    //     }
    //     cout << "\n";
    // }
    REP(i, N)REP(j, N){
        ans += G_str[i][j];
    }
    return ans/2;
}

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

    int N;
    cin >> N;
    vector< vector<int> > G(N, vector<int>(N));
    REP(i, N)REP(j, N){
        cin >> G[i][j];
    }
    cout << WarshallFloyd(N, G) << "\n";
    
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
// make pair, tuple
// __gcd(int, int)
// bool isPrime(int n){
//       if(n <= 1)return false;
//       if(n <= 3)return true;
//       if(n % 2 == 0 || n % 3 == 0)return false;
//       for(int i = 5;i * i <= n;i += 6){
//             if(n % i == 0 || n % (i + 2) == 0)return false;
//       }
//       return true;
// }
// int countSubString(string s, string temp){
//       int ans = 0;
//       size_t f = s.find(temp);
//       while(f != string::npos){
//             ans++;
//             f = s.find(temp, f + 1);
//       }
//       return ans;
// }

int main(){
    int n;cin >> n;
    string s;cin >> s;
    int ans = 1;
    for(int i = 1;i < n;i++){
        if(s[i] != s[i - 1])ans++;
    }
    cout << ans;
}

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

s = 0

import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

g = gcd(*A)

if K % g == 0 and max(A)>=K:
    ans = 'POSSIBLE'
else:
    ans = 'IMPOSSIBLE'

print(ans)

Measured memory_bytes: 14100
// Undone
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
public class Program {
  public static void Main() {
    string S = ReadStr();

    // 101010~~~
    int ans1 = 0;
    for (int i = 0; i < S.Length; i++) {
      if ((i % 2 == 0 && S[i] == '0') || (i % 2 == 1 && S[i] == '1')) {
        ans1++;
      }
    }

    // 010101~~~
    int ans2 = 0;
    for (int i = 0; i < S.Length; i++) {
      if ((i % 2 == 0 && S[i] == '1') || (i % 2 == 1 && S[i] == '0')) {
        ans2++;
      }
    }

    Console.WriteLine(Math.Min(ans1, ans2));
  }

  private static List<int> _var;
  public static int cin() { if (_var == null || _var.Count() == 0) { _var = Console.ReadLine().Split(' ').Select(int.Parse).ToList<int>(); } int ans = _var[0]; _var.RemoveAt(0); return ans; }
  public static void Swap<T>(ref T a, ref T b) {T temp = a;a = b;b = temp;}
  public static string ReadStr() { return Console.ReadLine(); }
  public static int ReadInt() { return int.Parse(Console.ReadLine()); }
  public static double ReadDouble() { return double.Parse(Console.ReadLine()); }
  public static long ReadLong() { return long.Parse(Console.ReadLine()); }
  public static char ReadChar() { return Console.ReadLine()[0]; }
  public static string[] ReadStringArray() { return Console.ReadLine().Split(' '); }
  public static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
  public static double[] ReadDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
  public static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
  public static char[] ReadCharArray() { return Console.ReadLine().ToArray(); }
  public static string[] ReadCharStringArray() { return Console.ReadLine().ToCharArray().Select(c => c.ToString()).ToArray(); }
}


Measured memory_bytes: 13244
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - Common Subsequence
 */

#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 */

const int MAX_N = 2000;
const int MAX_M = 2000;
const int MOD = 1000000007;

/* typedef */

typedef long long ll;
typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

int ss[MAX_N], ts[MAX_M];
int dsums[MAX_N + 1][MAX_M + 1];

/* subroutines */

inline void addmod(int &a, int b) { a = (a + b) % MOD; }

/* main */

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

  for (int i = 0; i < n; i++) scanf("%d", ss + i);
  for (int j = 0; j < m; j++) scanf("%d", ts + j);

  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      int d = (ss[i] == ts[j]) ? (dsums[i][j] + 1) % MOD : 0;

      dsums[i + 1][j + 1] = d;
      addmod(dsums[i + 1][j + 1], dsums[i][j + 1]);
      addmod(dsums[i + 1][j + 1], dsums[i + 1][j]);
      addmod(dsums[i + 1][j + 1], MOD - dsums[i][j]);
    }

  printf("%d\n", (dsums[n][m] + 1) % MOD);
  return 0;
}


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

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define ll long long
#define bit __builtin_popcountll
#define sqr(x) (x) * (x)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
#define debug(x) cout << #x <<" = " << x << endl
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define printvpair(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i].first  <<" " << v[i].second << endl;
#define printv(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i] << " "; cout << endl;

using namespace std;

typedef pair<int, int> pii;

const double eps = 1e-9;
const double pi = acos(-1.0);
const int INF = 1000000000;

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

const int N = 101;
int sum,a[N];
int main() {
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	forn(i,n){
		cin >> a[i];
		sum += a[i];
	}
	int m;
	cin >> m;
	forn(i,m){
		int x,y;
		cin >> x >> y;
		cout << sum - a[x - 1] + y << endl;
	}
  	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a = a[::-1]
b = b[::-1]
ans = 0
for i, bi in enumerate(b):
    ans += min(a[i], b[i])
    remain = max(0, b[i] - a[i])
    ans += min(a[i + 1], remain)
    a[i + 1] = max(0, a[i + 1] - remain)
print(ans)

Measured memory_bytes: 18624
N,K = [int(i) for i in input().split()]
H = sorted([int(input()) for i in range(N)])
ans = H[K - 1] - H[0]
for i in range(N - K + 1):
    t = H[K + i - 1] - H[i]
    if ans > t:
        ans = t
print(ans)

Measured memory_bytes: 8200
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, X): (i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let ans = (0..(N + 1)).map(|i|
        (i, (0..(N - i + 1)).find(|j| 10000 * i + 5000 * j + 1000 * (N - i - j) == X))
    ).find(|&(_, j)| j != None)
    .map(|(i, j)| (i, j.unwrap()))
    .map_or("-1 -1 -1".to_string(), |(i, j)| format!("{} {} {}", i, j, N - i - j));

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


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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

int main() {

	IOS

	int h, w, k;
	cin >> h >> w >> k;

	char c[h][w];
	int black = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> c[i][j];

			if (c[i][j] == '#')
				black++;
		}
	}


	int res = 0;
	int cx = 0;

	for (int row_mask = 0; row_mask < 1<<h; row_mask++) {
		set<pair<int, int>> us;
		int rm = row_mask, ri = 0;

		while (rm > 0) {
			if (rm & 1) {
				for (int j = 0; j < w; j++)
					if (c[ri][j] == '#')
						us.insert({ri, j});
			}

			ri++;
			rm >>= 1;
		}

		// cout << row_mask << " " << us.size() << endl;

		for (int col_mask = 0; col_mask < 1<<w; col_mask++) {
			set<pair<int, int>> ust = us;
			int cm = col_mask, ci = 0;

			while (cm > 0) {
				if (cm & 1) {
					for (int i = 0; i < h; i++)
						if (c[i][ci] == '#')
							ust.insert({i, ci});
				}

				ci++;
				cm >>= 1;
			}

			// cout << row_mask << " " << col_mask << " " << ust.size() << endl;

			if (black - ust.size() == k)
				res++;
		}
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <cstring>
#define rep(i,o,u) for(int i = o;i <= u; i++)
using namespace std;

int a[101];
int main(){
	int n;
	cin >> n;
	rep(i,1,n) cin >> a[i];
	int ans = 0;
	rep(i,1,n){  
		int mn = i;
		rep(j,i+1,n){
			if(a[mn] > a[j]){
				mn = j;
			}
		}
		swap(a[i],a[mn]);
		if(i != mn){
			ans++;
		}
	}
	rep(i,1,n){ cout << a[i];if(i != n) cout << " ";}
	cout << endl;
	cout << ans << endl;
	return 0;
}

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

#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 1e3 + 3;

signed main(){
    int n;
    cin >> n;
    cout << n * (n-1) / 2 - n/2 << endl;
    int h = !(n & 1);
    for(int i=1; i<=n; i++)
        for(int j=i+1; j<=n; j++){
            if(j == n-i+h) continue;
            cout << i << " " << j << endl;
        }
    
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
using namespace std;
#include<cstring>
int main()
{
	string a;cin>>a;
	int la=a.length();
	cout<<a[0]<<la-2<<a[la-1]<<endl;
	return 0;
}//再次与时间赛跑
//19.3.25 21:47 

Measured memory_bytes: 256
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 998244353
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}

void solve(){
	ll n , s;
	cin>> n >> s ;
	vector<ll>arr(n+1,0);
	ll dp[n+1][s+1];
	for(ll i=1;i<=n ;i++)cin>>arr[i];
	for(ll i=0;i<=n ;i++){
		for(ll sum=0 ; sum<=s ;sum++){
			if(i==0)dp[i][sum]=0;
			if(sum==0)dp[i][sum]=1;
			if(i==0){
				continue;
			}
			if(arr[i]>sum)dp[i][sum]=(2*dp[i-1][sum])%mod;
			else{
				dp[i][sum]=(2*dp[i-1][sum]%mod + dp[i-1][sum-arr[i]]%mod)%mod;
				dp[i][sum]%=mod;
			}
		
		}
	}

	// ll ans=0;
	// for(ll i=1;i<=s ;i++)ans+=dp[n][i];
	// cout<<ans<<endl;
	cout<<dp[n][s]<<endl;
}
int main(){
	//mahakal(),fast;
	ll t=1 ;
	// cin>> t;
	while(t--)solve();

	return 0;
}

Measured memory_bytes: 73948
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
long long int A, B, C; 
cin >> A >> B >> C; 
if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0){
cout << 0 << endl; 
}
else{
cout << min({A * B, B * C, C * A}) << endl; 
}
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.lang.*;

class Main{
  public static void main(String[] args) throws IOException{
    Scanner scan=new Scanner(System.in);
    int n=Integer.parseInt(scan.next());
    int[] numbers=new int[n];
    for(int i=0;i<numbers.length;i++){
      numbers[i]=Integer.parseInt(scan.next());
    }

    int count=0;
    for(int i=0;i<numbers.length;i++){
      if(numbers[i]==2){
        count++;
        continue;
      }else if(numbers[i]<2 || numbers[i]%2==0){
        continue;
      }
      int j=3;
      while(j<=Math.sqrt(numbers[i])){
        if(numbers[i]%j==0){
          break;
        }
        j+=2;
      }
      if(j>Math.sqrt(numbers[i])){
        count++;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 41044
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n; cin >> n;
  vector<int> mochi(n);
  for(int i=0;i<n;i++){
    cin >> mochi.at(i);
  }
  sort(mochi.begin(), mochi.end());
  int count=1;
  for(int i=0;i<n-1;i++){
    if(mochi.at(i+1) > mochi.at(i))
      count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main{
	static int ans_sum=0;
	static int ko=0;
	static int sum=0;
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		while(true){
			ko=sc.nextInt();
			sum=sc.nextInt();
			if(ko==0 && sum==0) {
				//pl(0);
				break;
			}
			ans_sum=0;
			dfs(0,sum,sum);
			pl(ans_sum);
		}
	}
	public static void dfs(int kettei_num,int rest,int ika) {
		if(kettei_num==ko) {
			if(rest==0) {
				ans_sum++;
			}
			else {
				//
			}
		}
		if(rest<0) {
			return ;
		}
		else {
			for(int i=Math.min(ika,9); i>=0; i--) {
				dfs(kettei_num+1,rest-i,i-1);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


Measured memory_bytes: 24252
<?PHP
list($item_num , $weight_upper)=explode(" ",  fgets(STDIN));
for($i=0;$i<$item_num;++$i){
    fscanf(STDIN,"%d %d ",$x,$y);
    $weight[$i]=$x;
    $value[$i]=$y;
}

$dp = [];
foreach (range(0, $item_num-1) as $item_index) {
    $item_value = $value[$item_index];
    $item_weight = $weight[$item_index];
    foreach (range(1, $weight_upper) as $weight_index) {
        $zantei=$dp[$item_index-1][$weight_index]?? 0;
        
        if($weight[$item_index] <= $weight_index) {
            $new=($dp[$item_index-1][$weight_index-$weight[$item_index]] +$item_value);
            $dp[$item_index][$weight_index]=$zantei >=$new ? $zantei:$new;
        }else{    
            $dp[$item_index][$weight_index] = $zantei;
        };
        
    }
}
echo $dp[(int)$item_num-1][(int)$weight_upper];


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K, X;
    cin >> K >> X;
    for (int i = -K + 1; i <= K - 1; i++) {
        cout << X + i << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
//
// Created by Huang,Zhiqiang on 2018/7/28.
//

#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int n;
    int ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int t;
        cin >> t;
        ans += t - 1;
    }
    cout << ans << endl;
}

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

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

const double pi = 3.1415926;

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

    int n;
    cin >> n;
    cout << setprecision(10) << fixed << pi * 2 * n << endl;
    
    return 0;
}


Measured memory_bytes: 3800
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int a, b, c;
  int k, t = 1;

  cin >> a >> b >> c >> k;

  for(int i=0;i<k;i++) t *= 2;

  cout << a + b + c + max({a, b, c}) * (t - 1) << endl;

  return 0;
}


Measured memory_bytes: 256
while (n=gets.to_i)!=0
  mt=Array.new(n).map{Array.new(n,0)}
  y,x=n/2,n/2-1
  (1..n**2).each do |i|
    y,x=(y+1)%n,(x+1)%n
    if mt[y][x]!=0
      y,x=(y+1)%n,(x-1)%n 
    end
    mt[y][x]=i
  end
  mt.each do |l|
    puts l.map{|j| printf("%4d",j)}.join
  end
end

Measured memory_bytes: 8824
//@author rohit_0801

 
#include <bits/stdc++.h>
#define ll int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define debug 0
 
using namespace std;
const ll MOD = 1000000007;
const ll MODD = MOD-1;
 
ll ar[900780],has[1234567];

string strng[505];

vector<ll> vec,pec;

map<ll,ll> mark;

 
 
int main() {
	//srand(time(0));
	ll a,b,n,m,flag=0,r,t,u,v,w,x,y,z,k,res=0,d,maxm=-999999999,i,j,ct,h,ans=0,s,l,e,f,p,minm=999999999,c,type,q,len,siz,g;
 	
 	map<ll,ll>::iterator it,jt;
 	
 	string str="",ptr="";
 	char ch;
 	
 	cin>>n>>m;
 	
 	for(i=0;i<n;i++){
 		cin>>strng[i];
	 }
	 
	 for(i=0;i<n;i++){
	 	flag=0;
	 	ar[i]=0;
	 	for(j=0;j<m;j++){
	 		if(strng[i][j]!='.'){
	 			flag=1;
			 }
			 has[j]=0;
		 }
		 
		 if(flag==0){
		 	ar[i]=1;
		 }
	 }
	 
	 for(i=0;i<m;i++){
	 	flag=0;
	 	for(j=0;j<n;j++){
	 		if(strng[j][i]!='.'){
	 			flag=1;
			 }
		 }
		 
		 if(flag==0){
		 	has[i]=1;
		 }
	 }
	 
	 for(i=0;i<n;i++){
	 	if(ar[i]==0){
	 		for(j=0;j<m;j++){
	 			if(has[j]==0){
	 				cout<<strng[i][j];
				 }
		 	}
		 	cout<<"\n";
		}
	 	
	 }
 	
		
	return 0;
}  

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)

int main(int argc, char const *argv[])
{
	int n, k; cin >> n >> k;
	vector<ll> x(n); {
		rep(i, n) cin >> x[i];
	}

	ll ans = 1e18;
	rep(i, n - k + 1) {
		int l = i, r = i + k - 1;
		// printf("l %d r %d\n", l, r);
		if (x[l] * x[r] >= 0) {
			ans = min(ans, max(abs(x[l]), abs(x[r])));
		} else {
			ll ma = max(abs(x[l]), abs(x[r]));
			ll mi = min(abs(x[l]), abs(x[r]));
			ans = min(ans, mi * 2 + ma);
		}
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 1152
N=int(input())#奇数
D=[int(x) for x in input().split()]#ダムの貯水量
Ame=[0]
for i in range(N):
  Ame[0] +=D[i]*((-1)**i)
for i in range(1,N):
  Ame +=[2*D[i-1]-Ame[i-1]]
print(*Ame)

Measured memory_bytes: 14092
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n;
  vi l(n);

  vi dp(1001);
  
  REP(i,n){
    cin>>l[i];
    dp[l[i]]++;
  }
  sort(l.begin(), l.end());






  for(int i=0;i<n;i++){
    for(int j=i+2;j<n;j++){
      
        int k=l[i];
        if (k<=l[j]-l[i]){
          k=l[j]-l[i]+1;
        }
        auto Iter2 = lower_bound(l.begin(),l.end(), k);
        int kw=Iter2-l.begin();
        kw=max(kw,i+1);
        ans+=max(0,j-kw);
    }
  }

/*













  vi rsum(1001);
  ans=0;

  REP(i,1001){
    ans+=dp[i];
    rsum[i]=ans;
  }
  ans=0;




  
  for(int i=0;i<1001;i++){
    if (dp[i]==0)continue;
    dp[i]-=1;
    for(int j=i;j<1001;j++){
      if (dp[j]==0){
        continue;
      }else{
        
        dp[j]-=1;


        //int k=max(j-i,i);
        //cout<<i<<" "<<j<<endl;
        

        int k=i;
        if (k<=j-i){
          k=j-i+1;
        }

        if (j-k>=2){
          ans+=rsum[j-1]-rsum[k+1];
          if (dp[j]>0)ans++;
          if (dp[i]>0){
            if (i==k)ans++;
          }

        }
        if (j-k==1){
          ans+=dp[k];
          ans+=dp[j];
          /*
          if (i==k){
            if (dp[i]>0)ans++;
          }else{
            ans+=rsum[j]-rsum[k+1];
          }
          */
        /*
        }
        if (j==k){
          if (dp[j]>0)ans++;
        }
        
        */
       /*
       int w=1;
       if ((i==k)|(k==j))w=4;
       if ((i==k)&(k==j))w=27;

        
        for(;k<=j;k++){
          if (dp[k]>0){
            dp[i]++;
            dp[j]++;
            ans+=dp[k]*dp[i]*dp[j]/w;
            dp[i]--;
            dp[j]--;
            //cout<<i<<" "<<k<<" "<<j<<endl;
          }
        }
        

        
        dp[j]+=1;
      }


    }

    dp[i]+=1;
  }
    */




cout<<ans<<endl;

  return 0;
}



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

#define FOR(i, a, b) for (int (i) = (a); (i) < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cerr << #x << " " << x << endl
#define eb emplace_back
#define _ << " " <<
typedef long long ll;
typedef std::pair<int, int> ii;
#define X first
#define Y second
#define double long double
typedef double db;
using namespace std;

const int MaxN = 200100;
const int Mod = 1e9 + 7;

int a[MaxN], N;

void solve() {

}

void load() {
  cin>>N;
  int ret = 0, cnt = 0;
  REP(i, N) {
    cin>>a[i];
    if (i == 0) {cnt = 1; continue;}
    else if (a[i - 1] == a[i]) {
      cnt++;
    }
    else{
      ret += cnt / 2;
      cnt = 1;
    }
  }

  ret += cnt/2;

  cout << ret << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  load();	
  solve();
  return 0;
}




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


using namespace std;

int n;
int maxW;
vector<pair<int,int>> vec;
long long meme[105][100007];


long long solve(int index, int remain){
    if(index==n){
        return 0;
    }
    
    if(meme[index][remain]!=-1){
        return meme[index][remain];
    }
    long long res1;
     res1 = solve(index+1,remain);
    long long res2 =0;
    if(remain>=vec[index].first){
        res2 = solve(index+1,remain-vec[index].first) + vec[index].second;
    }
    return meme[index][remain] = max(res1,res2);
}

int main(){
    cin>>n>>maxW;
    memset(meme,-1,sizeof(meme));
    int one,two;
    for(int i = 0 ; i<n ; i++){
        cin>>one>>two;
        vec.push_back(make_pair(one,two));
    }
    long long go = solve(0, maxW);
    cout<<go<<endl;
    return 0;
}

Measured memory_bytes: 85632
import java.util.Scanner;
 
class Main {
 
	public static void main(String[] args) {
		
		Scanner stdIn = new Scanner(System.in);
		
		int K = stdIn.nextInt();
		int X = stdIn.nextInt();

		if( X <= 500*K ) {
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
    
}

Measured memory_bytes: 22612
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
vector<ll> A;
map<ll, int> cnt;
int main() {

  cin >> N;
  A.resize(N);
  for (auto &val : A){
    cin >> val;
    cnt[val]++;
  }
  sort(A.begin(), A.end());
  ll result = 0;
  ll a = 0;
  for (const auto &val : cnt){
    if (val.second >= 4){
      result = max(result, val.first * val.first);
    }
    if (val.second >= 2){
      result = max(result, val.first * a);
      a = max(a, val.first);
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 7296
//93 B - Small and Large Integers 2018/04/07
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    uint64 a , b;
    int k;
    cin >> a >> b >> k;
    uint64 l_max;
    for(int i=a;i<=k+a-1;++i){
        if(i>b) {l_max=b; break;}
        cout << i << endl;
    }
    l_max=k+a-1;
    for(int j=max(l_max+1,b-k+1);j<=b;++j){
        if(j<a) continue;
        cout << j << endl;
    }
}


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

using namespace std;

#define EPS 1e-10
#define equal(a,b) (fabs(a-b) < EPS)
#define lt(a,b) (a-b < -EPS)

struct Point{
    double x,y;

    Point(){}
    Point(double x,double y) : x(x),y(y) {}

    Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y); }
    Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); }
    Point operator * (const double &k)const{ return Point(x*k,y*k); }
};

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

#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
typedef Point Vector;

int ccw(Point p0,Point p1,Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if(cross(a,b) > EPS) return COUNTER_CLOCKWISE;
    if(cross(a,b) < -EPS) return CLOCKWISE;
    if(dot(a,b) < -EPS) return ONLINE_BACK;
    if(norm(a) < norm(b)) return ONLINE_FRONT;
    return ON_SEGMENT;
}

struct Segment{
    Point s,t;
    Segment(){}
    Segment(Point s,Point t) : s(s),t(t) {}
};

typedef Segment Line;

Line getPerpendicularBisector(const Point &a,const Point &b){
    double cx = (a.x + b.x) / 2.0;
    double cy = (a.y + b.y) / 2.0;
    Point p = Point(cx + (a.y - b.y), cy + (b.x - a.x));
    return Line(Point(cx,cy),p);
}

Point crosspointLL(const Line &a,const Line &b){
    Vector va = a.t-a.s, vb = b.t-b.s;
    double d = cross(vb,va);
    if(abs(d) < EPS) return b.s;
    return a.s+va*cross(vb,b.t-a.s)*(1.0/d);
}

#define prev(G,i) (G[(i-1+G.size())%G.size()])
#define curr(G,i) (G[i%G.size()])
#define next(G,i) (G[(i+1)%G.size()])
typedef vector<Point> Polygon;

Polygon convex_cut(const Polygon &pg,const Line &l){
    Polygon res;
    for(int i = 0 ; i < (int)pg.size() ; i++){
	Point cp = curr(pg,i), np = next(pg,i);
	if(ccw(l.s,l.t,cp) != -1) res.push_back(cp);
	if(ccw(l.s,l.t,cp)*ccw(l.s,l.t,np) < 0){
	    res.push_back(crosspointLL(Line(cp,np),l));
	}
    }
    return res;
}
	
double area(const Polygon &pg){
    double res = 0;
    for(int i = 0 ; i < (int)pg.size() ; i++){
	res += cross(pg[i],next(pg,i));
    }
    return abs(res)/2.0;
}

int main(){
    int N,M;
    while(cin >> N >> M, N){
	Polygon pg(N);
	for(int i = 0 ; i < N ; i++){
	    cin >> pg[i].x >> pg[i].y;
	}
	vector<Point> ps(M);
	for(int i = 0 ; i < M ; i++){
	    cin >> ps[i].x >> ps[i].y;
	}
	for(int i = 0 ; i < M ; i++){
	    Polygon p = pg;
	    for(int j = 0 ; j < M ; j++){
		if(i == j) continue;
		p = convex_cut(p,
			       getPerpendicularBisector(ps[i],ps[j]));
	    }
	    printf("%.15f\n",area(p));
	}
    }
    return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int K;
      string S;
      cin >> K >> S;
     
    if (K >= S.size()) {
      cout << S << endl;
    }
      
      else if (K < S.size()) {
       S = S.substr(0, K);
         cout << S << "..." << endl;
         }
    }

Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second

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


signed main(){
	
	ll a,b,k,n,cnt = 0;
	cin >> a >> b >> k;
	n = max(a,b);
	
	rep(i,0,n){
		if(a % (n-i) == 0 && b % (n-i) == 0){
			cnt++;
			//cout << n-i << endl;
		}
		if(cnt == k){
			cout << n-i << endl;
			break;
		}
	}
	return 0;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        long a,b,c;
        
        a = sc.nextLong();
        b = sc.nextLong();
        c = sc.nextLong();
        
        if(a == b) System.out.println(c);
        else if(b == c) System.out.println(a);
        else System.out.println(b);
        
        sc.close();
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  string a;
  cin >> a;

  string b;
  cin >> b;

  string ans;

  for(int i = 0; i<2*n; i++){
    if(i%2==0){
      ans += a.at(i/2);
    }
    if(i%2==1){
      ans += b.at(i/2);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<string.h>
#include<math.h>
#include<queue>
#include<cstring>
#include<new>
#include<cmath>
#include<sstream>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define sz size()
#define em empty()
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define sett(a,b) memset(a,b,sizeof(a))
#define copy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
const int c[]={0,3,5,7};
int s[10];
int main(){
	int n,ans=0;
	cin>>n;
	fo(i1,0,4) fo(i2,0,4) fo(i3,0,4) fo(i4,0,4) fo(i5,0,4) fo(i6,0,4) fo(i7,0,4) fo(i8,0,4) fo(i9,0,4){
		s[0]=c[i1];s[1]=c[i2];s[2]=c[i3];s[3]=c[i4];s[4]=c[i5];s[5]=c[i6];s[6]=c[i7];s[7]=c[i8];s[8]=c[i9];
		int x=0,x3=0,x5=0,x7=0;
		fo(i,0,9)x=x*10+s[i];
		if(x<=n){
			int f=8;
			fo(i,0,9)if(s[i]!=0){f=i;break;}
			fo(i,0,9){
				if(s[i]==3)x3++;
				if(s[i]==5)x5++;
				if(s[i]==7)x7++;
			}
			bool v=1;
			fo(i,f,9)if(s[i]==0)v=0;
			if(v&&x3&&x5&&x7)ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
using namespace std;


int main()
{
	int n;
	cin >> n ;
	long *R = new long[n];
	for(int i = 0 ; i < n; i++) cin >> R[i] ;
	long maxv = R[1] - R[0];
	long minv = R[0];
	for(int i = 1; i < n ; i++){
		if( maxv <( R[i] - minv) ) maxv = R[i] - minv;
		if(minv > R[i]) minv = R[i];
	}
	cout << maxv <<endl;
	return 0;
}





Measured memory_bytes: 4672
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;
typedef long long ll;
ll N, M;
struct drinks{
    ll A;
    ll B;
};
drinks drink[100000];
ll ans = 0;
ll total = 0;


int main(void) {
    // insert code here...
    cin >> N >> M;
    pair<ll, ll> item[N];
    for(int i = 0; i < N; i++){
        cin >> item[i].first >> item[i].second ;
    }
    
    sort(item, item + N);
//    for(int i = 0; i < N; i++){
//        cout << item[i].first << endl;
//    }
    
    for(int i = 0; i < N; i++){
        if((total + item[i].second) < M){
            total += item[i].second;
            ans += item[i].first*item[i].second;
        }else{
            ans += item[i].first*(M-total);
            break;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys


def f(b: int, n: int) -> int:
    if n < b:
        return n
    return f(b, n // b) + n % b


def sqrt(n: int):
    lb = 0
    hb = n + 1
    while hb - lb > 1:
        m = (lb + hb) // 2
        if m * m <= n:
            lb = m
        else:
            hb = m
    return lb


def solve(n: int, s: int):
    if s == n:
        print(n + 1)
        return
    sn = sqrt(n)
    for b in range(2, sn + 1):
        if f(b, n) == s:
            print(b)
            return
    for p in reversed(range(1, sn + 1)):
        q = s - p
        if q < 0:
            continue
        b, r = divmod(n - q, p)
        if r != 0 or b <= p:
            continue
        if f(b, n) == s:
            print(b)
            return
    print(-1)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    s = int(next(tokens))  # type: int
    solve(n, s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
int a,b;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>a>>b;
	if (b%a==0) cout<<b+a;
	else cout<<b-a;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a, b, c;
	int t;
	while(~scanf("%d %d %d", &a, &b, &c))
	{
		if(a < b)
		{
			t = a;
			a = b;
			b = t;
		}
		if(a < c)
		{
			t = a;
			a = c;
			c = t;
		}
		if(a == (b + c))
			printf("Yes\n");
			else
				printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, G[MAX][MAX];

void dijkstra(){
  int min, i, v, u;
  int d[MAX], color[MAX];

  for( i = 0 ; i < n ; i++ ){
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;

  while(1){
    min = INFTY;
    u = -1;
    for( i = 0 ; i < n ; i++ ){
      if( min > d[i] && color[i] != BLACK ){
	u = i;
	min = d[i];
      }
    }
    if( u == -1 ) break;
    color[u] = BLACK;
    for( v = 0 ; v < n ; v++ ){
      if( color[v] != BLACK && G[u][v] != INFTY ){
	if( d[v] > d[u] + G[u][v] ){
	  d[v] = d[u] + G[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }
  for( i = 0 ; i < n ; i++ ){
    printf("%d %d\n",i,(d[i]==INFTY ? -1 : d[i]));
  }  
}

int main(){
  int i, j;
  scanf("%d",&n);
  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n ; j++ ){
      G[i][j] = INFTY;
    }
  }

  int k, c, u, v;
  for( i = 0 ; i < n ; i++ ){
    scanf("%d%d",&u, &k);
    for( j = 0 ; j < k ; j++ ){
      scanf("%d%d",&v,&c);
      G[u][v] = c;
    }
  }

  dijkstra();

  return 0;
}



Measured memory_bytes: 2112
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

using namespace std;

int main(void){
  int X,Y,Z;
  int ans;

  cin>>X>>Y>>Z;
  ans = (X-Z)/(Y+Z);
  cout<<ans<<endl;
  
  return 0;
}



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

int main(){
	int n,m;
	char s[1000005];
	while(scanf("%d",&n),n!=0){
		scanf("%d%s",&m,s);
		vector<int> p;
		int i=0;
		while(i<m-2){
			int count=0;
			while(s[i]=='I'&&s[i+1]=='O'&&s[i+2]=='I'){ count++; i+=2; if(i>=m-2) break;}
			if(count) p.push_back(count);
			i++;
		}
		int res=0;
		for(int i=0;i<p.size();i++) res+=max(0,p[i]-n+1);
		printf("%d\n",res);
	}
}

Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod (ll)1e9+7
/*ll binpow(ll a, ll b) {
    a %= mod;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}*/
int main() {
    int t=1;
    //cin>>t;
    while(t--)
    {
        int i;
        vector<int>a(5);
        int ans;
        for(i=0;i<5;i++)
        {
            cin>>a[i];
            if(a[i]==0) ans=i+1;
        }
        cout<<ans;
    }
	return 0;
}

Measured memory_bytes: 3528
#include <stdio.h>
char exchange(char c) {
      if('A' <= c && c <= 'Z') {
          return c + ('a' - 'A');
      }
      if('a' <= c && c <= 'z') {
          return c - ('a' - 'A');
      }
      else return c;
  }
int main(void){
   char ch;
   while(1){
   scanf("%c" ,&ch);
  // printf("%c", ch);
   printf("%c" , exchange(ch));
   if(ch == '\n') break;
   }
  return 0;
}



Measured memory_bytes: 2036
fun main(args: Array<String>) {
    val (A, B) = listOfLong()
    fun f(v: Long): Long {
        val c = (v + 1) / 2
        val result = c % 2
        return if (v % 2 == 0L) result xor v else result
    }
    val ans = f(A - 1) xor f(B)
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map(String::toLong)

Measured memory_bytes: 37992
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var strs = Console.ReadLine().Split();
            var A = int.Parse(strs[0]);
            var B = int.Parse(strs[1]);
            var C = int.Parse(strs[2]);

            var sum = new int[3];
            sum[0] = A * 10 + B + C;
            sum[1] = A + B * 10 + C;
            sum[2] = A + B + C * 10;

            Console.WriteLine(sum.Max());
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>

using namespace std;

int main(void){
	int n, m;
	while (cin >> n >> m){
		if (n==0 && m==0){
			return 0;
		}
		int *taro = new int[n];
		int *hanako = new int[m];
		int t_sum=0, h_sum=0;
		for (int i = 0; i<n; ++i){
			cin >> taro[i];
			t_sum += taro[i];
		}
		for (int i=0; i<m; ++i){
			cin >> hanako[i];
			h_sum += hanako[i];
		}
		int t,h,t_card,h_card;
		bool flag = false;
		for (int i=0; i<n; ++i){
			for (int j=0; j<m; ++j){
				h = h_sum - hanako[j] + taro[i];
				t = t_sum - taro[i] + hanako[j];
				if (t == h){
					flag = true;
					t_card = taro[i];
					h_card = hanako[j];
					break;
				}
			}
			if (flag == true){
				break;
			}
		}
		if (flag == true){
			cout << t_card << " " << h_card << endl;
		}
		else{
			cout << -1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<algorithm>
#include<vector>

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

using namespace std;

const int INF = 10000;

int main()
{
	int a, b;

	cin >> a >> b;

	if (a < b) {
		cout << "a < b";
	}
	else if (a > b) {
		cout << "a > b";
	}
	else {
		cout << "a == b";
	}
	cout << endl;
 
	return 0;

}



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

int main(int argc, char const *argv[])
{
    long long int n; cin >> n;
    int a[200010];
    for (int i = 0; i < n; i++) cin >> a[i];
    int b[200010];
    queue<int> q;
    long long int balls = 0;
    for (int i = n-1; i >= 0; i--)
    {
        int k = n / (i+1);
        int count = 0;
        for (int j = 2; j <= k; j++)
        {
            count = (count+b[j*(i+1)-1])%2;
        }
        if (count == a[i]) b[i] = 0;
        else {
            b[i] = 1;
            q.push(i+1);
            balls ++;
        }
    }
    cout << balls << endl;
    for (int i = 0; i < balls; i++)
    {
        cout << q.front() <<" ";
        q.pop();
    }


    return 0;
}


Measured memory_bytes: 3072