akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N,K;
  cin>>N>>K;
  if(K==1){
    cout<<0<<endl;
    return 0;
  }
  cout<< N-(K-1)-1<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;



int main(){
    
    int H, W;
    cin>>H>>W;
    vector<vector<int>> a(H, vector<int>(W));
    int odd=0;
    rep(i,H){
        rep(j,W) {
            cin>>a[i][j];
            if(a[i][j] & 1) odd++;
        }
    }

    vector<pair<P, P>> res;
    int num = 0;
    int x = 0, y = 0;
    rep(i, W*H){
        if(a[x][y] & 1) num++;

        int nx = x, ny = y;
        if(x%2 == 0){
            if(ny == W-1) nx++;
            else ny++;
        }else{
            if(ny == 0) nx++;
            else ny--;
        }
        if(num & 1){
            if(num < odd) res.push_back(make_pair(make_pair(x, y), make_pair(nx, ny)));
        }
        x = nx;
        y = ny;
    }
    cout<<res.size()<<endl;
    for(auto p: res){
        cout<<p.first.first+1<<" "<<p.first.second+1<<" "<<p.second.first+1<<" "<<p.second.second+1<<endl;
    }
}


Measured memory_bytes: 8364
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<int> A(N,0);

    int ans = 0;

    priority_queue<int> queP;
    priority_queue<int> queN;
    for(int i=0; i<N; i++){
        cin >> A[i];
        ans+=abs(A[i]);
        if(A[i]>=0){
            queP.push(-A[i]);
        }else{
            queN.push(A[i]);
        }
    }

    if((int) queP.size() !=0 && (int) queN.size()!=0){
        cout << ans << endl;
        int tmp = queP.top();
        queP.pop();
        queP.push(-queN.top());
        queN.pop();
        queN.push(-tmp);
    }else if((int) queP.size()!=0){
        cout << ans + 2*queP.top() << endl;
    }else{
        cout << ans + 2*queN.top() << endl;
    }

    while((int) queP.size() >1){
        int x = -queP.top();
        queP.pop();
        int y = -queP.top();
        queP.pop();
        if((int) queP.size()==0 && (int) queN.size() == 0){
            cout << y << ' ' << x << endl;
            return 0;
        }else{
            cout << x << ' ' << y << endl;
        }
        queP.push(-x+y);
    }

    if((int) queP.size() == 1){
        queN.push(-queP.top());
    }
    while((int) queN.size() >1){
        int x = queN.top();
        queN.pop();
        int y = queN.top();
        queN.pop();
        cout << x << ' ' << y << endl;
        queN.push(x-y);
    }

}

Measured memory_bytes: 2808
from collections import Counter

def mapdict(n, dictionary):
    return dict(map(lambda t:(t[0]-n,t[1]), dictionary.items()))

def count(dic):
    count = 0
    for k,v in dic.items():
        count += abs(k*v)
    return count

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

A2 = sorted([A[i-1]-i for i in range(1,N+1)])


Adic = Counter(A2)
Ax  = A2[N//2]
Adic = mapdict(Ax, Adic)

res = count(Adic)

if N==1:
    print(0)

elif N==2:
    print(sum(map(abs,map(lambda x:x-min(A2),A2))))

else:
    pl = count(mapdict(A2[N//2 +1],Adic))
    mn = count(mapdict(A2[N//2 -1],Adic))
    if pl<=res:
        tmp = pl
        tmpc = 1
        while tmp <= res:
            tmpc += 1
            if N//2 + tmpc > N-1:
                break
            res = tmp
            Adic = mapdict(A2[N//2 +tmpc], Adic)
            tmp = count(Adic)
    elif mn<=res:
        tmp = mn
        tmpc = 1
        while tmp <= res:
            tmpc += 1
            if N//2 - tmpc < 0:
                break
            res = tmp
            Adic = mapdict(A2[N//2 -tmpc], Adic)
            tmp = count(Adic)

    print(res)

Measured memory_bytes: 69272
#include<bits/stdc++.h>
#include <string>
using namespace std;
int main(){
    string s;
    int ans=0;
    cin >> s;
    for(int i=0;i<4;i++){
        if(s[i]=='+'){
            ans++;
        }else{
            ans--;
        }

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

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

list = []
sim=0
for i in range(N-1):
  if A[i]<A[i+1]:
    list.append(1)
  if A[i]>A[i+1]:
    list.append(0)
  if A[i]==A[i+1]:
    sim+=1
    
i = 0
count = 0

while i<N-2-sim:
  if list[i] != list[i+1]:
    count += 1
    i+=1
  i+=1

print(count + 1)

Measured memory_bytes: 20192
import java.util.HashSet;
import java.util.Scanner;

public class Main 
{
	static int[] par;
	static int[] rank;
	
	static void union(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		
		if(rank[rx] >= rank[ry])
		{
			par[ry] = rx;
			if(rank[rx] == rank[ry])
				rank[rx]++;
		}
		else par[rx] = ry;
	}
	
	static int root(int x)
	{
		if(par[x] != x)
			par[x] = root(par[x]);
		return par[x];
	}
	
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		par = new int[n];
		rank = new int[n];
		int[] found = new int[n];
		for(int i = 0; i < n; i++)
			par[i] = i;
		
		for(int i = 0; i < m; i++)
		{
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			int c = sc.nextInt();
			union(a,b);
		}
		
		int qt = 0;
		HashSet<Integer> set = new HashSet<>();
		for(int i = 0; i < n; i++)
		{
			set.add(root(i));
		}
		System.out.println(set.size());

	}

}


Measured memory_bytes: 94072
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define popb(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  ull n,sum=0,cnt=0;
  
  while(1){
    cin>>n;
    if(n==0){
      return 0;
    }
    rep(i,1,n){
      sum=i;
      rep(j,i+1,n){
       sum+=j;
        if(sum==n){
          cnt++;
          sum=0;
          break;
        }else if(sum>n){
          sum=0;
          break;
        }
      }
    }
    cout<<cnt<<endl;
    cnt=0;
  }
}

Measured memory_bytes: 3068
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int X;
  cin>>X;

  cout<<X*800 - X/15*200<<endl;
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	int n;
	cin >> n;
	while (n)
	{
		str.push_back('0' + abs(n % (-2)));
		n = (n - abs(n % (-2))) / -2;
	}
	reverse(str.begin(), str.end());
	if (str.empty()) str = "0";
	cout << str << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,n,k;
    cin>>a>>b>>k;
    int ans[100];
    n=a;
    c=1;
    if(a>b) n=b;
    for (int i=1;i<=n;i++){
        if(a%i==0 && b%i==0){
            ans[c]=i;
            c+=1;
        }
    }
    cout<<ans[c-k]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

int main(){
    vector<int>A;
    int a;
    fol(i,3){
        cin>>a;
        A.pb(a);
    }
    sort(A.begin(),A.end());
    int k;cin>>k;
    A[2]*=pow(2,k);
    cout << accumulate(A.begin(),A.end(),0)<<endl;
    return 0;
}


Measured memory_bytes: 256
import math
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
def num(R):
  _R = R
  ans = 0
  for i in range(N):
    if _R[i] != 1:
      ans += (_R[i]-1)*math.factorial(N-i-1)
    if i == N-1:
      ans += _R[-1]
    _R = [_R[j]-1 if R[j]>R[i] else _R[j] for j in range(N)]
    
  return ans
print(abs(num(P)-num(Q)))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ioso ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define kholo freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define endl '\n'
#define laglo cerr << "Time Laglo: " << 1.0*clock() / CLOCKS_PER_SEC << endl;
int main() {
	ioso;
	//kholo;
	int n;
	long long a,b;
	cin >> a >> b;
	long long ans = ((a*b)/ __gcd(a,b));
	cout << ans << endl;
	//laglo;
	}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
        string s;
        cin >> s;
        int counter = 0;
        if (s[0] == '1') counter++;
        if (s[1] == '1') counter++;
        if (s[2] == '1') counter++;
        cout << counter << endl;
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        // cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

double dp[600][600];
signed main() {
    REP(i, 600) REP(j, 600) dp[i][j] = -INF;

    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    cin >> a;
    vector<int> sum(n+1, 0);
    REPF(i, 1, n+1) sum[i] = sum[i-1] + a[i-1];
    
    dp[0][0] = 0;
    REP(i, n+1) {
        REP(j, i+1) {
            REPF(k, 1, n+1) {
                if (i+k > n) continue;
                double avr = sum[i+k] - sum[i];
                avr /= k;
                chmax(dp[i+k][j+1], dp[i][j] + avr);
            }
        }
    }
    double ans = 0;
    REPF(i, 1, m+1) chmax(ans, dp[n][i]);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 6104
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s1 = sc.next();
    String s2 = sc.next();
    String s3 = sc.next();

    String n1 = s1.substring(0,1);
    String n2 = s2.substring(0,1);
    String n3 = s3.substring(0,1);
    String a = n1.toUpperCase();
    String b = n2.toUpperCase();
    String c = n3.toUpperCase();

    System.out.println(a+b+c);

  }

}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n;
    cin >> n;
    rep(x,1,n){
        if(n == int((ld)x*1.08)){
            cout << x << endl;
            return 0;
        }
    }
    cout << ":(" << endl;



    time_taken();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    ll N; cin >> N;

    vector<ll> p;
    p.push_back(2);
    for (ll n = 3; n <= 1000000; ++n) {
        for (ll k = 0; k < p.size(); ++k) {
            if (n % p[k] == 0) { goto xyz; }
            if (p[k] > sqrt(n)) { break; }
        }
        p.push_back(n);
    xyz:;
    }

    int ans = 0;

    if (N == 1) { cout << 0 << endl; return 0; }

    for (int i = 0; i < p.size(); ++i) {
        if (N % p[i] == 0) {
            int j = 0;
            ll M = p[i];
            while (1) {
                if (N % M == 0) {
                    N /= M;
                    M *= p[i];
                    ++j;
                }
                else {
                    break;
                }
            }
            ans += j;
        }
    }

    if (ans > 0) {
        if (N > 1000000) {
            cout << ans + 1 << endl; return 0;
        }
        else {
            cout << ans << endl;
        }
    }
    else { cout << 1 << endl; return 0; }
}

Measured memory_bytes: 4280
#include<iostream>
using namespace std;
int main(){
long ww,n,v,*w,**p,i,j,k=1,sw;
char c;
while(cin>>ww){
if(ww==0)break;
cin>>n;
w=new long[n+1];
p=new long*[n+1];
for(i=0;i<=n;i++){p[i]=new long[ww+1];p[i][0]=0;}
for(j=0;j<=ww;j++)p[0][j]=0;
sw=0;
for(i=1;i<=n;i++){
cin>>v>>c>>w[i];
for(j=1;j<=ww;j++){
if(w[i]>j)p[i][j]=p[i-1][j];
else if(p[i-1][j-w[i]]+v>p[i-1][j])p[i][j]=p[i-1][j-w[i]]+v;
else p[i][j]=p[i-1][j];
}
}
for(j=ww;j>=1;j--)if(p[n][j]!=p[n][j-1])break;
for(i=n;i>=1;i--){
if(p[i][j]!=p[i-1][j]){sw+=w[i];j-=w[i];}
}
cout<<"Case "<<k<<":"<<endl;
cout<<p[n][ww]<<endl;
cout<<sw<<endl;
k++;
}
return 0;
}

Measured memory_bytes: 9400
#include<bits/stdc++.h>
#define ll long long int
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
using namespace std;
int main()
{

  int x;
  cin >> x;

  if (x==1)
    cout << '0';
  else if(x==0)
    cout << '1';
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define inf 100000000
using namespace std;

//お土産の購入額と1000札のみで購入したときのおつり
typedef struct {
  int v;
  int cha;
} souv;

// DP配列の中身。500円玉の枚数と、購入額
typedef struct {
  int mon;
  int sum;
} table;

bool cmp(table l, table r) {
  if(l.mon > r.mon) return 1;
  if(l.mon == r.mon && l.sum < r.sum) return 1;
  return 0;
}

void dpset();
void solve();

souv memo[105];
table dp[105][1000 * 102];
int n;

int main() {
  int i;
  table ans;
  while(1) {
    cin >> n;
    if(n == 0) break;
    for(i = 1; i <= n; i++) {
      cin >> memo[i].v;
      memo[i].cha = 1000 - (memo[i].v % 1000);
      if(memo[i].cha == 1000) memo[i].cha = 0;
    }
    dpset();
    solve();
    ans.mon = 0;
    ans.sum = inf;
    for(i = 0; i <= n * 1000; ++i)
      if(cmp(dp[n][i], ans)) ans = dp[n][i];
    if(ans.sum == inf) ans.sum = 0;
    cout << ans.mon << " " << ans.sum << endl;
  }
  return 0;
}

void dpset() {
  for(int i = 0; i <= n; ++i)
    for(int j = 0; j <= (n + 1) * 1000; ++j) {
      dp[i][j].mon = 0;
      if(j == 0)
        dp[i][j].sum = 0;
      else
        dp[i][j].sum = inf;
    }
}

void solve() {
  int i, j;
  table now;
  for(i = 1; i <= n; ++i) {
    for(j = 0; j <= n * 1000; ++j) {
      //札払いでおつりが500超えるので確実に購入
      if(memo[i].cha >= 500 && j >= memo[i].cha % 500 &&
         dp[i - 1][j - memo[i].cha % 500].sum != inf) {
        dp[i][j] = dp[i - 1][j - memo[i].cha % 500];
        ++dp[i][j].mon;
        if(dp[i][j].sum == inf) dp[i][j].sum = 0;
        dp[i][j].sum += memo[i].v;
      }
      //札払いでおつりが500を超えない
      else if(memo[i].cha < 500) {
        //購入しない
        dp[i][j] = dp[i - 1][j];
        //端数使って枚数増やすパターン
        if(dp[i - 1][j + (500 - memo[i].cha)].sum != inf) {
          now = dp[i - 1][j + (500 - memo[i].cha)];
          ++now.mon;
          now.sum += memo[i].v;
          if(cmp(now, dp[i][j])) dp[i][j] = now;
        }
        //端数増やすパターン
        if(j >= memo[i].cha && memo[i].cha != 0 &&
           dp[i - 1][j - memo[i].cha].sum != inf) {
          now = dp[i - 1][j - memo[i].cha];
          if(now.sum == inf) now.sum = 0;
          now.sum += memo[i].v;
          if(cmp(now, dp[i][j])) dp[i][j] = now;
        }
      }
      //if(dp[i][j].sum!=inf)cout << dp[i][j].sum << " " << dp[i][j].mon<<" " ;
    }
  }
}


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;

inline void f(int & t){
	t = t == 1 ? INF : t;	
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 
	int a , b;
	cin >> a >> b;
	f(a);
	f(b);
	if(a == b)dier("Draw");
	if(a > b)dier("Alice");
	die("Bob");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
	
	int a, b, c, d, result;
	scanf("%d %d %d %d", &a, &b, &c, &d);

	result = (int)( fmin((double)b, (double)d) - fmax((double)a, (double)c) );
	if( result < 0 ){
		result = 0;
	}
	printf("%d", result);
	
	return 0;
	
}

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

int main()
{
	int n, k;
	cin >> n >> k;
	
	vector<int> h(n);
	for(int i = 0; i < n;i++)
	{
		cin >> h[i];
	}	
	vector<int> dp(n, INT_MAX);
	dp[0] = 0;
	for(int i = 1; i < n; i++)
	{
		for(int j = 1; j <= k and (i - j) >= 0 ; j++)
		{
			dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]), dp[i]);
		}
	}
	cout << dp[n - 1] << endl;
}


Measured memory_bytes: 4024
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;


int main(){
    int k;
    string s;
    cin >> k>> s;
    if(s.size()<=k){
        cout<<s<<endl;
    }else
    {
        rep(i,k)cout<<s[i];
        cout<<"..."<<endl;
    }
    
}

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

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

    if (a >= 13){
        cout << b;
    }
    else if (6 <= a and a <= 12){
        cout << b / 2;
    }
    else{
        cout << 0;
    }

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for n in range(N)]
B = sorted(A)[::-1]
a1 = B[0]
a2 = B[1]

if a1==a2:
  for n in range(N):
    print(a1)
else:
  for n in range(N):
    if A[n]==a1:
      print(a2)
    else:
      print(a1)

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n), b(m), c(m);
    REP(i, n) cin >> a[i];
    REP(i, m) cin >> b[i] >> c[i];
    vector<pair<ll, ll>> p(m);
    REP(i, m) p[i] = MP(-c[i], b[i]);
    sort(ALL(p));
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    REP(i, n) pq.emplace(a[i]);
    REP(i, m){
        REP(j, p[i].S){
            if(-p[i].F > pq.top()){
                pq.pop();
                pq.emplace(-p[i].F);
            }
            else break;
        }
    }
    ll ans = 0;
    REP(i, n){
        ans += pq.top();
        pq.pop();
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 8164
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <iostream>
#include <algorithm>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

vector< vector<int> > memo(201, vector<int>(201, -1));

int gcd(int a, int b) {
  if (memo[a][b] > 0) return memo[a][b];
  if (a % b == 0) {
    return memo[a][b] = b;
  } else {
    return memo[a][b] = gcd(b, a % b);
  }
}

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

  unsigned k;
  cin >> k;

  ll sum = 0;
  rep(a, k) rep(b, k) rep(c, k) {
    sum += gcd(a + 1, gcd(b + 1, c + 1)); 
  }
  cout << sum << endl;
}

Measured memory_bytes: 3844
#include <stdio.h>

int main(void){
  long int N; // 入力された数
  scanf("%ld", &N);
  
  if (N%2 == 1) {
    printf("0\n");
    return 0;
  }
  
  long int ans = 0; // Nの素因数5の数
  long int N_tens = N / 10; // 1からNまでに何個の10, 20, 30・・・があるか
  ans += N_tens;
  
  while(N_tens!=0){
    ans += N_tens / 5;
    N_tens /= 5;
  }
  
  printf("%ld", ans);
}


Measured memory_bytes: 128
#include<stdio.h>

#define N 8
#define FREE -1
#define NOT_FREE 1

int col[N];
int row[N];
int dpos[N*2-1];
int dneg[N*2-1];

int state[N];

void init();
void put(int,int);
void putQueen(int);
void printBoard();

int main(){
  int n;
  int r ,c;
  int i;

  init();

  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf("%d%d",&r ,&c);
    put(r,c);
  }
  
  putQueen(0);
  
  return 0;
}

void init(){
  int i, j;

  for(i=0; i<N; i++){
    state[i] = col[i] = row[i] = FREE;
  }

  for(i=0; i<N*2-1; i++){
    dpos[i] = dneg[i] = FREE;
  }
}

void put(int r,int c){
  row[r] = c;
  state[r] = col[c] = dpos[r+c] = dneg[r-c+N-1] = NOT_FREE;
}

void putQueen(int i){
  int j;

  if(i==N){
    printBoard();
    return;
  }

  while(state[i]==NOT_FREE){
    i++;

    if(i==N){
      printBoard();
      return;
    }
  }
  
  for(j=0; j<N; j++){
    if(col[j] == NOT_FREE ||
       dpos[i+j] == NOT_FREE ||
       dneg[i-j+N-1] == NOT_FREE)
      continue;

    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
    
    putQueen(i+1);
    
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
}

void printBoard(){
  int i, j;
  
  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      if(j==row[i])
	printf("Q");

      else
	printf(".");
    }
    printf("\n");
  }
}



Measured memory_bytes: 2112
#include <stdio.h>

int main(void)
{
	int x, y; 
	int i;
	int gx = 0, gy = 0;
	int a[] = {4, 6, 9, 11};
	int b[] = {1,3, 5, 7, 8, 10 , 12};
	scanf("%d %d", &x, &y);

	if (x == 2 && y == 2)
	{
		gx = 0;
		gy = 0;
	}

	for (i = 0; i < 4; i++)
	{
		if (x == a[i])
		{
			gx = 1;
		}
		if (y == a[i])
		{
			gy = 1;
		}
	}

	if (gx == 0 || gy == 0)
	{
	for (i = 0; i < 7; i++)
	{
		if (x == b[i])
		{
			gx = 2;
		}
		if (y == b[i]){
			gy = 2;
		}
	}
	}


	if (gx == gy)
	{
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
}


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

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

	while (n--)
	{
		int a, b, c;
		cin >> a >> b >> c;
		//a???????????§????????????????????\?????????
		if (a < b) swap(a, b);
		if (a < c) swap(a, c);
		//??????????????????????????????
		if (a*a == b*b + c*c)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int x;
  cin >> x;
  rep(i, 200){
    rep(j, 200){
      ll ii = (ll)i*i*i*i*i;
      ll jj = (ll)j*j*j*j*j;
      if(ii - jj == x){
        cout << i << " " << j << endl;
        return 0;
      }
      if(ii + jj == x){
        cout << i << " " << -j << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3632
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
mod = 998244353; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

def inverse(N, mod):
	return (pow(N, mod - 2, mod))

def main():
	N, K = getlist()
	DP = [0] * (2 * N + 1)
	DP2 = [0] * (2 * N + 1)
	DP[0] = 1
	LR = []
	for i in range(K):
		L, R = getlist()
		LR.append([L, R])

	for i in range(N):
		DP[i] += DP2[i]
		DP[i] %= mod
		for l, r in LR:
			DP2[i + l] += DP[i]
			DP2[i + l] %= mod
			DP2[i + r + 1] -= DP[i]
			DP2[i + r + 1] %= mod
		DP2[i + 1] += DP2[i]
		DP2[i + 1] %= mod

	ans = DP[N - 1]
	print(ans % mod)

if __name__ == '__main__':
	main()

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

bool IncludeKeyWords(const string& Sentence)
{
	if(Sentence.find("the")  <= 80) return true;
	if(Sentence.find("this") <= 80) return true;
	if(Sentence.find("that") <= 80) return true;
	return false;
}

string OneShift(string Sentence)
{
	for(int i = 0; i < Sentence.size(); i++){
		if(97 < Sentence[i] && Sentence[i] < 123){
			Sentence[i] --;
		}else if(Sentence[i] == 97){
			Sentence[i] = 122;
		}
	}
	return Sentence;
}

string Decrypt(string Sentence)
{
	int RoopCount = 0;
	while(IncludeKeyWords(Sentence) == false){
		assert(RoopCount < 26);
		Sentence = OneShift(Sentence);
		RoopCount++;
	}
	return Sentence;
}

int main()
{
	while(true){
		string Sentence;
		getline(cin, Sentence);
		if(cin.eof() == true) break;
		string DecryptedSentence = Decrypt(Sentence);
		cout << DecryptedSentence << endl;
	}
	return 0;
}

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

int main() {
  char c;
  cin >> c;
  
  if (c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
    cout << "vowel" << endl;  
  }
  
  else {
    cout << "consonant" << endl;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[20][10000],dp[20][10000];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	  scanf("%d",&a[1][i]);
	for (int i=1;i<=n;i++)
	  scanf("%d",&a[2][i]);
	dp[1][1]=a[1][1];
	dp[2][1]=a[2][1]+a[1][1];
	for (int i=2;i<=n;i++)
	{
		dp[1][i]=dp[1][i-1]+a[1][i];
		dp[2][i]=max(dp[1][i],dp[2][i-1])+a[2][i];
	}
	cout<<dp[2][n];
}

Measured memory_bytes: 256
S=input()
S+="E"
x,y=map(int,input().split())
go=[[],[]]
idx=0
while S[idx]=="F":
    x-=1
    idx+=1
g=1
idx+=1
while idx<len(S):
    now=0
    while S[idx]=="F":
        now+=1
        idx+=1
    if now>0:
        go[g].append(now)
    g=(g+1)%2
    idx+=1
def check(L,m):
    dp={0}
    for x in L:
        dpc=dp.copy()
        dp=set()
        for now in dpc:
            dp|={now+x,now-x}
    if m in dp:
        return True
    return False
if check(go[0],x) and check(go[1],y):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 4144
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;



int main() {
  string s;
  cin >> s;
  if (s <= "2019/04/30") cout << "Heisei" << endl;
  else cout << "TBD" << endl;
}

Measured memory_bytes: 256
x = parse.(split(readline()))
N = x[1]
K = x[2]
X = N%K
if N==0
    println(0)
elseif N < K
    if(N < K/2)
        println(N)
    else
        println(K-N)
    end
else # K <= N
    if X > K-X
    	println(K-X)
    else
    	println(X)
  	end
end
    

Measured memory_bytes: 119560
import sys
import math
import decimal

args = []
for l in sys.stdin:
    args.append(l)
lines = []
cnt = 0

while cnt < int(len(args)) - 1:
    num = int(args[cnt])
    cnt += 1
    if(num == 0):
        continue
    data = args[cnt].split(' ')
    cnt += 1

    numLine = []
    for points in data:
        numLine.append(int(points))

    average = 0.0
    for points in numLine:
        average += int(points)
    average /= num
    
    distributed = []
    for points in numLine:
        distributed.append((points - average) * (points - average))
    
    std_dev = 0.0
    for value in distributed:
        std_dev += value
    
    lines.append(math.sqrt(std_dev / num))

for line in lines:
    result = decimal.Decimal(line).quantize(decimal.Decimal("0.00000000"))
    if(decimal.Decimal(0E-8) == result):
        print("0.00000000")
    else:
        print(result)







Measured memory_bytes: 6580
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a, b;
    cin >> a >> b;
    reverse(ALL(a));
    if (a == b)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(){
  unsigned long long int A, B, X;
  cin >> A >> B >> X;
  unsigned long long int ans;
  if(A != 0LL)ans = (B / X) - ((A-1) / X);
  else ans = B / X + 1;
  cout << ans;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define PI 3.14159265358979323846
#define INF 2000000007
#define LINF 2000000000000000007
#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;
int ans;
int n,a[111111];
signed main(){
	cin>>n;
	rep(i,n){
		cin>>a[i];
		a[i]--;
	}
	int f[111111]={0};
	rep(i,n){
		if(f[i])continue;
		if(a[i]==a[a[a[i]]]&&a[a[i]]==i){
			ans++;
			f[i]=1;
			f[a[i]]=1;
		}
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 1920
import java.util.Scanner;
public class Main{
 public static void main(String args[]){
  boolean flag=false;
  Scanner scan=new Scanner(System.in);
  String s;

  s=scan.next();
  int n=Integer.parseInt(s);

  int d[]=new int[n+10];
  int mx=0,a; 
  long ans=1;
  for(int i=0;i<n;i++)d[i]=0;

  for(int i=0;i<n;i++){
   s=scan.next();
   a=Integer.parseInt(s);
   if((i==0&&a!=0)||(i!=0&&a==0))ans=0;
   d[a]++;
   if(mx<a)mx=a;
  }
  for(int i=1;i<=mx;i++){
   for(int j=0;j<d[i];j++){
    ans*=d[i-1];
    ans%=998244353;
   }
  if(d[i-1]==0)ans=0;
  } 
  System.out.println(ans);
 }

 ///////////////////////////////////////////////
 public static boolean prime(long a){
  if(a<=1)return false;
  for(int i=2;i*i<=a;i++){
   if(a%i==0)return false;
  }
  return true;
 }
 public static long llpow(long x,long n){
  long ans=1;
  for(int i=0;i<n;i++)ans*=x;
  return ans;
 }
 public static long max(long a,long b){
  if(a<b)return b;
  else return a;
 }
 public static long min(long a,long b){
  if(a>b)return b;
  else return a;
 }
}



Measured memory_bytes: 58564
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int k,n;
  cin>>k>>n;
  vector<int> as(n);

  for(int i=0;i<n;i++) cin>>as[i];
  as.emplace_back(as[0]+k);

  int ans=k;
  for(int i=0;i<n;i++)
    chmin(ans,k-(as[i+1]-as[i]));

  cout<<ans<<newl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int x,y; cin >> x >> y;
    int ans = 0;
    ans += max(0, (4-x)*100000);
    ans += max(0, (4-y)*100000);
    if(x == 1 && y == 1) ans += 400000;
    cout << ans << endl;
}


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

#define ll long long int
#define inv(name,Type,size) vector<Type> name(size);for(int index=0;index<size;index++) cin>>name[index];
#define F(a,n,i) for(int i=a;i<n;i++)
#define FLL(a,n,i) for(long long int i=a;i<n;i++)
#define pb push_back
#define endl "\n"
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()

const int mod=1000000007;
const int modpro=988244353;

const int di[8]={-1,0,1,0,-1,1,1,-1},dj[8]={0,1,0,-1,1,1,-1,-1};


void solve(){
	double d,t,s;
	cin>>d>>t>>s;
	if((d/t)<=s){
		cout<<"Yes";
	}
	else cout<<"No";
}

int main()
{

  //freopen("out", "w", stdout);
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
  //int t;cin>>t;while(t--) solve(),cout<<endl;
  solve();
  
  cerr<<endl << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << " ms\n";
}



Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end())
using namespace std;

typedef long long ll;
typedef pair<ll, ll> p;
const ll mod = 998244353;

ll n, k, dp[202020], sum[202020];
p range[11];

ll Mod(ll x){
    x %= mod; x += mod; x %= mod;
    return x;
}

ll query(int s, int e){
    if(e < 0) return 0;
    s = max(s, 0);
    if(!s) return sum[e];
    else return Mod(sum[e] - sum[s-1]);
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    cin >> n >> k; for(int i=1; i<=k; i++) cin >> range[i].x >> range[i].y;
    dp[1] = sum[1] = 1;
    for(int i=2; i<=n; i++){
        for(int j=1; j<=k; j++) dp[i] += query(i-range[j].y, i-range[j].x);
        dp[i] %= mod;
        sum[i] = sum[i-1] + dp[i]; sum[i] %= mod;
    }
    cout << dp[n];
}

Measured memory_bytes: 6776
H, W, K = map(int, input().split())

S = [input() for i in range(H)]
C = [[0 for i in range(W)] for j in range(H)]
L = []
u = 0
M = []
for i in range(H):
  s = 0
  for j in range(W):
    if S[i][j] == '#':
      s += 1
      u += 1
      C[i][j] = u
  if s == 0:
    L.append(i)
  else:
    M.append(i)
d = 0
for i in range(len(M)):
  for j in range(W):
    if C[M[i]][j] != 0:
      for k in range(d, j):
        C[M[i]][k] = C[M[i]][j]
      d = j + 1
  for k in range(d, W):
    C[M[i]][k] = C[M[i]][d-1]
  d = 0
ma, mi = max(M), min(M)
M.insert(0, -1)
for i in range(W):
  for j in range(len(M)-1):
    for k in range(M[j]+1, M[j+1]):
      C[k][i] = C[M[j+1]][i]
  for j in range(ma+1, H):
    C[j][i] = C[ma][i]
for i in range(H):
  for j in range(W):
    if j != W-1:
      print(C[i][j], end = ' ')
    else:
      print(C[i][j], end = '')
  print()

Measured memory_bytes: 7576
#include <stdio.h>

int main(void){
    int data[10],bf;
    for(int i=0;i<10;i++){
        scanf("%d",&data[i]);
    }
    for(int i=10-1;i>0;i--){
        for(int j=0;j<i;j++){
            if(data[j]<data[j+1]){
                bf=data[j];
                data[j]=data[j+1];
                data[j+1]=bf;
            }
        }
    }
    for(int i=0;i<3;i++){
        printf("%d\n",data[i]);
    }
    return 0;
}

Measured memory_bytes: 1028
def main():
    n = int(input())

    ans = [0 for _ in range(n+1)]
    x = 1
    y = 1
    z = 1
    while True:
        f = x * x + y * y + z * z + x * y + y * z + z * x
        if f > n:
            if z > 1:
                y += 1
                z = 1
            elif y > 1:
                x += 1
                y = 1
            else:
                break
        else:
            ans[f] += 1
            z += 1

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

if __name__ == '__main__':
    main()


Measured memory_bytes: 9164
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define pb push_back
#define mp make_pair

/** Edge-based graph with costs (directed or undirected) */
template<class C>
struct ECGraph {
    int n, m;
    vector<int> head, u, v, next;
    vector<C> c;
    ECGraph(int _n) : n(_n), m(0), head(_n, -1) {}
    void add(int _u, int _v, const C& _c) {
        u.pb(_u); v.pb(_v); c.pb(_c); next.pb(head[_u]); head[_u] = m++;
    }
};

/** Edge-based undirected graph with costs */
template<class C>
struct UECGraph : public ECGraph<C> {
    UECGraph(int n) : ECGraph<C>(n) {}
    void add(int u, int v, const C& c) {
        ECGraph<C>::add(u, v, c);
        ECGraph<C>::add(v, u, c);
    }
};

/** Dijkstra's shortest path algorithm */
template<class C>
C dijkstra(const ECGraph<C>& g, int s, int t) {
    typedef pair<C, int> T;
    priority_queue<T, vector<T>, greater<T> > q;
    set<int> vis;
    q.push(mp(0, s));
    while(!q.empty()) {
        T vv(q.top());
        q.pop();
        const C c(vv.first);
        const int at = vv.second;
        if(vis.count(at)) continue;
        vis.insert(at);
        if(at==t) return c;
        for(int x=g.head[at]; x!=-1; x=g.next[x]) {
            if(vis.count(g.v[x])==0) q.push(mp(c+g.c[x], g.v[x]));
        }
    }
    return -1;
}

/** Numbering the Key based on the order of appearance */
template<class Key>
class Numbering {
    map<Key, int> is;
public:
    int find(const Key& k) const {
        if(is.count(k)) return is.find(k)->second;
        return -1;
    }
    int ix(const Key& k) {
        int x = find(k);
        if(x==-1) {
            const int m = is.size();
            x = is[k] = m;
        }
        return x;
    }
};

int main() {
    for(;;) {
        int n, m;
        cin >> n >> m;
        if(n==0 && m==0) return 0;
        string S, P, G;
        cin >> S >> P >> G;
        UECGraph<int> g(n);
        Numbering<string> nb;
        rep(i, m) {
            string a, b;
            int d, t;
            cin >> a >> b >> d >> t;
            g.add(nb.ix(a), nb.ix(b), d/40+t);
        }
        printf("%d\n", dijkstra(g, nb.ix(S), nb.ix(P))
                + dijkstra(g, nb.ix(P), nb.ix(G)));
    }
}

Measured memory_bytes: 0