akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		int n = in.readInt();
		int ans = 0;
		for(int i = 0; i<n; i++) {
			int l = in.readInt();
			int r = in.readInt();
			ans += (r-l)+1; 
		}
		System.out.println(ans);
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

Measured memory_bytes: 21332
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    H, N = map(int, input().split())
    A = [0 for _ in range(N)]
    B = [0 for _ in range(N)]
    for i in range(N):
        a, b = map(int, input().split())
        A[i] = a
        B[i] = b

    INF = 1000000005
    dp = [[INF for _ in range(H + 1)] for _ in range(N + 1)]
    dp[0][0] = 0
    for i in range(N):
        for j in range(H + 1):
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
            dp[i + 1][min(j + A[i], H)] = min(dp[i + 1]
                                              [min(j + A[i], H)], dp[i + 1][j] + B[i])

    print(dp[N][H])


if __name__ == '__main__':
    main()


Measured memory_bytes: 125784
S=input()
if len(S)<26:
    for char in range(ord("a"),ord("z")):
        if chr(char) not in S:
            break
    print(S+chr(char))
else:
    stack=list(S[-1])
    for s in S[len(S)-2::-1]:
        if s>stack[-1]:
            stack.append(s)
        else:
            break
    if len(stack)==26:
        print(-1)
    else:
        print(S[0:len(S)-len(stack)-1]+min(char for char in stack if char>S[-len(stack)-1]))

Measured memory_bytes: 9060
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
#define reprd(i,a,b) for (int i=(a);i>=(b);--i)
#define repr(i,n) reprd(i,n,0)
typedef long long ll;

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 110000;
int A, B, M;
int a[Max], b[Max], c[Max], x[Max], y[Max];

int main(int argc, const char * argv[]) {
    cin >> A >> B >> M;
    inputArray(a, A);
    inputArray(b, B);
    rep(i, M) {
        cin >> x[i] >> y[i] >> c[i];
    }


    int minA = *min_element(a, a+A);
    int minB = *min_element(b, b+B);
    int ans = minA + minB;

    rep(i, M) {
        int cost = a[x[i]-1] + b[y[i]-1] - c[i];
        if (chmin(ans, cost)) {
            // printf("%d,%d,%d,%d\n", a[x[i]-1], b[y[i]-1], c[i], cost);
        }
    }

    output(ans);
    return 0;
}

Measured memory_bytes: 2176
# 190526_2

N = int(input())
S = []
P = []
I = []
Z = []

for i in range(N):
    s, p = input().split()
    S.append(s)
    P.append(int(p))
    I.append(i+1)

for i, j, k in zip(S,P,I):
    Z.append([i,j,k])

Z_sorted = sorted(Z)

for j in range(N-1):
    for i in range(N-1):
        if Z_sorted[i][0] == Z_sorted[i+1][0]:
            if Z_sorted[i][1] < Z_sorted[i+1][1]:
                a = Z_sorted[i]
                b = Z_sorted[i+1]
                Z_sorted[i] = b
                Z_sorted[i+1] = a

for i in range(N):
    print(Z_sorted[i][2])

Measured memory_bytes: 3188
let is_over_50 c1 c2 c3 =
  let l1 = [1;2;3;4;5;6;7;8;9;10] in
  let l2 = List.filter (fun x -> x <> c1 && x <> c2 && x <> c3 && c1 + c2 + x <= 20) l1 in
  List.length l2 >= 4

let _ =
  try
    while true do
      let c1, c2, c3 = Scanf.scanf "%d %d %d\n" (fun x y z -> (x, y, z)) in
      Printf.printf "%s\n" (if is_over_50 c1 c2 c3 then "YES" else "NO")
    done
  with
    End_of_file -> ()

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

int main(){
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    if(a==0){
        cout << "1" << endl;
    }
    else if(b==0){
        cout << "2" << endl;
    }
    else if(c==0){
        cout << "3" << endl;
    }
    else if(d==0){
        cout << "4" << endl;
    }
    else cout << "5" << endl;
}

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

// #define int long long
#define rep(i, n) for (ll i = (ll)(0); i < (ll)(n); ++i)
#define reps(i, n) for (ll i = (ll)(1); i <= (ll)(n); ++i)
#define rrep(i, n) for (ll i = ((ll)(n)-1); i >= 0; i--)
#define rreps(i, n) for (ll i = ((ll)(n)); i > 0; i--)
#define irep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); ++i)
#define ireps(i, m, n) for (ll i = (ll)(m); i <= (ll)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) ll(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  priority_queue<pair<ll,pll>> q;
  rep(i,n){
    ll a,b; cin>>a>>b;
    q.emplace(a+b,pll(a,b));
  }
  ll a=0,b=0;
  ll i=0;
  while(!q.empty()){
    auto p=q.top(); q.pop();
    if(i%2==0) a+=p.second.first;
    else b+=p.second.second;
    i++;
  }
  cout<<a-b<<endl;
}

Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
#define N 200001
#define ll long long
#define mod 1000000007
int n, m, num;
ll f[N] = {1}, dp[N];
ll fac[N] = {1}, ifac[N] = {1}, inv[N] = {1, 1};
ll Calc(int n, int k) { return fac[n] * ifac[k] % mod * ifac[n - k] % mod; }
struct faner {
    int x, y;
} a[N] = {1, 1};
bool cmp(faner a, faner b) { return a.x == b.x ? a.y < b.y : a.x < b.x; }
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 2; i <= n + m; ++i)
        inv[i] = (mod - mod / i) * inv[mod % i] % mod;
    for (int i = 1; i <= n + m; ++i)
        fac[i] = fac[i - 1] * i % mod, ifac[i] = ifac[i - 1] * inv[i] % mod;
    scanf("%d", &num);
    for (int i = 1; i <= num; ++i) scanf("%d%d", &a[i].x, &a[i].y);
    sort(a + 1, a + 1 + num, cmp);
    a[++num] = {n, m};
    for (int i = 0; i < num; ++i) {
        for (int j = i + 1; j <= num; ++j) {
            if (a[i].y > a[j].y) continue;
            ll sum = Calc(a[j].x - a[i].x + a[j].y - a[i].y, a[j].x - a[i].x);
            f[j] = (mod + f[j] - f[i] * sum % mod) % mod;
        }
    }
    printf("%lld\n", (mod - f[num]) % mod);
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pi pair<int, int>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define deb(x) cout << #x << ":" << x << endl;
/* freopen("input.txt", "r", stdin); */
/* freopen("output.txt", "w", stdout); */
const int MOD = 1000000007;

int main() {
	fastio();
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int ans = 0;
	if(a >= k)
		cout << k << "\n";
	else {
		ans += a;
		if(b >= k-a)
			cout << ans << "\n";
		else
			cout << ans - (k-a-b) << "\n";
	}
	return 0;
}


Measured memory_bytes: 3692
import java.util.*;
import java.io.*;
public class Main{
   public static void main(String[] args) throws  IOException{
	        		  assign();
	        		  	long[] n1=long_arr();
	        		  	int n=(int)n1[0];long k=n1[1];
	        		  	int[] a=int_arr();
	        		  	int[][] dp=new int[n+1][64];
	        		  	for(int i=1;i<=n;i++){
	        		  		dp[i][0]=a[i-1];
	        		  	}
	        		  	for(int j=1;j<64;j++){
	        		  		for(int i=1;i<=n;i++){
	        		  			dp[i][j]=dp[dp[i][j-1]][j-1];
	        		  		}
	        		  	}
	        		  	int cc=1;
	        		  	for(int i=0;i<64;i++){
	        		  		if((k&1l<<i)!=0){
	        		  			cc=dp[cc][i];
	        		  		}
	        		  	}
		  	        	out.write(cc+"");
	
                      out.flush();		 
	}
  
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
}

Measured memory_bytes: 107972
from bisect import bisect_left
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999

n = int(input())
A = [-INF] + get_nums_l()

log(n)
log(A)

edges = [ [] for _ in range(n+1) ]
for _ in range(n-1):
#for line in map(lambda s: s.strip(), sys.stdin.readlines()):
    line = input().strip()
    log(line)
    u,v = map(int, line.split())
    edges[u].append(v)
    edges[v].append(u)

def dfs(dp, u, p=None):

    # log(u)
    # log(dp)

    # dpの中でA[u]以上の値が入っている最小のindex
    i = bisect_left(dp, A[u])

    old = dp[i]
    dp[i] = A[u]

    # 有効値(INF以外)が入っている最大のindex
    ans[u] = bisect_left(dp, INF) - 1

    for v in edges[u]:
        if v == p:
            continue
        dfs(dp, v, u)

    # 巻き戻し
    dp[i] = old

# ans[i] = ノード1からノードiへの経路中の最長増加部分列長
ans = [0] * (n+1)

# dp[i] = 最長増加部分列長がiの場合の末尾ノード値の最小
# dp[0]は使用しないので負の無限大を入れておく
dp = [INF] * (n+1)
dp[0] = -INF

dfs(dp, 1, None)

for i in range(1, n+1):
    print(ans[i])


Measured memory_bytes: 366540
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;
	using BigNum = std::vector<long long>;

	class InputData {
	public:
		void getInput(void);
		void skipInput(void);
		Str getStr(void);
		Num getNum(void);
		BigNum getBigNum(void);
	private:
		Str str;
		Num num;
		BigNum bNum;
	};
	Str AtCoder::InputData::getStr(void) {
		return this->str;
	}
	Num AtCoder::InputData::getNum(void) {
		return this->num;
	}
	BigNum AtCoder::InputData::getBigNum(void) {
		return this->bNum;
	}
	void AtCoder::InputData::skipInput(void) {
		std::string buf = "";
		std::getline(std::cin, buf);
	}
	void AtCoder::InputData::getInput(void) {
		this->str.clear();
		this->num.clear();
		this->bNum.clear();

		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				this->str.push_back(row);
				this->num.push_back(std::atoi(row.c_str()));
				this->bNum.push_back(std::atoll(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		this->str.push_back(row);
		this->num.push_back(std::atoi(row.c_str()));
		this->bNum.push_back(std::atoll(row.c_str()));
	}

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(long long);
		void decrement(void);
		void decrement(long long);
		long long getResult(void);
	private:
		long long result;
	};
	void Ans::showResult(void) {
		printf("%lld\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(long long value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(long long value) {
		this->result -= value;
	}
	long long AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::InputData* data = new AtCoder::InputData();

	data->getInput();

	AtCoder::Num num = data->getNum();

	const long long int n = num[0], d = num[1];
	AtCoder::Num psr;

	const long long int sc = d * d;

	for (int i = 0; i < n; i++) {
		data->getInput();
		AtCoder::BigNum buf = data->getBigNum();
		const long long int bufr = (buf[0] * buf[0]) + (buf[1] * buf[1]);
		if (bufr <= sc) {
			psr.push_back(1);
		}
	}

	const int ans = psr.size();

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

	delete(data);

	return 0;
}


Measured memory_bytes: 3800
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007


signed main(){
    int A,B,C;
    cin>>A>>B>>C;
    cout<<max(0ll,C-(A-B))<<endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int h,w;
	cin >> h >> w;
	string field[1010];
	queue<P> que;
	int dist[1010][1010];
	for(int i = 0;i < h;i++){
		cin >> field[i];
		for(int j = 0;j < w;j++){
			if(field[i][j] == '#'){
				que.emplace(i,j);
				dist[i][j] = 0;
			}else dist[i][j] = INF;
		}
	}
	for(int i = 0;;i++){
		int siz = que.size();
		if(!siz){
			cout << i - 1 << endl;
			return 0;
		}
		for(int j = 0;j < siz;j++){
			P p = que.front();que.pop();
			for(int k = 0;k < 4;k++){
				int nx = p.first + dx[k],ny = p.second + dy[k];
				if(in(nx,ny,h,w) && dist[nx][ny] == INF){
					dist[nx][ny] = i + 1;
					que.emplace(nx,ny);
				}
			}
		}
	}
}

Measured memory_bytes: 25652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n; cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s[i];

  const string alphabet = "abcdefghijklmnopqrstuvwxyz";
  map<char, int> num;
  rep(j,26) num[alphabet[j]] = j;

  Graph counter(n, vi(26));
  rep(i,n) for (auto c : s[i]) ++counter[i][num[c]];

  vi ans(26, 51);
  rep(j,26) rep(i,n) ans[j] = min(ans[j], counter[i][j]);

  rep(j,26) rep(i,ans[j]) cout << alphabet[j];
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i, n, N[45];
  
  scanf("%d", &n);
  for(i = 0; i <= n; i++) N[i] = 0;

  for(i = 0; i <= n; i++){
    if(i == 0 || i ==1) N[i] = 1;
    else N[i] = N[i-1] + N[i-2];
  }

  printf("%d\n", N[n]);

  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

char C[] = {'I', 'O', 'T', 'J', 'L', 'S', 'Z'};

LL func1(map<char, LL> mp) {
    LL ans = 0;


    LL buf = mp['I'] / 2 + mp['L'] / 2 + mp['J'] / 2;
    ans += buf * 2;



    return ans;
}
LL func2(map<char, LL> mp) {
    LL ans = 0;

    if (mp['I'] > 0 && mp['L'] > 0 && mp['J'] > 0) {
        mp['I'] --;
        mp['J'] --;
        mp['L'] --;
        ans += 3;
    }
    LL buf = mp['I'] / 2 + mp['L'] / 2 + mp['J'] / 2;
    ans += buf * 2;

    return ans;
}

int main(void) {
    map<char, LL> mp;
    REP(i, 7) {
        LL buf;
        scanf("%lld", &buf);
        mp[C[i]] = buf;
    }

    cout << max(func1(mp), func2(mp)) + mp['O'] << endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#define F first
#define S second
using namespace std;
typedef long long ll;
ll n;
int main(void){
  cin >> n;
  for(ll i = 1; i*(i-1)/2 < n; i++){
    ll p = n;
    if(i*(i+1)/2 >= n){
      for(ll j = i; j > 0; j--){
	if(p >= j){
	  p-=j;
	  printf("%lld\n",j);
	}
      }
    }
  } 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
 
int main() {
  int n, a, b, ans = 0;
  //string s;
  double l, donut;
  cin >> l;
  donut = l / 3;
  //vector<int> v(n), c(n);
  //if(1) {}
  //((a == b)? "Yes" : "No")
  printf("%.10lf\n", donut * donut * donut);
  //ドーナツを貪るピカミィﾁｬﾝﾇはいいぞ。
}

Measured memory_bytes: 256
import sys,math

def is_prime_number(arg):
    arg_sqrt=int(math.floor(math.sqrt(arg)))
    i=2
    while i <=arg_sqrt:
        if arg %i ==0:
            return False
        i+=1

    return True
        
        
n=0
prime_numbers=0
for line in sys.stdin:
    l=int(line)
    if n == 0:
        n=l
        continue

    if is_prime_number(l):
        prime_numbers+=1
        

print prime_numbers

Measured memory_bytes: 6404
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<double,double> P;
typedef complex<double> CP;
typedef long long ll;

ll L,N,M;

int main(){
	while(cin>>L,L){
		bool f=true;
		rep(i,12){
			cin>>M>>N;
			L-=M-N;
			if(L<=0&&f){
				cout<<i+1<<endl;
				f=false;
			}
			else if(i==11&&f) cout<<"NA"<<endl;
		}
	}
	return 0;
}

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

int main(){
  int a,b,c;
  int mx,md,mn;
  cin >> a >> b >> c;
  
  mx = max(a,max(b,c));
  mn = min(a,min(b,c));
  md = a+b+c - mx - mn;
  
  int ct=0;
  while(abs(md-mn)>1){
    mn = mn + 2; ct++;
  }
  while(abs(mn-mx)>0){
    mn++; md++; ct++;
  }
  if(md>mx){ct++;}
  
  cout << ct;
  
  return 0;
}

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

class Main
{
	public static void main (String[] args) throws IOException
	{
		String A,B;
		int a,b;
		
		Scanner in = new Scanner(System.in);
		
		A = in.next();
		B = in.next();
		
		a = Integer.parseInt(A);
		b = Integer.parseInt(B);
		
		if(a > b){
			System.out.println("a > b");
		}else if(a < b){
			System.out.println("a < b");
		}else if(a == b){
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 17120
import java.io.*;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
char[][] map;
while(!(line=br.readLine()).equals("0")){
if(line.isEmpty()){
continue;
}
int n=Integer.parseInt(line);
int m=Integer.parseInt(br.readLine());
int g=Integer.parseInt(br.readLine());
int d=Integer.parseInt(br.readLine());
map=new char[d][n+1];
for(int i=0;i<d;i++){
line="0"+br.readLine()+"0";
for(int j=0;j<=n;j++){
map[i][j]=line.charAt(j);
}
}
System.out.println(solve(m,g,map));
}
}

private static boolean canReachGoal(int m,int g,char[][] map){
int now=m;
for(int i=0;i<map.length;i++){
if(map[i][now-1]=='1'){
now--;
}
else if(map[i][now]=='1'){
now++;
}
}
return g==now;
}

private static String solve(int m,int g,char[][] map){
if(canReachGoal(m,g,map)){
return "0";
}
for(int i=0;i<map.length;i++){
for(int j=1;j<=map[0].length-2;j++){
if(map[i][j-1]=='0'&&map[i][j]=='0'&&map[i][j+1]=='0'){
map[i][j]='1';
if(canReachGoal(m,g,map)){
return String.valueOf(i+1)+" "+String.valueOf(j);
}
map[i][j]='0';
}
}
}
return "1";
}
}

Measured memory_bytes: 16992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
 
public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		int			cnt = parseCnt();
		byte[][]	map = new byte[9][9];
		byte[]		chk = new byte[9*9*3];

		for (int l = 0; l < cnt; l++) {
			parseMap(map, chk);

			if (l > 0) {
				System.out.println();
			}

			for (int i = 0; i < map.length; i++) {
				String	out = "";
				for (int j = 0; j < map[i].length; j++) {
					int	b   = (i / 3) * 3 + j / 3;
					int	num = (int)map[i][j];

					if ((chk[i*9+num-1] | chk[81+j*9+num-1] | chk[162+b*9+num-1]) > (byte)1) {
						out += "*"+num;
					} else {
						out += " "+num;
					}
				}
				System.out.println(out);
			}
		}
	}

	private static void parseMap(byte[][] map, byte[] chk) {
		String	stdin = null;

		Arrays.fill(chk, (byte)0);
		for (int i = 0; i < map.length; i++) {
			stdin = parseStdin().replaceAll(" ", "");
			for (int j = 0; j < map[i].length; j++) {
				int		b   = (i / 3) * 3 + j / 3;
				int		num = (int)(stdin.charAt(j)-'0');
				map[i][j] = (byte)num;
				chk[i*9+num-1]++;
				chk[81+j*9+num-1]++;
				chk[162+b*9+num-1]++;
			}
		}
	}

	private static int parseCnt() {
		int		cnt = 0;
		String	str = null;

		if ((str = parseStdin()) != null) {
			cnt = Integer.parseInt(str);
		}

		return cnt;
	}

	private static String parseStdin() {
		String  stdin = null;

		try {
			String  tmp = br.readLine();
			if (tmp != null) {
				if (!tmp.isEmpty()) stdin = tmp;
			}
		}
		catch (IOException e) {}

		return stdin;
	}
}

Measured memory_bytes: 19748
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;



int main()
{
	string s;
	cin >> s;
	int n=s.size();
	cout << s[0] << (n-2) << s[n-1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int A, B;
    cin >> A >> B;
    if (A <= 8 && B <= 8) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            var arr = ReadString().Select(val => val - '0').ToArray();
            for (int i = 0; i < 8; i++)
            {
                int sum = arr[0];
                for (int r = 0; r < 3; r++)
                {
                    sum += ((i >> r) & 1) == 0 ? arr[r + 1] : -arr[r + 1];
                }

                if (sum == 7)
                {
                    for (int r = 0; r < 3; r++)
                    {
                        Console.Write(arr[r]);
                        Console.Write(((i >> r) & 1) == 0 ? '+' : '-');
                    }

                    Console.Write(arr[3]);
                    Console.WriteLine("=7");
                    return;
                }
            }
        }

        //最小公倍数
        static int LCM(int num1, int num2)
        {
            var gcd = GCD(num1, num2);
            return num1 * (num2 / gcd);
        }

        static long LCM(long num1, long num2)
        {
            var gcd = GCD(num1, num2);
            return num1 * (num2 / gcd);
        }

        //最大公約数
        static int GCD(int num1, int num2)
        {
            int a = Math.Max(num1, num2);
            int b = Math.Min(num1, num2);
            int mod;
            while ((mod = a % b) != 0)
            {
                a = b;
                b = mod;
            }

            return b;
        }

        static long GCD(long num1, long num2)
        {
            long a = Math.Max(num1, num2);
            long b = Math.Min(num1, num2);
            long mod;
            while ((mod = a % b) != 0)
            {
                a = b;
                b = mod;
            }

            return b;
        }

        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static string ReadString()
        {
            return Console.ReadLine();
        }

        static void Out(object o)
        {
            Console.WriteLine(o);
        }
    }

    static class EnumerableExtension
    {
        public delegate void Function<in T>(T val);

        public static void ForEach<T>(this IEnumerable<T> enumerable, Function<T> function)
        {
            foreach (var x in enumerable)
            {
                function(x);
            }
        }
    }

    class PriorityQueue<T>
    {
    }
}

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

int main() {
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++) {
        dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <cstring>
#include <cmath>
#include <sstream>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int n;
int w,h;
int x1[1010],x2[1010];
int yy1[1010],y2[1010];
bool board[6000][6000];

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

int compress(int* z1,int* z2,int len){
	vi zs;
	rep(i,n)for(int d=-1;d<=1;d++){
		int tz1=z1[i]+d,tz2=z2[i]+d;
		if(0<=tz1&&tz1<=len) zs.pb(tz1);
		if(0<=tz2&&tz2<=len) zs.pb(tz2);
	}
	sort(zs.begin(),zs.end());
	zs.erase(unique(zs.begin(),zs.end()),zs.end());
	rep(i,n){
		z1[i]=find(zs.begin(),zs.end(),z1[i])-zs.begin();
		z2[i]=find(zs.begin(),zs.end(),z2[i])-zs.begin();
	}
	return zs.size();
}

int main(void){
	while(cin >> w >> h){
		if(w==0||h==0)
			break;
		cin >> n;
		rep(i,n) cin >> x1[i] >> yy1[i] >> x2[i] >> y2[i];
		rep(i,n) x2[i]--,y2[i]--;
		w=compress(x1,x2,w-1);
		h=compress(yy1,y2,h-1);
		clr(board,0);
		rep(i,n){
			for(int y=yy1[i];y<=y2[i];y++)
				for(int x=x1[i];x<=x2[i];x++)
					board[y][x]=true;
		}

		int ans=0;
		rep(y,h)rep(x,w){
			if(board[y][x])
				continue;
			ans++;

			queue<pii> q;
			q.push(mp(x,y));
			while(!q.empty()){
				int sx=q.front().first;
				int sy=q.front().second;
				q.pop();
				rep(i,4){
					int nx=sx+dx[i];
					int ny=sy+dy[i];
					if(nx<0||w<=nx||ny<0||h<=ny) continue;
					if(board[ny][nx]) continue;
					board[ny][nx]=true;
					q.push(mp(nx,ny));
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 36412
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def solve():
    n, m = map(int, input().split())
    course = [[] for i in range(n)]
    for i in range(m):
        a, b = map(int, input().split())
        course[a-1].append(b)
        course[b-1].append(a)
    for i in course[0]:
        if n in course[i-1]:
            print("POSSIBLE")
            break
    else:
        print("IMPOSSIBLE")
    return 0

if __name__ == "__main__":
    solve()

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

using namespace std;

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    // freopen("data.in","r",stdin);

    int k,s; cin >> k >> s;

    int ans = 0;

    for(int i = 0; i <= k; i++) {
        for(int j = 0; j <= k; j++) {
            if(s-i-j <= k && s-i-j >= 0)ans++;
        }
    }

    cout << ans << '\n';

    return 0;
}


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

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

    vector<ll> ai(n);
    vector<ll> di(n);
    for (int i = 0; i < n; i++) {
        cin >> ai.at(i);
    }
    for (int i = 0; i < n-1; i++) {
        di.at(i) = ai.at(i+1) - ai.at(i);
    }
    di.at(n-1) = k -ai.at(n-1) + ai.at(0);
    ll dmax = 0;

    for (ll i: di) dmax = max(i, dmax);
    cout << k - dmax << endl;

    return 0;
}

Measured memory_bytes: 6324
c=[list(map(int, input().split(' '))) for _ in range(3)]

right = 0
left = 0
for i in range(3):
    for j in range(3):
        if i == j:
            right += c[i][j]
        else:
            left += c[i][j]
if right * 2 == left:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<queue>
#include<vector>
using namespace std;
const long long INF=200000000000000000LL;
typedef pair<int,int> P;
int main(){
	int N,A[100000],B[100005]={},ans=0;
	cin>>N;
	for(int i=0;i<N;++i){
		cin>>A[i];
		B[A[i]]++;
		B[A[i]-1]++;
		B[A[i]+1]++;
	}
	for(int i=0;i<100000;++i){
		if(B[i]>ans)ans=B[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>

int main(void){
	int a,b;
    std::cin>>a>>b;
    if((a*b)%2==0){
        std::cout<<"Even"<<std::endl;
    }else{
        std::cout<<"Odd"<<std::endl;
    }
    
    return 0;
}


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

long long F[100000] = {};
long long f(int);

int main(){
	int n;
	cin >> n;
	cout << f(n) << endl;
	//for(int i = 0;i<n;i++) cerr << f(i) << " ";
	//cerr << endl;
	return 0;
}

long long f(int k){
	if(F[k] != 0) return F[k];
	else if (k <= 1) return F[k] = 1;
	else{
		return F[k] = f(k-1) + f(k-2);
	}
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define PB push_back
#define PII pair<int,int>
int N=1000000;
map<int ,int>my;
//vector<PII>v[1000005];

int main(){
    int n;
    cin>>n;
    vector<int>v;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        v.PB(x);
    }
    if(n==2){
        cout<<abs(v[0]-v[1]);
        return 0;
    }
    int f[n][2];
    for(int i=0;i<n;i++){
        f[i][0]=0;
        f[i][1]=0;
    }
    f[1][1]=N;
    for(int i=0;i<n;i++){
        if((i-1)>=0){
            f[i][0]+=abs(v[i]-v[i-1]);
            f[i][0]+=min(f[i-1][0],f[i-1][1]);
        }
        if((i-2)>=0){
            f[i][1]+=abs(v[i]-v[i-2]);
            f[i][1]+=min(f[i-2][0],f[i-2][1]);
        }
    }
    /*for(int i=0;i<n;i++){
        cout<<f[i][0]<<" "<<f[i][1]<<endl;
    }*/
    cout<<min(f[n-1][0],f[n-1][1]);
    return 0;
}


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

int main(){
  int A,B,C,X;
  cin>>A>>B>>C>>X;
  int ans=0;
  for(int i=0;i<=A;i++){
    for(int j=0;j<=B;j++){
      for(int k=0;k<=C;k++){
        if(500*i+100*j+50*k==X){
          ans++;
        }
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int main(){
    priority_queue<int> Q;
    string s;
    int n;
    while(cin >> s && s!="end"){
        if(s=="insert"){
            cin >> n;
            Q.push(n);
        }
        else{
            cout << Q.top() << endl;
            Q.pop();
        }
    }

}

Measured memory_bytes: 6508
/* Don't try to hack it :|
     
                _/﹋\_
                (҂`_´)
                <,︻╦╤─҉- - - - - - - - - - - - - - -
                _/﹋\_
    */
    //@ROMENE7
     
    #include <bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define pb push_back
    #define F first
    #define S second
    #define all(c)  c.begin(), c.end()
    #define ulli unsigned long long int
    #define lli long long int
    #define llv vector< ll >
    #define llc vector< char >
    #define lls vector< string >
    #define llb vector< bool >
    #define mp make_pair
    #define endl "\n"
    #define degb cout<<"HI"<<endl;
    #define ins insert
    #define foo(i,n) for(ll i = 0;i<n;i++)
    #define foa(i,a) for(auto i = a.begin();i!=a.end();i++)
    #define foe(i,a,b) for(ll i = a;i<=b;i++)
    #define INF 2147483647
    #define siz size
    #define len length
    #define sp setprecision(16)
     
     
    int main(){
      /*  #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif*/
        ios::sync_with_stdio(0);
        cin.tie(0); cout.tie(0);
          ll n, arr[1000000],sum=0;
          cin >> n;
          for(ll i=0;i<n;i++){
          	cin >> arr[i];
          }
          sort(arr,arr+n);
          for(ll i=0;i<n-1;i++){
          	sum+=arr[i];
          }
          if(arr[n-1]<sum){

          	cout << "Yes";
          }
          else{
          	cout << "No";
          }
     	
        cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
     
         
        return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;

struct city{
	int ken;
	int index;
	int year;
	int rank;
};

int main(){
	int n, m;
	cin >> n >> m;
	vector<city> v_city(m);
	vector<int> cnt(n+1);
	for(int i=0; i<m; i++){
		v_city[i].index = i;
		cin >> v_city[i].ken >> v_city[i].year;
	}
	sort(v_city.begin(), v_city.end(), [](city& a, city& b){return b.year > a.year;});
	for(int i=0; i<m; i++){
		cnt[v_city[i].ken]++;
		v_city[i].rank = cnt[v_city[i].ken];
	}
//	for(int i=0; i<m; i++){
//		cout << v_city[i].rank << endl;
//	}
	sort(v_city.begin(), v_city.end(), [](city& a, city& b){return b.index > a.index;});
	for(int i=0; i<m; i++){
		cout << setw(6) << setfill('0');
		cout << v_city[i].ken;
		cout << setw(6) << setfill('0');
		cout << v_city[i].rank << endl;
	}
	return 0;
}



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

using namespace std;

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

    string s;

    cin >> s;

    const int n = s.size();

    for(int i = 0; i < (n - 1) / 2; ++i) {
        if(s.at(i) != s.at(n - 1 - i)) {
            printf("No\n");
            return 0;
        }
    }
    for(int i = 0; i < (n - 1) / 4; ++i) {
        if(s.at(i) != s.at((n - 1) / 2 - 1 - i)) {
            printf("No\n");
            return 0;
        }
        if(s.at((n + 1) / 2 + i) != s.at(n - 1 - i)) {
            printf("No\n");
            return 0;
        }
    }

    printf("Yes\n");

    return 0;
}

Measured memory_bytes: 256
#include<string.h>
#include<stdio.h>
int main(void){
	int i,sum=0;
	int flag=0;
	char x[1002];
	scanf("%s",x);
	do{
		
		for(i=0;i<1002;i++){
			if(x[i]==0){
				printf("%d\n",sum);
				break;
			}else{
				sum+=x[i]-0x30;
			}
		}
		sum=0;
		scanf("%s",x);
	}while(x[0]!=0x30);
	
	return 0;
}

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

int main(void) {
    long long N;
    cin >> N;
    vector< long long > A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    long long money = 1000, stock = 0;
    for (int i = 0; i < N - 1; i++) {
        if (A[i] <= A[i + 1]) {
            if (money <= 0) {
                continue;
            }
            stock += money / A[i];
            money = money % A[i];
        } else {
            money += stock * A[i];
            stock = 0;
        }
    }
    money += stock * A[N - 1];
    printf("%lld\n", money);
    return 0;
}


Measured memory_bytes: 3716
#include <iostream>

using namespace std;

int main()
{
  bool card[4][14] = {false};
  int n;
  char c;
  int rank;
  
  cin >> n;
  for (int i = 0; i < n; i++){
    cin >> c >> rank;
    switch (c){
      case 'S':
        card[0][rank] = true;
        break;
      case 'H':
        card[1][rank] = true;
        break;
      case 'C':
        card[2][rank] = true;
        break;
      case 'D':
        card[3][rank] = true;
        break;
    }
  }
  
  for (int i = 0; i < 4; i++){
    for (int j = 1; j <= 13; j++){
      if (card[i][j] == false){
        switch (i){
          case 0:
            cout << "S " << j << endl;
            break;
          case 1:
            cout << "H " << j << endl;
            break;
          case 2:
            cout << "C " << j << endl;
            break;
          case 3:
            cout << "D " << j << endl;
            break;
        }
      }
    }
  }

  return (0);
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;

int main()
{
    int a,b,k;
    cin>>a>>b>>k;
    for(int i=0;i<k;i++)
    {
        if(i%2==0)
        {
            a=a/2;
            b+=a;
        }
        else
        {
            b=b/2;
            a+=b;
        }
    }
    cout<<a<<' '<<b<<endl;
}


Measured memory_bytes: 256
N = int(input())
P = list(map(int, input().split()))

m = []
for i, p in enumerate(P):
    if i+1 == p:
        m.append(True)
    else:
        m.append(False)

# print(m)

double = 0
flag = False
for mi in m:
    if mi:
        if flag:
            double += 1
            flag = False
        else:
            flag = True
    else:
        flag = False

single = m.count(True) - 2 * double
# print(single, double)
print(single+double)

Measured memory_bytes: 56300
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <utility>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

int main(void){
	int n, k;
  scanf("%d %d", &n, &k);
  if(((n + 1)/ 2)>=k){
    printf("YES");
  }else{
    printf("NO");
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;
bool ans = true;
int H, W, N;
int S[200000];
int T[200000];
pi start;

signed main(void) {
    int a,b;
    cin >> H >> W >> N >> a >> b;
    start.fi = a-1;
    start.se = b-1;
    rep(i,N){
        char p;
        cin >> p;
        switch(p){
            case 'L':
                S[i] = 0;
                break;
            case 'R':
                S[i] = 1;
                break;
            case 'U':
                S[i] = 2;
                break;
            case 'D':
                S[i] = 3;
                break;
        }

    }

    rep(i,N){
        char p;
        cin >> p;
        switch(p){
            case 'L':
                T[i] = 0;
                break;
            case 'R':
                T[i] = 1;
                break;
            case 'U':
                T[i] = 2;
                break;
            case 'D':
                T[i] = 3;
                break;
        }

    }

    int now1 = start.se;
    rep(i,N){
        if(S[i] == 0){
            now1--;
            if(now1 < 0){
                ans = false;
                break;
            }
        }
        if(T[i] == 1){
            if(now1+1 < W){
                now1++;
            }
        }
    }

    int now2 = start.se;
    if(ans){
        rep(i,N){
            if(S[i] == 1){
                now2++;
                if(now2 > W-1){
                    ans = false;
                    break;
                }
            }
            if(T[i] == 0){
                if(now2-1 >= 0){
                    now2--;
                }
            }
        }
    }

    int now3 = start.fi;
    if(ans){
        rep(i,N){
            if(S[i] == 2){
                now3--;
                if(now3 < 0){
                    ans = false;
                    break;
                }
            }
            if(T[i] == 3){
                if(now3+1 < H){
                    now3++;
                }
            }
        }
    }

    int now4 = start.fi;
    if(ans){
        rep(i,N){
            if(S[i] == 3){
                now4++;
                if(now4 > H-1){
                    ans = false;
                    break;
                }
            }
            if(T[i] == 2){
                if(now4-1 >= 0){
                    now4--;
                }
            }
        }
    }

    if(ans){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 3328
def main():
    while True:
        a,b,c = map(int,input().split())
        if a==-1 and b==-1 and c==-1:break
        res = 'F'
        d = a+b
        if a==-1 or b==-1:res = 'F'
        elif 80<=d       :res = 'A'
        elif 65<=d       :res = 'B'
        elif 50<=d       :res = 'C'
        elif 30<=d:
            if 50<=c     :res = 'C'
            else         :res = 'D'
        else             :res = 'F'
        print(res)


if __name__ == '__main__':
    main()




Measured memory_bytes: 5596
#include <stdio.h>
main(){
  int i,j,n,a[1000000],c;
  while(1){
    scanf("%d",&n);
    if(n==0) break;
    for(i=2;i<n;i++) a[i]=1;
    a[0]=0;
    a[1]=0;
    c=0;
    for(i=2;i<n;i++){
      if(a[i]==1){
	for(j=i*2;j<n;j+=i) a[j]=0;
      }
    }
    for(i=2;i*2<=n;i++){
      if(a[i]==1&&a[n-i]==1) c++;
    }
    printf("%d\n",c); 
  }
  return 0;
}

Measured memory_bytes: 4312
n, x = map(int, input().split())
l = [int(i) for i in input().split()]
d = [0 for i in range(n + 1)]
count = 1
for i in range(1, n + 1):
    d[i] = d[i - 1] + l[i - 1]
    if d[i] <= x:
        count += 1
print(count)

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
using namespace std;
int main(){
	int l, r, d;
	cin >> l >> r >> d;
	cout << (r/d) - (l-1)/d;
	return 0;
}


Measured memory_bytes: 3632