akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int A = sc.nextInt();
			final int B = sc.nextInt();
			final int T = sc.nextInt();
			
			System.out.println(T / A * B);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 23124
import sys
from collections import Counter
from collections import deque
import math
import fractions
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=input()
ans=["Sunny","Cloudy","Rainy","Sunny"]
print(ans[ans.index(s)+1])

Measured memory_bytes: 5580
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N, K; cin >> N >> K;
    vector<int> X(N);
    for(int& x:X) cin >> x;
    
    int ans = 1<<30;
    for(int i=0; i<N-K+1; i++){
        int t;
        if((long long)X[i]*X[i+K-1]>0) t = max(abs(X[i]), abs(X[i+K-1]));
        else t = 2*min(abs(X[i]), abs(X[i+K-1])) + max(abs(X[i]), abs(X[i+K-1]));
//        t = min(abs(X[i])+abs(X[i]-X[i+K-1]), abs(X[i+K-1])+abs(X[i]-X[i+K-1]));
        ans = min(ans, t);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define infi 100000000000009
#define int long long
int value[101];
int weight[101];
int dp[101][100001];
int  n;
 
 int rec(int idx,int val)
 {
     if(dp[idx][val] != -1) return dp[idx][val] ; 
 
     if(idx >= n) return (val > 0) ? infi : 0 ;
     if(val<0) return 0;
     // if(value[idx]>val) return rec(idx+1,val);
     return dp[idx][val] = min(rec(idx+1,val),weight[idx]+rec(idx+1,val-value[idx]));
 }
signed main()
{
    
    cin>>n;
    int w;
    cin>>w; 
    int tot=0;  
    for(int i=0;i<n;i++)
    { 
        cin>>weight[i]>>value[i];
        tot+=value[i];
 
    }
    memset(dp, -1, sizeof(dp));
    for(int i=tot;i>=1;i--)
    {
        if(rec(0,i)<=w)
        {
            cout << i ; return 0 ; 
        }
    }
    
    cout << 0 ; 
 
    return 0;
 
 
}


Measured memory_bytes: 79104
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 100005
int n;
pll loc[MN];

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

    cin >> n;
    F0R(i, n){
        ll x, y;
        cin >> x >> y;
        loc[i] = {x+y, x-y};
    }

    sort(loc, loc+n);
    int cnt = 0;
    int rt = -INF;
    F0R(i, n){
        if(loc[i].s >= rt){
            rt = loc[i].f;
            ++cnt;
        }
    }
    cout << cnt << "\n";

    return 0;
}


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

int main(void){

  int H,W;
  cin >> H >> W;

  for(int i=0; i<W+2; i++) cout << '#';
  cout << endl; 

  string S;
  for(int i=0; i<H; i++) {
    cin >> S;
    cout << '#' << S << '#' << endl;
  }


  for(int i=0; i<W+2; i++) cout << '#';
  cout << endl; 

  return 0;
}



Measured memory_bytes: 256
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    vecl X(N);
    vecl sort_X(N);
    vecl ans(N);
    REP(i,N) {
        cin >> X[i];
        sort_X[i] = X[i];
    }
    sort(sort_X.begin(),sort_X.end());
    ll r = sort_X[N/2];
    ll l = sort_X[N/2-1];
    REP(i,N) {
        if(X[i] <= l) cout << r << endl;
        else if(X[i] >= r) cout << l << endl; 
    }
}

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

int main ()
{
    int a, b, c;
    cin >> a;
    cin >> b;
    cin >> c;
    int e,f,g;
    e = a+b;
    f = a+c;
    g = b+c;
    if (e<=f && e <= g)
    {
        cout << e << endl;
    }
    else if (f <= e && f <= g)
    {
        cout << f << endl;
    }
    else if (g <= e && g <= f)
    {
        cout << g << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define P pair<int,int>
//P pa(114,514);   ,vector<P>vec(N,0);
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}
//cout << setprecision(123);
int main(){
  int N,a,b;
  string ans;
  cin>>N;
  a=N/100;
  b=N%100;
  
  if(1<=a && a<=12 && 1<=b && b<=12){
    ans="AMBIGUOUS";
  }
  else if(1<=a && a<=12){
    ans="MMYY";
  }
  else if(1<=b && b<=12){
    ans="YYMM";
  }
  else{
    ans="NA";
  }
  
  cout << ans<<endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

var N, K, ans int

func main() {
	fmt.Scan(&N, &K)

	if K != 1 {
		fmt.Println(N - K)
	} else {
		fmt.Println(0)
	}
}

/*  ----------------------------------------  */

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

// type LR []int

// func (a SortBy) Len() int           { return len(a) }
// func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
// func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProblemR
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var N = read[0];
            var M = read[1];

            var xs = new int[M];
            var ys = new int[M];

            for (int i = 0; i < M; i++)
            {
                read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                xs[i] = read[0];
                ys[i] = read[1];
            }
            var sortedInd = ys.Select((y, i) => new { ind = i, point = y }).OrderBy(x => x.point).Select(x => x.ind);
            var sortedxs = sortedInd.Select(i => xs[i]).ToArray();
            var sortedys = sortedInd.Select(i => ys[i]).ToArray();

            var current = 1;
            var res = 0;
            for (int i = 0; i < sortedxs.Length; i++)
            {
                if(sortedxs[i] >= current)
                {
                    current = sortedys[i];
                    res++;
                }
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 53604
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N, N2;
char color[9];
bool C[4011];
int A[4011];

int g[2][4011][2011];
int dp[2011][2011];

int pos[2][2011];


void MAIN() {
    scanf("%d", &N);
    N2 = N + N;
    REP (i, N2) {
	scanf("%s%d", color, A+i);
	C[i] = (*color == 'B');
	A[i]--;

	pos[C[i]][A[i]] = i;
    }

    REP (i, N2) {
	REP (t, N) {
	    g[0][i+1][t] = g[0][i][t];
	    g[1][i+1][t] = g[1][i][t];
	}

	REP (t, A[i]+1) g[C[i]][i+1][t]++;
    }


    memset(dp, 0x3f, sizeof dp);
    const int INF = dp[0][0];
    dp[0][0] = 0;

    REP (i, N+1) REP (j, N+1) if (dp[i][j] < INF) {
	int i_pos = pos[0][i];
	int j_pos = pos[1][j];

	if (i != N) {
	    amin(dp[i+1][j], dp[i][j] + g[0][i_pos][i] + g[1][i_pos][j]);
	}
	if (j != N) {
	    amin(dp[i][j+1], dp[i][j] + g[0][j_pos][i] + g[1][j_pos][j]);
	}
    }

    printf("%d\n", dp[N][N]);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 78976
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        int i,j;
        Scanner sc= new Scanner(System.in);

        int n= sc.nextInt();
        int intarr[]=new int[n];
        for(i=0;i<n;i++){
            intarr[i]=sc.nextInt(); 
        }
        int pivot=0;
        int times=0;
        int swap;

        for(i=0;i<n;i++){
            pivot=i;
            for(j=i;j<n;j++){
                if(intarr[j]<intarr[pivot]){
                    pivot=j;
                }
            }     
            if(i!=pivot){
                swap=intarr[i];
                intarr[i]=intarr[pivot];
                intarr[pivot]=swap;
                times++;  
            }                         
        }

        for(i=0;i<n;i++){
            if(i==n-1){
                System.out.printf("%d",intarr[i]);
            }else{
                System.out.printf("%d ",intarr[i]);
            }            
        }
        System.out.printf("%n");
        System.out.println(times);
    }    
}


Measured memory_bytes: 26580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

template <typename T>
struct Graph {
    int V, E;
    struct Edge {
        int from, to;
        T cost;
    };
    vector<vector<Edge>> edge;
    vector<vector<T>> dist;
    vector<Edge> es;

    Graph(int V, int E) : V(V), E(E) {
        edge.assign(V, vector<Edge>(0));
        dist.assign(V, vector<T>(0));
    }

    void input(bool is_direct, bool inputc, bool index0 = false) {
        int a, b;
        T c = 0;
        for (int i = 0; i < E; i++) {
            cin >> a >> b;
            if (inputc) cin >> c;
            if (!index0) a--, b--;
            edge[a].push_back((Edge){a, b, c});
            es.push_back((Edge){a, b, c});
            if (!is_direct) {
                edge[b].push_back((Edge){b, a, c});
                es.push_back((Edge){b, a, c});
            }
        }
        if (!is_direct) E *= 2;
    }

    void add_edge(int from, int to, T cost, bool is_direct) {
        edge[from].push_back({from, to, cost});
        es.push_back({from, to, cost});
        if (!is_direct) {
            edge[to].push_back({to, from, cost});
            es.push_back({to, from, cost});
            E++;
        }
        E++;
    }

    vector<int> B, W;
    vector<int> color;

    bool coloring(int v = 0, bool c = true, int from = -1) {
        if (color.size() == 0) color.assign(V, 0);
        if (color[v] && color[v] - 1 != c) return false;
        if (color[v] && color[v] - 1 == c) return true;

        color[v] = c + 1;
        if (c) W.push_back(v);
        if (!c) B.push_back(v);

        for (const auto& e : edge[v]) {
            int to = e.to;
            if (!coloring(to, !c)) return false;
        }
        return true;
    }
};

int main() {
    ll N, M;
    cin >> N >> M;
    Graph<int> g(N, M);
    g.input(false, false);
    if (g.coloring())
        cout << (ll)g.B.size() * g.W.size() - M << endl;
    else
        cout << N * (N - 1) / 2 - M << endl;
    return 0;
}

Measured memory_bytes: 12976
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;


int main(){
    int N, K;
    cin >> N >> K;
    if(N==1){
        int a;
        cin>>a;
        cout << a <<endl;
        return 0;
    }
    vector<int> x(N);
    int ans=1000000000;
    for(int i=0;i<N;i++) cin >> x[i];
    for(int i=0;i<N-K+1;i++){
         int l=abs(x[i])+abs(x[i+K-1]-x[i]);
         int r=abs(x[i+K-1])+abs(x[i]-x[i+K-1]);
         ans= min(ans, min(l,r));
    }
    cout << ans <<endl;
}


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

int main() {
    int n, x, c, tot;
    scanf("%d", &n);
    c=tot=0;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &x);    
        if(x==i) { 
            c++;
        } else {
            if(c!=0) {
                tot += max(int(ceil(c/2.)),1);
            }
            c=0;
        }
    }
    if(c!=0) {
        tot += max(int(ceil(c/2.)),1);
    }

    printf("%d\n", tot);
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll m=1000000007;
int main()
{
	int n,k;
	cin>>n>>k;
	int arr[n],dp[n]; 
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		
	}
	dp[0]=0;
	for(int i=1;i<n;i++)
	{
		dp[i]=dp[i-1]+abs(arr[i]-arr[i-1]);
	}
	for(int i=2;i<n;i++)
	{
		for(int j=1;j<=k && i>=j;j++)
		{
			dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
		}
	}
	cout<<dp[n-1];
}



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

int main(){
	int n; cin>>n;
	string s;
	for(int i=1; i<=n; i++) s+=to_string(i);
	string p,q;
	rep(i,n){
		int a; cin>>a;
		p+=to_string(a);
	}
	rep(i,n){
		int a; cin>>a;
		q+=to_string(a);
	}
	int a,b,cnt=0;
	do{
		cnt++;
		if(p==s) a=cnt;
		if(q==s) b=cnt;
	}while(next_permutation(s.begin(),s.end()));
	cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 3660
#include <iostream>
#include<math.h>
 
int main()
{
    double A,B,H,M;
    double r;
    std::cin>>A>>B>>H>>M;
    H=(H*60+M)*.5;
    H > M*6 ? r = H - M*6 : r = M*6 - H;
    if(r>180)
    {
        r=360-r;
    }
    r = (r  * M_PI) / 180.0;
    printf("%.10lf\n",sqrt((double)(A*A+B*B)-(double)(2*A*B*cos(r))));
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)

int h, w, s[510][510];
bool o = false;
vector<int> out;
int main(){
	cin >> h >> w;
	REPO(i, h) REPO(j, w)cin >> s[i][j];
	REPO(i, h) {
		REP(k, w) {
			int j;
			if (i % 2 == 0)j = w - k;
			else j = k + 1;
			if (s[i][j] % 2 == 1) {
				if (o)o = false; 
				else o = true;
			}
			if (o) {
				if ((h % 2 == 0 and i == h and j == 1) or (h % 2 == 1 and i == h and j == w))break;
				else {
					out.push_back(i);
					out.push_back(j);
					if (i % 2 == 1) {
						if(j == w){
							out.push_back(i + 1);
							out.push_back(j);
						}
						else {
							out.push_back(i);
							out.push_back(j + 1);
						}
					}
					else {
						if (j == 1) {
							out.push_back(i + 1);
							out.push_back(j);
						}
						else {
							out.push_back(i);
							out.push_back(j - 1);
						}
					}
				}
			}
		}
	}
	cout << out.size() / 4 << endl;
	REP(i, out.size()) {
		if (i % 4 == 3)cout << out[i] << endl;
		else cout << out[i] << " ";
	}
	cout << endl;
}

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

int main(){
  int n;cin >> n;
  map<int,int> d;
  rep(i,n){
    int num;cin >> num;
    d[num]++;
  }

  int m;cin >> m;
  vector<int> t(m);
  rep(i,m) cin >> t.at(i);

  rep(i,m){
    if( d[t.at(i)] == 0 ){
      cout << "NO" << '\n';
      return 0;
    }else{
      d.at(t.at(i))--;
    }
  }
  cout << "YES" << '\n';
  return 0;
}

Measured memory_bytes: 13132
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  ll c = a+b;
  ll d = n/c;
  ll e = n%c;
  cout<<d*a+min(a,e)<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)

{
 int n, i, b, j, c, d;
 int a[1000][1000];

 scanf("%d", &n);

 for(i = 1; i <= n; i++)
{
 scanf("%d", &d);
 scanf("%d", &b);

 for(j = 1; j <= b; j++)
{
 scanf("%d", &c);
 
 a[d][c] = 1;

 }

}

 for(i = 1; i <= n; i++)
 {
  for(j = 1; j <= n; j++)
 {
 if(j != n)
   printf("%d ", a[i][j]);
 else
   printf("%d", a[i][j]);

 }
 printf("\n");
}

return 0;
}



Measured memory_bytes: 2144
#include <stdio.h>
struct dice{
    int d[6], tmp[6];
};
struct dice dice1;
struct dice dice2;
struct dice dice3[110];
void copy1(int a){
    int i;
    for (i=0;i<6;i++){
        dice3[a].d[i]=dice2.d[i];
        dice3[a].tmp[i]=dice2.tmp[i];
    }
}
void copy2(int a){
    int i;
    for (i=0;i<6;i++){
        dice2.d[i]=dice3[a].d[i];
        dice2.tmp[i]=dice3[a].tmp[i];
    }
}
void init1(int n[6]){
    int i;
    for (i=0;i<6;i++){
        dice1.d[i]=n[i];
    }
}
void init2(int n[6]){
    int i;
    for (i=0;i<6;i++){
        dice2.d[i]=n[i];
    }
}
void throwdice(char c){
    int i;
    for(i=0;i<6;i++){
        dice1.tmp[i]=dice1.d[i];
    }
    if(c=='N'){
        dice1.d[0]=dice1.tmp[1];
        dice1.d[1]=dice1.tmp[5];
        dice1.d[2]=dice1.tmp[2];
        dice1.d[3]=dice1.tmp[3];
        dice1.d[4]=dice1.tmp[0];
        dice1.d[5]=dice1.tmp[4];
    }
    else if(c=='E'){
        dice1.d[0]=dice1.tmp[3];
        dice1.d[1]=dice1.tmp[1];
        dice1.d[2]=dice1.tmp[0];
        dice1.d[3]=dice1.tmp[5];
        dice1.d[4]=dice1.tmp[4];
        dice1.d[5]=dice1.tmp[2];
    }
    else if(c=='W'){
        dice1.d[0]=dice1.tmp[2];
        dice1.d[1]=dice1.tmp[1];
        dice1.d[2]=dice1.tmp[5];
        dice1.d[3]=dice1.tmp[0];
        dice1.d[4]=dice1.tmp[4];
        dice1.d[5]=dice1.tmp[3];
    }
    else if(c=='S'){
        dice1.d[0]=dice1.tmp[4];
        dice1.d[1]=dice1.tmp[0];
        dice1.d[2]=dice1.tmp[2];
        dice1.d[3]=dice1.tmp[3];
        dice1.d[4]=dice1.tmp[5];
        dice1.d[5]=dice1.tmp[1];
    }
    else if(c=='R'){
        dice1.d[0]=dice1.tmp[0];
        dice1.d[1]=dice1.tmp[3];
        dice1.d[2]=dice1.tmp[1];
        dice1.d[3]=dice1.tmp[4];
        dice1.d[4]=dice1.tmp[2];
        dice1.d[5]=dice1.tmp[5];
    }
}
int compare(){
    int i;
    for(i=0;i<6;i++){
        if(dice1.d[i]!=dice2.d[i]){
            return 0;
        }
    }
    return 1;
}
int main()
{
    int n[6];
    int m;
    int i,j,k,l;
    int ok=0;
    scanf("%d",&m);
    for(i=0;i<6;i++){
        scanf("%d",&n[i]);
    }
    init2(n);
    copy1(0);
    for(i=0;i<m-1;i++){
        for(j=0;j<6;j++){
            scanf("%d",&n[j]);
        }
        init1(n);
        for(j=0;j<i+1;j++){
            copy2(j);
            for(k=0;k<4;k++){
                for(l=0;l<4;l++){
                    throwdice('N');
                    throwdice('E');
                    throwdice('S');
                    if(compare()) ok=1;
                }
                throwdice('N');    
            }
            throwdice('E');
            for(k=0;k<2;k++){
                for(l=0;l<4;l++){
                    throwdice('N');
                    throwdice('E');
                    throwdice('S');
                    if(compare()) ok=1;
                }
                throwdice('W');    
                throwdice('W');    
            }
        }
        copy1(i+1);
    }
    if(!ok) puts("Yes");
    else puts("No");
    return 0;
}


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

int number[100005];

int main() {
    int N, min_count = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> number[i];
    }
    for (int i = 0; i < N; i++) {
        if (number[i] == i + 1) {
            if (i == N - 1) {
                min_count++;
            }
            else {
                swap(number[i], number[i + 1]);
                min_count++;
            }
        }
    }
    cout << min_count << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

int main(void){
  std::vector<long> A;
  int n;
  std::cin >> n;

  for(int i=0; i<(1<<n); i++){
    long temp;
    std::cin >> temp;
    A.push_back(temp);
  }

  for(int i=n-1; i>=0; i--){
    for(int j=0; j<(1<<(i)); j++){
      if(A[j*2] < A[j*2+1])      A[j] = A[j*2+1]-A[j*2];
      else if(A[j*2] > A[j*2+1]) A[j] = -(A[j*2+1]-A[j*2]);
    }
  }

  std::cout << A[0] << std::endl;

  return 0;
}



Measured memory_bytes: 2420
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size

ll sq(ll x){
	return x*x;
}

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

bool isvowel(char c){
	int i;
	string v="aeiou";
	for(i = (v.size()-1); i>=0; --i){
		if(c == v[i]){
			return true;
		}
	}
	return false;
}

int main(void){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << (max(a*b,c*d)) << endl;
	return 0;
}

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

using namespace std;

int main()
{
    int N;
    string S;

    cin >> N;

    S = to_string(N);

    char one = S[0];
    char two = S[1];
    char three = S[2];

    string ans = "No";

    if (one == '7')
    {
        ans = "Yes";
    }

    if (two == '7')
    {
        ans = "Yes";
    }

    if (three == '7')
    {
        ans = "Yes";
    }

    cout << ans << endl;
}

Measured memory_bytes: 3688
#include <stdio.h>

int main(void) {
	int i;
	int h1,m1,s1,h2,m2,s2;
	int t1,t2;
	int t;
	for(i=0;i<3;i++) {
		scanf("%d %d %d %d %d %d",
			&h1,&m1,&s1,&h2,&m2,&s2);
		t1=h1*3600+m1*60+s1;
		t2=h2*3600+m2*60+s2;
		t=t2-t1;
		printf("%d %d %d\n",t/3600,(t/60)%60,t%60);
	}
	return 0;
}

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

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

    int x, t;
    cin >> x >> t;

    if (x > t)
        cout << x - t << '\n';
    else
        cout << 0 << '\n';

    return 0;
}

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

void show_array(int *array, int &N){
	for(int i=0; i<N; ++i){
		cout << array[i];
		if(i < N-1){
			cout << " ";
		}
	}	
	cout << endl;
}


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

	int A[N]; // define a static array

	// Input values in the array
	for(int i=0; i<N; i++){
   scanf("%d", &A[i]);
	}

	// Bubble Sort
	int flag = 1;
	int temp;
	int count=0;
	while(flag){
		flag = 0;

		for(int j=N-1; 0<j; --j){
			if (A[j] < A[j-1]){
				temp = A[j-1];
				A[j-1] = A[j];
				A[j] = temp;

				count += 1;
				flag = 1;
			}
		}
	}

	show_array(A, N);
	cout << count << endl;


	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << #x << ": " << endl
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rrep(i,n) for(int i=(n); (i)>0; --(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
#define ALL(obj) (obj).begin(),(obj).end()
template<class T> inline bool print(T& x){ cout << x << endl; return true; }
template<class T> inline bool print_(T& x){ cout << x << " "; return true; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
const int INF = 1e9;
const ll llINF = 1LL<<60;
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main(){
    string s; cin >> s;
    int ans[2]={0};
    rep(i,(int)s.size()){ 
      if(s[i]=='0') ans[0]++;
      else ans[1]++;
    }
    cout << min(ans[0],ans[1])*2;
    
    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
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 a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	VE a(n); rep(i, n)cin >> a[i];
	sort(ALL(a));
	vector<P> d(m);
	rep(i, m) {
		cin >> d[i].second >> d[i].first;
	}
	sort(ALL(d), greater<P>());
	int now = 0;
	rep(i, m) {
		int b = d.at(i).second; int c = d.at(i).first;
		if (now == n)break;
		if (a.at(now) > c)break;
		rep(j, b) {
			if (now == n)break;
			if (a.at(now) > c)break;
			a.at(now) = c; now++;
		}
	}
	int ans = 0; rep(i, n)ans += a[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

void solve(){
    ll N;
    cin >> N;
    N %= 10;
    if(N == 3){
        print("bon");
    }else if(N == 0 || N == 1 || N == 6 || N == 8){
        print("pon");
    }else{
        print("hon");
    }
    

}

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

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

int main() {
  long long N, P;
  cin >> N >> P;
  string S;
  cin >> S;
  
  long long dp[N];
  long long pow_10 = 1;
  for (int i = N - 1; i >= 0; i--){
    if (i == N - 1) dp[i] = (S[i] - '0') % P;
    else {
      dp[i] = dp[i + 1] + (S[i] - '0') * pow_10;
      dp[i] %= P;
    }
    pow_10 *= 10; pow_10 %= P;
  }
  
  long long sum[P];
  for (int i = 0; i < P; i++) sum[i] = 0;
  for (int i = 0; i < N; i++){
    sum[dp[i]]++;
  }
  sum[0]++;
  long long count = 0;
  for (int i = 0; i < P; i++) count += sum[i] * (sum[i] - 1) / 2;
  if (P != 2 && P != 5) cout << count << endl;
  else {
    if (P == 2){
      long long sum = 0;
      for (int i = 0; i < N; i++) if ((S[i] - '0') % 2 == 0) {
        sum += i + 1;
      }
      cout << sum << endl;
    }
    if (P == 5){
      long long sum = 0;
      for (int i = 0; i < N; i++) if ((S[i] - '0') % 5 == 0) {
        sum += i + 1;
      }
      cout << sum << endl;
    }
  }
}

Measured memory_bytes: 5292
k,n=map(int,input().split())

List=[int(i) for i in input().split()]
a=[]
b=len(List)
c=[]
for i in range(b):
    if i ==0:
        c.append(List[0]+(k-List[-1]))
    else:
        c.append(abs(List[i]-List[i-1]))
       
print(k-(max(c)))
   

Measured memory_bytes: 26444
/* --- author: dxm --- */
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define INF 2147483647
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
inline void Fail(){
	printf("0");
	exit(0);
}

const int maxn=100005;
int n,e,t;
ll dp[maxn];
int x[maxn],y[maxn];
class segtree{
public:
	ll tree[maxn*4];
	int leaf[maxn];
	void build(int l,int r,int node){
		if(l==r){
			leaf[l]=node;
			tree[node]=Inf;
			return;
		}
		int mid=(l+r)>>1;
		build(l,mid,node*2);
		build(mid+1,r,node*2+1); 
		tree[node]=min(tree[node*2],tree[node*2+1]);
	}
	void upd(int node,ll val){
		node=leaf[node];
		tree[node]=val;
		node>>=1;
		while(node){
			tree[node]=min(tree[node*2],tree[node*2+1]);
			node>>=1;
		}
	}
	ll query(int l,int r,int vl,int vr,int node){
		if(r<l||vr<vl)return Inf;
		if(l>vr||r<vl)return Inf;
		if(l>=vl&&r<=vr)return tree[node];
		int mid=(l+r)>>1;
		return min(query(l,mid,vl,vr,node*2),query(mid+1,r,vl,vr,node*2+1));
	}
}t1,t2;

int main(){
	scanf("%d%d%d",&n,&e,&t);
	rep(i,n)scanf("%d",&x[i]),y[i]=2*x[i];
	t1.build(0,n-1,1);
	t2.build(0,n-1,1);
	rep(i,n){
		dp[i]=max((x[i]-x[0])*2LL,1LL*t);
		int pos=lower_bound(y,y+n,2*x[i]-t)-y;
		dp[i]=min(dp[i],min(t1.query(0,n-1,0,pos-2,1)+2LL*x[i],t2.query(0,n-1,max(pos-1,0),n-1,1)+t));
		t1.upd(i,dp[i]-2LL*x[i+1]);
		t2.upd(i,dp[i]);
	}
	printf("%lld",e+dp[n-1]);
	return 0;
}

/*
Input:
-----------------
Output:
*/

Measured memory_bytes: 8832
A11, A12, A13 = map(int, input().split())
A21, A22, A23 = map(int, input().split())
A31, A32, A33 = map(int, input().split())

N = int(input())
A = [0]*N
for i in range(N):
    A[i] = int(input())

for i in A:
    if A11 == i:
        A11 = 0
    elif A12 == i:
        A12 = 0
    elif A13 == i:
        A13 = 0
    elif A21 == i:
        A21 = 0
    elif A22 == i:
        A22 = 0
    elif A23 == i:
        A23 = 0
    elif A31 == i:
        A31 = 0
    elif A32 == i:
        A32 = 0
    elif A33 == i:
        A33 = 0

ans = 0
if A11+A12+A13==0:
    ans += 1
if A21+A22+A23==0:
    ans += 1
if A31+A32+A33==0:
    ans += 1
if A11+A21+A31==0:
    ans += 1
if A12+A22+A32==0:
    ans += 1
if A13+A23+A33==0:
    ans += 1
if A11+A22+A33==0:
    ans += 1
if A13+A22+A31==0:
    ans += 1
    
if ans == 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
ans :: String -> String
ans [] = []
ans ('@':l:c:xs) =
  let len = read [l] :: Int
  in
    (take len $ repeat c) ++ ans(xs)
ans (x:xs) = x:ans(xs)

main = do
  c <- getContents
  let i = lines c
      o = map ans i
  mapM_ putStrLn o

Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iostream>

#define X first
#define Y second
#define PB push_back

using namespace std;

typedef long long ll;
typedef pair < int, int > pii;
typedef vector < int > vi;

const int N = 1e5 + 500;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int LOG = 20;
const int OFF = (1 << LOG);

string s;

int main(){
	cin >> s;
	cout << s.substr(0, 3) << endl;
	return 0;
}

Measured memory_bytes: 3560
s = input()

s1 = int(s[0]+s[1])
s2 = int(s[2]+s[3])

if 1 <= s1 <= 12:
    if 1 <= s2 <= 12:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"
else:
    if 1 <= s2 <= 12:
        ans = "YYMM"
    else:
        ans = "NA"
    
print(ans)

Measured memory_bytes: 3064
#define errOut(s) \
  { std::cerr << __LINE__ << ":" << #s << ":" << (s) << std::endl; }

#include <bits/stdc++.h>

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
//#include <boost/multi_array.hpp>
//#include <boost/optional.hpp>
//#include <boost/range/adaptors.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

std::string solve(std::string s) {
  if (s[s.length() - 1]== 's') {
    return s + "es";
  }
  return s + "s";
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  std::string s;
  std::cin >> s;
  auto const res = solve(s);
  std::cout << res << std::endl;
  return 0;
}


Measured memory_bytes: 3624
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        a: usize, b: usize
    };

    let res = a.lcm(&b);
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2236
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

int main()
{
	string s, t, u;
	int a, b;
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;

	if (u == s) {
		a--;
	}
	if (u == t) {
		b--;
	}

	cout << a << " " << b << endl;
	return 0;
} 

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 998244353;
#define pii pair<int,int>
#define pll pair<ll,ll>


const int MAX = 30000000;
ll f[MAX],finv[MAX],inv[MAX];
void COMinit(int N){
    f[0] = 1;
    f[1] = 1;
    finv[0] = 1;
    finv[1] = 1;
    inv[1] = 1;
    for(int i=2;i<=N;++i){
        f[i] = f[i-1]*i %MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) %MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int N, int K){
    if(N<K || N<0 || K <0){ return 0; }
    return f[N]*(finv[K]*finv[N-K]%MOD) %MOD;
}

ll mpow(ll N, ll x){
    if(x==0){ return 1; }
    else if(x==1){ return N; }
    else if(x%2==0){ return mpow(N*N%MOD,x/2)%MOD;}
    else{ return N*mpow(N,x-1)%MOD;}
}


int main(){
    ll N,M,K; cin>>N>>M>>K;
    COMinit(N-1);
    ll ans = 0;
    for(ll k=0;k<=K;++k){
        ll group = N-k;
        ll p_color = M*mpow(M-1,group-1)%MOD;
        ll p_group = COM(N-1,k);
        ans += p_color*p_group%MOD;
        ans %= MOD;
    }
    cout << ans << "\n";
    
}

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

typedef struct {
  int t;
  int x;
  int y;
} Entry;

bool dis_check(int distance, int time)
{
  if ((((time + distance) & 1) == 0) &&
      (time >= distance)) {
    return true;
  }
  return false;
}

int main(){
  int N;
  vector<Entry> E;
  cin >> N;
  Entry entry;
  entry.t = 0;
  entry.x = 0;
  entry.y = 0;
  E.push_back(entry);
  for (int i=0;i<N;++i){
    cin >> entry.t >> entry.x >> entry.y;
    E.push_back(entry);
  }
  for (int i=0;i<N;++i){
    int distance = 
      (E[i+1].x > E[i].x ? 
       E[i+1].x - E[i].x : E[i].x - E[i+1].x)
      +
      (E[i+1].y > E[i].y ? 
       E[i+1].y - E[i].y : E[i].y - E[i+1].y);
    int time_span = E[i+1].t - E[i].t;
    if (dis_check(distance, time_span) == false){
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}


Measured memory_bytes: 1912
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

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

  int ans = max(max(a+b, a-b), a*b);
  printf("%d\n", ans);
  return 0;
}


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

int m, x, y;
int check(int a[15][15]){
	int f = 1;
	if(x == m)x -= m, f = 0;
	if(y == m)y -= m, f = 0;
	if(x == -1)x = m-1, f = 0;
	if(a[y][x]){x--;y++;f = 0;}
	if(f)return 0;
	check(a);
}

int func(int a[15][15], int n){
	a[y][x] = n;
	x++;y++;
	int f = 0;
	for(int i = 0;i < m;i++)
	for(int j = 0;j < m;j++)if(!a[i][j])f = 1;
	if(!f)return 0;
	check(a);
	func(a, n+1);
}

int main(){
	int a[15][15];
	while(scanf("%d", &m)){
		if(!m)break;
		fill((int*)a, (int*)(a+15), 0);
		x =  m/2, y = m/2+1;
		func(a, 1);
		for(int i = 0;i < m;i++){
			for(int j = 0;j < m;j++)printf("%4d", a[i][j]);
			puts("");
		}
	}
	return 0;
}

Measured memory_bytes: 3212
#include<stdio.h>

 


int main(void){
    char s[110];
    int a=0;
    scanf("%s",&s);
    
    for(int i=0;s[i]!='\0';i++){
        a++;
    }

    printf("%c%d%c",s[0],a-2,s[a-1]);

    return 0;


}

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

using namespace std;

int main() {

  int N, A, B;
  int ans[300006];

  cin >> N >> A >> B;
  if(A + B - 1 > N || 1LL * A * B < N) {
    puts("-1");
    return (0);
  }
  int ptr = 0, cur = 1, left = N - A;
  for(int i = 1; i <= A; i++) {
    int tk = min(left, B - 1);
    left -= tk;
    tk++;
    cur += tk;
    for(int j = cur - 1; j >= cur - tk; j--) {
      ans[ptr++] = j;
    }
  }
  for(int i = 0; i < N; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 3328
n = gets.chomp.to_i
l = gets.chomp.split(' ').map(&:to_i)

if (n < 3)
  puts 0
  exit
end

def ok?(abc)
  return false if (abc.uniq.size != 3)
  return false if (abc.max >= abc.min(2).sum)
  true
end

count = 0
l.combination(3).to_a.each do |abc|
  count += 1 if (ok?(abc))
end
puts count

Measured memory_bytes: 29968
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<iostream>

using namespace std;

long long int a[100000],x,y,n;

int fax(int z)
{
    int g=x-y,min=y*z;
    long long int sum=0;
    for(int i=n-1;i>=0;i--)
    {
        if(a[i]<=min) break;
        sum+=(a[i]-min)/g;
        if((a[i]-min)%g)
            sum++;
    }
    if(sum<=z)
        return 1;
    else return 0;
}

int main()
{
    cin>>n>>x>>y;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int mind,left,right;
    left=0;
    right=a[n-1]/y+1;
    while(left<right)
    {
        mind=left+(right-left)/2;
        if(fax(mind))
            right=mind;
        else
            left=mind+1;
    }
    cout<<left<<endl;
    return 0;
}


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

using namespace std;

int main(){
    char s;
    int c=0;
    for(int i=0;i<4;i++){
        cin >> s;
        if(s=='+') c++;
        else    c--;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
$N = gets.to_i
$ss, $sst = [], Array.new($N){Array.new($N)}
$N.times do |i|
    $ss[i] = gets.chomp.split('')
    $N.times do |j|
        $sst[j][i] = $ss[i][j]
    end
end

def check(a)
    (0...$N).each do |i|
        if $ss[i] != $sst[i]
            return false
        end
    end
    true
end

sum = 0
(0...$N).each do |a|
    sum += $N if check(a)
    (0...$N).each { |i| $ss[i].rotate!(1) }
    $sst.rotate!(1)
end
puts sum


Measured memory_bytes: 9596
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define bits_count __builtin_popcountll
#define ld long double
#define FOR(i,a,n) for (ll i=(a);i<(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>



int main()
{
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int a[5];
    for(int i=0;i<5;i++)
    {
        cin>>a[i];
        
    }
    for(int i=0;i<5;i++)
    {
        if(a[i]==0)
        {
            cout<<i+1<<endl;
            break;
        }
    }
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int A,B;
  cin>>A>>B;
  if(A<=B){
    cout << "unsafe" << endl;
  }
  else{
    cout << "safe" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;

int main() {

  int n, m, c;
  cin >> n >> m >> c;
  vec1 b(m);
  for(int i = 0; i < m; i++) { cin >> b.at(i);} 
  vec1 a(m);

  int tmp = 0;
  int ans = 0;
  for(int i = 0; i < n; i++) {
    tmp = 0;
    for(int j = 0; j < m; j++) {
      cin >> a.at(j);
    }
    for(int l = 0; l < m; l++) {
      tmp = tmp + (a.at(l) * b.at(l));
    }
    if(tmp + c > 0) {
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main(){
    char ch;
    string s = "";
    while(1){
        scanf("%c",&ch);
        s += ch;
        if( ch == '\n') break;
    }
    for(int i =0;i<s.length();i++){
        if(isupper(s[i])) s[i] = tolower(s[i]);
        else if(islower(s[i])) s[i] = toupper(s[i]); 
    }
    cout << s ;
    return 0;
}


Measured memory_bytes: 3208
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N, K = [int(x) for x in input().split()]
height = []
for _ in range(N):
    height.append(int(input()))

height.sort()
height.reverse()
sublist = []
for i in range(N-K+1):
    hmaxhmin = height[i]-height[i+K-1]
    sublist.append(hmaxhmin)

print(min(sublist))


Measured memory_bytes: 11288
route_num, limit = map(int, input().split(' '))

costs = []
spends = []
for i in range(route_num):
    cost, spend = map(int, input().split(' '))
    costs.append(cost)
    spends.append(spend)

min_cost = 2000
for cost, spend in zip(costs, spends):
    if spend <= limit and cost < min_cost:
        min_cost = cost

if min_cost == 2000:
    print("TLE")
else:
    print(min_cost)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll ga,ll gb){
while(gb>0){ll tmp;tmp=ga;ga=gb;gb=tmp%gb;}return ga;
}
ll lcm(ll hm,ll hn){
if(!(hm&&hn)){return 0;}else{return ((hm/gcd(hm,hn))*hn);}
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;ll a,ans;cin>>n;cin>>ans;for(int i=0;i<n-1;i++){cin>>a;ans=lcm(a,ans);}cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a[4], b[4], hit, blow, i, j;

	while (1){
		hit = 0;
		blow = 0;
		
		if (scanf("%d", &a[0]) == EOF){
			break;
		}
		for (i = 1; i < 4; i++){
			scanf("%d", &a[i]);
		}
		for (i = 0; i < 4; i++){
			scanf("%d", &b[i]);
		}
		
		for (i = 0; i < 4; i++){
			for (j = 0; j < 4; j++){
				if (a[i] == b[i]){
					hit++;
					break;
				}
				else if (a[i] == b[j] && i != j){
					blow++;
				}
			}
		}
		
		printf("%d %d\n", hit, blow);
	}
	
	return (0);
}

Measured memory_bytes: 596