akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int INF = 1 << 30;

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W;
    cin >> H >> W;
    vector<string> mp(H);
    for(int i=0; i<H; i++) cin >> mp.at(i);

    vector<vector<int>> dp(H, vector<int>(W,  INF));
    dp[0][0] = (mp[0][0] == '#' ? 1 : 0);
    for(int i=0; i<H; i++)
    {
        for(int j=0; j<W; j++)
        {
            if(i>0) chmin(dp[i][j], dp[i-1][j] + ((mp[i][j]=='#' && mp[i-1][j]=='.') ? 1 : 0));
            if(j>0) chmin(dp[i][j], dp[i][j-1] + ((mp[i][j]=='#' && mp[i][j-1]=='.') ? 1 : 0));
        }
    }
    cout << dp[H-1][W-1] << endl;

    return 0;
}


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

counter=0
i_t=1
for i in range(n):
    if  i_t == a[i]:
        i_t+=1
    else:
        counter+=1
if i_t==1:
    print(-1)
else:
    print(counter)

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

struct edge{int to,cap,rev;};//ikisaki youryou gyakuhen
class MF{//max flow
	public:
	int n;
	vector<vector<edge> >G;//[MAX];
	vector<bool>used;//[MAX];
	MF(int size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(int from, int to, int cap){
		edge q={to,cap,int(G[to].size())};
		G[from].push_back(q);
		q={from,0,int(G[from].size()-1)};
		G[to].push_back(q);
	}
	int dfs(int v,int t, int f) {
		if(v==t)return f;
		used[v]=1;
		for(int i=0;i<G[v].size();i++){
			edge &e=G[v][i];
			if(used[e.to]||e.cap<=0) continue;
			int d =dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
		return 0;
	}
	int mf(int s,int t) {//from s to t,ford_fulkerson
		int flow=0,f;
		while(1){
			used=vector<bool>(n,false);
			f=dfs(s,t,inf);
			if(f==0)return flow;
			flow+=f;
		}
	}
};
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n,m;
	vvi G;
	bool h=false;
	cin>>n>>m;
	G=vvi(n);
	MF mf(n);
	rep(i,m){
		int a,b;cin>>a>>b;
		a--;b--;
		G[a].pb(b);
		G[b].pb(a);
		mf.add_edge(a,b,1);
		mf.add_edge(b,a,1);
	}
	rep(i,n)if(G[i].size()%2)h=true;
	if(h){
		cout<<"No"<<endl;
		return 0;
	}
	int c=0;
	rep(i,n)if(G[i].size()>=6)h=true;
	vi t;
	rep(i,n)if(G[i].size()>=4)c++,t.pb(i);
	if(c>=3)h=true;
	else if(t.size()>=2&&mf.mf(t[0],t[1])==2)h=true;
	if(h)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

}


Measured memory_bytes: 15872
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)

//struct custom_hash {
//    static uint64_t splitmix64(uint64_t x) {
//        // http://xorshift.di.unimi.it/splitmix64.c
//        x += 0x9e3779b97f4a7c15;
//        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
//        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
//        return x ^ (x >> 31);
//    }
//    size_t operator()(uint64_t x) const {
//        static const uint64_t FIXED_RANDOM = 
//            chrono::steady_clock::now().time_since_epoch().count();
//        return splitmix64(x + FIXED_RANDOM);
//    }
//};

#define fi first
#define se second

ll dp[110][110][2];
char grid[110][110];

#define INF (1LL<<29)

void fill_dp()
{
    for(ll i=0;i<110;i++)
    {
        for(ll j=0;j<110;j++)
        {
            dp[i][j][0]=INF;
            dp[i][j][1]=INF;
        }
    }
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	fill_dp();
	ll h,w;
	cin>>h>>w;
	for(ll i=1;i<=h;i++)
	for(ll j=1;j<=w;j++)
	{
	    cin>>grid[i][j];
	}
	if(grid[1][1]=='.')
	{
	    dp[1][1][0]=0;
	}
	else
	{
	    dp[1][1][1]=1;
	}
	for(ll i=1;i<=h;i++)
	{
	    for(ll j=1;j<=w;j++)
	    {
	        if(grid[i][j]=='#')
	        {
	            if(i>1)
	            {
	                dp[i][j][1]=min(dp[i][j][1],dp[i-1][j][0]+1);
	                dp[i][j][1]=min(dp[i][j][1],dp[i-1][j][1]);
	            }
	            if(j>1)
	            {
	                dp[i][j][1]=min(dp[i][j][1],dp[i][j-1][0]+1);
	                dp[i][j][1]=min(dp[i][j][1],dp[i][j-1][1]);
	            }
	        }
	        else
	        {
	            if(i>1)
	            {
	                dp[i][j][0]=min(dp[i][j][0],dp[i-1][j][0]);
	                dp[i][j][0]=min(dp[i][j][0],dp[i-1][j][1]);
	            }
	            if(j>1)
	            {
	                dp[i][j][0]=min(dp[i][j][0],dp[i][j-1][0]);
	                dp[i][j][0]=min(dp[i][j][0],dp[i][j-1][1]);
	            }
	        }
	       
	    }
	}
	cout<<min(dp[h][w][0],dp[h][w][1]);
    return 0;
}


//252908XL

Measured memory_bytes: 512
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

ll n, a, b;
ll h[100005];

bool check(ll num){
	ll used = 0;
	rep(i, n){
		//do another binary search
		ll l = 0, r = num - used; //how many turns on this one
		while(l < r){
			ll mid = (l + r) / 2;
			if(h[i] - ((a * mid) + (b * (num - mid))) <= 0) r = mid;
			else l = mid + 1;
		}
		if((h[i] - ((a * l) + (b * (num - l)))) > 0) return 0;
		used += l;
	}
	return 1;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	cin >> n >> a >> b;
	rep(i, n) cin >> h[i];
	sort(h, h + n);
	reverse(h, h + n);
	ll l = 1, r = 1e9;
	while(l < r){
		ll mid = (l + r) / 2;
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	cout << l << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define max(a,b) a>b ? a:b

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    for(int i=k-n+1;i<=k+n-1;i++)
    {
        cout<<i<<' ';
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())
ab = []

for i in range(n):
    a, b = map(int, input().split())
    ab.append((a, b))

if n % 2 == 1:
    ab.sort()
    min_val = ab[n//2][0]
    ab.sort(key=lambda x: -x[1])
    max_val = ab[n//2][1]
    print(max_val - min_val + 1)
else:
    ab.sort()
    min_val = ab[n//2][0] + ab[n//2 - 1][0]
    ab.sort(key=lambda x: -x[1])
    max_val = ab[n//2][1] + ab[n//2 - 1][1]
    print(max_val - min_val + 1)


Measured memory_bytes: 45832
def main():
    inf=float("inf")
    n=int(input())
    mx=[-inf,-inf,-inf,-inf]
    mn=[inf,inf,inf,inf]
    for i in range(n):
        x,y=map(int,input().split())
        if x+y>mx[0] : mx[0]=x+y
        if x+y<mn[0] : mn[0]=x+y
        if x-y>mx[1] : mx[1]=x-y
        if x-y<mn[1] : mn[1]=x-y
        if -x-y>mx[2] : mx[2]=-x-y
        if -x-y<mn[2] : mn[2]=-x-y
        if -x+y>mx[3] : mx[3]=-x+y
        if -x+y<mn[3] : mn[3]=-x+y
    print(max([mx[i]-mn[i] for i in range(4)]))

main()       


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

int main(){
  int H, W;

  while(1){
    cin >> H >> W;
    if ( H == 0 && W == 0 ) break;

    for ( int i = 0; i < H; i++ ){
      for ( int j = 0; j < W; j++ ){
        if (( i != 0 && i != H - 1 ) && ( j != 0 && j != W - 1 )){
          cout << ".";
        } else {
          cout << "#";
        }
      }

      cout << endl;
    }

    cout << endl;
  }

  return 0;
}


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

int main()
{
    int n;
    cin>>n;
    ll k;
    cin>>k;
    vector<int>v(n);
    for (int i=0;i<n;i++)
        cin>>v[i];
    vector<ll>p;
    p.push_back(0);
    map<ll,ll>mp;
    mp[0]=1;
    ll no=0;
    while(k>0)
    {
        no=v[no]-1;
        if (mp[no]!=0)
        {
            ll cy=p.size()-mp[no]+1;
            ll f=k%cy;
            if (f==0)
                f=cy;
            cout<<p[mp[no]+f-2]+1;
            return 0;
        }
        k--;
        p.push_back(no);
        mp[no]=p.size();
    }
    cout<<no+1;
    return 0;
}


Measured memory_bytes: 15164
#include <bits/stdc++.h>
//#include <random>
#define int long long
#define double long double
#define endl "\n" 
const int INF = (int) 1e18 + 7;
const int maxn = (int) 1e6 + 6;
//const md = (int) 1e9 + 7;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

int arr[maxn];

signed main() {
    int n; cin >> n;
    int sum = 0;
    for(int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        arr[temp]++;
        sum += temp;
    }
    int q;
    cin >> q;
    while(q--) {
        int a, b;
        cin >> b >> a;
        sum -= arr[b] * b;
        sum += arr[b] * a;
        arr[a] += arr[b];
        arr[b] = 0;
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 4408
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

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

AL=[0]*N
AR=[0]*N
for i in range(N):
    if i == 0:
        AL[0] = A[0]
        AR[0] = A[N-1]
    else:
        AL[i] = gcd(AL[i-1],A[i])
        AR[i] = gcd(AR[i-1],A[N-i-1])

max=0
for i in range(N):
    if i == 0:
        n_ex_gcd =  AR[N-2]
    elif i == N-1:
        n_ex_gcd = AL[N-2]
    else:
        n_ex_gcd = gcd(AL[i-1],AR[N-i-2])
    if n_ex_gcd > max:
        max = n_ex_gcd
print(max)


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

int main(){
    int n, t, a, h[1000];
    int i, ansnum, kion, sa, min = 1000000;

    scanf("%d", &n);
    scanf("%d %d", &t, &a);

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

        kion = t*1000 - h[i]*6;
        sa = a*1000 - kion;
        sa = abs(sa);

        if(min > sa){
            min = sa;
            ansnum = i+1;
        }
    }

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

    return 0;
}

Measured memory_bytes: 128
while True:
    x = input().split(" ")
    h = x[0]
    w = x[1]
    if int(h) == 0 and int(w) == 0:
        break
    else:
        for i in range (0, int(h)):
            for j in range (0, int(w)):
                print("#", end='')
            print()
        print()


Measured memory_bytes: 7004
import java.util.Scanner;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		long a = in.nextLong();
		long b = in.nextLong();
		long c = in.nextLong();
		long d = in.nextLong();
		long prod = Long.MIN_VALUE;
      prod = Math.max(prod, b*d);
      prod = Math.max(prod, a*c);
        prod = Math.max(prod, Math.min(b,d) * Math.max(a,c));
      System.out.println(prod);
	}
}

Measured memory_bytes: 35648
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i <= (n); ++i)
#define rip(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
int main() {
	string s;
	cin >> s;
	if (s[0] == 'A') s = 'T';
	else if (s[0] == 'C') s = 'G';
	else if (s[0] == 'G') s = 'C';
	else if (s[0] == 'T')  s = 'A';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
ans s [] = if s == 0 then "YES" else "NO"
ans s (l:ls) =
  case l of
    "A"  -> ans (s+1) ls
    "Un" -> if s == 0 then "NO" else ans (s-1) ls

main = do
  _ <- getLine
  c <- getContents
  let i = lines c
      o = ans 0 i
  putStrLn o
  



Measured memory_bytes: 3592
#include <algorithm>
#include<iostream>
#include<vector>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

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

  if(a+b>=c){
	cout << "Yes" << endl;
  }
  else{
	cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define pyn(a) if(a)puts("Yes");else puts("No");
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
int n,cnt;
bool flag;
string s;
int main()
{
    cin>>s;
    int size=s.size();
    for(int i=0,j=size-1;i<j;i++,j--){
        if(s[i]!=s[j])cnt++;
    }
    pf(cnt);
    return 0;
}


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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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 (b < a) { a = b; return 1; } return 0; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
constexpr double EPS = 1e-10;
constexpr int INF = 1001001001;
//constexpr ll INF = 1001001001001001001ll;


long long GCD(long long a, long long b) {
    return b != 0 ? GCD(b, a % b) : a;
}

int main() {
    int N; cin >> N;
    vll A(N);
    rep(i, N) cin >> A[i];
    ll ans = GCD(A[0], A[1]);

    for (int i = 2; i < N; i++) {
        ans = GCD(ans, A[i]);
    }

    cout << ans << endl;

}

Measured memory_bytes: 1024
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

a = ni()
s = ns()
print("red" if a < 3200 else s)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define tios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define tmod 1000000007

#define tvi vector<int>
#define tvii vector<int,int>
#define tvpii vector<pair<int,int>>
#define tmii map<int,int>
#define tmiv map<int,vector<int>>
#define tmsi map<string,int>
#define tmci map<char,int>
#define tumi unordered_map<int,int>
#define tumsi unordered_map<string,int>
#define tumci unordered_map<char,int>
#define tpii pair<int,int>
#define tsi set<int>
#define tusi unordered_set<int>
#define tqi queue<int>
#define tdqi deque<int>
#define tpqi priority_queue<int>

#define tr(i,n) for(int i=0;i<n;i++)
#define tl(i,n) for(int i=n;i>=0;i--)
#define tcr(a,x) for(auto a=x.begin();a!=x.end();a++)
#define tcbe(x) x.begin(),x.end()


int32_t main(void) {
    tios
    int n;
    cin>>n;
    cout<<(n==0) ? 1 : 0;
    return 0;
}


Measured memory_bytes: 3648
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    map<string, int> mp;
    string temp;
    for(int i = 0; i < n; i++) {
        cin >> temp;
        mp[temp] += 1;
    }
    
    int max = -1;
    
    for(auto it = mp.begin(); it != mp.end(); it++) {
        if((it->second) > max) {
            max = (it->second);
        }
    }
    
    set<string> s;
    
    for(auto it = mp.begin(); it != mp.end(); it++) {
        if((it->second) == max) {
            s.insert(it->first);
        }
    }
    
    for(auto it = s.begin(); it != s.end(); it++) {
        cout << (*it) << "\n";
    }
}


Measured memory_bytes: 34560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int t = 0, x = 0, y = 0;
    rep(i, n) {
        int a, b, c;
        cin >> a >> b >> c;
        if ((abs(b - x) + abs(c - y)) % 2 != (a - t) % 2) { puts("No"); return 0; }
        if (abs(b - x) + abs(c - y) > a - t) { puts("No"); return 0; }
        t = a; x = b; y = c;
    }
    puts("Yes");
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;

vector<vector<ll>> c;

void mk_c(){
    c.resize(2100);
    for(int i=1;i<2100;i++){
        c[i].resize(2100);
        c[i][0]=1;
        c[i][i]=1;
        for(int t=1;t<i;t++){
            c[i][t]=(c[i-1][t-1]+c[i-1][t])%MOD;
        }
    }
}

int main(){
    ll n,k;
    cin>>n>>k;
    if(n>k){cout<<0<<endl; return 0;}
    mk_c();
    cout<<c[k][n]<<endl;
    
    
    
    
    return 0;
}


Measured memory_bytes: 37428
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define trace(x)     cerr<<#x<<":"<<x<<endl;
#define trace2(x,y) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<endl;
#define trace3(x,y,z) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<"|"<<#z<<":"<<z<<endl;
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
int main(){
	fast_io;
	int n,k;
	cin>>n>>k;
	vi a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	vi dp(k+1,0);
	for(int i=0;i<=k;i++){
		for(int j:a){
			if(i-j>=0 && dp[i-j] == 0)
				dp[i] = 1;
		}
	}
	if(dp[k])cout<<"First";
	else cout<<"Second";
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 640
// include
//------------------------------------------

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef long long unsigned int ll;
// container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
// for
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

// const

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

// debug
//------------------------------------------

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
    vint a(3);
    REP(i,3){
        cin >> a[i];
    }
    SORT(a);
    vint b(3);
    b[0] = 5;
    b[1] = 5;
    b[2] = 7;
    bool flag = true;
    REP(i,3){
        if (a[i] != b[i]) flag = false;
    }

    if (flag) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << (#a) << " " << (a) << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

const int INF = (1 << 30) / 2;

int main()
{
	int n;

	while(cin >> n && n)
	{
		vector<vint> v(2, vint(n));
		vector<vint> d((n + 1) * 2, vint((n + 1) * 2, INF));

		rep(i, 2) rep(j, n)
			cin >> v[i][j];


		rep(i, (n + 1))
			d[i][i] = 0;

		// ツつサツづェツつシツづェツづ個湘ェツ渉環つゥツづァ1ツ偲ィツづ督楪達ツづつォツづゥツづつアツづォツづ可陛督づーツ陳」ツづゥ
		rep(y, n) rep(x, 2)
		{
			if(v[x][y] != 2)
			{
				for(int c = 0; c < 3 && y + c < n; c++)
				{
					int ny = y + c, nx = (x + 1) % 2;
					d[y * 2 + x][ny * 2 + nx] = 1;
				}

				if(v[x][y] == 1)
				{
					if(y + 1 < n && v[x][y + 1] == 1)
						d[y * 2 + x][(y + 1) * 2 + x] = 0;
				}
			}
			else
			{
				if(0 <= y - 1 && v[x][y - 1] == 2)
					d[y * 2 + x][(y - 1) * 2 + x] = 0;
			}
		}

		// ツ催終ツマツスツつゥツづァツ陛督づーツ陳」ツづゥ
		if(v[0][n - 1] != 2) d[(n - 1) * 2][n * 2 + 1] = 0;
		if(v[1][n - 1] != 2) d[(n - 1) * 2 + 1][n * 2] = 0;


		
		// ツδ渉ーツシツδδδ仰フツδ債イツドツづ催短ツ仰猟猟」ツづーツ出ツつキ
		rep(k, 2 * (n + 1)) rep(i, 2 * (n + 1)) rep(j, 2 * (n + 1))
				chmin(d[i][j], d[i][k] + d[k][j]);


		// ツづつソツづァツつゥツづァツづつソツづァツづ可行ツつュツづ個つェツ暗ェツ氾板短ツつ「ツつゥ
		int res = min(min(d[0][2 * n], d[0][2 * n + 1]), min(d[1][2 * n], d[1][2 * n + 1]));


		if(res == INF)
			cout << "NA" << endl;
		else
			cout << res << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a-1;i>=(ll)b;i--)
#define Fi first
#define Se second
typedef pair<ll, ll> pll;
const ll MAX = 100;
const char ENDL = '\n';
ll N;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> N;
	vector<ll> Ans(4);
	vector<char> sim(3);
	repr(i, 4, 0) {
		Ans[i] = N % 10;
		N /= 10;
	}
	bool flag = false;
	rep(i, 2) {
		rep(j, 2) {
			rep(k, 2) {
				ll judge = Ans[0];
				if (i == 0) {
					sim[0] = '+';
					judge += Ans[1];
				}
				else {
					sim[0] = '-';
					judge -= Ans[1];
				}
				if (j == 0) {
					sim[1] = '+';
					judge += Ans[2];
				}
				else {
					sim[1] = '-';
					judge -= Ans[2];
				}
				if (k == 0) {
					sim[2] = '+';
					judge += Ans[3];
				}
				else {
					sim[2] = '-';
					judge -= Ans[3];
				}
				if (judge == 7) {
					flag = true;
					break;
				}
			}
			if (flag == true)
				break;
		}
		if (flag == true)
			break;
	}
	rep(i, 4) {
		if (i)
			cout << sim[i-1];
		cout << Ans[i];
	}
	cout << '=' << 7 << ENDL;
	return 0;
}

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

using namespace std;
using ll = long long;

#define FOR(i, N) for (int i = 0; i < N; i++)


vector<ll> binary_gauss_jordan(const vector<ll>& x) {
	vector<ll> y(x);
	int sz = x.size();

	FOR(i, sz) {
		auto imax = max_element(y.begin() + i, y.end()) - y.begin();
		if (y[imax] == 0) break;

		swap(y[i], y[imax]);

		ll msb = 1;

		while ((msb << 1) <= y[i]) msb <<= 1;

		FOR(j, sz)
			if (j != i && y[j] & msb) y[j] ^= y[i];
	}
	while (y.size() && y.back() == 0) y.pop_back();
	return y;
}

int main(void) {
	int N;

	cin >> N;

	vector<ll> A(N);
	ll total = 0;

	FOR(i, N) cin >> A[i];
	FOR(i, N) total ^= A[i];
	FOR(i, N) A[i] &= ~total;

	auto A_std = binary_gauss_jordan(A);

	ll ans = 0;
	FOR(i, A_std.size()) ans = max(ans, ans ^ A_std[i]);

	cout << (2LL * ans + total) << endl;
}

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

int main() {
  long long N; cin>>N;
  vector<long long> a(N+1),b(N);
  long long ans =0;
  
  for(long long i=0; i<N+1 ;i++){
    cin >> a[i];
  }
  for(long long i=0; i<N; i++){
    cin >> b[i];
  }

  for(long long i=0;i<N;i++){
    
    if(a[i] >= b[i]){
      ans+=b[i];
    }
    else{
      ans+=a[i]; 
      b[i]-=a[i];
      
      if(a[i+1]>=b[i]){
        ans+=b[i]; 
        a[i+1]-=b[i];
      }
      
      else{
        ans+=a[i+1]; 
        a[i+1]=0;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int N = 3e3+10 ;
int dp[N][N] ;
int main()
{
    string s , t ;
    cin >> s >> t ;
    for ( int i = 1 ; i <= t.size() ; i++) {
        for ( int j = 1; j <= s.size(); j++){
              if (s[j-1] == t[i-1]) {
                dp[i][j] = dp[i-1][j-1]+1 ;
              }
              else {
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
              }
        }
    }
    int i = t.size();
    int j = s.size();
    string c ;
    while (i&&j) {
        if ( s[j-1] == t[i-1]){
            c += s[j-1] ;
            i--,j-- ;
        }
        else {
            if (dp[i][j-1] >= dp[i-1][j]){
                j-- ;
            }
            else
                i-- ;
        }
    }
    reverse(c.begin(),c.end());
    cout <<c ;
}


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

int main()
{
 int n;
 cin>>n;
 int arr[n-1];
 for(int i=0;i<n-1;i++)
  cin>>arr[i];

  map<int,int> mp;
  for(int i=0;i<n-1;i++)
     mp[arr[i]]++;

   for(int i=0;i<n;i++)
   {
   int t=i+1;
   auto it=mp.find(t);
   if(it!=mp.end())
    cout<<it->second<<endl;
   else
   cout<<0<<endl;
   }

   return 0;
  }


Measured memory_bytes: 13712
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("-ffloat-store")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define endl "\n"
#define f(i,a,b) for(int i=a;i<b;i++)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define mod 1000000007
#define inf  1e18
#define ps(x,y)   fixed<<setprecision(y)<<x
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define inp(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main() 
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
    FIO;
    // int t;
    // cin>>t;
    // while(t--)
    //{
        ll n;
        cin>>n;
        ll a[n];
        inp(a,n);
        ll sum=0;
        f(i,0,n-1)
        {
            if(a[i+1] < a[i])
            {
                sum+=(a[i]-a[i+1]);
                a[i+1]=a[i+1]+(a[i]-a[i+1]);
            }
        }
        cout<<sum;
    // }
return 0;   
}

Measured memory_bytes: 5216
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> q[i];
    }
    for (int i = 0; i < n; ++i) {
        v[i] = i+1;
    }
    int a, b;
    int num = 1;
    do{
        bool aflag = true;
        bool bflag = true;
        for (int i = 0; i < n; ++i) {
            if(v[i] != p[i]) aflag = false;
            if(v[i] != q[i]) bflag = false;
        }
        if(aflag) a = num;
        if(bflag) b = num;
        num++;
    } while(next_permutation(v.begin(), v.end()));

    cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
import sys
from collections import deque, defaultdict
import copy
import bisect
sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions

import sys
def input():
	return sys.stdin.readline().strip()


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

graph = [[] for _ in range(N)]
depth = [0 for _ in range(N)]
parent_list = [[] for _ in range(N)]
parent_num = [0 for _ in range(N)]
parent = [-1 for _ in range(N)]

for i in range(N - 1 + M):
	A, B = list(map(int, input().split()))
	A -= 1
	B -= 1
	graph[A].append(B)
	parent_list[B].append(A)
	parent_num[B] += 1

for i in range(N):
	if len(parent_list[i]) == 0:
		root = i
		break

que = deque([])
que.append(root)

while len(que) > 0:
	node = que.popleft()
	if len(graph[node]) > 0:
		for edge in graph[node]:
			depth[edge] = depth[node] + 1
			parent_num[edge] -= 1
			if parent_num[edge] == 0:
				que.append(edge)

for i in range(N):
	parent_depth = -1
	parent_node = -1
	if len(parent_list[i]) > 0:
		for p in parent_list[i]:
			if depth[p] > parent_depth:
				parent_depth = depth[p]
				parent_node = p
		parent[i] = parent_node

#print(parent_list, depth)

for i in range(N):
	print(parent[i] + 1)



Measured memory_bytes: 97676
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2

ll dp[202020][5];
int main() {
	ll l;
	cin >> l;
	vector<ll>a(l);
	rep(i, 0, l)cin >> a[i];

	rep(i, 0, 202020)rep(j, 0, 5)dp[i][j] = inf;
	rep(j, 0, 5)dp[0][j] = 0;
	rep(i, 1, l + 1)rep(j, 0, 5) {
		ll cost;
		if (j == 0 || j == 4) {
			cost = a[i - 1];
		}
		else if (j == 1 || j == 3) {
			cost = (a[i - 1] % 2 == 0) ? 0 : 1;
			cost = (a[i - 1] == 0) ? 2 : cost;
		}
		else {
			cost = (a[i - 1] % 2 == 0) ? 1 : 0;
		}
		for (int k = 0; k <= j; k++) {
			dp[i][j] = min(dp[i-1][k]+cost,dp[i][j]);
		}
	}

	ll ans = inf;
	rep(j, 0, 5)ans = min(ans, dp[l][j]);
	puts(ans);

	return 0;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const int N = 1e5 + 10;
ll a[N], sum[N];
ll pre[N], suf[N];

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n, k; cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum[i] = a[i] + sum[i - 1];
    pre[i] = pre[i - 1] + max(0ll, a[i]);
  }
  for (int i = n; i >= 1; i--) {
    suf[i] = suf[i + 1] + max(0ll, a[i]);
  }

  ll ans = 0;
  for (int i = 1; i + k - 1 <= n; i++) {
    ans = max(ans,
      max(0ll, sum[i + k - 1] - sum[i - 1])
      + pre[i - 1]
      + suf[i + k]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6744
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

ll to_ll(string s) {
  if(s == "") return 0;
  int n = s.size();
  ll tmp = 1;
  ll ret = 0;
  rep(i, n) {
    ret += int(s[n-1-i] - '0') * tmp;
    tmp *= 10;
  }
  return ret;
}

int main() {
  string S;
  cin >> S;
  int N = S.size();
  ll ans = 0;
  rep(i, 1<<(N-1)) {
    int tmp = 0;
    rep(j, N-1) {
      if(i & 1<<(N-2-j)) {
        ans += to_ll(S.substr(tmp, j+1-tmp));
        tmp = j+1;
      }
    }
    ans += to_ll(S.substr(tmp, N-tmp));
  }
  cout << ans << endl;
  return 0;
}



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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = 2147483647;
constexpr ll L_INF = 9223372036854775807LL;

//===




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

	int a = 1 + 8 * N;
	int sqrt_a = sqrt(a);

	if (sqrt_a * sqrt_a != a) {
		cout << "No" << endl;
		return 0;
	}
	
	int b = (sqrt_a - 1) / 2;
	
	vector<Vi> s(b + 1, Vi(b));


	int shift = 0;
	int idx = 0;
	for (int i = 1; i <= N; ++i) {
		s[shift][idx] = i;
		s[idx + 1][shift] = i;
		++idx;
		if (idx == b) {
			++shift;
			idx = shift;
		}
	}

	cout << "Yes" << endl;
	cout << b + 1 << endl;
	for (int i = 0; i < b + 1; ++i) {
		cout << b << " ";
		for (int j = 0; j < b - 1; ++j) {
			cout << s[i][j] << " ";
		}
		cout << s[i][b - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 2176
def sumproductsofpairs(lst):
    total = 0
    psum = 0
    for x in lst:
        total = (total + (psum * x)%mod)%mod
        psum = ((psum)%mod + (x)%mod)%mod
    return total


N=int(input())
array=[int(x) for x in input().split()]

mod=10**9+7
print(sumproductsofpairs(array)%mod)

Measured memory_bytes: 94228
import queue

N = int(input())
A_list = sorted(list(map(int, input().split())), reverse=True)

edge_que = queue.Queue()
edge_que.put(A_list[0])
score = 0
for i, a in enumerate(A_list[1:]):
    score += edge_que.get()
    edge_que.put(a)
    edge_que.put(a)
print(score)

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

int main(){

	int N;
	long int d[110],sum=0;
	int i,j;
	scanf("%d",&N);
	for(i=0;i<N;i++)scanf("%ld",&d[i]);
	
	for(i=0;i<N-1;i++){
		for(j=i+1;j<N;j++){
			sum += d[i]*d[j];
		}
		
	}
	printf("%ld\n",sum);
	return 0;
 }

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

using namespace std;

#define MOD 1000000007
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<ll> now(3);
  ll ans = 1;
  for (int i = 0; i < N; ++i) {
    ll A;
    cin >> A;
    ll newans = 0;
    bool clean = 1;
    for (int j = 0; j < 3; ++j)
      if (now[j] == A) {
        newans = (newans + ans) % MOD;
        if (clean) now[j]++;
        clean = 0;
      }
    ans = newans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//https://cpprefjp.github.io/reference/tuple.html ->tuple

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<tuple>

int main(){
    std::vector<std::tuple<int,int,char,long long int,std::string>> product;
    
    int n;
    std::cin>>n;

    int price, weight;
    char type;
    long long int date;
    std::string name;
    
    for(int i=0;i<n;i++){
        std::cin>>price>>weight>>type>>date>>name;
        product.push_back(std::make_tuple(price,weight,type,date,name));
    }

    std::sort(product.begin(),product.end());

    for(int i=0;i<n;i++){
        std::cout<<std::get<0>(product[i])<<" "<<std::flush;
        std::cout<<std::get<1>(product[i])<<" "<<std::flush;
        std::cout<<std::get<2>(product[i])<<" "<<std::flush;
        std::cout<<std::get<3>(product[i])<<" "<<std::flush;
        std::cout<<std::get<4>(product[i])<<std::endl;
    }

    return 0;

}



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

ll fre[210000];

int main()
{
    ll N,K,x,sum=0;
    cin>>N>>K;
    for(int i=0; i<N; i++)
    {
        cin>>x;
        fre[x]++;
    }
    sort(fre,fre+N,greater<ll>());
    for(int i=K; i<=N; i++)
    {
        sum+=fre[i];
    }
    cout<<sum<<endl;

}



Measured memory_bytes: 1792
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, x[26], y[26], r[26], col[26], b[26][26]; short dp[16777222];
int solve(int bit) {
	if (dp[bit]) return dp[bit] - 1;
	int ret = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (col[i] != col[j]) continue;
			if (bit & (1 << i)) continue;
			if (bit & (1 << j)) continue;
			if ((bit & b[i][j]) == b[i][j]) {
				int res = solve(bit + (1 << i) + (1 << j));
				ret = max(ret, res + 2);
			}
		}
	}
	dp[bit] = ret + 1;
	return ret;
}
int main() {
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> r[i] >> col[i];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				b[i][j] = 0;
				for (int k = 0; k < n; k++) {
					int disti = (x[k] - x[i]) * (x[k] - x[i]) + (y[k] - y[i]) * (y[k] - y[i]);
					int distj = (x[k] - x[j]) * (x[k] - x[j]) + (y[k] - y[j]) * (y[k] - y[j]);
					if (k < i && disti < (r[i] + r[k]) * (r[i] + r[k])) b[i][j] |= 1 << k;
					if (k < j && distj < (r[j] + r[k]) * (r[j] + r[k])) b[i][j] |= 1 << k;
				}
			}
		}
		fill(dp, dp + (1 << n), 0);
		int ret = solve(0);
		cout << ret << endl;
	}
	return 0;
}

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

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

    ll res=0;
    ll rem=0;
    res = n/(a+b) * a;
    rem = n%(a+b);
    res += min(rem, a);

    cout << res << endl;
    return 0;
}

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

int n, s, now = 0, ans = 0;
pair<int, int> lr[505];
int memo[505][505] = {0};
// dp[i][j] =
// i+1番目にjに行ったときの、それまでの布教時間の最大値
int dp[505][505] = {0};

int main() {
  int i, j, k;
  cin >> n >> s;
  --s;
  for(i = 0; i < n; ++i) cin >> lr[i].first >> lr[i].second;
  for(i = 0; i < n; ++i)
    for(j = 0; j < n; ++j) cin >> memo[i][j];
  // wf
  for(k = 0; k < n; ++k)
    for(i = 0; i < n; ++i)
      for(j = 0; j < n; ++j)
        memo[i][j] =
            min(memo[i][j], memo[i][k] + memo[k][j]);
  for(i = 0; i < n; ++i)
    for(j = 0; j < n; ++j) dp[i][j] = -1;
  // i=0はsからの値をそれぞれメモ
  for(i = 0; i < n; ++i)
    dp[0][i] = lr[i].second - max(memo[s][i], lr[i].first);
  // nが1のときはコーナーケースとして処理
  if(n == 1) ans = dp[0][0];
  for(i = 1; i < n; ++i) {
    // jからkに行ったときに増える量を計算し、最大値をメモする
    for(j = 0; j < n; ++j) {
      if(dp[i - 1][j] < 0) continue;
      for(k = 0; k < n; ++k) {
        int x = lr[k].second -
                max(lr[j].second + memo[j][k], lr[k].first);

        //既に計算済みの値と、新しくjからkに行ったときの合計値を比較
        if(x>=0)dp[i][k] =
            max(dp[i][k], dp[i - 1][j] + x);
         ans = max(ans, dp[i][k]);
      }
  	}
  }
  cout  <<  ans  << endl;
  return 0;
}


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

int main() {
  int X;
  cin>>X;
  int N=X;
  int i=0;
  int x=0;
  int M=X;
  while(N!=0){
    N/=10;
    i++;
  }
  for(int j=0;j<i;j++){
    x+=(X%10);
    X/=10;
  }
  if(M/x==(M+x-1)/x){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


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

int main(){
    unsigned long long n, a, b;
    cin >> n >> a >> b;
    unsigned long long abset = n / (a+b);
    unsigned long long surplus = n % (a+b);
    unsigned long long ans = abset * a;
    if(surplus < a){
        ans += surplus;
    } else {
        ans += a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,t=0,ma=10000000000000000,s=0;
  cin>>n;
  ll a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    t+=a[i];
  }
  for(int i=0;i<n-1;i++){
    t-=a[i];
    s+=a[i];
    ma=min(abs(s-t),ma);
  }
  cout<<ma;
}

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



int main() {
    int n;
    cin >> n;
    
    ll xd0, yd0, xd1, yd1;
    xd0 = yd0 = 100100100100;
    xd1 = yd1 = -100100100100;
    rep(i,n) {
        ll x, y;
        cin >> x >> y;
        
        xd0 = min(xd0, x-y);
        yd0 = min(yd0, x+y);
        xd1 = max(xd1, x-y);
        yd1 = max(yd1, x+y);
    }
    
    cout << max(xd1 - xd0, yd1- yd0) << endl;
    
    
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

signed main()
{
    int a;
    cin >> a;
    cout << a + pow(a,2) + pow(a,3);    
    return 0;
}

Measured memory_bytes: 4284
#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mod 1000000007
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
void init() {
  int n, k;
  cin >> n >> k;
  int div = n / k;
  int ans = div * div * div;
  int cnt = 0;
  if (!(k & 1)) {
    for (int i = k / 2; i <= n; i += k) {
      cnt++;
    }
    ans += cnt * cnt * cnt;
  }
  cout << ans << endl;
}
int32_t main() {
  IOS;
  init();
  return 0;
}


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

int main() {
  int N,X;
  cin >> N >> X;
  int ans = 1;
  int L;
  int tot = 0;
  for (int i=0; i<N; i++) {
    cin >> L;
    tot += L;
    if (tot > X) {
      break;
    }
    ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    string str;
    cin >> str;
    transform(str.begin(),str.end(),str.begin(),::tolower);
    
    int count=0;
    while(1){
        string tmp;
        cin>>tmp;
        if(tmp=="END_OF_TEXT") break;
        transform(tmp.begin(),tmp.end(),tmp.begin(),::tolower);
        if(str==tmp) count++;
    }
    cout <<count<<endl;
   
}


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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef pair<int,int> pii;
const int MN = 2e5+5;
int N,A[MN],B[MN];
priority_queue<pii> PQ;
int main()
{
    cin >> N;
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N; i++){
        cin >> B[i];
        if(B[i]<A[i]){
            cout << -1;
            return 0;
        }
        if(B[i]>A[i]) PQ.emplace(B[i],i);
    }
    int v,x;
    long long ans=0;
    while(PQ.size()){
        tie(v,x) = PQ.top();
        PQ.pop();
        if(B[x]-(B[(x-1+N)%N]+B[(x+1)%N])<A[x]){
            cout << -1;
            return 0;
        }
        int cnt = (B[x]-A[x])/(B[(x-1+N)%N]+B[(x+1)%N]);
        B[x] -= cnt*(B[(x-1+N)%N]+B[(x+1)%N]);
        ans += cnt;
        if(B[x]>A[x]) PQ.emplace(B[x],x);
    }
    cout << ans;
}


Measured memory_bytes: 3700
a,b = map(int,input().split())
s = list(map(int,input().split()))
num1 =0
num2 =0
if b ==0:
  print(a)
  exit()
for i in range(100):
    num1 = a-i
    num2 = a+i
    if not num1 in s and not num2 in s:
        print(num1)
        exit()
    if not num1 in s:
        print(num1)
        exit()
    if not num2 in s:
        print(num2)
        exit()

Measured memory_bytes: 9144