akhauriyash/Code-Regression huggingface dataset:
/*
I am not somebody you can put inside a box
And I am not somebody who will let you take my spot
It's written on my face I'm somebody who never stop
I do it because I gotta I don't do it for you props
Nah, you can keep those
I'm aiming way higher than planes in Heathrow
And I'm sorry to say but my game can't be sold
And look to be honest either you got it or don't
But if you got a dream and a vision
Put it in your mind that you gotta go out and get it
People try to stop you it's so hard in the beginning
But you said that you a winner so keep going ain't no quiting
I'm giving you the words that out me in this posotion
Some people hear and some people listen
Wanna be the best then you gotta learn the difference
*/
#include <bits/stdc++.h>                                           
 
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define int long long	
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define ll long long
#define vi vector < int >
#define pii pair < int, int > 
#define sz(s) (int)s.size()
#define all(x) x.begin(), x.end()                                                                    
#define pb push_back   
#define ppb pop_back
#define mp make_pair
#define s second
#define f first                                               
	
   
typedef tree < int, null_type, less < int >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;   
   
const int N = 2e3 + 13, inf = 1e9, mod = 1e9 + 7, block = 444;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
const ll INF = 1e18;
//fucking constants
 
int s, t, d;

main () {
	cin >> d >> t >> s;
	if (t*s >= d) {
		cout << "Yes\n";
	} else
		cout << "No\n";
			
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;typedef long long ll;const int N=2e5+7;ll n,fa[N],ans,d,a[N],l[N],r[N];main(){cin>>n>>d,ans=(n-1)*d;for(int i=1;i<=n;i++)cin>>a[i],ans+=a[i],l[i]=r[i]=1e18;l[1]=a[1];for(int i=2;i<=n;i++)l[i]=min(l[i-1],a[i]-(i-1)*d);r[n]=a[n]+(n-1)*d;for(int i=n-1;i;i--)r[i]=min(r[i+1],a[i]+(i-1)*d);for(int i=2;i<n;i++)ans+=min((i-1)*d+l[i],r[i]-(i-1)*d);cout<<ans;}

Measured memory_bytes: 6400
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <cassert>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)
#define RRANGE(i, m, n) for(ll i = (m); i >= (n); --i)
#define POSITIVE(x) (x)=((x) < 0) ? 0 : (x)

ll power(ll x, ll y) {
    ll ret = 1;
    while(y-- > 0) ret *= x;
    return ret;
}

ll gcd(ll a, ll b) {
    assert(a >= 0);
    assert(b >= 0);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll extgcd(ll a, ll b, ll& x, ll& y) {
    x = 1; y = 0;
    assert(a >= 0);
    assert(b >= 0);
    if (b == 0) return a;
    ll X, Y;
    auto d = extgcd(b, a % b, X, Y);
    x = Y;
    y = X - (a / b) * Y;
    return d;
}

int run(istream& in, ostream& out) {
    string S;

    in >> S;
    ll ans = 0;
    sort(S.begin(), S.end());
    S.erase(unique(S.begin(), S.end()), S.end());


    out << ((S.size() == 1) ? "No": "Yes") << endl;
    return 0;
}

int run2(istream& in, ostream& out) {
    ll N, M, R;
    in >> N >> M >> R;
    vector<ll> r{};
    REP(i, R) {
        ll x;
        in >> x;
        r.emplace_back(x);
    }
    vector<tuple<ll,ll,ll>> v{};
    REP(i, M) {
        ll a,b,c;
        in >> a >> b >> c;
        v.emplace_back(make_tuple(a,b,c));
    }

    ll ans = 0;

    // solution here

    out << ans << endl;
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 256
# -*-coding:utf-8

def main():

    inputLine = int(input())

    taro = hanako = 0

    for i in range(inputLine):
        tokens = list(input().split())
        if(tokens[0] > tokens[1]):
            taro += 3
        elif(tokens[0] < tokens[1]):
            hanako += 3
        else:
            taro += 1
            hanako += 1

    print('%d %d' % (taro, hanako))



if __name__ == '__main__':
    main()

Measured memory_bytes: 7772
def main():
    import sys
    from bisect import bisect_left
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))
    mod = 1000000007

    for i in range(N-1):
        A[i+1] ^= A[i]
    if A[-1]:
        a = A[-1]
        ans_a = 0
        ans_zero = 1
        for i in range(N-1):
            if A[i] == a:
                ans_a = (ans_a + ans_zero)%mod
            elif A[i] == 0:
                ans_zero = (ans_zero + ans_a)%mod
        print(ans_zero)
    else:
        dic = {}
        zero_num = 0
        for a in A:
            if a:
                if a in dic:
                    dic[a].append(zero_num)
                else:
                    dic[a] = [zero_num]
            else:
                zero_num += 1
        ans = (1 << (zero_num-1))%mod
        for X in dic.values():
            ans_x = 1
            ans_zero = 1
            for i in range(1, len(X)):
                ans_zero = (ans_zero + ans_x * (X[i] - X[i-1])) % mod
                ans_x = (ans_x + ans_zero) % mod
            ans = (ans + ans_x)%mod
        print(ans)


if __name__ == '__main__':
    main()


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

int main(){
  int n;
  cin >>n;
  if(100<=n and n<=111) cout << 111 << endl;
  else if(112<=n and n<=222) cout << 222 << endl;
  else if(223<=n and n<=333) cout << 333 << endl;
  else if(334<=n and n<=444) cout << 444 << endl;
  else if(445<=n and n<=555) cout << 555 << endl;
  else if(556<=n and n<=666) cout << 666 << endl;
  else if(667<=n and n<=777) cout << 777 << endl;
  else if(778<=n and n<=888) cout << 888 << endl;
  else if(889<=n and n<=999) cout << 999 << endl;
  return 0;
}

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

using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++)
#define NMAX 20
#define TMAX 100
static const int dy[5] = {0, 0, -1, 0, 1};
static const int dx[5] = {0, 1, 0, -1, 0};
class State{
public:
  int y, x, t, s;
  State(){}
  State(int y, int x, int t, int s):y(y), x(x), t(t), s(s){}
};

struct Item{ int disc, ts, te; };

int W, H, sy, sx, n;

bool T[NMAX][NMAX][TMAX+1][(1<<8)];
char G[NMAX][NMAX];
Item I[10];

bool valid(int ny, int nx){
  if ( ny < 0 || nx < 0 || ny >= H || nx >= W ) return false;
  return G[ny][nx] == '.';
}

int getAVPoint( int y, int x, int t ){
  int u = 0;

  for ( int r = 1; r < 5; r++ ){
    int ny = y + dy[r];
    int nx = x + dx[r];
    if (ny < 0 || nx < 0 || ny >= H || nx >= W )  continue;
    if ( G[ny][nx] == '.' ) continue;
    int inum = G[ny][nx] - '0';
    //if ( I[inum].ts  <= t && t <= I[inum].te ){
    if ( I[inum].ts  <= t && t < I[inum].te ){
      u = (u | (1<<inum));
    }
  }

  return u;
}

int getPoint(int s){
  int sum = 0;

  for ( int i = 0; i < n; i++ ){
    if ( (s & (1<<i)) > 0 ){
      sum += I[i].disc;
    }
  }

  return sum;
}

void compute(){
  rep(i, H) rep(j, W) rep(k, TMAX+1) rep(l, (1<<n)){
    T[i][j][k][l] = false;
  }

  T[sy][sx][0][getAVPoint(sy, sx, 0)] = true;

  queue<State> Q;
  Q.push(State(sy, sx, 0, getAVPoint(sy, sx, 0)));

  State u, v;

  int ans = 0;
  while(!Q.empty() ){
    u = Q.front(); Q.pop();
    ans = max(ans, getPoint(u.s));
    for ( int r = 0;  r < 5; r++ ){
      int ny = u.y + dy[r];
      int nx = u.x + dx[r];
      if ( !valid(ny, nx) ) continue;
      v = u;
      v.y = ny;
      v.x = nx;
      v.t++;
      if ( v.t > 100 ) continue;
      v.s = (v.s | getAVPoint(v.y, v.x, v.t));
      if ( !T[v.y][v.x][v.t][v.s] ){
	T[v.y][v.x][v.t][v.s] = true;
	Q.push(v);
      }
    }
  }

  cout << ans << endl;
}

main(){
  while(1){
    cin >> W >> H;
    if ( W == 0 && H == 0 ) break;
    rep(i, H) rep(j, W) {
      cin >> G[i][j];
      if ( G[i][j] == 'P' ){
	G[i][j] = '.';
	sy = i; sx = j;
      }
    }
    cin >> n;
    rep(i, n) {
      int g; cin >> g;
      cin >> I[g].disc >> I[g].ts >> I[g].te;
    }
    compute();
  }
}

Measured memory_bytes: 12504
#include <iostream>
using namespace std;
int main(){
    int m=100000;
    int n;
    cin >> n;
    for (int i = 0; i<n;i++){
        m = m*1.05;
        if(m%1000 != 0)
            m = m - m%1000 +1000;
        else
            m = m - m%1000;
    }
    cout << m << endl;
}

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

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

    int ans = 0;
    for (int i = 0; i + 2 < N; i++)
    {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
        {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/python3
import math

# main
n, q = map(int, input().split())
b_size = math.ceil(math.sqrt(n))
b_len = math.ceil(n/b_size)
a = [2 ** 31 - 1 for i in range(n)]
b = [min(a[b_size * i:b_size * (i + 1)]) for i in range(b_len)]
for i in range(q):
    com, x, y = map(int, input().split())
    if com == 0:
        # update
        a[x] = y
        # update b
        index = x // b_size
        b[index] = min(a[index * b_size:(index + 1) * b_size])

    else:
        # find
        target = []
        x_index = x // b_size
        y_index = y // b_size
        x_mod = x % b_size
        y_mod = y % b_size
        if x_index == y_index:
            target.extend(a[x:y + 1])
        else:
            if x_mod == 0:
                target.append(b[x_index])
            else:
                target.extend(a[x:(x_index + 1) * b_size])

            if y_mod == b_size - 1:
                target.append(b[y_index])
            else:
                target.extend(a[y_index * b_size:y + 1])

            if x_index + 1 <= y_index - 1:
                target.append(min(b[x_index + 1 : y_index]))
        print(min(target))

Measured memory_bytes: 9900
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#include<tuple>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
#define REP(i,n) for (int i = 1; i <= (int)n; i++)//i=1からi=nまで
#define RREP(i,n)for(int i=n;i>=1;i--) 
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
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; }
int main() {
    int N, M,a=0,w=0; cin >> N >> M;
    vector<string> S(N+1);
    vector<int> wa(N+1 ,0);
    vector<bool>ac(N+1 , false);
    REP(i, M) {
        int p; cin >> p;
        cin >> S[p];
        if (ac[p] == false) {
            if (S[p]!= "AC") {
                wa[p]++;
            }
            else {
                ac[p] = true;
            }
        }
    }
    REP(i, N) {
        if (ac[i] == true) {
            a++;
            w += wa[i];
        }
    }
    cout << a << " " << w << endl;

            


}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{ 
    cin>>s;
    int l=s.size();
    int cnt=0;
    for(int i=0;i<l-1;i++)
        if(s[i]!=s[i+1]) 
		    cnt++;
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 512
def howmany2_5(x):
    x = round(x * 10 ** 9)
    n2, n5 = 0, 0
    while x % 2 == 0:
        n2 += 1
        x //= 2
    while x % 5 == 0:
        n5 += 1
        x //= 5
    
    if n2 > 18:
        n2 = 18
    if n5 > 18:
        n5 = 18
    
    return (n2, n5)

def lower_bound_0(A, x):
    s, t = -1, len(A)
    while t - s > 1:
        m = (s + t) // 2
        if A[m][0] >= x:
            t = m
        else:
            s = m
    
    return t
    

def upper_bound_0(A, x):
    s, t = -1, len(A)
    while t - s > 1:
        m = (s + t) // 2
        if A[m][0] > x:
            t = m
        else:
            s = m
    
    return t
    
def lower_bound_1(A, x):
    s, t = -1, len(A)
    while t - s > 1:
        m = (s + t) // 2
        if A[m] >= x:
            t = m
        else:
            s = m
            
    return t

def upper_bound_1(A, x):
    s, t = -1, len(A)
    while t - s > 1:
        m = (s + t) // 2
        if A[m] > x:
            t = m
        else:
            s = m
            
    return t


N = int(input())
A = [howmany2_5(float(input())) for _ in range(N)]
A.sort()
B = []
for i in range(19):
    B.append(list(map(lambda x: x[1], A[lower_bound_0(A, i): upper_bound_0(A, i)])))
C = []
for i in range(19):
    C.append([upper_bound_1(B[i], j) - lower_bound_1(B[i], j) for j in range(19)])
    
ans = 0
for i in range(9):
    for j in range(19):
        cnt = C[i][j]
        for k in range(18 - i, 19):
            ans += sum(C[k][18-j:]) * cnt
    

for i in range(9, 19):
    for j in range(9):
        cnt = C[i][j]
        for k in range(9, 19):
            ans += sum(C[k][18-j:]) * cnt

upper_9_9 = 0
for i in range(9, 19):
    upper_9_9 += sum(C[i][9:])
ans += upper_9_9 * (upper_9_9 - 1) // 2

print(ans)

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

typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
typedef vector< vector<char> > vvc;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef long long ll;

int main(){
    int N;
    string S;
    cin >> N >> S;
    ll a=0,b=0,c=0;
    for(int i=0;i<N;i++){
        if(S[i]=='R') a++;
        else if(S[i]=='G') b++;
        else c++;
    }
    ll sum=a*b*c;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(2*j-i>N-1) break;
                if(S[i]!=S[j]&&S[i]!=S[2*j-i]&&S[j]!=S[2*j-i])
                    sum--;
        }
    }
    cout << sum << endl;
    return 0;
}

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

int main()
{
    int N,K,X,Y;
    cin>>N>>K>>X>>Y;
    int sum=0;

    if(1<=K<=10000 && 1<=Y<=X<=10000 && 1<=N<=10000)
    {
        if(N<=K)
        {
            sum=N*X;
        }
        if(N>K)
        {
            sum=K*X+(N-K)*Y;
        }









    }
    cout<<sum;







    return 0;

}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	string s;
	cin >> n >> s;

	ll ans = LONG_LONG_MAX;
	vll black, white;
	vll bsum, wsum;

	bool flg=false;
	ll cnt=0;

	rep(i, n){
		if (flg && s[i]=='#') cnt++;
		if (flg && s[i]=='.') flg = false, black.pb(cnt), cnt=0;
		if (flg==false && s[i]=='#') flg = true, cnt++;
	}

	flg = false;
	cnt = 0;

	rep(i, n){
		if (flg && s[n-i-1]=='.') cnt++;
		if (flg && s[n-i-1]=='#') flg = false, white.pb(cnt), cnt=0;
		if (flg==false && s[n-i-1]=='.') flg = true, cnt++;
	}

	bsum.pb(0);
	rep(i, black.size()){
		bsum.pb(black[i]+bsum.back());
	}

	wsum.pb(0);
	rep(i, white.size()){
		wsum.pb(white[i]+wsum.back());
	}

	rep(i, bsum.size()){
		ans = min(ans, bsum[i] + wsum[bsum.size()-i-1]);
	}


	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 4364
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
    string S;
    cin >> N >> S;
	int ans = 0;
	for(int i = 1; i < N; i++){
		int X[26] = {};
        int Y[26] = {};
        int cnt = 0;
		for(int j = 0; j < i; j++){
			X[S[j]-'a'] = 1;
		}
		for(int j = i; j < N; j++){
			Y[S[j]-'a'] = 1;
		}
		for(int j = 0; j < 26; j++){
	        if(X[j] == Y[j] && X[j] == 1) {
                cnt++;
            }
		}
        ans = max(ans,cnt);
	}
	cout << ans << endl;
}	

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

using namespace std;

class State{
public:
  int ay, ax, by, bx, t;
  State(int ay = 0, int ax = 0, int by = 0, int bx = 0, int t = 0)
    : ay(ay), ax(ax), by(by), bx(bx), t(t) {}
};

int h, w;
char data[20][20];
int pat[10];
int pat_size;
int say, sax, sby, sbx;
int dy[] = {-1, 0, 1, 0, 0};
int dx[] = {0, 1, 0, -1, 0};

bool check(int y, int x){
  if(y<0 || y>=h) return false;
  if(x<0 || x>=w) return false;
  return true;
}

void solve(){
  int ans = -1, ansy, ansx;
  bool vis[20][20][20][20][10];
  State u = State(say, sax, sby, sbx, 0), v;
  fill(vis[0][0][0][0], vis[20][0][0][0], false);
  queue<State> q;
  q.push(u);
  while(!q.empty()){
    u = q.front(); q.pop();
    if(u.ay == u.by && u.ax == u.bx){
      ans = u.t;
      ansy = u.ay;
      ansx = u.ax;
      break;
    }
    int nby = u.by + dy[pat[u.t%pat_size]];
    int nbx = u.bx + dx [pat[u.t%pat_size]];
    if(!check(nby, nbx)){
      nby = u.by;
      nbx = u.bx;
    }
    for(int i=0;i<4;i++){
      int nay = u.ay + dy[i];
      int nax = u.ax + dx[i];
      if(!check(nay, nax)){
        nay = u.ay;
        nax = u.ax;
      }
      if(data[nay][nax] == '#'){
        nay = u.ay;
        nax = u.ax;
      }
      if(!vis[nay][nax][nby][nbx][u.t%pat_size]){
        vis[nay][nax][nby][nbx][u.t%pat_size] = true;
        q.push(State(nay, nax, nby, nbx, u.t+1));
      }
    }
  }
  if(ans == -1){
    cout << "impossible" << endl;
  }else{
    cout << ans << ' ' << ansy << ' ' << ansx << endl;
  }
}

main(){
  while(cin >> h >> w && (h|w)){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin >> data[i][j];
        if(data[i][j] == 'A'){
          say = i;
          sax =j;
          data[i][j] = '.';
        }
        if(data[i][j] == 'B'){
          sby = i;
          sbx = j;
          data[i][j] = '.';
        }
      }
    }
    getchar();
    string in;
    getline(cin, in);
    pat_size = in.size();
    for(int i=0;i<pat_size;i++){
      if(in[i] == '8') pat[i] = 0;
      if(in[i] == '6') pat[i] = 1;
      if(in[i] == '2') pat[i] = 2;
      if(in[i] == '4') pat[i] = 3;
      if(in[i] == '5') pat[i] = 4;
    }
    solve();
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h> 
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
using Pii = std::pair<int, int>;
 
int main(int argc, char *argv[])
{
    std::string S;
    std::cin >> S;

    int n = S.size();

    ll ans = 0;
    for (ll bit = 0; bit < (1<<(S.size()-1)); bit++) {
        ll number = S[0] - '0'; 
        for (int i = 0; i < S.size()-1; i++) {
            if (bit & (1<<i)) {
                ans += number;
                number = 0;
            }
            number = number * 10 + S[i+1] - '0';
        }
        ans += number;
    }

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


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, Q;
  cin >> N >> Q;
  vector<vector<int>> G(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  vector<int> counter(N, 0);
  for (int i = 0; i < Q; i++) {
    int p, x;
    cin >> p >> x;
    counter[p - 1] += x;
  }
  function<void(int, int)> dfs = [&](int u, int p) {
    for (int v : G[u]) {
      if (v == p) continue;
      counter[v] += counter[u];
      dfs(v, u);
    }
  };
  dfs(0, 0);
  for (auto &v : counter) {
    cout << v << (&v == &counter.back() ? '\n' : ' ');
  }
  return 0;
}


Measured memory_bytes: 29696
N, A, B, C, D = map(int, input().split())

dif = B - A

ans = "NO"
for i in range(N):
    pos = i
    neg = N - i - 1
    high = D * pos - C * neg
    low = C * pos - D * neg
    if low <= dif <= high:
        ans = "YES"
        break

print(ans)

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

int main(void){

   int n;
   cin >> n;

   int cnt = 1;
   int ans = 0;

   vector<int> num(n+1);
   for (int i = 1; i <= n;i++){
      cin >> num[i];
      if(cnt == num[i]){
         ans++;
         cnt++;
      }
   }

   if(ans == 0){
      cout << -1 << endl;
      return 0;
   }
   cout << n-ans << endl;

   return 0;
}

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

#define INF 999999

int main() {
    int n,m;
    cin >> n >> m;
    
    int c[m];
    for(int i=0; i<m; i++){
        cin >> c[i];
    }
    
    int dp[m][n+1];
    for(int i=0; i<m; i++){
        for(int j=0; j<n+1; j++){
            dp[i][j] = INF;
        }
    }
    
    //そのコイン１種類で表せるものを先に埋めておく
    for(int i=0; i<m; i++){
        for(int j=0; j<n+1; j++){
            if(j % c[i] == 0){
                dp[i][j] = j/c[i];
            }
        }
    }
    
    for(int i=1; i<m; i++){
        for(int j=0; j<n+1; j++){
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
            if(j-c[i] > 0){
                dp[i][j] = min(dp[i][j], dp[i][j-c[i]] + 1);
            }
        }
    }
    
    cout << dp[m-1][n] << endl;
    return 0;
}



Measured memory_bytes: 7000
#include<iostream>
#include<vector>
using namespace std;
#define MAX 7500000
int prime[MAX];
int main(){
    int n,m;
    while(cin >> m >> n,n){
        for(int i = m; i < MAX; i++)prime[i] = 0;
        int cnt = 0;
        for(int i = m; i < MAX; i++)if(prime[i] == 0){
            cnt++;
            if(cnt > n){
                cout << i << endl;
                break;
            }
            for(int j = 2; i*j < MAX; j++)prime[i*j] = 1;
        }
    }
}



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

using namespace std;

const int N = 14;

int n, m, x;

int a[N][N], c[N], cur[N], ans = -1;

int main () {
    cin >> n >> m >> x;
    for (int i = 0;i < n;i ++) {
        cin >> c[i];
        for (int j = 0;j < m;j ++) {
            cin >> a[i][j];
        }
    }
    for (int mask = 0;mask < (1 << n);mask ++) {
        int cnt = 0;
        for (int i = 0;i < m;i ++) {
            cur[i] = 0;
        }
        for (int i = 0;i < n;i ++) {
            if (mask & (1 << i)) {
                cnt += c[i];
                for (int j = 0;j < m;j ++) {
                    cur[j] += a[i][j];
                }
            }
        }
        bool ok = true;
        for (int i = 0;i < m;i ++) {
            if (cur[i] < x)ok = false;
        }
        if (ok) {
            if (ans == -1)ans = cnt;
            else ans = min (ans, cnt);
        }
    }
    cout << ans;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

const int N = 100100;
const int INF = 19191919;
vector<int> G[N];
int d[N][2];

const int P = 1000000;
bool prime[P];

int main(){
    fill(prime, prime+P, true);
    prime[0] = prime[1] = false;
    for(int i=2; i<P; ++i){
        if(prime[i]) for(int j=2*i; j<P; j+=i) prime[j] = false;
    }

    int n,m,s,t;
    scanf(" %d %d %d %d", &n, &m, &s, &t);

    rep(i,m){
        int a,b;
        scanf(" %d %d", &a, &b);
        G[a].pb(b);
        G[b].pb(a);
    }

    fill(d[0],d[N],INF);
    d[s][0] = 0;
    queue<pi> que({{s,0}});
    while(!que.empty()){
        pi now = que.front();
        que.pop();

        int v = now.fi, p = now.se;
        int np = !p;
        for(int e:G[v]){
            if(d[e][np] > d[v][p]+1){
                d[e][np] = d[v][p]+1;
                que.push({e,np});
            }
        }
    }

    int ans = INF;
    if(d[t][1]<INF){
        ans = d[t][1];
        while(!prime[ans]) ans += 2;
    }
    if(d[t][0]<=2) ans = 2;
    if(ans == INF) ans = -1;
    printf("%d\n", ans);
    return 0;
}



Measured memory_bytes: 10540
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d,e,f;
    cin >> a >> b >> c;
    d = max(a,b); e=max(b,c);
    f = max(d,e);
    if(f==a){
        cout << b+c << endl;
    }
    else if(f==b){
        cout << a+c << endl;
    }
    else{
        cout << a+b << endl;
    }
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N;
	if (N & 1) {
		cout << 0 << endl;
		return 0;
	}
	long long int ans = 0;
	long long int box = 10;
	while (1) {
		long long int add = N / box;
		ans += add;
		if (add < 5)break;
		box *= 5;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

using i8 = ::std::int_least8_t;
using i32 = ::std::int_least32_t;
using i64 = ::std::int_least64_t;
using u8 = ::std::uint_least8_t;
using u32 = ::std::uint_least32_t;
using u64 = ::std::uint_least64_t;
using isize = ::std::ptrdiff_t;
using usize = ::std::size_t;

template <class T = usize> class rep {
	const T f, l;

public:
	class itr {
		friend rep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { ++i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr rep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(f); }
	constexpr itr end() const noexcept { return itr(l); }
};
template <class T = usize> class revrep {
	const T f, l;

public:
	class itr {
		friend revrep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { --i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr revrep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(l - 1); }
	constexpr itr end() const noexcept { return itr(f - 1); }
};
template <class T> bool amax(T &a, const T &b) {
	return a <= b ? (a = b, 1) : 0;
}
template <class T> bool amin(T &a, const T &b) {
	return b <= a ? (a = b, 1) : 0;
}
template <class T> bool samax(T &a, const T &b) {
	return b <= a ? 0 : (a = b, 1);
}
template <class T> bool samin(T &a, const T &b) {
	return a <= b ? 0 : (a = b, 1);
}
template <class T> using vec_alias = ::std::vector<T>;
template <class T> auto md_vec(usize n, const T &value) {
	return ::std::vector<T>(n, value);
}
template <class... Args> auto md_vec(usize n, Args... args) {
	return ::std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> const T &as_const(const T &v) noexcept { return v; }
template <class T> constexpr T difference(const T &a, const T &b) {
	return a <= b ? b - a : a - b;
}

#include <cstddef>

template <class T> T power(T x, u64 exp) {
	T ret = 1;
	while (exp) {
		if (exp & 1)
			ret *= x;
		exp >>= 1;
		x *= x;
	}
	return ret;
}


#include <algorithm>
#include <iostream>
#include <utility>
#include <cmath>
#include <limits>

int main() {
	u64 n, p;
	::std::cin >> n >> p;
	if (n == 1) {
		::std::cout << p << ::std::endl;
		return 0;
	}
	if (n > 50) {
		::std::cout << 1 << ::std::endl;
		return 0;
	}
	const u64 m = ::std::pow(static_cast<double>(2000000000000), static_cast<double>(1) / n);
	for (const auto i : revrep<u64>(1, m+1)) {
		if (p%power(i, n) == 0) {
			::std::cout << i << ::std::endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

int main(){
    ll k; cin>>k;
    vector<ll>a(k);
    a[0]=7%k;
    for(int i=1;i<k;i++){
        a[i]=(a[i-1]*10+7)%k;
    }
    rep(i,k){
        if(a[i]==0){
            cout<<i+1<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}








































Measured memory_bytes: 11068
#include <bits/stdc++.h>
using namespace std;
int t, n, f[4];
double dp[303][303][303]; //expected step to have a * 1, b * 2, c * 3
double solve(int a, int b, int c){
    //printf("%d %d %d\n", a, b, c);
    if  (a < 0 || b < 0 || c < 0 || a + b + c == 0)
        return 0;
    if (dp[a][b][c] != 0.0)
        return dp[a][b][c];
    dp[a][b][c] = solve(a - 1, b, c) * (double) a / n;
    dp[a][b][c] += solve(a + 1, b - 1, c) * (double) b / n;
    dp[a][b][c] += solve(a, b + 1, c - 1) * (double) c / n;
    dp[a][b][c] += 1.0; //one more step
    dp[a][b][c] = dp[a][b][c] * (double) n / (a + b + c); //0 
    //probability to have the following states
    //printf("%d %d %d %.4lf!\n", a, b, c, dp[a][b][c]);
    return dp[a][b][c];
}
int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; i++){
        scanf("%d", &t);
        f[t]++;
    }
    printf("%.15lf\n", solve(f[1], f[2], f[3]));
    return 0;
}
//https://qiita.com/drken/items/03c7db44ccd27820ea0d 

Measured memory_bytes: 217344
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 1e18+10 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
signed main(){
	int n;
	while(cin>>n,n){
		vvi in(n,vi(2));
		rep(i,n)rep(j,2)cin>>in[i][j];
		sort(all(in));
		int tim=0;
		queue<pii>que[2];
		rep(i,n)que[0].push({in[i][0],i});
		while(!que[0].empty()||!que[1].empty()){
			tim=inf;
			rep(i,2)if(!que[i].empty()){
				int t=que[i].front().first;
				if(tim>t)tim=t;
			}
			rep(i,2){
				vp ne;
				while(!que[i].empty()&&que[i].front().first<=tim){
					ne.pb(que[i].front());
					que[i].pop();
				}
				rep(j,ne.size())rep(k,ne.size())
					if(in[ne[j].second][0]<in[ne[k].second][0])swap(ne[j],ne[k]);
				rep(j,ne.size()){
					pii p=ne[j];
					if(i){
						in[p.second][1]--;
						if(in[p.second][1])que[i^1].push({tim+in[p.second][0],p.second});
					}else que[i^1].push({tim+in[p.second][0],p.second});
				}
			}
		}
		cout<<tim<<endl;
	}
}









Measured memory_bytes: 3088
module Memoizable
	def memoize(name)
		original = "__original_#{name}__"
		([Class, Module].include?(self.class) ? self : self.class).class_eval {
			alias_method(original, name)
			private(original)
			cache = {}
			define_method(name){|*args|
				cache[args] ||= send(original, *args)
			}
		}
	end 
end

include Memoizable

$possible_next = {}
(1..7).each{|x|
	prev_attend = (0..2).select{|i| x[i] == 1}
	(0..2).each{|in_charge|
		(1..7).each{|y|
			next_attend = (0..2).select{|i| y[i] == 1}
			if next_attend & prev_attend != [] && next_attend.include?(in_charge)
				($possible_next[[x, in_charge]] ||= []) << y
			end
		}
	}
}

n = gets.to_i
$in_charge = gets.chomp.split("").map{|c|
	case c
		when ?J; 0
		when ?O; 1
		when ?I; 2
	end
}

def f(prev_attend, k)
	in_charge = $in_charge[k-1]
	if k == $in_charge.size
		$possible_next[[prev_attend, in_charge]].size
	else
		sum = 0
		$possible_next[[prev_attend, in_charge]].each{|next_attend|
			sum += f(next_attend, k+1)
		}
		sum % 10007
	end
end

memoize :f

sum = 0
(1..7).each{|x|
	if x[$in_charge[0]] == 1 && x[0] == 1
		sum += f(x, 2)
	end
}
p sum % 10007

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

int N;
const int MAX_N = 1.0e5 + 100;
int A[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];

    ll fare = abs(A[0]);
    for (int i = 1; i < N; i++) {
        fare += abs(A[i] - A[i-1]);
    }
    fare += abs(A[N-1]);

    cout << fare + abs(A[1]) - abs(A[0]) - abs(A[0] - A[1]) << endl;
    for (int i = 0; i < N-1; i++) {
        cout << fare + abs(A[i+2] - A[i]) - abs(A[i+1] - A[i]) - abs(A[i+2] - A[i+1]) << endl;
    }

    return 0;
}


Measured memory_bytes: 1664
using System;
using System.Linq;
using static System.Console;

class AtCoder
{
    public static void Main()
    {
        var t = ReadIntArray();
        int n = t[0];
        int q = t[1];
        var s = ReadLine();

        var a = new int[n]; a[0] = 0;
        int ct = 0;
        for (int i = 0; i < n - 1; i++){
            if (s[i] == 'A' && s[i+1] == 'C'){
                ct++;    
            }
            a[i+1] = ct;
        }

        for (int i = 0; i < q; i++){
            var x = ReadIntArray();
            int l = x[0];
            int r = x[1];
            WriteLine(a[r-1] - a[l-1]);
        }        
    }

    static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

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

a.sort()

minc=0
maxc=0

for i in range(1,9):
    if len([x for x in a if x<400*i and x>=400*(i-1)]):
        minc+=1

if minc:
    maxc = minc + len([x for x in a if x>=400*(9-1)])
else:
    maxc = len([x for x in a if x>=400*(9-1)])
    minc = 1

print(str(minc) + ' ' + str(maxc))


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

int main() {
  int N, L;
  cin >> N >> L;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int M = 0;
  int s;
  for (int i = 0; i < N-1; i++) {
    if (M < a[i]+a[i+1]) {
      M = a[i]+a[i+1]; s = i+1;
    }
  }
  if (M < L) {
    cout << "Impossible" << endl;
    return 0;
  }
  cout << "Possible" << endl;

  for (int i = 1; i < s; i++) {
    cout << i << endl;
  }
  for (int i = N-1; i > s; i--) {
    cout << i << endl;
  }
  cout << s << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int find(int a[],int p,int n){
	for(int i=0;i<n;i++){
		if(a[i]==p)
			return 0;
	}
	return 1;
}
int main(){
	int x,n,p,q;
	cin >> x >> n;
	if(n==0){
		cout << x << endl;
		return 0;
	}
	int a[n];
	p = q = x;
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	while(1){
		if(find(a,p,n)){
			cout << p << endl;
			return 0;
		}
		if(find(a,q,n)){
			cout << q << endl;
			return 0;
		}
		p--;
		q++;
	}
}


Measured memory_bytes: 3764
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//幅優先探索のテンプレ.デフォルトではstartからの距離を返す.
//graphは隣接リスト.startは探索開始地点
vector<int> bfs(vector<vector<int>> &graph, int start){
	queue<int> todo;
	vector<int> dist(graph.size(),-1);
	dist[start] = 0;
	todo.push(start);
	while(!todo.empty()){
		int now = todo.front();
		todo.pop();
		for (int i=0;i<graph[now].size();i++){
			int nxt = graph[now][i];
			if (dist[nxt] != -1) continue;
			dist[nxt] = dist[now] + 1;
			todo.push(nxt);
		}
	}
	return dist;
}

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int flag = 1;
	rep(i,n){
		if (a[i] % 2 == 0){
			if (a[i] % 3 == 0 || a[i] % 5 == 0){

			} else {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(LL, n, k);
	n %= k;
	OUT(min(n, k - n));
}


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

signed main(){
int a,b;cin>>a>>b;
if(a==1){cout<<b<<endl; return 0;}
int ans=1;
for(int i=2;i<=10000000;i++){
if(pow(i,a)>=pow(10,15))break;
while(b%(int)pow(i,a)==0){ans*=i;b/=(int)pow(i,a);}
}
cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <iostream>

bool inputPoint(int&, int&, int&);
int culculateSumPoint(const int&, const int&);
char askGrading(const int&, const int&);

int main(){
	int chukanPoint;
	int kimatsuPoint;
	int saishikenPoint;

	while (inputPoint(chukanPoint, kimatsuPoint, saishikenPoint)){
		int sumPoint = culculateSumPoint(chukanPoint, kimatsuPoint);	//合計点数
		char grading = askGrading(sumPoint, saishikenPoint);			//成績
		std::cout << grading << std::endl;
	}
	return 0;
}

//点数入力を受け付ける関数
//入力数値がすべて-1ならfalseを返す
bool inputPoint(int& chukanPoint, int& kimatsuPoint, int& saishikenPoint){
	std::cin >> chukanPoint >> kimatsuPoint >> saishikenPoint;
	if (chukanPoint == -1 && kimatsuPoint == -1 && saishikenPoint == -1){
		return false;
	}
	else{
		return true;
	}
}

//合計点数を求める関数
int culculateSumPoint(const int& chukanPoint, const int& kimatsuPoint){
	if (chukanPoint == -1 || kimatsuPoint == -1){
		return 0;
	}
	else{
		return chukanPoint + kimatsuPoint;
	}
}

//成績を求める関数
char askGrading(const int& sumPoint, const int& saishikenPoint){
	if (sumPoint >= 80){
		return 'A';
	}
	else if (sumPoint >= 65){
		return 'B';
	}
	else if (sumPoint >= 50){
		return 'C';
	}
	else if (sumPoint >= 30){
		if (saishikenPoint >= 50){
			return 'C';
		}
		else{
			return 'D';
		}
	}
	else {
		return 'F';
	}
}


Measured memory_bytes: 3104
#include <stdio.h>

int main(void) {
  int i, n;
  scanf("%d", &n);
  for(i = 1; i <= n; ++i) {
    if(!(i % 3)) printf(" %d", i);
    else if(i % 10 == 3) printf(" %d", i);
    else {
      int x = i;
      while( x ) {
        x /= 10;
        if(x % 10 == 3) {
          printf(" %d", i);
          break;
        }
      }
    }
  }
  printf("\n");
  return 0;
}


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


typedef pair<ll,ll> pll;


ll n;
ll a[200005];
vector<ll> v;
int main()
{
        cin >> n;
        for(ll i=1;i<=n;i++) {
                cin >> a[i];
                v.pb(a[i]);
        }
        sort(v.rbegin(), v.rend());
        ll ma = v[0];
        ll sa = v[1];
        for(ll i=1;i<=n;i++){
                if(a[i] != ma) cout << ma << endl;
                else cout << sa << endl;
        }
        return 0;
}


Measured memory_bytes: 4848
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,a[100005],c=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]%2)
		c++;
	}
	if(c%2 && n!=1)
	printf("NO\n");
	else
	printf("YES\n");
}

Measured memory_bytes: 640
N = int(input())
c = list(input())
a=0; b=0; ans = 0

for i in range(N):
    if c[i] == "R":
        a += 1
ans = max(a,b)

for i in range(N):
    if c[i] == "R":
        a -= 1
    else:
        b += 1
    now = max(a,b)
    ans = min(ans,now)
print(ans)

Measured memory_bytes: 10772
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = sc.nextLong();
		for (int i = 1; i < n; i++)
			a[i] += a[i - 1];
		long min = Long.MAX_VALUE;
		for (int i = 1; i < n; i++)
			min = Math.min(min, Math.abs(a[i - 1] - (a[n - 1] - a[i - 1])));
		out.println(min);
		out.flush();
		out.close();
	}

	static class MyScanner {
		StringTokenizer st;
		BufferedReader br;

		public MyScanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public MyScanner(String filename) throws IOException {
			br = new BufferedReader(new FileReader(new File(filename)));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}
}


Measured memory_bytes: 47956
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n;
    cin >> n;
    vector a(n,0LL);
    for (int i=0; i<n; i++) cin >> a[i];
    map<int64,int64> mp;
    for (int i=1; i<=n; i++) mp[a[i-1] + i]++;

    int64 ans = 0;
    for (int j=1; j<=n; j++) {
        ans += mp[j - a[j-1]];
    }
    cout << ans << endl;
}

Measured memory_bytes: 27004
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		
		int[] a = {-1, 1, 2, 1, 3, 1, 3, 1, 1, 3, 1, 3, 1};
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (a[x] == a[y]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}
	

Measured memory_bytes: 20948
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n, m;
    cin>>n>>m;
    string s, t;
    cin>>s>>t;

    ll l = lcm(n, m);
    ll g = gcd(n, m);
    ll nx = n / g;
    ll mx = m / g;

    ll ans = l;
    for(ll i=0;i<g;++i){
        if(s[nx * i] != t[mx * i]){
            ans = -1;
            break;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long
signed main(){
  int n;
  cin>>n;
  string s,t;
  set<string> ss;
  for(int i=0;i<n;++i){
    cin>>t;
    if(ss.find(t)!=ss.end()||(s!=""&&s[s.size()-1]!=t[0]))return cout<<"No",0;
    ss.insert(t);
    s=t;
  }
  cout<<"Yes";
}

Measured memory_bytes: 256