akhauriyash/Code-Regression huggingface dataset:
// dile a la jardinera que traigo flores
// corner cases // int vs ll // cin vs scanf
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define N 1024
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int h,w, dp[N][N];
char tab[N][N];

void sum(int &a, int b){ a += b; if(a > MOD) a -= MOD; }

int main(){

	fastio;
	cin >> h >> w;
	FER(i,0,h) FER(j,0,w) cin >> tab[i][j];

	dp[0][0] = 1;
	FER(i,0,h) FER(j,0,w){
		dp[i][j] = (i == 0 && j == 0);
		if(tab[i][j] == '#') continue;
		if(i) sum(dp[i][j],dp[i-1][j]);
		if(j) sum(dp[i][j],dp[i][j-1]);
	}
	cout << dp[h-1][w-1] << endl;
	return 0;
}


Measured memory_bytes: 5248
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	int h[100001];
	int dp[100001]={};
	scan(N);
	rep(i,N){
		scan(h[i]);
	}
	dp[1]=abs(h[0]-h[1]);
	for(int i=2;i<N;i++){
		dp[i]=min(dp[i-2]+abs(h[i-2]-h[i]),dp[i-1]+abs(h[i-1]-h[i]));
	}
	prin(dp[N-1]);
	return 0;
}


Measured memory_bytes: 1024
//srinivas
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
// using namespace __gnu_pbds;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define fr(x,in,n,r) for(x=in;x<n;x+=r)
#define ifr(x,n) for(x=0;x<n;x++)
#define dfr(x,n) for(x=n-1;x>=0;x--)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pof(a) pop_front(a)
#define pob(a) pop_back(a)
#define eb(a) emplace_back(a)
#define ef(a) emplace_front(a)
typedef long long ll;
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007

struct chash{ 
    ll operator()(ll x) const {return hash<ll>{}(x);}
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt","r",stdin);
    ll n,i,j;
    cin>>n;
    ll a[n];
    ifr(i,n)cin>>a[i];
    if(n==1){
       	cout<<"0\n";
       	return 0;
    }
    ll dp[n];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    fr(i,2,n,1)
    	dp[i]=min(dp[i-2]+abs(a[i-2]-a[i]),dp[i-1]+abs(a[i-1]-a[i]));
    cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine().trim());
        String s=br.readLine().trim();
        System.out.println(algo(s,n));
    }




    public static int algo(String s,int n){
        int i=-1;
        int j=n;
//        int n=s.length();
        int cnt=0;

        while(i<j){
            do{
                i++;
            }while (i<n && s.charAt(i)=='R');
            do{
                j--;
            }while (j>=0 && s.charAt(j)=='W');

            if(i>=j){
                return cnt;
            }
            cnt++;
        }
        return cnt;
    }







}


Measured memory_bytes: 36276
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    string s;
    cin>>s;
    int i,ans=0;
    for (i=0;i<6;i++)
    {
        if (s[i]=='1')
            ans++;
    }
    cout<<ans<<endl;
}

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

int main(){
int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b==c)
cout<<1<<endl;
  else if(a==b||b==c||a==c)
    cout<<2<<endl;
  else
    cout<<3<<endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: u64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn main() {
    input! {
        A: usize,
        B: usize,
        N: usize,
    }

    let X = min(N, B - 1);
    println!("{}", (A * X) / B - A * (X / B));
}


Measured memory_bytes: 2056
N, M = (int(i) for i in input().split())
hoge = {i + 1 for i  in range(M)}

for i in range(N):
    likes = set()
    on = input().split()
    on.pop(0)
    likes = {int(j) for j in on}
    hoge &= likes


c = len(hoge)

print(c)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) (x&-x)

int num[4][100010],c0[300010],c1[300010],n;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline void add0(int x) { for (;x;x-=lowbit(x)) c0[x]++; }

inline void add1(int x) { for (;x;x-=lowbit(x)) c1[x]++; }

inline int sum0(int x)
{
	int res=0;
	for (;x<=n*3;x+=lowbit(x)) res+=c0[x];
	return res;
}

inline int sum1(int x)
{
	int res=0;
	for (;x<=n*3;x+=lowbit(x)) res+=c1[x];
	return res;
}

int main()
{
	n=rd();
	for (int i=1;i<=3;i++) for (int j=1;j<=n;j++) num[i][j]=rd();
	int t0=0,t1=0,tt0=0,tt1=0;
	for (int i=1;i<=n;i++)
	{
		int h1=num[1][i],h2=num[2][i],h3=num[3][i];
		if (h1<h3)
		{
			if (h2-h1!=1||h3-h2!=1) { puts("No");return 0; }
			if (h1%3!=1) { puts("No");return 0; }
			int hh=h1/3+1;
			if (abs(i-hh)&1) { puts("No");return 0; }
		}
		else
		{
			if (h2-h3!=1||h1-h2!=1) { puts("No");return 0; }
			if (h3%3!=1) { puts("No");return 0; }
			int hh=h3/3+1;
			if (abs(i-hh)&1) { puts("No");return 0; }
			if (i&1) t1^=1;
			else t0^=1;
		}
	}
	for (int i=1;i<=n;i++)
	{
		int h1=num[1][i],h3=num[3][i];
		if (h1<h3)
		{
			if (i&1) tt0+=sum1(h1),add1(h1);
			else tt1+=sum0(h1),add0(h1);
		}
		else
		{
			if (i&1) tt0+=sum1(h3),add1(h3);
			else tt1+=sum0(h3),add0(h3);
		}
		tt0&=1;tt1&=1;
	}
	if (t0==tt0&&t1==tt1) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, m;
  cin >> n >> m;
  ll res = 0;
  for (ll i = n; i <= m; i++) {
    string s = to_string(i);
    bool flag = 1;
    rep(i, 5) {
      if (s.at(i) != s.at(4-i)) flag = 0;
    }
    if (flag) res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long cc;
typedef pair<int, int> pii;
#define X first
#define Y second
#define mp make_pair
int H, W;
int n;
int a[101][101];
int inc(pii &cur) {
    if (cur.X % 2) {
        cur.Y++;
        if (cur.Y > W) {
            cur.Y = W;
            cur.X++;
        }
    }
    else {
        cur.Y--;
        if (!cur.Y) {
            cur.Y = 1;
            cur.X++;
        }
    }
}
int main()
{
    ios_base :: sync_with_stdio(false); cin.tie(0);
    cin >> H >> W;
    pii cur = mp(1, 1);
    cin >> n;
    for (int i = 0; i < n; i++) {
        int val; cin >> val;
        while (val--) {

            a[cur.X][cur.Y] = i + 1;
            inc(cur);

        }
    }
    for (int i = 1; i <= H; i++)
    {
        for (int j = 1; j <= W; j++) cout << a[i][j] << " ";
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 384
#include <string>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <unordered_map>
#include <iostream>
using namespace std;

class NameSvc{
public:
  string nickname(string s){
    return s.substr(0,3);
  }
};

int main(int argc, const char*argv[]){
  NameSvc ns;
  string sLn;
  getline(cin,sLn);
  string nn = ns.nickname(sLn);
  cout<<nn<<endl;
  return 0;
}


Measured memory_bytes: 3628
N = int(input())
a = [int(input()) for i in range(N)]

A = sorted(a)
if A[-1] == A[-2]:
    for i in range(N):
        print(A[-1])

else:
    for i in range(N):
        if a[i] == A[-1]:
            print(A[-2])
        else:
            print(A[-1])

Measured memory_bytes: 14108
// C++ program for the 
// above approach
#include<bits/stdc++.h>
using namespace std;
#define int long long

// Function to count 
// number of trailing zeros
// in double factorial
int trailingZeros(int n){
  
  // If n is odd
  // return 0
  if(n%2==1){
    return 0;
  }

  // If n is even
  // check 
  else{

    n = n/2;
    int cnt = 0;

    while(n){
      cnt = cnt + n/5;
      n = n/5;
    }

    return cnt;
  }
}

int32_t main(){
    
  int n; cin >> n;
  cout << trailingZeros(n);

  
  return 0;
}


Measured memory_bytes: 256
//AtCoder ABC088 A - Infinite Coins
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll N,A;
    cin>>N>>A;
    ll r=N%500;
    cout<<(r<=A?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long LL;

// import here

int main(){
    LL n;
    cin >> n;
    LL ans = 0;
    bool flag = false;
    while(n >= 10){
        if(flag) --n;
        ans += 9;
        flag = (n % 10 != 9);
        n /= 10;
    }
    if(flag) --n;
    ans += n;
    cout << ans << endl;
    return 0;
}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long 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())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main(){
  int N;
  cin >> N;
  VI L(N);
  
  REP(i,N) {
    cin >> L.at(i);
  }
  int A = 0;
  SORT(L);
  REP(i,N-1) {
    A += L.at(i);
  }
  if (A > L.at(N-1)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

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

int main() {
  string S;
  cin >> S;
  if (S=="Sunny") {
    cout << "Cloudy" << endl;
  }
  else {
    if (S=="Cloudy") {
      cout << "Rainy" << endl;
    }
    else {
      cout << "Sunny" << endl;
    }
  }
}

Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, D, count = 0, ans = 0;
    cin >> N >> D;
    vector<vector<int>> data(N, vector<int>(D, 0));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            cin >> data[i][j];
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            int sum=0;//初期化
            for (int k = 0; k < D; k++) {
                int sum1 = abs(data[i][k] - data[j][k]);
                int sum2 = sum1 * sum1;
                sum += sum2;
            }
        for (int k = 0; k <= sum; k++) { //=忘れてた
            if (k * k == sum) {
                count=1;
            }
        }
        if (count == 1) {
            count = 0;
            ans++;
        }
    }}
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef pair<int, int> P;

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

int H, W;
int field[8][8];
bool arrive[8][8][8][8][8][8];

void init(){
  memset(field, 0, sizeof(field));
  memset(arrive, false, sizeof(arrive));
}

void canArrive(int bx, int by, int sx, int sy){
  int tmp_field[8][8];
  memset(tmp_field, 0, sizeof(tmp_field));
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      if(field[i][j] != 1) tmp_field[i][j] = 0;
      else tmp_field[i][j] = field[i][j];
    }
  }
  
  tmp_field[by][bx] = 2;

  queue<P> que;
  que.push(P(sx, sy));
  while(!que.empty()){
    P q = que.front(); que.pop();
    arrive[by][bx][sy][sx][q.second][q.first] = true;
    
    for(int i = 0 ; i < 4 ; i++){
      int nx = q.first + dx[i], ny = q.second + dy[i];
      if(nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
      if(tmp_field[ny][nx] != 0) continue;
      if(arrive[by][bx][sy][sx][ny][nx]) continue;
      que.push(P(nx, ny));
    }    
  }
}

struct State{
  int x, y, sx, sy, cost;
  State(int x, int y, int sx, int sy, int cost) : x(x), y(y), sx(sx), sy(sy), cost(cost){}
};

const bool operator < (const State &a, const State &b){
  return a.cost > b.cost;
}

int bfs(){
  int sx, sy, bx, by;
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      if(field[i][j] == 2) bx = j, by = i;
      if(field[i][j] == 4) sx = j, sy = i;
    }
  }
  
  priority_queue<State> que;
  que.push(State(bx, by, sx, sy, 0));
  
  bool used[8][8][8][8];
  memset(used, false, sizeof(used));
  
  while(!que.empty()){
    State p = que.top(); que.pop();

    if(field[p.y][p.x] == 3) return p.cost;    

    if(used[p.y][p.x][p.sy][p.sx]) continue;
    used[p.y][p.x][p.sy][p.sx] = true;
    
    for(int i = 0 ; i < 4 ; i++){
      int nx1, nx2, ny1, ny2;
      nx1 = p.x + dx[i], ny1 = p.y + dy[i];
      nx2 = p.x - dx[i], ny2 = p.y - dy[i];
      if(nx1 < 0 || nx1 >= W || ny1 < 0 || ny1 >= H ||
	 nx2 < 0 || nx2 >= W || ny2 < 0 || ny2 >= H) continue;
      if(field[ny1][nx1] == 1) continue;
      if(field[ny2][nx2] == 1) continue;
      if(!arrive[p.y][p.x][p.sy][p.sx][ny2][nx2]) continue;      
      que.push(State(nx1, ny1, nx2, ny2, p.cost+1));
    }    
  }
  return -1;
}

int main(){
  while(cin >> W >> H, W|H){
    init();
    
    for(int i = 0 ; i < H ; i++)
      for(int j = 0 ; j < W ; j++) cin >> field[i][j];
    
    for(int by = 0 ; by < H ; by++){
      for(int bx = 0 ; bx < W ; bx++){
	if(field[by][bx] == 1) continue;
	for(int sy = 0 ; sy < H ; sy++){
	  for(int sx = 0 ; sx < W ; sx++){
	    if(sy == by && sx == bx) continue;
	    if(field[sy][sx] == 1) continue;
	    canArrive(bx, by, sx, sy);
	  }
	}
      }
    }
    cout << bfs() << endl; 
  }
  return 0;
}

Measured memory_bytes: 1492
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,b) for (int i = 0; i < (b); i++ )

typedef pair<int,int> P;
typedef long long ll;

const int INF = 100000000;
const double PI=3.14159265358979323846;

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

    ll a[N], b[N];

    rep(i,N) {
        cin >> a[i];
    }
    rep(i,N) {
        cin >> b[i];
    }

    ll p,n;

    ll tmp = 0;
    rep(i,N) {
        if (a[i]-b[i]>0) {
            tmp+=(a[i]-b[i]);
        }
        else {
            tmp -=(b[i]-a[i])/2;
        }
    }

    if (tmp<=0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 384
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextssort(n,a){return a?cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>b-a):cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>a-b);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}
var streams=[];function print(s){streams.push(s);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));
if(streams.length)console.log(streams.join("\n"));

function main(){
  var a = nextbig();
  var b = nextbig();
  var c = nextbig();
  var d = nextbig();
  var ans = a*c;
  if(a*d > ans)ans = a*d;
  if(b*c > ans)ans = b*c;
  if(b*d > ans)ans = b*d;
  return ans;
}

Measured memory_bytes: 29692
// ~/Remember,remember the 6th of March
#include <functional>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include<complex>
#include <unordered_map>
#include<unordered_set>
#include <numeric>
#include <string>
#include<iostream>
#include <fstream>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include<cmath>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int N = 1e5 + 5;
void fast()
{
	std::ios_base::sync_with_stdio(0);
}
ll freq[10][10],n,ans;
int main()
{
/*
#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
 */
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		int temp = i;
		while (temp > 9)temp /= 10;
		freq[temp][i % 10]++;
	}
	for (int i = 1; i <= n; i++)
	{
		int temp = i;
		while (temp > 9)temp /= 10;
		ans+=freq[i%10][temp];
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

struct way
{
    int x;
    int y;
    int z;
};

int need;
int lg,n;
vector<way>ans;

inline void print()
{
    cout<<n<<" "<<ans.size()<<"\n";
    for(auto &it:ans)
        cout<<it.x<<" "<<it.y<<" "<<it.z<<"\n";
    exit(0);
}

int capat;

inline int nou(int i)
{
    return capat+(1<<(i-1))-1;
}

inline void add(int i,int x)
{
    ans.push_back({i,n,x});
}

int main()
{
  ///  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>need;
    while(1<<(lg+1)<=need)
        lg++;
    n=lg+1;
    for(int i=1;i<n;i++)
    {
        ans.push_back({i,i+1,0});
        ans.push_back({i,i+1,(1<<(i-1))});
    }

    capat=(1<<lg);

    for(int i=n-1;i>=1;i--)
    {///continue;
        while(1)
        {
            int x=nou(i);
       ///     cout<<i<<" , "<<x-capat<<" - > "<<capat<<" : "<<x<<" ,"<<need<<"\n";
            if(x>=need)
                break;
         ///   cout<<"\t"<<capat<<" "<<x<<"\n";
            add(i,capat);
            capat=x+1;
        }
    }
   // cout<<capat<<"\n";
   // cout<<nou(2)<<"\n";

  ///  cout<<"\n";cout<<"\n";cout<<"\n";cout<<"\n";cout<<"\n";cout<<"\n";cout<<"\n";cout<<"\n";cout<<"\n";cout<<"\n";cout<<"\n";cout<<"\n";cout<<"\n";cout<<"\n";cout<<"\n";cout<<"\n";
    print();
    return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    input=sys.stdin.readline
    n=int(input())
    A=list(map(int,input().split()))
    A_=[0]*n
    for i in range(n):
        if i%2==0:
            A_[i]=A[i]
        else:
            A_[i]==0
    for i in range(n-1):
        A_[i+1]+=A_[i]
    dp=[0]*n
    dp[1]=max(A[0],A[1])
    for i in range(2,n):
        if i%2==0:
            dp[i]=max(dp[i-2]+A[i],dp[i-1])
        else:
            dp[i]=max(dp[i-2]+A[i],A_[i-1])
    print(dp[n-1])
if __name__ == '__main__':
    main()

Measured memory_bytes: 92088
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll INF = 1e16;



int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	ll k;
	cin >> n >> k;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ll x, y;
		cin >> x >> y;
		if (x * x + y * y <= k * k)ans++;
	}
	cout << ans;
}

Measured memory_bytes: 3636
function Main(input) {
	const A = input.split("\n");
	const B = A[0].split(" ");
	
	const S = B[0];
	const T = B[1];

	console.log(T + S);
}
 
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
def make_diviser(n):
  D=[]
  for i in range(1,int(n**0.5)+2):
    if n%i==0:
      D.append(i)
      D.append(n//i)
  D=sorted(set(D))
  l=len(D)
  if l%2==0:
    return D[(l//2)-1]+D[l//2]
  else:
    return D[l//2]*2
n=int(input())  
print(make_diviser(n)-2)

Measured memory_bytes: 3936
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cctype>
#include <cstdio>
#include <math.h>
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
 
using f32 = float;
using f64 = double;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
 
constexpr i64 MOD = 1'000'000'007LL;
 
constexpr f64 EPS = 1e-12;
 
constexpr f64 PI = 3.14159265358979323846;
using namespace std;
#define rep(i, n) for (i64 i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (i64 i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define down(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
using LL = long long;
using ULL = unsigned long long;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
 
int main()
{
  cin.tie(0);
ios::sync_with_stdio(false);
i64 L, R,w;
cin >> L >> R;
  w= L*R;
if(R-L>=2019)return cout << 0,0;
FOR(i,L,R){
		for(int j=L+1;j<=R;j++)
			w=min(w,(i*j)%2019);
}
cout << w << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	int A[300000];
	rep(i, 3 * N) A[i] = getint();
	sort(A, A + 3 * N);

	ll kotae = 0;
	for (int i = 3 * N - 2; i > N - 1; i -= 2) {
		kotae += A[i];
	}
	co(kotae);

	Would you please return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n;
	t = 1;
	while(t--) {
	 cin >> n;
	 if(n < 1200)
	  cout << "ABC" << endl;
	 else if(n < 2800)
	  cout << "ARC" << endl;
	 else
	  cout << "AGC" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List




getBysplit = map read . words <$> getLine

main :: IO()
main = do
  [n, m] <- getBysplit :: IO [Int]
  xlst <- getBysplit :: IO [Int]
  let (x:xs) = sort  xlst
  let difflist = diffList x xs
  let ans = (sum . take (m - n) . sort) difflist
  print ans

diffList :: Int -> [Int] -> [Int]
diffList pre [] = []
diffList pre (x:xs) = (x - pre):diffList x xs


Measured memory_bytes: 32764
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

signed main() {
	int n, m, ans = 0;
	cin >> n >> m;
	P pa[100005];
	rep(i, n) {
		cin >> pa[i].second >> pa[i].first;
		pa[i].second--;
	}
	sort(pa, pa + n);
	reverse(pa, pa + n);
	vector<int>vec;
	rep(i, m) vec.push_back(i);
	rep(i, n) {
		auto x = lower_bound(vec.begin(), vec.end(), pa[i].second);
		if (x == vec.end()) continue;
		else {
			ans += pa[i].first;
			vec.erase(x);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2936
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		int n=nextInt();
		int l[]=new int[2*n+1];
		for(int i=1;i<=2*n;i++)
			l[i]=nextInt();
		Arrays.sort(l,1,2*n+1);
		long ans=0;
		for(int i=1;i<=2*n;i+=2)
			ans+=l[i];
		out.println(ans);
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 22996
#include <queue>
#include <cstdio>
int q,cnt;
long long delta,ans;
struct val1{
	int u;
	bool operator <(val1 b)const{return u < b.u;}
};
struct val2{
	int u;
	bool operator <(val2 b)const{return u > b.u;}
};
inline int abs(int a){return a<0?-a:a;}
std :: priority_queue <val1> q1;
std :: priority_queue <val2> q2;
int main(){
	scanf("%d",&q);
	for(int i=1,ty,a,b;i<=q;++i){
		scanf("%d",&ty);
		if(ty == 1){
			scanf("%d %d",&a,&b),delta += b;
			if(q1.size() == 0)q1.push((val1){a});
			else{
				ans += abs(q1.top().u-a);
				if(a>q1.top().u)q2.push((val2){a});
				else q1.push((val1){a});
//				printf("shik? : %d %d\n",q1.size(),q2.size());
				if(q1.size() - q2.size() == 2){
//					printf("shik : %d %d\n",q1.size(),q2.size());
					int t = q1.top().u;
					q1.pop();
					q2.push((val2){t});
				}
//				printf("shik? : %d %d\n",q1.size(),q2.size());
				if(q2.size() - q1.size() == 1){
					int t = q2.top().u;
					ans -= q2.top().u-q1.top().u;
					q2.pop();
					q1.push((val1){t});
				}
			}
		}
		if(ty == 2)printf("%d %lld\n",q1.top(),ans+delta);
//		if(q1.size()&&q2.size())printf("%d %d %d %d %lld\n",q1.top().u,q2.top().u,q1.size(),q2.size(),ans);
	}
	return 0;
}
/*
10
1 2 1
1 1 1
1 4 1
*/

Measured memory_bytes: 3672
Soba = [[2,380],[3,550],[5,850],[10,1520],[12,1870],[15,2244]] #???,??????
while True:
    g = int(input())
    if g == 0:
        break
    g_g = int(g / 100)
    DP = [[10000 for j in range(g_g + 1)] for i in range(7)]
    for i in range(7):
        DP[i][0] = 0
    for i in range(7):
        for j in range(g_g + 1):
            if j - Soba[i - 1][0] + 1 >= 0: 
                DP[i][j] = min(DP[i-1][j],DP[i][j - Soba[i - 1][0]] + Soba[i - 1][1])
            else:
                DP[i][j] = DP[i - 1][j]
    print(DP[6][g_g])    
                

Measured memory_bytes: 7664
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int a= gi();
	    int b= gi();
	    int c= gi();
	    int d= gi();


        System.out.print(Math.max(a*b, c*d));

	   
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
}

Measured memory_bytes: 35720
#include <bits/stdc++.h>
#define rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)


#define SZ(x) ((int)(x).size())


typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
struct Vector{
    double x, y;
};

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;



int main()
{
    int N, i;
    string S;
    cin >> N;
    vector<int> result = {0, 0, 0, 0};
    vector<string> judge = {"AC", "WA", "TLE", "RE"};
    rep(i, N) {
        cin >> S;
        if ("AC" == S)
            result[0] += 1;
        if ("WA" == S)
            result[1] += 1;
        if ("TLE" == S)
            result[2] += 1;
        if ("RE" == S)
            result[3] += 1;
    }
    rep(i, 4)
        cout << judge[i] << " x " << result[i] << endl;
    

    return 0;
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    bool found=false;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(4*i+7*j==n){
                found=true;
                break;
            }
        }
        if(found)break;
    }
    cout<<(found?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1)
#define io  ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;
int main(){
    int n,r,fg = 0;
    cin>>n;
    while(n){
        r = n%10;
        if(r==7) {fg = 1; break;}
        else n = n/10;
    }
    if(fg) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#define ll long long
const ll mod = 1e+9;
using namespace std;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
int main(){
    int a,b;    cin >> a >> b;
    cout << (6-(a+b)) << "\n";
return 0;
}

Measured memory_bytes: 3616
fun main(args : Array<String>) {
    val (N, K) = readLine()!!.split(" ").map { it.toInt() }
    val S = readLine()!!


    var A = mutableListOf<Int>()


    var prev = ' '
    S.forEach { c ->
        if (prev == c) {
            A[A.size - 1]++
        } else {
            A.add(1)
        }
        prev = c
    }
    val new = mutableListOf<Int>()

    var sum = 0
    (0 until Math.min(2*K + 1, A.size)).forEach {
        sum += A[it]
    }
    new.add(sum)
    (2*K + 1 until A.size).forEach {
        new.add(A[it])
    }
    print(new.sum() - new.size)
}

Measured memory_bytes: 41640
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  long long int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define S set<int>
#define pb(v) push_back(v)
int main(){
    CIN(A);CIN(B);CIN(X);
    if(A!=0){
    COUT(B/X-(A-1)/X);
   }else{
     COUT(B/X+1);
   }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#define LEN 100005
typedef struct pp
{
    char name[100];
    int t;

}P;
P Q[LEN];
int head,tail,n;
void enqueue(P x)
{
    Q[tail]=x;
    tail=(tail+1)%LEN;
}
P dequeue()
{
    P x=Q[head];
    head=(head+1)%LEN;
    return x;
}
int min(int a,int b){return a<b?a:b;}
int main()
{
    int elaps=0,c;
    int i,q;
    P u;
    scanf("%d %d",&n,&q);
    for(i=1;i<=n;i++)
    {
        scanf("%s",Q[i].name);
        scanf("%d",&Q[i].t);
    }
    head=1;
    tail=n+1;
    while(head!=tail)
    {
        u=dequeue();
        c=min(q,u.t);
        u.t-=c;
        elaps+=c;
        if(u.t>0)enqueue(u);
        else{
            printf("%s %d\n",u.name,elaps);
        }
    }
    return 0;
}
/*
5 100
p1 150
p2 80
p3 200
p4 350
p5 20
*/

Measured memory_bytes: 13296
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
#include <list>
using namespace std;

using ll = long long;

#define rep_init(i, init, n) for(int i = (init); i < (n); ++i)
#define rep(i, n) rep_init(i, 0, n)

int main()
{
	int X, N;
	std::vector<bool> P(102, true);

	cin >> X >> N;
	rep(i, N)
	{
		int p;
		cin >> p;
		P[p] = false;
	}

	int d = 0;
	int ans;
	while (true)
	{
		if (P[X-d])
		{
			ans = X-d;
			break;
		}
		else if(P[X+d])
		{
			ans = X+d;
			break;
		}

		++d;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3568
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int S = in.Int();
            int W = in.Int();
            out.println(S <= W ? "unsafe" : "safe");
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 32608
#include <stdio.h>

int main()
{
	int H, W, N;
	scanf("%d%d%d", &H, &W, &N);
	int a[N];
	int i, j, k;
	for (i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}
	int s[H][W];
	
	int flag = 0;
	int tmp=0;
	i = 1;
	int l = 1;
	for (j = 0; j < H; j++) {
		if (flag == 0) {
			for (k = 0; k < W; k++) {
				if (tmp == a[i-1]) {
					i++;
					tmp = 0;
				}
				s[j][k] = i;
				tmp++;
			}
			flag = 1;
		} else if (flag == 1) {
			for (k = W - 1; k >= 0; k--) {
				if (tmp == a[i-1]) {
					i++;
					tmp = 0;
				}
				s[j][k] = i;
				tmp++;
			}
			flag = 0;
		}
	}
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			printf("%d ", s[i][j]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 100005
#define PI 	3.14159265358979323846

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,x;
    cin >> n >> x;
    ll a[1000];
    REP(i,n)cin >> a[i];
    sort(a,a+n);
    int i;
    for(i=0;i<n;i++){
        x -= a[i];
        if(x<0)break;
    }
    //cout << i << endl;
    //if(i==n)i--;
    if(x>0)i--;
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
        int n = int.Parse(ReadLine());

        for (int i = 0; i <= n/4; i++)
        {
            int r = n - 4*i;

            if (r%7 == 0)
            {
                WriteLine("Yes");
                return;
            }
        }

        WriteLine("No");
    }
}


Measured memory_bytes: 13140
n,m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]

tmp = []
if n == 1:
    tmp.append(0)
for i in range(10**(n-1), 10**n):
    tmp.append(i)

ans = -1
for i in tmp:
    l = list(map(int, list(str(i))))
    if all(l[s-1] == c for s,c in sc):
        ans = i
        break
print(ans)


Measured memory_bytes: 39664
import sys

from typing import List


class Dice:

    def __init__(self, values: List[int]):
        self.face_value = values

    def get_value(self, face_num) -> int:
        return self.face_value[face_num]

    def get_all_values(self) -> str:
        return ' '.join(map(str, self.face_value))

    def get_upper_value(self) -> int:
        return self.get_value(0)

    def invoke_method(self, mkey: str) -> None:
        if mkey == 'S':
            self.S()
        elif mkey == 'N':
            self.N()
        elif mkey == 'E':
            self.E()
        elif mkey == 'W':
            self.W()
        else:
            raise ValueError(f'This method does not exist. : {mkey}')

    def set_value(self, s0, s1, s2, s3, s4, s5) -> None:
        self.face_value[0] = s0
        self.face_value[1] = s1
        self.face_value[2] = s2
        self.face_value[3] = s3
        self.face_value[4] = s4
        self.face_value[5] = s5

    def S(self) -> None:
        self.set_value(self.face_value[4], self.face_value[0],
                       self.face_value[2], self.face_value[3],
                       self.face_value[5], self.face_value[1])

    def N(self) -> None:
        self.set_value(self.face_value[1], self.face_value[5],
                       self.face_value[2], self.face_value[3],
                       self.face_value[0], self.face_value[4])

    def E(self) -> None:
        self.set_value(self.face_value[3], self.face_value[1],
                       self.face_value[0], self.face_value[5],
                       self.face_value[4], self.face_value[2])

    def W(self) -> None:
        self.set_value(self.face_value[2], self.face_value[1],
                       self.face_value[5], self.face_value[0],
                       self.face_value[4], self.face_value[3])

    def T(self) -> None:
        """横回転."""
        self.set_value(self.face_value[0], self.face_value[2],
                       self.face_value[4], self.face_value[1],
                       self.face_value[3], self.face_value[5])


def check_T(dice1, dice2) -> bool:
    """横回転させて一致したらTrueを返す."""
    for _i in range(4):
        dice1.T()
        if dice1.get_all_values() == dice2.get_all_values():
            return True
    return False


def is_same_dice(dice1, dice2) -> bool:
    for _i in range(4):
        dice1.S()
        if dice1.get_upper_value() == dice2.get_upper_value():
            if check_T(dice1, dice2):
                return True
    for _i in range(4):
        dice1.E()
        if dice1.get_upper_value() == dice2.get_upper_value():
            if check_T(dice1, dice2):
                return True
    return False


# 提出用1
N = int(input())
dices = [Dice([int(j) for j in input().split()]) for i in range(N)]

# # 動作確認用2
# with open('input_itp1_11_d_1.txt', mode='r', encoding='utf8') as fin:
#     N = int(next(fin))
#     dices = [Dice([int(j) for j in next(fin).split()]) for i in range(N)]

for i in range(len(dices) - 1):
    for j in range(i + 1, len(dices)):
        if is_same_dice(dices[i], dices[j]):
            print('No')
            sys.exit()
print('Yes')



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

using namespace std;

bool is_not_small(char c){
    bool ans = 1;
    if (c >= 'a' && c <= 'z'){
        ans = 0;
    }
    return ans;
}

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

    int n = s.size();
    string ans = "AC";

    if (s[0] != 'A'){
        ans = "WA";
    }
    if (is_not_small(s[1]) || is_not_small(s[n - 1])){
        ans = "WA";
    }

    int C_counter = 0;
    for (int i = 2; i < n - 1; i++){
        if (is_not_small(s[i])){
            if (s[i] == 'C'){
                C_counter++;
            } else {
                ans = "WA";
            }
        }
    }
    if (C_counter == 0 || C_counter > 1){
        ans = "WA";
    }

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

Measured memory_bytes: 256
// 記述をスリム化して, 再提出.
// 解き直し.
// https://img.atcoder.jp/abc162/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
LL a[202020], dp[5][202020];

int main(){
    
    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    rep(i, N) scanf("%lld", &a[i]);
    
    // 2. 解説通り(dp更新).
    dp[1][1] = a[0];
    dp[2][1] = max(a[0], a[1]);
    if(N >= 3){
        dp[3][1] = max({a[0], a[1], a[2]});
        dp[3][2] = a[0] + a[2];
    }
    repx(i, 4, N + 1){
        // i に ついて, s個以上, e個以下 を 選択.
        int s = i / 2 - 1, e = (i + 1) / 2;
        int c = (i % 3 == 0) ? 3 : (i % 3); // 現在.
        int o = (c - 1 == 0) ? 3 : c - 1;   // 一つ前.
        int t = (o - 1 == 0) ? 3 : o - 1;   // 二つ前.
        dp[c][s]     = max(dp[t][s - 1] + a[i - 1], dp[o][s]);
        dp[c][s + 1] = max(dp[t][s] + a[i - 1],     dp[o][s + 1]);
        if(s + 2 == e) dp[c][s + 2] = dp[t][s + 1] + a[i - 1];
    }
    // rep(i, 5){
    //     rep(j, N + 1) printf("%lld ", dp[i][j]);
    //     puts("");
    // }
    
    // 3. 出力.
    int index = (N % 3 == 0) ? 3 : (N % 3);
    printf("%lld\n", dp[index][N / 2]);
    return 0;
    
}

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

int main()
{
    int N;
    int max = 0;
    string s;
    map<string, int> mp;
    
    //青カード読み込み
    cin >> N;
    for (int i=0;i<N;i++) {
        cin >> s;
        mp[s] += 1;
        //cout << mp[s] << endl;
    }
    //赤カード読み込み
    cin >> N;
    for (int i=0;i<N;i++) {
        cin >> s;
        mp[s] -= 1;
    }
    
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if (itr->second > max) {
            max = itr->second;
        }
    }
    
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
import Data.Maybe(fromMaybe)

main = do
    [n,t] <- (fmap read) <$> words <$> getLine
    list <- buildLs n []
    let res = min' $ map fst $ filter ((t >=) . snd) list
    putStrLn $ fromMaybe "TLE" $ show <$> res

buildLs :: Int -> [(Int,Int)] -> IO [(Int,Int)]
buildLs 0 ac = return ac
buildLs n ac = do
    [c,t] <- (fmap read) <$> words <$> getLine
    buildLs (n-1) $ (c,t):ac

min' [] = Nothing
min' xs = Just $ minimum xs

Measured memory_bytes: 1020
n,h=gets.split
n=n.to_i
h=h.to_i
arr1=[]
arr2=[]
n.times{
   a,b=gets.split.map(&:to_i) 
    arr1<<a
    arr2<<b}
arr2=arr2.sort.reverse
amax=arr1.max

i=0
loop{
  if h<=0
   puts i 
   exit
   end

  if  i<=n-1&&arr2[i]>amax
    h=h-arr2[i]
    i=i+1
else 
break
end
}

if  h%amax==0
 puts i+h/amax
 
else   
puts i+h/amax+1
end

Measured memory_bytes: 4996
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N,a[100000];
int main(){
	cin>>N;
	rep(i,N){
		cin>>a[i],a[i]--;
	}
	int ans=0;
	rep(i,N) if(a[a[i]]==i) ans++;
	cout<<ans/2<<endl;
}


Measured memory_bytes: 640