akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
#define EN cout<<endl;
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
const ll mod=1000000007;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yes(T b){if(b)out("yes");else out("no");}
template<class T> void Yes(T b){if(b)out("Yes");else out("No");}
template<class T> void YES(T b){if(b)out("YES");else out("NO");}
template<class T> void no(T b){if(b)out("no");else out("yes");}
template<class T> void No(T b){if(b)out("No");else out("Yes");}
template<class T> void NO(T b){if(b)out("NO");else out("YES");}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}
 


int main(){
    int n,t;
    cin>>t;
    rep(x,t){
        cin>>n;
        vector<P>vl,vr;
        ll ans=0;
        rep(j,n){
            ll k,l,r;
            cin>>k>>l>>r;
            
            ans+=min(l,r);
            
            if(l>r){
                vl.emplace_back(k,l-r);
                }
            else {
                if(k!=n)
                vr.emplace_back(k,r-l);
                }
        }
        sort(ALLr(vl));
        sort(ALL(vr));
        priority_queue<ll> q,q2;
        ll j=0;
        rep(i,vl.size()){
            while(j<vl.size()&&vl[j].F>=vl.size()-i){
                q.push(vl[j].S);
                j++;
            }
            if(!q.empty()){
                ans+=q.top();
                q.pop();
            }
            
            
        }
        
        j=0;
        rep(i,vr.size()){
            
            while(j<vr.size()&&vr[j].F<=n-vr.size()+i){
                q2.push(vr[j].S);
                j++;
            }
            if(!q2.empty()){
                ans+=q2.top();
                q2.pop();
            }
            
        }
        //rep(i,vr.size())cout<<vr[i].F<<endl;

        cout<<ans<<endl;
    }
    
}


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

int main(){
  int N;
  cin>>N;
  int A[N];
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  bool ans=true;
  sort(A,A+N);
  for(int i=0;i<N-1;i++){
    if(A[i]==A[i+1]){
      ans =false;
      break;
    }
  }
  if(ans){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 4324
#include<bits/stdc++.h>
#define int long long
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
#define mod 1e9
//int a[100005],b[i][30];
int32_t main() {
	/*int t;
	cin>>t;
	while(t--)
	{
		int n,i,j,k;
		cin>>n;
		for(i=1;i<=n;i++)
		{
			cin>>a[i];
			for(j=0;j<=26;j++)
				b[i][j]=b[i][j-1];
			b[i][a[i]]++;
		}*/
	string s;
	int a,b;
	cin>>a>>b;
	cin>>s;
	map<char ,int> mp;
	for(auto c:s)
	{
		mp[c]++;
	}
	if(s[a]=='-' && mp['-']==1)
		cout<<"Yes\n";
	else cout<<"No\n";
		
		
}

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

namespace Modop {
    ll modAdd(ll a, ll b) {
        return (a + b) % MOD;
    }
    
    ll modSub(ll a, ll b) {
        return (((a - b) % MOD) + MOD) % MOD;
    }
    
    ll modMul(ll a, ll b) {
        return ((a % MOD) * (b % MOD)) % MOD;
    }

    ll modExp(ll base, ll power) {
        if (power == 0) {
            return 1;
        } else {
            ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
            if (power % 2 == 1) cur = cur * base;
            cur = cur % MOD;
            return cur;
        }
    }
    
    ll modInv(ll a) {
        return modExp(a, MOD - 2);
    }
    
    ll modDiv(ll a, ll b) {
        return modMul(a, modInv(b));
    }
}

using namespace Modop;

int n;
string s, garbage;

ll ans = 1;

// 0 if horiz, 1 if vert
int last = -1;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> s >> garbage;
    if (n == 1 || s[0] != s[1]) {
        ans *= 3;
        last = 0;
    } else {
        ans *= 6;
        last = 1;
    }

    for (int i = last + 1; i < n; ++i) {
        if (i == n - 1 || s[i] != s[i + 1]) {
            if (!last) ans = modMul(ans, 2);
            else last = !last;
        } else {
            if (!last) {
                last = !last;
                ans = modMul(ans, 2);
            } else {
                ans = modMul(ans, 3);
            }
            i++;
        }
    }
    cout << ans;
}
    
    


Measured memory_bytes: 256
#include <stdio.h>

int a[10500],n;

int linearSearch(int key){
  int i;
  
  a[n]=key;
  
  for(i=0; i<n; i++)
    if(key==a[i])
      return 1;

  return 0;
}

int main(){
  int count=0,i,q,b;

  scanf("%d",&n);
  for(i=0; i<n; i++)
    scanf("%d",&a[i]);

  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&b);
    if(linearSearch(b)==1)
      count++;
  }

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

  return 0;
}

  
  
      

  



Measured memory_bytes: 2104
n,m,q=map(int, input().split())
abcd=[]
for i in range(q):
  a,b,c,d=map(int, input().split())
  abcd.append([a,b,c,d])
def dfs(i):
  if i==0:
    alist=[]
    for k in range(m):
      alist.append([k+1])
    return alist
  elif i>0:
    blist=[]
    for k in dfs(i-1):
      last=k[-1]
      for l in range(last,m+1):
        clist=k.copy()
        clist.append(l)
        blist.append(clist)
    return blist
ans=0
for alist in dfs(n-1):
  cnt=0
  for i in range(q):
    if alist[abcd[i][1]-1]-alist[abcd[i][0]-1]==abcd[i][2]:
      cnt+=abcd[i][3]
  ans=max(ans,cnt)
print(ans)

Measured memory_bytes: 38576
#include <iostream>

#include <map>
#include <string>

#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cinttypes>


using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	if (a == b && b != c || a == c && c != b || b == c && c != a)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
using namespace std;

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    long long a,b,c;
    cin>>a>>b>>c;
    if(a==(b+c)||b==(a+c)||c==(b+a))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;




}


Measured memory_bytes: 256
import sys
n = int(input())
ls = list(map(int,input().split()))
ls.sort()
a = 1
for i in range(n):
    a *= ls[i]
    if a > 10**18:
        print("-1")
        sys.exit()
    elif a == 0:
        print("0")
        sys.exit()
print(a)

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

int main(){
  int N;cin>>N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  double ans=0.0;
  for (int j=0; j<N;j++){
    ans += 1.0/A.at(j);
  }
  
  cout<<1/ans<<endl;
}

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

using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;


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

	int y,m,d;
	scanf("%d/%d/%d", &y,&m, &d);
	if(y > 2019) cout << "TBD";
	else{
		if(m > 4) cout << "TBD";
		else{
			if(m > 30) cout << "TBD";
			else cout << "Heisei";
		}
	}
	return 0;
}


Measured memory_bytes: 256
x, y = map(int, input().split())
y /= 1000

def calc(x, y):
    for i in range(x + 1):
        for j in range (x + 1 - i):
            if i * 10 + j * 5 + (x - i - j) * 1 == y:
                return  print(i, j, (x - i - j))
    return print('-1 -1 -1')
calc(x, y)

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

int main()
{
  int n,m;
  cin>>n>>m;
  vector<int> a(n);
  vector<int> b(n);
  int i;
  for(i = 0; i < n; i++)
  {
    cin >> a.at(i) >> b.at(i);
  }
  vector<pair<int, int>> p(n);
  for(i = 0; i < n; i++)
  {
    p.at(i) = make_pair(a.at(i), b.at(i));
  }
  int index = 0;
  sort(p.begin(), p.end());
  int day = 1;
  long long ans = 0;
  priority_queue<int> que;
  while(day <= m)
  {
    while(index < n)
    {
      if(p.at(index).first == day)
      {
        que.push(p.at(index).second);
        index++;
      }
      else break;
    }
    if(!que.empty())
    {
      ans += que.top();
      que.pop();
    }
    day++;
  }
  cout << ans << endl;
}

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

using namespace std;

string s, t;
int dp[3001][3001];
int his[3001][3001];
int xdir[4] = {0, -1, -1, 0};
int ydir[4] = {0, 0, -1, -1};
vector <char> ans;

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

    int slen = s.length(), tlen = t.length();
    for(int i = 1; i <= slen; i++)
    {
        for(int j = 1; j <= tlen; j++)
        {
            if(s.at(i-1) == t.at(j-1))
            {
                dp[i][j] = dp[i-1][j-1] + 1;
                his[i][j] = 2;
            }
            else if(dp[i-1][j] > dp[i][j-1])
            {
                dp[i][j] = dp[i-1][j];
                his[i][j] = 1;
            }
            else
            {
                dp[i][j] = dp[i][j-1];
                his[i][j] = 3;
            }
        }
    }

    int xind = slen, yind = tlen, aind = 0;
    while(xind >= 1 && yind >= 1)
    {
        if(his[xind][yind] == 2)
        {
            ans.push_back(s.at(xind-1));
            xind--;
            yind--;
        }
        else if(his[xind][yind] == 1) xind--;
        else yind--;
    }

    for(int i = ans.size()-1; i >= 0; i--)
    {
        cout << ans[i];
    }
    cout << endl;

    for(int i = 0; i < slen; i++)
    {
        for(int j = 0; j < tlen; j++)
        {
            //cout << his[i][j] << ' ';
        }
        //cout << endl;
    }
}

Measured memory_bytes: 70656
# include<iostream>
# include<algorithm>
# include<cmath>
using namespace std;
int main ()
{
	int K;
	cin>>K;
	int A,B;
	cin>>A>>B;
	bool ok = false;
	for(int i=A;i<=B;i++)
	{
		if(i%K==0)
		{
			cout<<"OK"<<endl;
			return 0;
		}
	}
	
	cout<<"NG"<<endl;
	return 0;
}

Measured memory_bytes: 3624
void main() {
  problem();
}

void problem() {
  auto N = scan!int;
  auto M = scan!int;
  auto Q = scan!int;
  auto ABCD = Q.iota.map!(x => scan!int(4)).array;

  long calcScore(int[] nm) {
    
    long s;
    foreach(abcd; ABCD) {
      auto a = abcd[0];
      auto b = abcd[1];
      auto c = abcd[2];
      auto d = abcd[3];

      if (nm[b] - nm[a] == c) s += d;
    }

    nm.deb;

    return s;
  }

  long solve() {
    int[] numbers = new int[N + 1];
    numbers[] = 1;
    numbers[$-1] = 0;

    long max_score;
    while(true) {

      foreach_reverse(right; 1..N+1) {
        if (numbers[right] == M) continue;

        numbers[right..$] = numbers[right] + 1;
        break;
      }
      
      long score = calcScore(numbers);
      if (score > max_score) max_score = score;
      
      if (numbers[1] == M) break;
    }

    return max_score;
  }

  writeln(solve());
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

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


Measured memory_bytes: 2728
#include <stdio.h>

int main() {

	char a[10],b[10];
  	scanf( "%s%s", a , b );
  	
  	if( a[0] == b[2] && a[1] == b[1] && a[2] == b[0] ) printf(" YES\n" );
  	else printf(" NO\n ");
  
}

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

bool hantei(string s){
	if(s.size() == 1){
		return true;
	}
	else{
		for(int i = 0;i < s.size()-1;i++){
			if(s[i]+1 != s[i+1]){
				return false;
			}
		}
	}
	return true;
}

int main(){
	int n,x;
	int a[1001];
	int result = -1;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	for(int i = 0;i < n-1;i++){
		for(int j = i+1;j < n;j++){
			x = a[i] * a[j];
			stringstream ss;
			string s;
			ss << x;
			ss >> s;
			if(hantei(s)){
				result = max(result,x);
			}
		}
	}
	cout << result <<endl;
	return 0;
}

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

int main(){

    int a = 0;
    int b = 0;
    char A[25];
    char B[25];
    char C[25];

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

    a = strlen(A);
    b = strlen(B);

    if (A[a-1] == B[0]){
        if (B[b-1] == C[0])         
            puts("YES");
        else
            puts("NO");
    }
    else{
        puts("NO");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

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

  int H, W; cin >> H >> W;
  vector<string> s(H);
  rep(i, H) cin >> s[i];
  int left[2020][2020], right[2020][2020], up[2020][2020], down[2020][2020];

  rep(i, H) {
      int cur = 0;
      rep(j, W) {
          if(s[i][j]=='#') cur = 0;
          else ++cur;
          left[i][j] = cur;
      }
  }
  rep(i, H) {
      int cur = 0;
      for(int j = W-1; j >= 0; --j) {
          if(s[i][j]=='#') cur = 0;
          else ++cur;
          right[i][j] = cur;
      }
  }
  rep(j, W) {
      int cur = 0;
      rep(i, H) {
          if(s[i][j]=='#') cur = 0;
          else ++cur;
          up[i][j] = cur;
      }
  }
  rep(j, W) {
      int cur = 0;
      for(int i = H-1; i >= 0; --i) {
          if(s[i][j]=='#') cur = 0;
          else ++cur;
          down[i][j] = cur;
      }
  }

  // Output
  int ans = -1;
  rep(i, H) rep(j, W) {
      if(s[i][j]=='#') continue;
      ans = max(ans, left[i][j]+right[i][j]+up[i][j]+down[i][j]-3);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 68224
# coding: utf-8
# Your code here!
a=[]
try:
    while True:
        a.append(int(input()))
except EOFError:
    pass
b=[0]*101

for i in a:
    b[i]+=1
c=max(b)

for i in range(100):
    if b[i]==c:
        print(i)


Measured memory_bytes: 5600
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		List<Integer> list = new ArrayList<>();
		for(int i = 0; i < 3; i++) {
		list.add(Integer.parseInt(sc.next()));
		}
		list.sort(null);
		int ans = list.get(0) + list.get(1);
		System.out.print(ans);
	}

}


Measured memory_bytes: 23636
#include <iostream>

int main(int argc, char const *argv[])
{
  using namespace std;
  bool flag = true;
  int n;
  int count = 0;
  cin >> n;
  int * a = new int[n];
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  for (int i = 0; flag; i++)
  {
    flag = false;
    for (int j = n - 1; j > i; j--)
    {
      if (a[j] < a[j - 1])
      {
        int temp = a[j];
        a[j] = a[j - 1];
        a[j - 1] = temp;
        count++;
        flag = true;
      }
    }
  }
  for (int i = 0; i < n - 1; i++)
  {
    cout << a[i] << ' ';
  }
  cout << a[n - 1] << endl;
  cout << count << endl;
  delete[] a;
  return 0;
}



Measured memory_bytes: 3088
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD=1000000007;
//scanf("%d", &a); '\n';


int main() {
	int n;
	cin >> n;
	vector<int> L(n);
	rep(i, n) scanf("%d", &L[i]); '\n';;
	int sum = 0;
	sort(L.begin(), L.end());
	rep(i, n) {
		rep2(j, i + 1, n) {
			int it = lower_bound(L.begin() + j + 1, L.end(), L[i] + L[j]) - L.begin();
			sum += it - j - 1;
		}
	}
	cout << sum << endl;
	}

	

Measured memory_bytes: 256
import Control.Monad (unless)
import Data.List

main = do
  n <- readLn
  unless (n == 0) $ do
    str <- getLine
    putStrLn.foldl1 (.) (replicate n countStr) $ str
    main

countStr = concat.map count.group
  where count cs = (show.length $ cs) ++ [head cs]

Measured memory_bytes: 4236
//https://yukicoder.me/problems/25
//https://yukicoder.me/submissions/194289
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <string.h>
using namespace std;

const int MAX_N=10000;
int h,r;

int main(){
	cin >> h >> r;
	
	cout << (h==-1*r?0:(h>-1*r?1:-1)) << endl;
	return 0;
}

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

int main()
{
	long long s, n, k;
	const long long M = 1000000000;

	cin >> s;

	n = s / M;
	k = s % M;
	
	if (n == 0)
		cout << 0 << " " << 0 << " " << 1 << " " << 0
			<< " " << 0 << " " << s << endl;
	else if (n == M)
		cout << 0 << " " << 0 << " " << M << " " << 0
		<< " " << 0 << " " << M << endl;
	else
		cout << 0 << " " << 0 << " " << M << " " << 1
			<< " " << M - k << " " << n + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<double, double>  iidb;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9;
const double PI = acos(-1);
const ll MOD= 200003;
#define initseg ll new_nodo=(nodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 3100
#define offset 200
#define ptr nodo*
ll dp[tam][tam][4];
ll n,m,k;
ll val[tam][tam];
ll f(int y,int x,int cuanto)
{
	
	if (y==n && x==m)
		return (cuanto>0)?val[n][m]:0;

	if (x>m|| y>n|| cuanto<0)
		return -2e18;
	if (dp[y][x][cuanto]!=-1)
		return dp[y][x][cuanto];
	ll res=0;
	res=max(f(y,x+1,cuanto-1)+((cuanto>0)?val[y][x]:0),res);
	res=max(f(y,x+1,cuanto),res);
	res=max(f(y+1,x,3)+((cuanto>0)?val[y][x]:0),res);
	return dp[y][x][cuanto]=res;
}
int  main()
{
	memset(dp,-1,sizeof dp);
	cin>>n>>m>>k;
	ll iz,der;
	forr(i,0,k)
	{
		cin>>iz>>der;
		cin>>val[iz][der];
	}
	cout<<f(1,1,3)<<endl;
}				

Measured memory_bytes: 377016
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	vector<int>v(n+1);
	for(int i = 1; i < n+1; i++)
	{
		for(int j = 1; j <= (n/i); j++){
			v[i*j]++;
		}
	}
	ll ret = 0;
	for(int i = 1; i< n+1; i++){
		ret+=v[n-i];
	}
	cout<<ret;
	return 0;
}

Measured memory_bytes: 7084
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val ans = IntArray(n){0}

    for (x in 1..n) {
        if (x*x + 2*x > n) break
        y@for (y in 1..n) {
            if (x*x + y*y + x*y + x + y > n) break@y
            z@for (z in 1..n) {
                val tmp = x*x + y*y + z*z + x*y + y*z + z*x
                if (tmp <= n) {
                    ans[tmp-1]++
                } else {
                    break@z
                }
            }
        }
    }

    println(ans.joinToString(separator = System.lineSeparator()))
}

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

int main() {
  int x,y;
  cin >> x;
  y = x;
  
  int f = 0;
  while(y > 0) {
    f += y % 10;
    y /= 10;
  }
  if(x % f == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n+1);
    for (int i = 1; i <= n; i++) cin >> a[i];
    vector<int> id(n+1, -1);
    vector<int> s;
    int len = 0;
    int x = 1;
    while (id[x] == -1) {
        id[x] = len;
        s.push_back(x);
        len++;
        x = a[x];
    }

    int c = len - id[x];

    int ans = 0;
    if (k < len) {
        ans = s[k];
    }
    else {
        k -= len;
        k %= c;
        ans = s[id[x]+k];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;


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

    int N = s.size();

    int i=0, j = N-1;

    int ans = 0;
    while (i < j) {
        if (s[i] != s[j]) ++ans;

        ++i;--j;
    }

    cout << ans << endl;

    return 0;
}

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



int main()
{
    int small =0;
    int result = 1;
    int N;
    cin >> N;
    vector<int> arr;
    for(int i=0;i<N;i++){
        int tmp;
        cin >> tmp;
        arr.push_back(tmp);
        if(i==0) small = tmp;
    }

    for(vector<int>::iterator it = arr.begin();it !=arr.end();++it){
        if(*it < small){
            result++;
            small = *it;
        }
        
    }
    cout << result;
    return 0;
}

Measured memory_bytes: 1400
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int flag=0;
	for(int i=0;i<=n/4;i++)
		for(int j=0;j<=n/7;j++)
		{
			if(4*i+7*j==n)
			{
				flag=1;
				break;
			}
		}
		if(flag==0)
			printf("No\n");
		else
			printf("Yes\n");
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val n = readLine()!!.toLong()
    when {
        n < 10 -> println(n)
        n.toString().substring(1,n.toString().length).all { it == '9' } -> println((n.toString().length - 1) * 9 + n.toString()[0].toString().toInt())
        n.toString()[0] == '1' -> println((n.toString().length - 1) * 9)
        else -> println((n.toString().length - 1) * 9 + n.toString()[0].toString().toInt() - 1)
    }
}

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

int main(int argc , char **argv)
{
	(void)argc;
	(void)argv;

	int sum=0;
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		int l,r;
		cin >> l >> r;
		sum += (r-l+1);
	}

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

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

bool f(vector<int> x, vector<int> y){
    for(int i = 0; i < x.size(); i++){
        if(x[i] != y[i])return false;
    }
    return true;
}

int main(){

    int N;
    cin >> N;
    vector<int> A(N), P(N), Q(N);
    for(int i = 1; i <= N; i++){
        A[i - 1] = i;
        cin >> P[i - 1];
    }
    for(int i = 0; i <N; i++){
        cin >> Q[i];
    }
    int cnt = 0, p, q;
    do{
        if(f(A, P))p = cnt;
        if(f(A, Q))q = cnt;
        cnt++;
        //for(int i = 0; i < N; i++){
        //    cout << A[i];
        //}
        //cout << endl;
    }while(next_permutation(all(A)));
    cout << abs(p - q) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    
    int N;
    cin >> N;
    const ll mod = 1000000007;
    
    string A,B;
    cin >> A;
    cin >> B;
    
    ll ans = 0;
    
    int n = 0;
    int f = 0;
    
    if(A[0] == B[0]){
        n = 1;
        ans = 3;
        f = 1;
    }else{
        n = 2;
        ans = 6;
        f = 2;
    }

    
    for (int i = n; i < N; i++) {
         if(A[i] == B[i]){
             if(f == 1){
                 ans *= 2;
                 ans %= mod;
                 
             }else{
                 ans *= 1;
                 ans %= mod;
                 
             }
             f = 1;
             
             
             
           }else{
               if(f == 1){
                   i += 1;
                   ans *= 2;
                   ans %= mod;
                   
               }else{
                   i += 1;
                   ans *= 3;
                   ans %= mod;
               }
               f = 2;
               
           }
               
    }
    
    cout << ans%mod << endl;
    
    return 0;
}



Measured memory_bytes: 256
n = int(input())
p1 = list(map(int, input().split()))
p2 = p1.copy()
p2.sort()
cnt = 0
for i in range(n):
    if p1[i] != p2[i]:
        cnt += 1
if cnt <= 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var m, f, r int

	for {
		fmt.Scan(&m, &f, &r)

		if m == -1 && f == -1 && r == -1 {
			break
		}

		switch {
		case m == -1 || f == -1:
			fmt.Println("F")
		case m+f >= 80:
			fmt.Println("A")
		case m+f >= 65:
			fmt.Println("B")
		case m+f >= 50 || r >= 50:
			fmt.Println("C")
		case m+f >= 30:
			fmt.Println("D")
		default:
			fmt.Println("F")
		}

	}
}


Measured memory_bytes: 1136
stdin = gets().split(" ")
to_iStdin = stdin.map{ |x| x.to_i }

sHur = to_iStdin[0]
sMin = to_iStdin[1]
fHur = to_iStdin[2]
fMin = to_iStdin[3]
studyT = to_iStdin[4]

startTime = sHur * 60 + sMin
sleepTime = fHur * 60 + fMin

result = sleepTime  - startTime - studyT

puts result

Measured memory_bytes: 14268
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll maxn = 2e5 + 5 , mod = 1e9 + 7;
int n;
ll c[maxn];
ll fpow(ll x , ll k) {
	ll ans = 1 , base = x;
	while(k) {
		if(k & 1) ans = ans * base % mod;
		base = base * base % mod;
		k >>= 1;
	}
	return ans;
}
inline bool cmp(ll a , ll b){ return a > b; }
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n;
	for(register int i = 1; i <= n; ++i) cin >> c[i];
	sort(c + 1 , c + n + 1 , cmp);
	ll ans = 0;
	for(register int i = 1; i <= n; ++i) 
		ans = (ans + c[i] * (i + 1) % mod) % mod;
	ans = ans * fpow(2 , 2 * n - 2) % mod;
	cout << ans << endl;
	return 0;
} 

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

# from numba import njit

# input = stdin.readline

def countProcedure(string):
  res = 0
  strCount = 1
  prev = "" # 1つまえの文字
  for i in range(len(string)):
    if string[i] == prev:
      strCount += 1
    else:
      res += strCount // 2
      strCount = 1
    prev = string[i]

  if strCount != 1:
    res += strCount // 2
  return res

def solve(s,k):
  if s[0] != s[-1]:
    return countProcedure(s)*k
  if all(x == s[0] for x in s):
    return len(s)*k//2
  else:
    leftLength = max(i for i in range(1,len(s)) if s[:i]== s[0]*i)
    left = s[0]*leftLength
    right = s[leftLength:]
    ans = countProcedure(left) + countProcedure(right) + countProcedure("".join([right,left]))*(k-1)
    return ans


def main():
  S = input()
  K = int(input())
  # N,M = map(int,input().split())
  # a = list(map(int,input().split()))
  print(solve(S,K))
  
  
if __name__ == '__main__':
  main()


Measured memory_bytes: 9236
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int k;
	cin>>k;
	queue<ll> q;
	for(int i = 1;i<10; i++)
		q.push(i);
	k--;
	while(k--)
	{
		ll h = q.front();
		q.pop();
		int g = h%10;
		for(int i =max(g-1,0);i<=min(9,g+1); i++)
			q.push(10*h+i);
	}
	cout<<q.front()<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
using namespace std;

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


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

	for(int i=0; i<min((ll)s.size(), k); i++) {
		if (s[i]!='1') {
			cout << s[i] << endl;
			return 0;
		}
	}
	cout << '1' << endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

/*

*/

fn main() {
    input!{
        n: usize,
        mut m: usize,
        mut ab: [(usize, usize); n],
    }
    ab.sort();
    let mut abab = BinaryHeap::new();
    let mut ans = 0;
    let mut pos = 0;
    for i in 1..(m+1) {
        while pos < n && ab[pos].0 <= i {
            abab.push(ab[pos].1);
            pos += 1;
        }
        if let Some(b) = abab.pop() {
            ans += b;
        }
    }

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


Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define sortall(obj) sort(ALL(obj))
#define revall(obj) reverse(ALL(obj))
#define SortRevAll(obj) revall(sortall(obj))
typedef string str;
typedef long long ll;
const int mod=1e9+7;
const int INF=1e9;
const ll LINF=1e18;
#define VI vector<int>
#define P pair
#define M map
#define F first()
#define S second()
#define PB(a) push_back(a)
#define IN(a) insert(a)
#define ins(a) int a;cin >> a
#define lls(a) ll a;cin >> a
#define in(a) cin >> a
#define sts(a) string (a);cin >> a
#define For(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) For(i,0,n)
#define Forr(i,m,n) for(int i=n-1;i>=m;i--)
#define repr(i,n) Forr(i,0,n)
#define print(a) cout << a << endl
#define Endl cout << endl
#define YES(n) cout << ((n)? "YES" : "NO") << endl
#define Yes(n) cout << ((n)? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define br(c,y,n) cout << ((c)? y : n) << endl

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

int main()
{
    ins(a);ins(b);ins(c);
    print((a+b)*c/2);
    return 0;
}


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

using namespace std;
int main(void){
    // Your code here!
    string s = "",t;
    cin >> t;
    s += t;
    cin >> t;
    s += t;
    
    t = s;
    
    reverse(t.begin(),t.end());
    
    if(t == s){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}


Measured memory_bytes: 256
#include<cstdio>

char s[8001];
int d[2][16001];

int main() {
	int x, y, i;
	scanf("%s%d%d", s, &x, &y);
	for (i = 0; i < 16001; i++) {
		d[0][i] = 0;
		d[1][i] = 0;
	}
	d[1][8000] = 1;
	int sread = 0, direction = 0, distance = 0;
	while (s[sread] == 'F') {
		sread++;
		distance++;
	}
	d[0][8000 + distance] = 1;
	while (s[sread] != '\0') {
		while (s[sread] == 'T') {
			direction++;
			sread++;
		}
		direction = direction % 2;
		distance = 0;
		while (s[sread] == 'F') {
			sread++;
			distance++;
		}
		if (distance > 0) {
			for (int i = 0; i < 16001; i++) {
				if (d[direction][i] % 2 == 1) {
					d[direction][i + distance] += 2;
					d[direction][i - distance] += 2;
				}
			}
			for (i = 0; i < 16001; i++) {
				d[direction][i] = (d[direction][i] >= 2) ? 1 : 0;
			}
			printf("");
		}
	}
	if (d[0][8000 + x] == 1 && d[1][8000 + y] == 1) {
		printf("Yes");
	}
	else {
		printf("No");
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());

        int[] flg = new int[n];

        for (int i = 0; i < k; i++) {
            int d = Integer.parseInt(sc.next());
            for (int j = 0; j < d; j++) {
                int a = Integer.parseInt(sc.next());
                flg[a - 1]++;
            }
        }
        sc.close();

        // 主処理
        int count = Arrays.stream(flg).filter(i -> i == 0).toArray().length;
        int result = count;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 41952
#                         author:  kagemeka 
#                         created: 2019-11-08 12:38:16(JST)
## internal modules
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## external modules
# import scipy.special   # if use comb function on AtCoder, 
# import scipy.misc      # select scipy.misc.comb (old version) 

def main():
    d, n = (int(x) for x in sys.stdin.readline().split())
    if n < 100:
        ans = n * 100 ** d
    else:
        ans = 101 * 100 ** d
    
    print(ans)


if __name__ == "__main__":
    # execute only if run as a script
    main()


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

int main(){
    long long int n,D; cin >>n>>D;
    int ans = 0;
    for(int i=0; i<n; i++){
        long long int p,q;cin>>p>>q;
        ans+=((p*p+q*q)<=D*D);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

ll N,D,A;

bool cmp(const pair<ll, ll> &i, const pair<ll, ll> &j) {
    return i.first < j.first;
}

int main() {
    cin>>N>>D>>A;
    vector<pair<ll, ll>> X(N);
    vector<ll> x(N);
    for (int i = 0; i < N; ++i) {
        cin >> X[i].first >> X[i].second;
    }
    sort(X.begin(), X.end(), cmp);
    for (int i = 0; i < N; ++i) x[i] = X[i].first;

    vector<ll> sub(N, 0);
    ll acc = 0LL, ans = 0LL;
    for (int i = 0; i < N; ++i) {
        acc -= sub[i];
        ll damage = acc * A;
        ll rem_health = X[i].second - damage;
        if (rem_health <= 0LL)
            continue;

        ll n_extra_bombs = rem_health / A;
        if (rem_health % A) ++n_extra_bombs;
        acc += n_extra_bombs;
        ans += n_extra_bombs;

        vector<ll>::iterator it = upper_bound(x.begin(), x.end(), X[i].first + (D<<1));
        ll pos = it - x.begin();
        if (pos < N)
            sub[pos] += n_extra_bombs;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>
#include <stdlib.h>

int s[200000];

int compare(const void* a, const void* b)
{
    return *(int*)a - *(int*)b;
}

int main(void)
{
    int n;
    int q;
    int cnt;
    int i, j;

    scanf("%d", &n);
    for (i = 0; i < n; ++i){
        scanf("%d", s + i);
    }

    scanf("%d", &q);
    cnt = 0;
    for (i = 0; i < q; ++i){
        int t;

        scanf("%d", &t);
        if (bsearch(&t, s, n, sizeof(int), compare) != NULL){
            ++cnt;
        }
    }

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

    return (0);
}

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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

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

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  ll n, m;
  cin >> n >> m;

  vector<pair<ll, ll>> a(n + m);
  rep(i, n) {
    cin >> a[i].first;
    a[i].second = 1;
  }

  rep(i, m) {
    cin >> a[n + i].second >> a[n + i].first;
  }

  sortAlr(a);

  ll remain = n;
  ll sum = 0;
  FORm(it, a) {
    if (it->second > remain) {
      sum += it->first * remain;
      break;
    } else {
      sum += it->first * it->second;
      remain -= it->second;
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3456
N,M,L,Q;
D[301][301];
i,j,k;
a,b,c;
main()
{
	scanf("%d%d%d",&N,&M,&L);
	for(i=0;i<N;i++)for(j=0;j<N;j++)D[i][j]=1000000001;
	for(i=0;i<M;i++)
	{
		scanf("%d%d%d",&a,&b,&c);
		--a;
		--b;
		D[a][b]=D[b][a]=c;
	}
	for(k=0;k<N;k++)for(i=0;i<N;i++)for(j=0;j<N;j++)
		if(D[i][j]>D[i][k]+D[k][j])D[i][j]=D[i][k]+D[k][j];
	for(i=0;i<N;i++)for(j=0;j<N;j++)
	{
		D[i][j]=D[i][j]>L?1000000000:1;
	}
	for(k=0;k<N;k++)for(i=0;i<N;i++)for(j=0;j<N;j++)
		if(D[i][j]>D[i][k]+D[k][j])D[i][j]=D[i][k]+D[k][j];
	scanf("%d",&Q);
	for(i=0;i<Q;i++)
	{
		scanf("%d%d",&a,&b);
		--a;
		--b;
		printf("%d\n",D[a][b]<1000000000?D[a][b]-1:-1);
	}
}

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

int main(){
int A,B,C,i=1,x;
  cin >> A >> B >> C >> i >> x;
  
  while(true){
    x = A*i;
    if(x >= A*B)
      break;
  
  if(x % B == C){
  cout << "YES" << endl;
    return 0;
  }
  ++i;
  }
  cout << "NO" << endl;
  
}


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

int main() {
  long N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0, a; cin >> a; i++) {
    A.at(i) = --a;
  }
  vector<int> V;
  vector<bool> B(N);
  long now = 0, last = -1;
  while (N--) {
    if (B.at(now)) {
      last = now;
      break;
    }
    V.push_back(now);
    B.at(now) = true;
    now = A.at(now);
  }
  vector<int> X, Y;
  bool b = 0;
  for (int i = 0; i < V.size(); i++) {
    if (V.at(i) == last) b = 1;
    if (!b) X.push_back(V.at(i));
    else Y.push_back(V.at(i));    
  }
  if (K < X.size()) {
    cout << X.at(K) + 1 << "\n";
  } else {
    K -= X.size();
    cout << Y.at(K % Y.size()) + 1 << "\n";
  }
}

Measured memory_bytes: 6376
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
//これは、頭が悪く競プロが世界で一番できないHIR180が
//IOI2014日本代表になるまでのN日間の記録である。
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define f first
#define s second
#define rep(i,x) for(int i=0;i<x;i++)
int dp[155][15][155];
int num[155];
//position,slipness(?)
P st[155][15];
int main()
{
	srand((unsigned int)time(NULL));
	while(1)
	{
		int n,k; scanf("%d %d",&n,&k);if(!n) return 0;
		for(int i=0;i<155;i++)for(int j=0;j<15;j++)for(int k=0;k<155;k++)dp[i][j][k]=INF;
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&num[i]);
			for(int j=0;j<num[i];j++)
			{
				scanf("%d%d",&st[i][j].f,&st[i][j].s);
			}
		}
		num[0]=num[n+1]=1;
		dp[0][0][k]=0;
		for(int i=0;i<=n;i++)
		{
			for(int j=0;j<num[i];j++)
			{
				for(int rem=0;rem<=k;rem++)
				{
					if(dp[i][j][rem]==INF) continue;
					if(rem && i!=n)
					{
						if(i==n-1 || i==0)
						{
							for(int s=0;s<num[i+2];s++) dp[i+2][s][rem-1]=min(dp[i+2][s][rem-1],dp[i][j][rem]);
						}
						else
						{
							for(int s=0;s<num[i+2];s++)
							{
								dp[i+2][s][rem-1]=min(dp[i+2][s][rem-1],dp[i][j][rem]+abs(st[i][j].f-st[i+2][s].f)*abs(st[i][j].s+st[i+2][s].s));
							}
						}
					}
					
					{
						if(i==n || i==0)
						{
							for(int s=0;s<num[i+1];s++) dp[i+1][s][rem]=min(dp[i+1][s][rem],dp[i][j][rem]);
						}
						else
						{
							for(int s=0;s<num[i+1];s++)
							{
								dp[i+1][s][rem]=min(dp[i+1][s][rem],dp[i][j][rem]+abs(st[i][j].f-st[i+1][s].f)*abs(st[i][j].s+st[i+1][s].s));
							}
						}
					}
				}
			}
		}
		int ret=INF;
		for(int i=0;i<=k;i++) ret=min(ret,dp[n+1][0][i]);
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 2616
n,k=(int(i) for i in input().split())
h=[]
for i in range(n):
    h.append(int(input()))
h.sort()
dif = 10000000000
for i in range(n-k+1):
    if dif>h[i+k-1]-h[i]:
        dif = h[i+k-1]-h[i]

print(dif)

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/23  Problem: 085_abc_d / Link: https://abc085.contest.atcoder.jp/tasks/abc085_d?lang=en  ----- */
/* ------問題------

あなたが散歩していると、突然一体の魔物が出現しました。幸い、あなたは N 本の刀、刀 1、刀 2、…、刀 N を持っていて、次の二種類の攻撃を自由な順番で行うことができます。
持っている刀のうち一本を振る。刀 i (1≤i≤N) を振ると、魔物は ai ポイントのダメージを受ける。同じ刀を何度振ることもできる。
持っている刀のうち一本を投げつける。刀 i (1≤i≤N) を投げつけると、魔物は bi ポイントのダメージを受け、あなたはその刀を失う。すなわち、あなたは以後その刀を振ることも投げつけることもできなくなる。
魔物は、受けたダメージの合計が H ポイント以上になると消滅します。魔物を消滅させるには、最小で合計何回の攻撃が必要でしょうか。

-----問題ここまで----- */
/* -----解説等-----

刀の使用は順序を必要としないので、これは貪欲に強いものを使用していけば良い。
Aは最大値のみ、Bはこれを比較していけばいいので降順にみていけばよい。

----解説ここまで---- */

LL N,H;

LL ans = 0LL;

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

	cin >> N>>H;
	VL a(N), b(N);
	priority_queue<LL>pqa;
	priority_queue<LL>pqb;

	FOR(i, 0, N) {
		cin >> a[i] >> b[i];
		pqa.push(a[i]);
		pqb.push(b[i]);
	}

	while (true){

		LL A = pqa.top();
		if (pqb.empty()) {
			ans += (H + A - 1) / A;
			break;
		}
		LL B = pqb.top();
		if (A >= B) {
			ans += (H+A-1) / A;
			break;
		}
		else {
			ans++;
			H -= B; if (H <= 0)break;
			pqb.pop();
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll N;
vector<int> vec;

void solve() {

  int mn = 0;
  int ans=0;
  
  rep(i,N) {
    if (vec[i]>=mn) {
      ans++;
      mn = vec[i];
    }
  }
  
  cout << ans;
  	
	return;
}

int main() {

	cin >> N;
  vec.resize(N);
  rep(i,N) cin >> vec[i];

	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 256