akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

class Point{
	int t,x,y;
	Point(int t, int x, int y){
		this.x = x;
		this.y = y;
		this.t = t;
	}
	
	int distanceTo(Point p){
	    return Math.abs(this.x-p.x)+Math.abs(this.y-p.y);
	}
	boolean canGoTo(Point p){
	    return (distanceTo(p)<=p.t-this.t) && ((distanceTo(p)%2==0)==((p.t-this.t)%2==0));
	}
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Point[] plan = new Point[N+1];
        plan[0]=new Point(0,0,0);
        for(int n=1;n<=N;n++){
        	plan[n] = new Point(sc.nextInt(), sc.nextInt(), sc.nextInt());
        }
        for(int n=1;n<=N;n++){
        	if(!plan[n-1].canGoTo(plan[n])){
        		System.out.println("No");
        		System.exit(0);
        	}
        }
        System.out.println("Yes");
        
    }
}

Measured memory_bytes: 93264
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    class Program
    {
        static void Main(string[] args)
        {
            var cin = new Scanner();
            var N = cin.nextInt();
            var S = new string[N];
            for (int i = 0; i < N; i++)
            {
                S[i] = cin.next();
            }

            var min = new int[30];
            int index = 0;
            for (char ch = (char)0x61; ch <= 0x7a; ch++)
            {
                var minch = 100;
                for (int i = 0; i < N; i++)
                {
                    var s = S[i];
                    var c = s.Count(ss => ss == ch);
                    if(minch >= c)
                    {
                        minch = c;
                    }
                }
                min[index] = minch;
                index++;
            }

            int ii = 0;
            for (char ch = (char)0x61; ch <= 0x7a; ch++)
            {
                var item = min[ii];
                for (int j = 0; j < item; j++)
                {
                    Console.Write(ch);
                }
                ii++;
            }
            
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}


Measured memory_bytes: 11220
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define FOR(i, c) \
  \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp

// Union Find
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3]=2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  ll z=0,k,n,m,h,w,ans=1,sum=0,cnt=0,Max=-1e9,Min=1e9+1;
  string u;
  bool ok = false;
  cin >> h;
  ll x = log2(h);
  ans = 1;
  while(x>0){
    ans *= 2;
    x--;
  }
  cout << ans*2 -1 << endl;
  return 0;
}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef map<int, int> mi;
typedef pair<int, int> pi;
typedef long long ll;

void solve() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  S[K - 1] = S[K - 1] + 0x20;
  cout << S << endl;
}

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

  solve();

  return 0;
}

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

int main() {
    ll X, K, D; cin >> X >> K >> D;
    X = abs(X);
    if (X / D > K) cout << X - K * D << endl;
    else {
        K -= X / D;
        if (K % 2) cout << D - (X - X / D * D) << endl;
        else cout << X - X / D * D << endl;
    }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define endl '\n'
#define debug(X) cout << #X << " = " << X << endl

using namespace std;

int ceil(int a, int b) { return (a + b - 1) / b; }

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	#ifdef UTP
	freopen("input.txt", "r", stdin);
	#endif
	int n, k; cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	cout << ceil(n - 1, k - 1) << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  string n;
  int s=0,ans=0;
  cin>>n;
  for(int i=0;i<n.size();i++){
    if(n[i]=='S')s++;
    else{
      if(s>0)s--;
      else ans++;
    }
  }
  cout<<ans*2<<endl;
  return 0;
}


Measured memory_bytes: 640
import java.io.IOException;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws IOException{
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt();
        int sum = 0;

        PriorityQueue<Integer> q = new PriorityQueue<>(Collections.reverseOrder());

        for(int i=0; i<n; i++) q.add(sc.nextInt());
        for(int i=0; i<k; i++) sum += q.poll();

        System.out.println(sum);
    }
}


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

const int MAXN = 1000010;
const int inf = 0x3f3f3f3f;

int n, m, ids, tot;
map< pair<int, int>, int> H;

inline int getid(int u, int v)
{
	if(H.find(make_pair(u, v)) != H.end()) return H[make_pair(u, v)];
	return H[make_pair(u, v)] = ++ids;
}

struct Edge
{
	int to, nxt; int w;
}e[MAXN << 1];
int h[MAXN];

inline void add(int u, int v, int w)
{
	e[++tot] = (Edge){v, h[u], w}; h[u] = tot;
	e[++tot] = (Edge){u, h[v], w}; h[v] = tot;
}

struct Node
{
	int u; int d;
	bool operator < (const Node &x) const
	{
		return d > x.d;
	}
};
priority_queue<Node> q;
int dis[MAXN];

void dijkstra()
{
	for(int i = 1; i <= ids; ++i) dis[i] = inf;
	dis[1] = 0; q.push((Node){1, 0});
	while(!q.empty())
	{
		Node x = q.top(); q.pop();
		if(dis[x.u] != x.d) continue;
		for(int i = h[x.u]; i; i = e[i].nxt)
		{
			int y = e[i].to; int z = e[i].w;
			if(dis[y] > dis[x.u] + z)
			{
				dis[y] = dis[x.u] + z;
				q.push((Node){y, dis[y]});
			}
		}
	}
}

int main()
{
	scanf("%d %d", &n, &m); ids = n;
	for(int i = 1; i <= m; ++i)
	{
		int u, v, z; scanf("%d %d %d", &u, &v, &z);
		int a = getid(u, z), b = getid(v, z);
		add(u, a, 1), add(a, b, 0), add(v, b, 1);
	}
	dijkstra();
	printf("%d\n", dis[n] == inf ? -1 : dis[n] >> 1);
	return 0;
}

Measured memory_bytes: 48892
s = input()

s_d = dict()

for c in s:
  if s_d.get(c) is None:
    s_d[c] = 1
  else:
    s_d[c] += 1
  
flag = True
for v in s_d.values():
  if not v == 2:
    flag = False

if flag:
  print("Yes")
else:
  print("No")

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int gcd(int x, int y){
  if(y==0)return x;
  return gcd(y,x%y);
}

int cnter(int n){
  int cnt = 0;
  while(n&&n%2==0){
    cnt++;
    n/=2;
  }
  return cnt;
}

int f(int x){
  int y = 0;
  while(x){
    y += x%10;
    x /= 10;
  }
  return y;
}

int main(){
  int x; cin >> x;
  cout << (x%f(x) == 0 ? "Yes" : "No") << endl;
} 


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

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

int main() {
  LL N, X;
  cin >> N >> X;

  LL z = 0;
  z += N;
  LL a = N - X;
  LL b = X;

  if (a < b) {
    LL t = a;
    a = b;
    b = t;
  }

  while (b != 0) {
    z += 2 * (a / b) * b;
    LL t = b;
    b = a % b;
    a = t;
  }
  z -= a;
  cout << z << endl;

  return 0;
}


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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define INF INT_MAX/3
#define N 3
typedef pair<int, int> P;

struct State {
    int g, h;
    string state;
    P blank;
    string path;
    bool operator<(const State &a) const {
        return g + h > a.g + a.h;
    }
};

int d[5] = {-1, 0, 1, 0, -1};
string r[4] = {"D", "R", "U", "L"};
string ans_str = "";
int ans[N][N], puzzle0[N][N], puzzle1[N][N];
set<string> s;
priority_queue<State> next_state;
string path;

bool range(int y, int x) {return 0 <= y && y < N && 0 <= x && x < N;}

int h0() {
    int find = -1;
    while(next_state.size()) {
        State state = next_state.top();
        next_state.pop();
        if (s.count(state.state)) continue; // already search
        s.insert(state.state); // visited

        P blank = state.blank;
        rep(i, 4) {
            int y = d[i] + blank.first, x = d[i + 1] + blank.second; // next blank position
            if (range(y, x)) { // can be replaced
                string tmp = state.state; // next state (string)
                int p = blank.first * N + blank.second, q = y * N + x;
                if (N < 4) swap(tmp[p], tmp[q]);
                else swap(tmp[2 * p], tmp[2 * q]), swap(tmp[2 * p + 1], tmp[2 * q + 1]);
                if (s.count(tmp)) continue; // already search

                if (tmp == ans_str) { // answer
                    find = state.g + 1;
                    path = state.path + r[i];
                    break;
                }

                next_state.push(State{state.g + 1, 0, tmp, P(y, x), state.path + r[i]});
            }
        }
        if (find != -1) break; // find an answer
    }
    return find;
}

int main(){
    // create answer's numbers
    iota(ans[0], ans[0] + N * N, 1);
    ans[N - 1][N - 1] = 0;
    // create number
    iota(puzzle0[0], puzzle0[0] + N * N, 0);
    rep(i, N)rep(j, N) cin >> puzzle0[i][j];

    string state = "";
    P blank;
    int manhattan = 0, wrong_place = 0;
    rep(i, N)rep(j, N) {
        state += to_string(puzzle0[i][j]);
        ans_str += to_string(ans[i][j]);

        if(puzzle0[i][j] == 0) blank = P(i, j);
        else {
            int num = puzzle0[i][j] - 1;
            manhattan += (abs(num / N - i) + abs(num % N - j));
            if (puzzle0[i][j] != ans[i][j]) wrong_place++;
        }
    }

    if (manhattan == 0) { // the answer
        cout << 0 << endl;
    } else {
        int steps;
        next_state.push(State{0, manhattan, state, blank, ""});
        steps = h0();
        cout << steps << endl;
    }
    return 0;
}

Measured memory_bytes: 24516
fun main() {
    val (h, w) = readLine()!!.split(" ").map(String::toLong)

    if (h == 1L || w == 1L) {
        println(1)
        return
    }
    println(((w + 1) / 2) * ((h + 1) / 2) + (w / 2) * (h / 2))
}

Measured memory_bytes: 36288
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        if(A >= 10 || B>= 10){
            System.out.println(-1);
            return;
        }
        System.out.println(A*B);

    }
}

Measured memory_bytes: 23636
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t int64;

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

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using namespace std;

class A {
	vector<int> a;
public:
	A()
	{
		a.resize(3);
		cin >> a[0] >> a[1] >> a[2];
		sort(ALL(a), greater<>());

	}
	void solve()
	{
		int cur{ a[0] };
		int ans{ 0 };
		REP(i, 3)
		{
			ans += abs(cur - a[i]);
			cur = a[i];
		}

		cout << ans << endl;
	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
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; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  ll n,a,b,c,d,e;cin>>n>>a>>b>>c>>d>>e;
  ll m=min({a,b,c,d,e});
  cout<<(n%m?n/m+1:n/m)+4<<endl;
}

Measured memory_bytes: 256
object Main {
    def main(args:Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        while(sc.hasNext){
	        val n = sc.nextInt
	        var debt = 100000
	        for(i <- 1 to n){
	           debt = (debt * 1.05).asInstanceOf[Int]
	           debt = if (debt%1000 != 0) ((debt/1000)+1) * 1000 else (debt/1000) * 1000
	        }
	        println(debt)
    	}
    }
}

Measured memory_bytes: 44960
#pragma GCC optimize ("Ofast","unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define F first
#define S second
#define MEM(a,b) memset(a,b,sizeof a)
#define Tie ios::sync_with_stdio(0),cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll MOD=1e9+7;

struct datas
{
	ll n,m,a[51][51];
	datas operator*(const datas &x)const
	{
		datas re;
		MEM(re.a,0);
		re.n=n,re.m=x.m;
		for(int i=0;i<re.n;i++)
			for(int j=0;j<re.m;j++)
				for(int k=0;k<m;k++)
					re.a[i][j]=(re.a[i][j]+a[i][k]*x.a[k][j])%MOD;
		return re;
	}
}a,ans;

ll n,k,o;

int main()
{Tie
	cin>>n>>k,a.n=a.m=n;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin>>a.a[i][j];
	k--,ans=a;
	while(k)
	{
		if(k&1)
			ans=ans*a;
		k>>=1,a=a*a;
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			o=(o+ans.a[i][j])%MOD;
	cout << o<<'\n';
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  if(n==2) {
    pr(1);
    return;
  }
  vector<ll> v;
  for(ll i=2; i*i<=n; i++) {
    if(n%i==0) {
      v.pb(i);
      if(i*i!=n) v.pb(n/i);
    }
  }
  for(ll i=2; i*i<=n-1; i++) {
    if((n-1)%i==0) {
      v.pb(i);
      if(i*i!=(n-1)) v.pb(n/i);
    }
  }
  v.pb(n);
  v.pb(n-1);
  sort(all(v));
  v.erase(unique(all(v)),v.end());
  ll ans=0;
  rep(i,v.size()) {
    ll x=n;
    while(x>=v[i]) {
      if(x%v[i]==0) x/=v[i];
      else x%=v[i];
    }
    if(x==1) ans++;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 384
import sys
from collections import deque
input = sys.stdin.readline

def dfs(x):
    if Visited[x]: return
    Visited[x] = True
    for e in AB[x]:
        dfs(e)

n,m = map(int,input().split())
AB = [[] for i in range(n)]
Edges = [];
st = 0
for i in range(m):
    a,b = map(int,input().split())
    if i == 0: st = a-1
    AB[a-1].append(b-1)
    AB[b-1].append(a-1)
    Edges.append((a-1,b-1))
ans = 0
for a,b in Edges:
    AB[a].remove(b);AB[b].remove(a)
    Visited = [False] * n
    dfs(st)
    if not all(Visited):
        ans += 1
        #print(Visited)
    AB[a].append(b);AB[b].append(a)
print(ans)

Measured memory_bytes: 3316
N = int(input())
An = list()
for i in range(N):
    An.append(int(input()))
MaxIndex = An.index(max(An))
SecondIndex = An.index(sorted(An)[-2])
for i in range(0,N):
    if i == MaxIndex:
        print(An[SecondIndex])
    else:
        print(An[MaxIndex])

Measured memory_bytes: 13384
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>
#include<cmath>
#include<queue>
#include <functional>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define PI 3.141592

using namespace std;

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

	int count = 1;
	int result = 0;
	while (true)
	{
		if (count >= B)
		{
			break;
		}

		count -= 1;
		count += N;

		result += 1;
	}

	printf("%d", result);
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map> 
#include<iostream>
using namespace std;
typedef long long ll;
const double pi=acos(-1.0);
const ll mod=1e9+7;
const int inf=0x3f3f3f3f;

int main()
{
	int a,b,c,d;
	map<string,int>z;
	scanf("%d",&a);
	string e;b=0;
	while(a--)
	{
		cin>>e;
		if(!z[e])
		{
			b++;z[e]++;
		}
	}
	printf("%d\n",b);
	
}



Measured memory_bytes: 19384
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

int main() {
    ll n, k;
    cin >> n >> k;

    vector<ll> p(n), c(n);
    for (int i = 0; i < n; i++) { cin >> p[i]; p[i]--; }
    for (int i = 0; i < n; i++) cin >> c[i];

    ll ans = -1e9;
    for (int i = 0; i < n; i++) {
        ll sum = 0, cur = i, num = 0;
        do {
            cur = p[cur];
            sum += c[cur];
            num++;
        } while (cur != i);

        ll tmp = 0, mx = -1e9;
        for (int j = 1; j <= min(k, num); j++) {
            cur = p[cur];
            tmp += c[cur];
            mx = max(mx, tmp + (sum > 0 ? sum * ((k - j) / num) : 0));
        }

        ans = max(ans, mx);
    }

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

Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
multiset<int> A,B;
int p[100100],q[100100],r[100100],x,y,a,b,c;
long long ans=0;
int main()
{
	cin>>x>>y>>a>>b>>c;
	for(int i=1;i<=a;i++) scanf("%d",p+i);
	for(int i=1;i<=b;i++) scanf("%d",q+i);
	for(int i=1;i<=c;i++) scanf("%d",r+i);
	sort(p+1,p+a+1);
	sort(q+1,q+b+1);
	sort(r+1,r+c+1);
	for(int i=a;i>=a-x+1;i--) A.insert(p[i]),ans+=p[i];
	for(int i=b;i>=b-y+1;i--) B.insert(q[i]),ans+=q[i];
	for(int i=c;i;i--)
	{
		if(*A.begin()<*B.begin())
		{
			if(r[i]-*A.begin()<0) continue;
			ans+=r[i]-*A.begin();
			A.erase(A.begin());
			A.insert(r[i]);
		}
		else
		{
			if(r[i]-*B.begin()<0) continue;
			ans+=r[i]-*B.begin();
			B.erase(B.begin());
			B.insert(r[i]);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 9856
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;

void intersect(set<int> &Set_A, set<int> &Set_B, set<int> &Set_res) {
    set_intersection(Set_A.begin(), Set_A.end(), Set_B.begin(), Set_B.end(), inserter(Set_res, Set_res.end()));
}

int main() {
    
    int n;
    cin>>n;
    set<int> s,t,u;
    rep(i,n){
        int a;
        cin>>a;
        s.insert(a);
    }
    int m;
    cin>>m;
    rep(i,m){
        int a;
        cin>>a;
        t.insert(a);
    }
    intersect(s,t,u);
    irep(i,u){
        fin(*i);
    }
}


Measured memory_bytes: 23676
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int d=s.length();
	if(d<=n)
    cout<<s;
    else
    {
    	for(int i=0;i<n;i++)
    	cout<<s[i];
	    cout<<"...";
	}
}

Measured memory_bytes: 3544
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;

int main() {
  ll a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  ll f = c * max(x,y)* 2;
  ll d = a*x+b*y;
  ll mn = min(x,y);
  ll e = mn * 2 * c;
  if(x > y) {
    if(a > c*2) e += c * (x -mn)*2;
    else e += a * (x -mn);
  }
  else if(x < y) {
    if(b > c*2) e += c * (y -mn)*2;
    else e += b * (y -mn);
  }
  cout << min(min(d,e),f) << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

int main() {
    ll N;   cin >> N;
    for (ll h = 1; h <= 3500; h++) {
        for (ll n = 1; n <= 3500; n++) {
            ll k = N*h*n, l = 4*h*n - N*n - N*h;
            if (l > 0 && k % l == 0) {
                cout << h << " " << n << " " << k/l << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=505,M=200005;
int b[N],a[N],z[N],S,T,flag[N],x[N],y[N],opt[N],lx[N],rx[N],ly[N],ry[N],n,m,sl[M],ne[M],fi[N],zz[M],w[M],tot,dis[N],cur[N];
queue<int> Q;
void jb(int x,int y,int z,int v){
	ne[++tot]=fi[x];fi[x]=tot;zz[tot]=y;sl[tot]=z;w[tot]=v;
	ne[++tot]=fi[y];fi[y]=tot;zz[tot]=x;sl[tot]=0;w[tot]=-v;
}
int get(){
	char s[2];
	scanf("%s",s);
	if (s[0]=='L')return 1;
	if (s[0]=='R')return 2;
	if (s[0]=='D')return 3;
	return 4;
}
int bfs(){
	Q.push(S);
	memset(dis,0x3f3f3f3f,sizeof dis);
	dis[0]=0;
	while (!Q.empty()){
		int now=Q.front();Q.pop();
		flag[now]=0;
		for (int i=fi[now];i;i=ne[i])
			if (sl[i]&&dis[zz[i]]>dis[now]+w[i]){
				dis[zz[i]]=dis[now]+w[i];
				if (!flag[zz[i]]){
					flag[zz[i]]=1;
					Q.push(zz[i]);
				}
			}
	}
	return dis[T]<=1e18;
}
int dfs(int x,int y){
	if (x==T)return y;
	int s=0,b;
	flag[x]=1;
	for (int &i=cur[x];i;i=ne[i])
		if (sl[i]&&!flag[zz[i]]&&dis[zz[i]]==dis[x]+w[i]&&(b=min(sl[i],dfs(zz[i],min(sl[i],y))))){
			s+=b;y-=b;
			sl[i]-=b;
			sl[i^1]+=b;
			if (!y)return s;
		}
	return s;
}
signed main(){
	scanf("%lld",&n);
	for (int i=1;i<=n;i++)scanf("%lld%lld%lld",&x[i],&y[i],&z[i]);
	scanf("%lld",&m);
	for (int i=1;i<=m;i++){
		opt[i]=get();
		scanf("%lld%lld",&a[i],&b[i]);
	}
	S=0;T=1;
	int ans=0;
	for (int k=1;k<=n;k++){
		memset(fi,0,sizeof fi);
		tot=1;
		for (int i=1;i<=k;i++)rx[i]=ry[i]=1e9,lx[i]=ly[i]=0;
		for (int i=1;i<=m;i++){
			if (opt[i]==1&&b[i]<k)lx[b[i]+1]=max(lx[b[i]+1],a[i]+1);
			if (opt[i]==2&&k>b[i])rx[k-b[i]]=min(rx[k-b[i]],a[i]-1);
			if (opt[i]==3&&b[i]<k)ly[b[i]+1]=max(ly[b[i]+1],a[i]+1);
			if (opt[i]==4&&k>b[i])ry[k-b[i]]=min(ry[k-b[i]],a[i]-1);
		}
		for (int i=2;i<=k;i++)lx[i]=max(lx[i-1],lx[i]);
		for (int i=k-1;i;i--)rx[i]=min(rx[i+1],rx[i]);
		for (int i=2;i<=k;i++)ly[i]=max(ly[i-1],ly[i]);
		for (int i=k-1;i;i--)ry[i]=min(ry[i+1],ry[i]);
		for (int i=2;i<=k+1;i++)jb(S,i,1,0);
		for (int i=2;i<=k+1;i++)jb(i+k,T,1,0);
		for (int i=1;i<=k;i++)
			for (int j=1;j<=n;j++)
				if (lx[i]<=x[j]&&rx[i]>=x[j])jb(i+1,j+2*k+1,1,0);
		for (int i=1;i<=k;i++)
			for (int j=1;j<=n;j++)
				if (ly[i]<=y[j]&&ry[i]>=y[j])jb(j+2*k+1+n,i+k+1,1,0);
		for (int i=1;i<=n;i++)jb(i+2*k+1,i+n+2*k+1,1,-z[i]);
		int ansc=0,ansm=0;
		while (bfs()){
			for (int i=0;i<=2*k+1+2*n;i++)cur[i]=fi[i];
			int t=dfs(S,1e9);
			ansm+=t;
			ansc+=t*dis[T];
			for (int i=0;i<=2*k+1+2*n;i++)flag[i]=0;
		}
		if (ansm==k)ans=max(ans,-ansc);
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ans=0,a[4]={0,0,0,0};
	cin >> n;
	char c[n];
	for(int i=0;i<n;i++)
	{
		cin >> c[i];
		if(c[i] == 'P')
			a[0]=1;
		if(c[i] == 'W')
			a[1]=1;
		if(c[i] == 'G')
			a[2]=1;
		if(c[i] == 'Y')
			a[3]=1;
	}
	for(int i=0;i<4;i++)
		ans += a[i];
	if(ans == 3) 
		puts("Three");
	if(ans == 4)
		puts("Four");
	return 0;
}

Measured memory_bytes: 256
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));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int[] x = new int[n];
		int[] y = new int[n];
		for (int i = 0; i < n; i++) {
			sa = br.readLine().split(" ");
			x[i] = Integer.parseInt(sa[0]);
			y[i] = Integer.parseInt(sa[1]);
		}
		br.close();

		System.out.println(calc(x, y));
	}

	static double calc(int[] x, int[] y) {
		double gosa = 1e-7;
		double l = 0;
		double r = 1000;
		double ret = 2000;
		while (r - l > gosa) {
			double m1 = (l * 2 + r) / 3;
			double m2 = (l + r * 2) / 3;
			double v1 = getMaxR(x, y, m1, getY(x, y, m1));
			double v2 = getMaxR(x, y, m2, getY(x, y, m2));
			if (v1 <= v2) {
				r = m2;
				ret = v1;
			} else {
				l = m1;
				ret = v2;
			}
		}
		return ret;
	}

	static double getY(int[] x, int[] y, double mx) {
		double gosa = 1e-7;
		double l = 0;
		double r = 1000;
		while (r - l > gosa) {
			double m1 = (l * 2 + r) / 3;
			double m2 = (l + r * 2) / 3;
			double v1 = getMaxR(x, y, mx, m1);
			double v2 = getMaxR(x, y, mx, m2);
			if (v1 <= v2) {
				r = m2;
			} else {
				l = m1;
			}
		}
		return r;
	}

	static double getMaxR(int[] x, int[] y, double mx, double my) {
		double max = 0;
		for (int i = 0; i < y.length; i++) {
			double d = Math.hypot(x[i] - mx, y[i] - my);
			max = Math.max(max, d);
		}
		return max;
	}
}


Measured memory_bytes: 21572
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
    long bitw[33] = {0};
    int n;
    cin >> n;
    long a[n];
    long i,j;
    for(i=0;i<n;i++){
        cin >> a[i];
        for(j=0;j<33;j++){
            if (a[i] & (1ull <<j))bitw[j]++;
        }
    }
    long bi = 0;
    for(i=0;i<33;i++){
        if(bitw[i]%2==1) bi += (1ull <<i);
    }
    for(i=0;i<n;i++){
        j = a[i] ^ bi;
        cout << j << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5196
N, K = map(int, input().split())
dices = list(map(int, input().split()))

exv = [(e+1)/2 for e in dices]
temp = sum(exv[0:K])
result = temp
for i in range(N-K):
    temp -= exv[i]
    temp += exv[i+K]
    if temp > result:
        result = temp
print(result)

Measured memory_bytes: 24804
use std::io::*;
// XORとは繰り上がりがない和であるため、
// l ~ rのXORが和に等しいという条件には単調性がある。
// なぜなら、l ~ rまでで条件を充せてなかったらl ~ r + 1も充せないので。

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut ans: usize = 0;
    let mut xor: usize = 0;
    let mut sum: usize = 0;
    let mut r: usize = 0;
    for l in 0..n {
        while r < n && xor ^ a[r] == sum + a[r] {
            xor ^= a[r];
            sum += a[r];
            r += 1;
        }
        ans += r - l;
        xor ^= a[l];
        sum -= a[l];
    }
    println!("{}", ans);
}


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

struct Edge
{
        int to, cost;
        Edge () {}
        Edge ( int to, int cost ) : to(to), cost(cost) {}
};

struct Node
{
        int node, cost;
        Node () {}
        Node ( int node, int cost ) : node(node), cost(cost) {}
        bool operator < (const Node &d) const { return ( cost < d.cost ); }
        bool operator > (const Node &d) const { return ( cost > d.cost ); }
};

constexpr int INF = (1 << 30) - 1;
int n;
vector < Edge > G[100005];
int d[10005];

void Dijkstra()
{
        priority_queue < Node , vector < Node > , greater < Node > > pq;

        fill_n(d, 10005, INF);
        d[0] = 0;
        pq.emplace(0, 0);
        
        while ( !pq.empty() ) {
                Node u = pq.top(); pq.pop();
                for ( auto &x : G[u.node] ) {
                        int cost = u.cost + x.cost;
                        if ( d[x.to] > cost ) {
                                d[x.to] = cost;
                                pq.emplace(x.to, cost);
                        }
                }
        }
}

int main()
{
        cin >> n;
        for ( int i = 0; i < n; i++ ) {
                int u, k;
                cin >> u >> k;
                for ( int j = 0; j < k; j++ ) {
                        int v, c;
                        cin >> v >> c;
                        G[u].emplace_back(v, c);
                }
        }
        Dijkstra();
        for ( int i = 0; i < n; i++ ) {
                cout << i << " " << d[i] << endl;
        }

        return (0);
}



Measured memory_bytes: 10128
s = int(input())
a = s//100
b = s % 100
if 1 <= a <=12 and 1 <= b <=12:
         print("AMBIGUOUS")
elif 1 <= a <=12 and (b == 0 or b >=13):
         print("MMYY")
elif 1 <= b <=12 and (a == 0 or a >=13):
         print("YYMM")
else:
         print("NA")


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <climits>
#include <cfloat>

using namespace std;

//start of 0uts1de's library

int cin_int_arr(vector<int>& arr){
    for (int i = 0; i < arr.size(); ++i){
        cin >> arr.at(i);
    }
    return 0;
}

int cin_int_arr(vector<int>& arr, int n){    //overload
    for (int i = 0; i < n; ++i){
        cin >> arr.at(i);
    }
    return 0;
}

int cin_double_arr(vector<double>& arr){
    for (int i = 0; i < arr.size(); ++i){
        cin >> arr.at(i);
    }
    return 0;
}

int cin_double_arr(vector<double>& arr, int n){    //overload
    for (int i = 0; i < n; ++i){
        cin >> arr.at(i);
    }
    return 0;
}


int cout_int_arr(vector<int>& arr){
    for (int i = 0; i < arr.size(); ++i){
        cout << arr.at(i) << endl;
    }
    return 0;
}

int cout_int_arr(vector<int>& arr, int n){    //overload
    for (int i = 0; i < n; ++i){
        cout << arr.at(i) << endl;
    }
    return 0;
}

int cout_double_arr(vector<double>& arr){
    for (int i = 0; i < arr.size(); ++i){
        cout << arr.at(i) << endl;
    }
    return 0;
}

int cout_double_arr(vector<double>& arr, int n){    //overload
    for (int i = 0; i < n; ++i){
        cout << arr.at(i) << endl;
    }
    return 0;
}


int max_int_arr(std::vector<int>& arr){    //data mode
    int maxVal = INT_MIN;       //min of int
    for (int i = 0; i < arr.size(); ++i){
        if (arr.at(i) > maxVal){
            maxVal = arr.at(i);
        }
    }
    return maxVal;
}

int max_int_arr(std::vector<int>& arr, int mode){    //overload index mode
    int maxVal = INT_MIN;       //min of int
    int maxIndex = 0;
    for (int i = 0; i < arr.size(); ++i){
        if (arr.at(i) > maxVal){
            maxVal = arr.at(i);
            maxIndex = i;
        }
    }
    return maxIndex;
}

double max_double_arr(std::vector<double>& arr){    //data mode
    double maxVal = -DBL_MAX;       //min of double
    for (int i = 0; i < arr.size(); ++i){
        if (arr.at(i) > maxVal){
            maxVal = arr.at(i);
        }
    }
    return maxVal;
}

int max_double_arr(std::vector<double>& arr, int mode){    //overload index mode
    double maxVal = -DBL_MAX;       //min of double
    int maxIndex = 0;
    for (int i = 0; i < arr.size(); ++i){
        if (arr.at(i) > maxVal){
            maxVal = arr.at(i);
            maxIndex = i;
        }
    }
    return maxIndex;
}

//end of 0uts1de's library

int main(){
    int a, b, ans;
    cin >> a >> b;
    if (b % a == 0){
        ans = a + b;
    }
    else{
        ans = b - a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
from typing import List


def main():
    _, K = map(int, input().split())
    p_lst: List[int] = list(map(int, input().split()))

    p_lst.sort()

    total: int = 0
    total = sum(p_lst[0: K])

    print(total)


if __name__ == "__main__":
    main()


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


int main(){
int n ;
cin >> n;
vector<int> l(n);
rep(i,n) cin >> l[i];

int max1 = 0;
rep(i,n){
   max1 = max (max1,l[i]);
}
int total = 0;
rep(i,n) total += l[i];

if (max1 < total-max1) cout << "Yes" << endl;
else cout << " No" << endl;
}

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

int main(){
  int H, W, N;
  cin >> H >> W >> N;
  
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  
  vector<vector<int>> ans(H, vector<int>(W));
  int now = 0, col = 1;
  for (int num : A){
    for (int i = 0; i < num; i++){
      int Hpos = now / W;
      int Wpos;
      if (Hpos % 2 == 0){
        Wpos = now % W;
      }
      else{
        Wpos = W - 1 - now % W;
      }
      
      ans.at(Hpos).at(Wpos) = col;
      now++;
    }
    col++;
  }
  
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cout << ans.at(i).at(j) << ' ';
    }
    cout << endl;
  }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cout << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

using P = pair<int,int>;
random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////

int main(){
  ini(N); ins (S);
  out(N >= 3200 ? S : "red");

}

Measured memory_bytes: 256
import bisect 
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
ans=0
for i in b:
  A=bisect.bisect_left(a,i)
  C=bisect.bisect(c,i)
  ans+=A*(n-C)
print(ans)


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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s; cin >> s;
  for(int i = 0; i < 3; i++){
    if(s[i] == '7'){
      cout << "Yes" << endl;
      exit(0);
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
 
using namespace std;
 
int main(int argc, char *argv[]) {
  int N, count = 1;
  cin >> N;
  int flg = 0, u, v;
 
  cin >> v;
  for (int i = 1; i < N; i++) {
    u = v;
    cin >> v;
    int d = v - u > 0 ? 1 : v - u < 0 ? -1 : 0;
    if (flg == 0)
      flg = d;
    else {
      if (flg * d < 0) {
        count++;
        flg = 0;
      } else {
        if (d) flg = d;
      }
    }
  }
  cout << count << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, k, i, j;
	cin >> k >> n;
	vector<int> a(k);
	for (i = 0; i < k; i++) cin >> a[i];

	vector<bool> dp(n + 1, false);
	for (i = 1; i <= n; i++) {
		for (auto p : a) {
			if (p > i) continue;
			if (!dp[i - p]) dp[i] = true;
		}
	}

	if (dp[n]) cout << "First\n";
	else cout << "Second\n";

	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector < pii > vpii;
typedef vector < pll > vpll;
typedef vector <string> vs;
typedef vector < vi > vvi;
typedef vector < vll > vvll;
typedef vector< vpii > vvpii;
typedef vector< vpll > vvpll;
#define all(v)     (v).begin(), (v).end()
#define srt(v)    sort (all (v))
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
 
int main(){
	int n;
	cin>>n;
	if(n>=30)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
 
int main() {
  int k;
  cin >> k;
  vector<ll> a;
  for(int i = 1; i <=9; i++) a.push_back(i);
  while(1){
    if(k <= a.size()){
      cout << a[k-1] << endl;
      return 0;
    }
    k = k-a.size();
    vector<ll> old;
    swap(a, old);
    for(ll x : old){
      for(int i = -1; i <= 1; i++){
        int d = x%10+i;
        if(d < 0 || d > 9) continue;
        ll nx = x*10+d;
        a.push_back(nx);
      }
    }
  }
  return 0;
}
    

Measured memory_bytes: 1712
from sys import exit
N,Z,W = [int(n) for n in input().split()]
a = [int(n) for n in input().split()]
# N = int(input())
# a = [int(input()) for _ in range(N)]
# L = len(S)
# T = str(input())
if N == 1:
    print(abs(W-a[N-1]))
else:
    print(max(abs(a[N-1]-a[N-2]), abs(W-a[N-1])))


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int H, W, A, B; cin >> H >> W >> A >> B;
    if(A>W/2 || B>H/2){
        cout << "No" << endl;
        return 0;
    }
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if((i<B && j<A) || (i>=B && j>=A)) cout << 0;
            else cout << 1;
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1280
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>

using namespace std;

//같은 연속된 문자열이 존재할 때.

int findmax(map <char, int> count)
{
	int M = 0;
	for (auto it = count.begin(); it != count.end(); it++)
	{
		if (M < it->second)
		{
			M = it->second;
		}
	}

	return M;
}
bool isunbalanced(string s)
{
	int len = s.size();
	map <char, int> count;
	for (int i = 0; i < len; i++)
	{
		count[s[i]] += 1;
		if (count[s[i]] >(len / 2))
		{
			return true;
		}
	}

	return false;
}

int main(void)
{
	string s;
	map <char, int> count;


	cin >> s;
	
	//가지 치기를 한다.
	//생각을 해보자.
	//unbalnce할려면 문자가 xx이어져있거나 xaxbx 이러면 된다. 5까지 봤는데 안나오면 이 스트링은 balnce하다.
	
	for (int i = 2; i <= min((int)s.size(),5); i++)
	{
		for (int j = 0; j <= s.size() - i; j++)
		{
			string sub = s.substr(j, i);
			//cout << " " << j << " " << j+i << " " << sub << endl;
			if (isunbalanced(sub) == true)
			{
				cout << j + 1 << " " <<  i+j << endl;
				return 0;
			}
		}
	}
	

	cout << "-1 -1" << endl;

	return 0;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N, K = readnums()
    x = list(readnums())
    ans = 0
    for i in range(K - 1, N):
        ls = i - K + 1
        le = i
        if x[ls] > 0:
            val = abs(x[le])
        elif x[le] < 0:
            val = abs(x[ls])
        else:
            val = abs(x[ls]) + abs(x[le])
            val += min(abs(x[ls]), abs(x[le]))
        if not ans:
            ans = val
        else:
            ans = min(ans, val)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 20532
n,m = map(int,input().split())
ans = 0

import math

if n == m:
    ans = (math.factorial(n)%(10**9+7)) * (math.factorial(m)%(10**9+7)) * 2
    
elif abs(n-m) == 1:
    ans = (math.factorial(n)%(10**9+7)) * (math.factorial(m)%(10**9+7))
    
print(ans%(10**9+7))

Measured memory_bytes: 4092