akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

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; }

int main(){
	ll A, B, K;
	cin >> A >> B >> K;
	set<ll> num;
	rep(i, A, A + K){
		if (i > B) continue;
		num.insert(i);
	}
	repR(i, B, B - K){
		if (i < A) continue;
		num.insert(i);
	}
	for (set<ll>::iterator i = begin(num); i != end(num); i++){
		cout << *i << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  struct Edge {
    Edge(long s, long t, long w) : s(s), t(t), w(w) {}
    long s, t, w;
  };
  long n, m;
  std::vector<std::array<long, 3>> xs;
  Solver() {
    S002 reader;
    reader >= n >= m >m>= xs;
  }
  std::vector<Edge> neighbours[1024];
  std::vector<long> score;
  void solve() {
    std::vector<Edge> edges;
    for(auto x : xs) {
      edges.push_back(Edge(x[0]-1, x[1]-1, x[2]));
    }
    score.resize(n);
    const long inf = 1LL << 60;
    for(auto& d : score) d = -inf;
    score[0] = 0;
    long p2, p3;
    for(long i = 0; i < 3 * n; ++i) {
      bool updated = false;
      for(Edge edge : edges) {
        long s = edge.s;
        long t = edge.t;
        long w = edge.w;
        if( score[s] + w > score[t] ) {
          score[t] = score[s] + w;
          updated = true;
        }
      }
      if( not updated ) {
        printf("%ld\n", score[n-1]);
        return;
      }
      if( i == 2 * n - 1 ) p2 = score[n-1];
      if( i == 3 * n - 1 ) p3 = score[n-1];
    }
    if( p2 == p3 ) printf("%ld\n", score[n-1]);
    else puts("inf");
  }
  ~Solver() { fprintf(stderr, "--end--\n"); }
};
 
int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}



Measured memory_bytes: 384
N,K,Q = map(int,input().split())
a = [K]*N

for i in range(Q):
    a[int(input())-1]+=1
a=list(map(lambda x: x-Q, a))
for i in range(N):
    if a[i]>0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 54360
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int main()
{
    int N,i;
    cin>>N>>i;
    cout<<N-i+1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> l(q), r(q);
    for(int i = 0; i < q; i++) cin >> l[i] >> r[i];
    vector<int> sum(n+1, 0);
    for(int i = 1; i < n; i++){
        if(s[i-1] == 'A' && s[i] == 'C'){
            sum[i+1] = sum[i] + 1;
        }else{
            sum[i+1] = sum[i];
        }
    }
    for(int i = 0; i < q; i++){
        int ans = sum[r[i]] - sum[l[i]];
        cout << ans << endl;
    }
}


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

int main(){
    int N, K;
    string S;
    cin >> N >> S >> K;
    char good;
    for (int i = 0; i < S.size(); i++){
        if (S.at(K-1) != S.at(i)){
            S.at(i)='*';
        }
        cout << S.at(i);
    }
    cout << endl;
}


Measured memory_bytes: 256
import bisect
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
counta = [0]
countb = [0]
for i in range(n):
    if counta[-1] + a[i] > k:
        break
    tmp = counta[-1]+a[i]
    counta.append(tmp)
for j in range(m):
    if countb[-1] + b[j] > k:
        break
    tmp = countb[-1]+b[j]
    countb.append(tmp)
ans = 0
for i in range(len(counta)):
    tmp = bisect.bisect_right(countb,k-counta[i])
    ans = max(ans,i+tmp-1)
print(ans)


Measured memory_bytes: 132416
let N = Int(readLine()!)!
let c = Array(readLine()!)
let reds = c.reduce(0, {$0 + ($1 == "R" ? 1 : 0)})
if reds == 0 {
    print(0)
} else {
    print(reds - c[..<reds].reduce(0, {$0 + ($1 == "R" ? 1 : 0)}))
}


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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

void ALLIN1_NUMBER(vector<ll>& V)
{
    for(auto& x : V)
    {
        cin >> x;
    }
}

void ALLOUT_NUMBER(vector<ll> V)
{
    ll N = V.size();
    for(ll i=0;i<N;i++)
    {
        cout << V[i];
        if(i<N-1) cout << ' ';
    }
    cout << endl;
}

template<class T>
void OUT0(T N)
{
    cout << N << endl;
}

static const double pi = acos(-1.0);

double Cos(double D)
{
    return cos(pi/180 * D);
}

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

    vector<ll> ans;
    while(N>0)
    {
        ans.push_back((N%26));
        N--;
        N /= 26;
    }
    reverse(ALL(ans));
    for(auto& x : ans)
    {
        if(x==0) x = 26;
    }

    string ans_str;
    for(auto x : ans)
    {
        ans_str.push_back((char)('a'+x-1));
    }
    OUT0(ans_str);

    return 0;
}

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

class union_find {
	vector<int> par;
public:
	union_find(int n) : par(n, -1) {}
	int find(int a) {
		return par[a] < 0 ? a : par[a] = find(par[a]);
	}
	bool same(int a, int b) {
		return find(a) == find(b);
	}
	void unite(int a, int b) {
		a = find(a);
		b = find(b);
		if (a == b) return;
		if (par[a] < par[b]) {
			par[a] += par[b];
			par[b] = a;
		}
		else {
			par[b] += par[a];
			par[a] = b;
		}
	}
	int size(int a) {
		return -par[find(a)];
	}
};

int main()
{
	int N, M;
	cin >> N >> M;
	union_find uf(N);
	for (int i = 0; i < M; i++) {
		int X, Y, Z;
		cin >> X >> Y >> Z; --X, --Y;
		uf.unite(X, Y);
	}
	int res = 0;
	for (int i = 0; i < N; i++) {
		res += (uf.find(i) == i);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>

using namespace std;

int main() {
	int n, s[14]{ 0 }, h[14]{ 0 }, c[14]{ 0 }, d[14]{0};
	cin >> n;
	for (int i = 0; i < n; i++) {
		string m;
		int num;
		cin >> m >> num;
		switch(m[0]) {
		case 'S':
			s[num]++;
			break;
		case 'H':
			h[num]++;
			break;
		case 'C':
			c[num]++;
			break;
		case 'D':
			d[num]++;
			break;
		}
	}
	for (int i = 1; i <= 13; i++) {
		if (s[i] == 0)cout << "S" << " " << i << endl;
	}
	for (int i = 1; i <= 13; i++) {
		if (h[i] == 0)cout << "H" << " " << i << endl;
	}
	for (int i = 1; i <= 13; i++) {
		if (c[i] == 0)cout << "C" << " " << i << endl;
	}
	for (int i = 1; i <= 13; i++) {
		if (d[i] == 0)cout << "D" << " " << i << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int h[n + 1];
    for (int i = 1; i <= n; i++)
    {
        cin >> h[i];
    }
    int dp[n + 1];
    dp[1] = 0;
    for (int i = 2; i <= n; i++)
    {
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        for (int j = 2; j <= k && i - j > 0; j++)
        {
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }
    cout << dp[n] << "\n";
}

Measured memory_bytes: 1024
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
#define NIL -1

int main() {
    LL n;
    cin >> n;

    LL tmp=0;
    LL ans;
    while(tmp<n){
        tmp+=1000;
    }
    ans=tmp-n;

    cout << ans << endl;

    return 0;
}


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

int a[100002],s[100002];
struct cz{int b,c;} z[100002];
bool cmp(cz x,cz y)
{
	return x.c>y.c; 
}
int main()
{
    int n,m; cin>>n>>m;
    for (int i=1; i<=n; i++) cin>>a[i];
    sort (a+1,a+n+1);
    
    int r=0;
    for (int i=1; i<=m; i++)
    {
    	cin>>z[i].b>>z[i].c;
	}
	sort (z+1,z+m+1,cmp);
	
	for (int i=1; i<=m; i++)
	{
		while (z[i].b>0&&r<n)
		{
			s[++r]=z[i].c;
			z[i].b--;
		}
	}
	
	long long ans=0;
	for (int i=1; i<=n; i++) ans+=max(a[i],s[i]);
	cout << ans;
 } 

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std ;
#define pb push_back
#define ll long long
#define mod 998244353
const ll N = 200007 ;
ll fact[N] ;
ll BigMod(ll a, ll b)
{
    if(b==0) return 1;
    ll x=BigMod(a, b/2);
    if(b%2==0) return (x*x)%mod;
    x=(x*x)%mod;
    return (x*a)%mod;
}


ll inv (ll x) {
    return BigMod (x , mod-2 ) % mod ;
}

ll c ( ll n , ll r) {
    ll iv = inv( (fact[r] *fact[n-r])%mod ) %mod  ;
    iv+=mod ;
    iv%=mod ;
    return ( fact[n] * iv )%mod ;

}

void fun (  ) {
    fact[0]= fact[1] = 1 ;
    for (ll i = 2 ; i<N ; i++ ) fact[i] = (i*fact[i-1]) %mod ;
}


int main() {
    fun() ;
    ll n , m , k ,i;

    cin>>n  >> m >> k ;

    ll ans = 0 ;
    for (i = 0 ; i<=k ;i++) {
        ans += ( (c(n-1,i) * m)%mod * BigMod(m-1,n-i-1) ) ;
        ans%=mod ;
        ans += mod ;
        ans%=mod ;

    }
    cout << ans << endl ;


}


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

using namespace std;

#define MAX 200
#define INF INT_MAX
typedef pair<string,int> P;
typedef vector<string> Vec;

int N;
vector<P> vec;

int cost(Vec v){
  int res = 0;
  for(int i = 0 ; i < (int)v.size() ; i++){
    for(int j = 0 ; j < N ; j++){
      if(vec[j].first == v[i]){
        res += vec[j].second;
        break;
      }
    }
  }
  return res;
}

int main(){
  int M, K;

  while(cin >> N, N){
    map<string,Vec> mp;
    P in; 

    vec.clear();
    for(int i = 0 ; i < N ; i++){
      cin >> in.first >> in.second;
      vec.push_back(in);
    }

    string str, s, item;
    cin >> M;
    for(int i = 0 ; i < M ; i++){
      cin >> str >> K;
      for(int j = 0 ; j < K ; j++){
        cin >> s;
        mp[str].push_back(s);
      }
    }    

    map<string,Vec>::iterator it;
    for(int i = 0 ; i < 10 ; i++){
      for(it = mp.begin() ; it != mp.end() ; ++it){
        for(int j = 0 ; j < N ; j++){
          if(vec[j].first == it->first){
            vec[j].second = min(vec[j].second, cost(it->second));
          }
        }
      }
    }
    cin >> item;
    int ans = INF;
    for(int i = 0 ; i < N ; i++){
      if(vec[i].first == item){
        ans = vec[i].second;
        break;
      }
    }
  
    cout << ans << endl;
  }

  return 0;
}

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

#define MAX(X,Y) ((X)>(Y)?(X):(Y))

int main(void){
  vector<int> v;
  int n, ans, len;
  
  cin >> n;
  v.push_back(0); // furidashi
  for (int i=0; i<n; i++){
    int t; cin >> t;
    v.push_back(t);
  }
  v.push_back(0); // agari
  ans = len = 0;
  for (int i=1; i<=n+1; i++){
    if (v[i]==1) len++;
    else {
      ans = MAX(ans, len+1);
      len=0;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3160
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from scipy.sparse.csgraph import floyd_warshall
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations, combinations_with_replacement
from heapq import heappop, heappush, heapify
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def main():
    h,w,k = map(int,input().split())
    c = [list(input()) for _ in range(h)]
    ans = 0
    for n1 in range(h+1):
        for e1 in combinations(range(h),n1):
            for n2 in range(w+1):
                for e2 in combinations(range(w),n2):
                    cc = copy.deepcopy(c)
                    for x in e1:
                        for j in range(w):
                            cc[x][j] = '.'
                    for x in e2:
                        for i in range(h):
                            cc[i][x] = '.'
                    cnt = 0
                    for i in range(h):
                        for j in range(w):
                            if cc[i][j] == '#':
                                cnt += 1
                    if cnt == k:
                        ans += 1
    print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 78052
while True:
    try:
        xa,ya,xb,yb,xc,yc,xd,yd=map(float,input().split())
    except EOFError:
        break
    if abs((ya-yb)*(yc-yd)+(xa-xb)*(xc-xd))<=1e-10:
        print("YES")
    else:
        print("NO")



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

#define endl '\n'
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define ALL(v) v.begin(), v.end()
#define ALLR(v) v.rbegin(), v.rend()
#define deb cout<<"HOLA\n";
#define UNIQUE(v) (v).resize(unique(ALL(v))-(v).begin())
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define bs(v,f) binary_search(ALL(v),f)
#define lb(v,f) lower_bound(ALL(v),f)
#define ub(v,f) upper_bound(ALL(v),f)
#define pb push_back

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<ii> vii;

struct tri{
    int a,b,c;
};
vector<tri>v;
int n;
map<int,map<int,int> >dp;
int ans(int x,int t){
    if(x>=n)return 0;
    if(dp[x][t])return dp[x][t];
    int t1,t2,t3;
    t1=t2=t3=INT_MIN;
    if(t!=1){
        t1=ans(x+1,1)+v[x].a;
    }if(t!=2){
        t2=ans(x+1,2)+v[x].b;
    }if(t!=3){
        t3=ans(x+1,3)+v[x].c;
    }
    return dp[x][t]=max(t1,max(t2,t3));
}

void solve(){
	cin>>n;
	v.resize(n);
	forn(i,n)
        cin>>v[i].a>>v[i].b>>v[i].c;
	cout<<ans(0,0);
}
int main(){
	/*int t;
	cin>>t;
	while(t--)*/
		solve();
	return 0;
}



Measured memory_bytes: 32640
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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;
vector<int> ans;
vector<int> preans;
vector<int> G[1000000];
bool b[1000000];

void solve(int n) {
    ans.push_back(n);
    b[n] = true;
    rep(i, G[n].size()) {
        if (!b[G[n][i]]) {
            solve(G[n][i]);
            break;
        }
    }
}

void solve2(int n) {
    if (n != 0) preans.push_back(n);
    b[n] = true;
    rep(i, G[n].size()) {
        if (!b[G[n][i]]) {
            solve2(G[n][i]);
            break;
        }
    }
}

int main(){
    int N, M;
    cin >> N >> M;
    rep(i, M){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    rep(i, N){
        b[i] = false;
    }
    solve(0);
    solve2(0);
    cout << ans.size() + preans.size() << endl;
    rep(i, preans.size()){
        cout << preans[preans.size()-i-1] + 1 << " ";
    }
    rep(i, ans.size()){
        cout << ans[i] + 1 << " ";
    }
    cout << endl;

}

Measured memory_bytes: 30840
N, A, B = [int(_) for _ in input().split()]

if (B - A) % 2 == 0:
    print((B - A) // 2)
else:
    X = A + ((B - A) - 1) // 2
    Y = (N - B + 1) + (N - (A + (N - B + 1))) // 2
    print(min(X, Y))


Measured memory_bytes: 9128
n=int(input())
l=list(map(int,input().split()))
ans=0
c=True

while c == True:
    for i in range(n):
        if l[i]%2==1:
            c = False
    if c == False:
        break
    else:
        for i in range(n):
            l[i]/=2
        ans+=1
print(ans)

Measured memory_bytes: 38640
import java.io.*;
import java.util.*;
import java.math.BigInteger;

public class Main {
    public static BigInteger gcd(BigInteger a, BigInteger b){
        if(a.mod(b).equals(BigInteger.ZERO))
            return b;
        if(b.mod(a).equals(BigInteger.ZERO))
            return a;
        if(a.compareTo(b)<0)
            return gcd(a,b.mod(a));
        return gcd(b,a.mod(b));
    }
    
    public static void main(String args[])throws IOException{
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       int N = Integer.parseInt(br.readLine());
       BigInteger lcm = BigInteger.ONE;
       for(int i=0;i<N;i++){
           BigInteger next = new BigInteger(br.readLine());
           lcm = lcm.multiply(next).divide(gcd(lcm,next));
       }
        System.out.println(lcm);
    }
}
 


Measured memory_bytes: 22356
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int k = sc.nextInt();
	int[] x = new int[n];
	int ans = 0;
	for(int i = 0; i < n; i++) {
		x[i] = sc.nextInt();
		ans += 2 * (int)Math.min(x[i], k - x[i]);
	}
	System.out.println(ans);
}
}

Measured memory_bytes: 21716
#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;

int main(){
    char ch;
    int cnt[26]={};
    
    while(cin >> ch){
        ch=tolower(ch);
        if(isalpha(ch)){
            cnt[ch-'a']++;
        }
    }
    for(int i=0;i<26;i++){
        printf("%c : %d\n",i+'a',cnt[i]);
    }
    return 0;
}



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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const ll  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1000000007;

/*vll adj[MAXN];ll visit[MAXN]={};
ll dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
*/
// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m,k,d,w,summ;
string s,t;
vll a,b;

ll cnt[4000][4000];
// <------------- Implement Functions Here ----------> //

// <------------- Start of main() -------------------> //

void MAIN(ll _) {
	cin >> n >> m;
	cout << max(0ll , n - m);
}

int main() {
	fastio;randomINT;
	//freopen("out_hc.txt","w+",stdout);
	//cin>>T;
	for(ll i=1;i<=T;i++) {
		MAIN(i);
	}
	return 0;
}



Measured memory_bytes: 3604
k = int(input())
l = []
if 7 % k == 0:
    print(1)
    exit(0)
l.append(7 % k)
for i in range(1,k):
    a = (10 * l[i-1] + 7)
    if a % k == 0:
        print(i+1)
        exit(0)
    else:
        l.append(a % k)
print(-1)    

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

const ll INF = 1LL << 60;

ll N, K;
string S;
int main() {
    cin >> N >> K >> S;

    // 1 0 1 0 1 と連続している数の配列を作る
    vector<int> nums;

    int num = 1;
    int cnt = 0;

    for (int i = 0; i < N; i++) {
        if (S[i] == (char)(num + '0')) {
            cnt++;
        } else {
            // 切り替え
            // 1 -> 0
            // 0 - > 1
            nums.push_back(cnt);
            num = 1 - num; 
            cnt = 1;
        }
    }

    if (cnt != 0) {
        nums.push_back(cnt);
    }

    // 1 の数 0をたす
    if (nums.size() % 2 == 0) nums.push_back(0);

    // rep(i, nums.size()) {
    //     cout << nums[i] << " ";
    // }
    // cout << endl;

    int add = 2 * K + 1;
    int ans = 0;
    for (int i = 0; i < nums.size(); i+=2) {
        // 幅の上限
        int right = min((int)nums.size(), i + add);
        // cout << i << " " << right << endl;
        int tmp = 0;
        int left = i;
        for (int j = i; j < right; j++) {
            tmp += nums[j];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4088
H, W = map(int, input().split())
S = ['.'+input()+'. ' for _ in range(H)]

S.insert(0, '.'*(W+2))
S.insert(H+1, '.'*(W+2))

flg = 0
for i in range(1, H+1):
    for j in range(1, W+1):
        if S[i][j]=='#':
            if S[i+1][j]=='.' and S[i-1][j]=='.' and S[i][j+1]=='.' and S[i][j-1]=='.':
                flg = 1
                break
    else:
        continue
    break
    
if flg==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int n,h,w;
  cin>>n>>h>>w;
  vector<Int> x(n);
  for(Int i=0;i<n;i++) cin>>x[i];
  vector<Int> dp(n*w,0);
  for(Int i=0;i<n;i++){
    Int b=w*i;
    if(i&1) b-=x[i];
    else b+=x[i];
    for(Int j=0;j<w;j++)
      if(b+j<n*w) dp[b+j]++;
  }
  //for(Int i:dp) cout<<i<<endl;
  cout<<count(dp.begin(),dp.end(),0)*h<<endl;
  return 0;
}



Measured memory_bytes: 3284
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using li = long long int;
using uli = unsigned long long int;
using namespace std;

int main() {
    fastIO;
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (b <= c || d <= a)
        cout << 0;
    else if (c <= a && b <= d)
        cout << b - a;
    else if (a <= c && d <= b)
        cout << d - c;
    else if (a < c && c < b && b < d)
        cout << b - c;
    else
        cout << d - a;
}

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


namespace TestApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            var c = int.Parse(Console.ReadLine());
            var x = int.Parse(Console.ReadLine());

            var count = 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)
                            count++;
                    }
                }
            }
            Console.WriteLine(count);
            Console.ReadLine();
        }
    }

}

Measured memory_bytes: 13140
def f(a, b):
    return max(len(str(a)), len(str(b)))


def main():
    N = int(input())
    min_f = 10
    for i in range(1, N + 1):
        if i ** 2 > N:
            break
        if N % i != 0:
            continue
        f_v = f(i, N // i)
        if f_v < min_f:
            min_f = f_v
    print(min_f)

if __name__ == '__main__':
    main()


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

int main() {
    string S,T;cin >> S >> T;
    int N = S.size();
    for (int i = 0;i < N;i++){
        if (S[i] != T[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int ans = 1;
    for(int i = 0;i<n;i++)
    {
        if(2*ans >= ans+k)
        {
            ans +=k;
        }else{
            ans *= 2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <boost/multiprecision/mpfr.hpp>  // Defines the Backend type that wraps MPFR
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(long long int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
 
using namespace std;
 
 
int main(){
	long long int n;
	cin >> n;
	long long int a[n],b[n];
	forn(i,0,n) cin >> a[i];
	forn(i,0,n) cin >> b[i];
	long long int ans = 0;
	long long int mxk = 30;
	while(mxk--){
		// checking for mxk bit;
		long long int ca[n],cb[n];
		memcpy(ca,a,sizeof(ca));
		memcpy(cb,b,sizeof(cb));
		long long int t = (1<<mxk);
		forn(i,0,n){
			ca[i] = (a[i]%(2*t));
			cb[i] = (b[i]%(2*t));
		}
		sort(cb,cb+n);
		long long int cnt = 0;
		forn(i,0,n){
			long long int l= 0 ,r = n-1;
			while(l<=r){
				long long int m  = l+r>>1;
				if(ca[i]+cb[m]>=t)
					r = m-1;
				else
					l = m+1;
			}
			// l gives the smallest j s.t. ai + b[j] >= t
			long long int jmin = l;
			l = 0;r = n-1;
			while(l<=r){
				long long int m = l+r>>1;
				if(ca[i]+cb[m]<2*t)
					l = m+1;
				else
					r = m-1;
			} 
			long long int jmax = r;
			if(jmax>=jmin)
				cnt += (jmax-jmin + 1);
			l = 0,r = n-1;
			while(l<=r){
				long long int m  = l+r>>1;
				if(ca[i]+cb[m]>=3*t)
					r = m-1;
				else
					l = m+1;
			}
			jmin = l;
			l = 0;r = n-1;
					jmax = n-1;
			if(jmax>=jmin)
			cnt += (jmax-jmin + 1);
		}
		if(cnt%2==1)
			ans += (1<<mxk);
	}
	cout << ans << endl;
 
}

Measured memory_bytes: 9848
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	string str;
	string tmp;
	while(cin>>str){
		cin>>tmp;
		reverse(str.begin(),str.end());
		if(str==tmp) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

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

int main()
{
  string s;
  cin >> s;

  bool flag1 = false, flag2 = false, flag3 = false;

  if (s[0] == 'A') flag1 = true;

  int counter_1 = 0;
  for (int i = 2; i < s.size()-1; ++i) {
    if (s[i] == 'C') ++counter_1;
    else continue;
  }

  if (counter_1 == 1) flag2 = true;
  
  int counter_2 = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (isupper(s[i])) ++counter_2;
    else continue;
  }

  if (counter_2 == 2) flag3 = true;

  if (flag1 && flag2 && flag3) cout << "AC" << "\n";
  else cout << "WA" << "\n";

  return 0;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
const int N = 1e4 + 4;
int n;
string s[N];
string t;
int up , dn;
int main(){
	cin >> n;
	for(int i = 1 ; i <= n ; ++i){
		cin >> s[i];
	}
	cin >> t;
	up = 0;
	dn = 0;
	for(int i = 1 ; i <= n ; ++i){
		string mn = s[i];
		string mx = s[i];
		for(char &c : mn){
			if(c == '?'){
				c = 'a';
			}
		}
		for(char &c : mx){
			if(c == '?'){
				c = 'z';
			}
		}
		if(mx < t){
			++up;
		}
		if(mn > t){
			++dn;
		}
	}
	bool first = 0;
	for(int i = 1 ; i <= n + 1; ++i){
		if(i > up && i + dn <= n + 1){
			if(first){
				printf(" ");
			}
			printf("%d" , i);
			first = 1;
		}
	}
	printf("\n");
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define ll long long

using namespace std;

ll mod = 1e9 + 7;

ll dp[22][1<<21];

ll nop(int man, int women_set, int total, int comp[][21])
{
  if(man >= total)
  {
    return (women_set == 0) ? 1 : 0;
  }

  if(dp[man][women_set] != -1)
    return dp[man][women_set];

  ll ans = 0;
  //cout<<women_set<<endl;
  //cout<<"calling for man: "<<man<<endl;
  for(int woman = 0 ; woman <total ; woman ++)
  {
    bool avail = ((women_set & (1<<woman)) == 0)?false:true;

    //cout<<"for woman: "<<woman<<" avail = "<<avail<<endl;

    if(avail && comp[man][woman])
    {
      ans += nop(man+1,(women_set ^ (1<<woman)),total,comp);
    }

  }

  return dp[man][women_set] = ans%mod;

}

int main()
{
  int n;
  cin>>n;
  int comp[n][21];
  for(int i = 0 ; i<n ; i++)
    for(int j = 0 ; j<n ; j++)
      cin>>comp[i][j];

  memset(dp,-1,sizeof(dp));
  cout<<nop(0,(1<<n)-1,n,comp)%mod;
  
  return 0;
}

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

int main() {
  int A, B, C, D;
 
  cin >> A >> B >> C >> D;
   
  if((A+B)>(C+D)){
    cout << "Left" << endl;
  }
  else if((A+B)<(C+D)){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<set>
#include<typeinfo>
#include<numeric>
#include<complex>
#include<memory>
using namespace std;

const double pi=4*atan(1.0);

constexpr long long mod=static_cast<long long>(1e9+7);

using cWeightEdges=vector<vector<pair<int,int>>>;
using cEdges=vector<vector<int>>;

int main(){
	int N;
	cin>>N;
	vector<long long> T(N);
	vector<long long> A(N);
	for(auto& val:T)
		cin>>val;
	for(auto& val:A)
		cin>>val;

	if(T.back()!=A.front())cout<<0<<endl;
	else{
		long long ans=1;
		long long prev_T=0;
		long long next_A=LLONG_MAX;
		if(N==1){
			ans=1;
		}
		else{
			for(int i=0;i<N-1;++i){
				next_A=A[i+1];
				if(prev_T==T[i] && next_A==A[i]){
					ans*=min(T[i],A[i]);
					ans%=mod;
				}
				prev_T=T[i];
			}

			bool flag=true;
			for(int i=0;i<N;++i){
				if(A[i]==T[i] && A[i]==A.front())flag=false;
			}
			if(flag)ans=0;
		}
		cout<<ans<<endl;
	}
	
	//system("pause");
	return 0;
}

Measured memory_bytes: 1792
#Brute Force
n, c = map(int, input().split())
D = []
for i in range(c):
    new_line = list(map(int, input().split()))
    D.append(new_line)

C = []
for i in range(n):
    new_line = list(map(lambda x: int(x) - 1, input().split()))
    C.append(new_line)

color_list = [[], [], []]
for i in range(n):
    for j in range(n):
        mod = ((i + 1) + (j + 1)) % 3
        color = C[i][j]
        color_list[mod].append(color)

def change_color_cost(mod, change_color):
    target = color_list[mod]
    total = 0
    for base_color in target:
        total += D[base_color][change_color]
    return total
#print(change_color_cost(1, 1))

def top3(mod):
    min_costs = [[None, float("inf")]] * 3
    for color in range(c):
        cost = change_color_cost(mod, color)
        min_costs.append([color, cost])
        min_costs.sort(key=lambda x: x[1])
        min_costs = min_costs[:3]
    return min_costs
#print(top3(0))

tops = []
for mod in range(3):
    tops.append(top3(mod))
#print(tops)

min_cost = float("inf")
for color0, cost0 in tops[0]:
    for color1, cost1 in tops[1]:
        for color2, cost2 in tops[2]:
            if color0 != color1 and color1 != color2 and color2 != color0:
                min_cost = min(min_cost, cost0 + cost1 + cost2)
print(min_cost)



Measured memory_bytes: 91832
from itertools import accumulate, cycle, chain, repeat
from bisect import bisect

# 入力
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))

# (1, 1), (1, 2), ..., (1, W), (2, W), (2, W - 1), ..., (2, 2), (2, 1),
# (3, 1), (3, 2), ... の順で色1(1マス目), 色1(2マス目), ..., 色1(a_1マス目),
# 色2(1マス目), ..., 色2(a_2マス目), 色3(1マス目), ... と塗る
A = list(accumulate(a))
c = {
    (i, j): bisect(A, k) + 1
    for k, i, j in zip(
        range(H * W),
        chain(
            *(
                repeat(r, W)
                for r in range(H)
            )
        ),
        cycle(
            chain(
                range(W),
                reversed(range(W)),
            )
        )
    )
}
ans = '\n'.join(
    ' '.join(
        str(c[(i, j)])
        for j in range(W)
    )
    for i in range(H)
)

# 出力
print(ans)


Measured memory_bytes: 4988
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var N=Arr.shift()-0;
   if(N==0)break;
   var n=[];
   var p=0;
   for(var i=0;i<N;i++)n[i]=0;
   var str=Arr.shift();
   for(var i=0;i<str.length;i++){
      var v=str[i];
      var j=i%N;
      if(v=="M")n[j]++;
      if(v=="S"){p+=(n[j]+1);n[j]=0;}
      if(v=="L"){n[j]+=(p+1);p=0;}
   }
   n.sort(function(a,b){return a-b;});
   console.log(n.join(" ")+" "+p);
}

Measured memory_bytes: 8704
n, t = gets.split.map(&:to_i)
ts = gets.split.map(&:to_i)

total = t

1.upto(ts.size-1) do |i|
  if ts[i] > ts[i-1] + t
    total += t
  else
    total += t - (t - (ts[i] - ts[i-1]))
  end
end

puts total

Measured memory_bytes: 16004
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
#define rep(i,n) for (int i = 0; i< (n); i++)
using namespace std;
 
int main() {
  int N, M, x = 100, y = 0, z= 0,ans;
  
  cin>>N>>M;
  
  vector<int> s(M);
  vector<int> c(M);
  vector<int> d(3, 10);
  
  rep(i, M) cin>>s[i]>>c[i];
  
  
  if(N == 1){
    if (M != 0){
      ans = c[0];
    }
    else{
     ans = 0;
    }
    
  }
  else if(N == 2){
    rep(i, M){
      if(s[i] == 1){
        y = 10 * c[i];
      }
      else{
        z = c[i];
      }
    }
    if (y == 0) y = 10;
    ans = y + z;
  }
  
  else if(N == 3){
    rep(i, M){
      if(s[i] == 1){
        x = 100 * c[i];
      }
      else if(s[i] == 2){
        y = 10 * c[i];
      }
      else{
        z = c[i];
      }
    }
    ans = x + y + z;
  }
  
  
  rep(i, M){
    if (d[s[i]-1] == 10){
      d[s[i]-1] = c[i];
    }
    else{
      if(d[s[i] - 1] != c[i])  ans = -1;
      break;
    }
  }
  
  rep(i, M){
    if(N == 2){
      if(s[i] == 1 && c[i] == 0) ans = -1;
    }
    else if(N == 3){
      if(s[i] == 1 && c[i] == 0) ans = -1;
    }
    
  }
  
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d=0,e=0;
    cin>>a>>b>>c;
    d=b-a;
    e=c-b;
    if(d==e)
   {
       cout<<"YES";
   }
   else
   {
       cout<<"NO";
   }
    return 0;
}


Measured memory_bytes: 256
import math

N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))


sum_value = 0
sum_cost = 0

for i in range(N):

    if V[i] > C[i]:
        sum_value += V[i]
        sum_cost += C[i]

print(sum_value - sum_cost)





Measured memory_bytes: 3060
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "PP.hpp"
#define deb(x...) cerr << "[" << #x << "] = " << x << "\n";
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

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

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b;
	cin >> a >> b;
	cout << (b % a == 0? a + b:b - a) << '\n';
	return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP((i),0,(n))
#define ALL(v) (v).begin(),(v).end()

int main() {
	string n;
	cin >> n;

	if (n.at(0) == n.at(1) && n.at(1) == n.at(2))cout << "Yes" << endl;
	else if (n.at(1) == n.at(2) && n.at(2) == n.at(3))cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    int a[3];
    rep(i,0,3)cin>>a[i];
    sort(a,a+3);
    cout<<a[0]+a[1]<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2000000000;
constexpr ll mod = 1000000007;

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



int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	ll N, A, B; cin >> N >> A >> B;
	ll l = A - 1;
	if (B - A > 2) {
		++l;
		l+=(B - A) / 2;
	}
	else {
		l += B - A;
	}
	ll r = N - B;
	if (B - A > 2) {
		++r;
		r += (B - A) / 2;
	}
	else {
		r += B - A;
	}
	if ((B - A) % 2 == 0) {
		ll mid = (B - A) / 2;
		cout << min(l, min(r, mid));
	}
	else {
		cout << min(l, r) << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
from __future__ import division, print_function
from sys import stdin
while True:
    m, f, r = (int(s) for s in stdin.readline().split())
    if m < 0 and f < 0 and r < 0:
        break
    mf = m + f
    if m < 0 or f < 0 or mf < 30:
        print('F')
    elif mf >= 80:
        print('A')
    elif mf >= 65:
        print('B')
    elif mf >= 50 or r >= 50:
        print('C')
    else:
        print('D')

Measured memory_bytes: 4232
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String args[])throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		Long a = Long.parseLong(st.nextToken());
		String b = (st.nextToken());
		long b1 = Long.parseLong(b.substring(0,b.indexOf('.'))+b.substring(b.indexOf('.')+1));
		//System.out.println(b1); 
		System.out.println((a*b1)/100);
	}
}

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

enum Animal { WOLF, SHEEP };

Animal get_next(char c, Animal prev, Animal now) {
    bool x = prev == SHEEP;
    bool y = now == SHEEP;
    bool z = c == 'o';
    return (x == y == z) ? SHEEP : WOLF;
}

bool validate(Animal prev, Animal now, Animal next, char c) {
    bool w = prev == SHEEP;
    bool x = now == SHEEP;
    bool y = next == SHEEP;
    bool z = c == 'o';
    return w == x == y == z;
}

string solve(Animal prev, Animal now, string s, int n) {
    Animal first = prev, second = now;
    string ans(n, ' ');
    ans[0] = (prev == SHEEP) ? 'S' : 'W';
    for (int i = 1; i < n; i++) {
        Animal next = get_next(s[i], prev, now);
        prev = now;
        now = next;
        ans[i] = (prev == SHEEP) ? 'S' : 'W';
    }
    if (now != first) return "";
    if (!validate(prev, now, second, s[0])) return "";
    return ans;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    Animal animals[] = {SHEEP, WOLF};
    for (auto first: animals) {
        for (auto second: animals) {
            string ans = solve(first, second, s, n);
            if (ans != "") {
                cout << ans << endl;
                return 0;
            }
        }
    }
    cout << "-1" << endl;
    return 0;
}


Measured memory_bytes: 640
#include <queue>
#include <vector>
#include <iostream>
#include <functional>
using namespace std;
const long long inf = 123456789123456789;
const long long budget = 1000000000000000;
struct edge {
	int to; long long cost;
	edge() : to(-1), cost(0) {};
	edge(int to_, long long cost_) : to(to_), cost(cost_) {};
};
struct state {
	int pos; long long cost;
	state() : pos(-1), cost(0) {};
	state(int pos_, long long cost_) : pos(pos_), cost(cost_) {};
};
bool operator>(const state& s1, const state& s2) {
	return s1.cost > s2.cost;
}
vector<long long> shortest_path(int src, vector<vector<edge> > &G) {
	priority_queue<state, vector<state>, greater<state> > que;
	que.push(state(src, 0));
	vector<long long> dist(G.size(), inf);
	dist[src] = 0;
	while (!que.empty()) {
		state u = que.top(); que.pop();
		for (edge e : G[u.pos]) {
			if (dist[e.to] > dist[u.pos] + e.cost) {
				dist[e.to] = dist[u.pos] + e.cost;
				que.push(state(e.to, dist[e.to]));
			}
		}
	}
	return dist;
}
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N, M, S, T;
	cin >> N >> M >> S >> T; --S, --T;
	vector<vector<edge> > yen(N), snuke(N);
	for (int i = 0; i < M; ++i) {
		int u, v, a, b;
		cin >> u >> v >> a >> b; --u, --v;
		yen[u].push_back(edge(v, a));
		yen[v].push_back(edge(u, a));
		snuke[u].push_back(edge(v, b));
		snuke[v].push_back(edge(u, b));
	}
	vector<long long> dist_yen = shortest_path(S, yen);
	vector<long long> dist_snuke = shortest_path(T, snuke);
	vector<long long> ans(N);
	for (int i = 0; i < N; ++i) {
		ans[i] = budget - (dist_yen[i] + dist_snuke[i]);
	}
	for (int i = N - 2; i >= 0; --i) {
		ans[i] = max(ans[i], ans[i + 1]);
	}
	for (int i = 0; i < N; ++i) {
		cout << ans[i] << '\n';
	}
	return 0;
}

Measured memory_bytes: 19016
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b, c) = scan!(i64, i64, i64);
    if a <= c && c <= b {
        println!("Yes")
    } else {
        println!("No")
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<vector<pair<ll, ll>>> g(n);
    rep(i, n - 1) {
        ll u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        g[u].push_back(make_pair(v, w));
        g[v].push_back(make_pair(u, w));
    }
    queue<pair<ll, ll>> q;
    q.push(make_pair(0, 0));
    vector<bool> seen(n, false);
    seen[0] = true;
    vector<ll> ans(n);
    ans[0] = 0;
    while(!q.empty()) {
        pair<ll, ll> p = q.front(); q.pop();
        for(auto x : g[p.first]) {
            if (seen[x.first]) continue;
            seen[x.first] = true;
            ans[x.first] = (p.second + x.second) % 2;
            q.push(make_pair(x.first, (p.second + x.second) % 2));
        }
    }
    rep(i, n) printf("%lld\n", ans[i]);
    return 0;
}


Measured memory_bytes: 8704