akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
const int MAXN = 1005;
const int MAXV = MAXN*(MAXN-1)/2;
vector<int> E[MAXV];
int id[MAXN][MAXN];
 
bool reached[MAXV];
bool finished[MAXV];
int dp[MAXV]; // max length of path from v
int dfs(int pos) {
	if (reached[pos]) {
		if (!finished[pos])return -1;
		return dp[pos];
	}
	dp[pos] = 0;
	reached[pos] = true;
	for (int i = 0; i < E[pos].size(); i++) {
		//cout <<"pos == " << pos <<  "to " << E[pos][i] << endl;
		int res = dfs(E[pos][i]);
		if (res == -1)return -1;
		dp[pos] = max(dp[pos], res + 1);
	}
	finished[pos] = true;
	return dp[pos];
}
 
int main() {
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(n-1));
  
  int V = 0;
  rep(i,n)rep(j,n) {
    if (i < j) {
      id[i][j] = V++;
    }else if(i > j){
      id[i][j] = id[j][i];
    }
  }
  rep(i,n) {
    rep(j,n-1) {
      cin >> a[i][j];
      a[i][j]--;
      a[i][j] = id[i][a[i][j]];
    }
  }
  
  rep(i,n) {
    
    rep(j,n-2) {
      E[a[i][j+1]].push_back(a[i][j]);
    }
  }
  int ans = 0;
  rep(i,V) {
    int res = dfs(i);
    if (res == -1) {
      puts("-1");
      return 0;
    }
    ans = max(ans, res);
  }
  cout << ans + 1 << endl;
  return 0;
}

Measured memory_bytes: 38528
import scala.io.StdIn.{readLine,readInt}

object Main {

  def getFee(x:Int,y:Int,h:Int,w:Int) = {
    val l = x+y+h
    if(l<=60 && w <= 2) 600
    else if(l<=80 && w<=5) 800
    else if(l<=100 && w<=10) 1000
    else if(l<=120 && w<=15) 1200
    else if(l<=140 && w<=20) 1400
    else if(l<=160 && w<=25) 1600
    else 0
  }

  def main(args:Array[String]) = {
    var n = 0
    while({n=readInt;n} != 0) {
      val sum = (1 to n).map { i =>
        val m = readLine.split(" ").map(_.toInt)
        getFee(m(0),m(1),m(2),m(3))
      }.sum
      println(sum)
    }
  }
}

Measured memory_bytes: 60932
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

using std::min;
using std::max;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

ll inq(ll x, ll y, ll mod)
{
    if (y == 0) return 1;
    ll l = inq(x, y / 2, mod);
    if (y % 2) return l * l % mod * x % mod;
    return l * l % mod;
}

ll rev(ll x, ll mod)
{
    return inq(x, mod - 2, mod);
}

inline int nextInt()
{
    int x = 0;
    char c = getchar();
    int mi = (c == '-');
    if (c == '-') c = getchar();
    while ('0' <= c && c <= '9')
    {
        x = 10 * x + c - '0';
        c = getchar();
    }
    if (mi) return x * -1;
    return x;
}

int n;
int a[500000];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a, a + n);
    if (a[n - 1] - a[0] >= 2)
    {
        cout << "No";
        return 0;
    }
    ll x = 0, y = 0;
    int i = 0;
    while (i < n)
    {
        if (a[i] == a[0])
            x++;
        else
            y++;
        i++;
    }
    if (y == 0)
    {
        if (a[0] == n - 1)
        {
            cout << "Yes";
            return 0;
        }
        if (a[0] <= n / 2)
        {
            cout << "Yes";
            return 0;
        }
        cout << "No";
        return 0;
    }
    if (x + 1 <= a[n - 1] && a[n - 1] <= x + y / 2)
    {
        cout << "Yes";
        return 0;
    }
    cout << "No";
    return 0;
}

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

int main(void)
{
        int n,i,j=0,w=0;
        char s[110][13],c='1',d='1';

        scanf("%d",&n);

        for (i=0;i<n;i++)
                scanf("%s",s[i]);

        for (i=0;i<n;i++){
                j=0;
                while(c!='\0'){
                        d=c;
                        c=s[i][j];
                        j++;
                }
                c=s[i+1][0];
                if ((d!=s[i+1][0])&&(i<n-1)){
                        printf("No\n");
                        return 0;
                }
        }

        for (i=0;i<n;i++){
                for (j=0;j<n;j++){
                        if (strcmp(s[i],s[j])==0)
                                w++;
                }
        }

        if (w==n)
                printf("Yes\n");
        else
                printf("No\n");

        return 0;
}

Measured memory_bytes: 128
import numpy as np
n = int(input())

f = []
for i in range(n):
    f.append(int(input().replace(' ', ''), 2))

p = np.zeros((n, 11))
for i in range(n):
    p[i, :] = np.array(list(map(int, input().split())))

max_val = -10 ** 9
for i in range(1, 2 ** 10):
    benefit = 0
    for j in range(n):
        match = str(bin(i & f[j])).count('1')
        benefit += p[j, match]
    if benefit > max_val:
        max_val = benefit
print(int(max_val))


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


using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;



int main() {

	ll h;
	cin >> h;

	ll ans = 1;

	while (h) {
		h /= 2;
		ans *= 2;
	}

	ans--;

	cout << ans << endl;


}

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

ans = A[N-1] - A[0]
for i in range(N):
    ans = min(ans, min(A[(i+N-1)%N] + K - A[i], A[i] + K - A[(i+1)%N]))

print(ans)

Measured memory_bytes: 26444
#include <iostream>
#include <string>
#include <queue>

using namespace std;

int main(){
  char now = 'a';
  string S[3];
  queue<char> human[3];


  cin >> S[0] >> S[1] >> S[2];

  for(int i = 0;i < 3;i++){
    for(int j = 0;j < S[i].size();j++){
      human[i].push(S[i][j]);
    }
  }

  while(1){
    if(now == 'a'){
      if(human[0].empty()){
        cout << 'A'<< endl;
        return 0;
      }
      now = human[0].front();
      human[0].pop(); 
    } else if(now == 'b'){
      if(human[1].empty()){
        cout << 'B' << endl;
        return 0;
      }
      now = human[1].front();
      human[1].pop();
    } else {
      if(human[2].empty()){
        cout << 'C' << endl;
        return 0;
      }
      now = human[2].front();
      human[2].pop();
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,mx=0,x=0;
string s;
int main(){
	scanf("%d",&n);
	cin >> s;
	for(int i=0;s[i];i++){
		if(s[i]=='I'){
			mx=max(mx,x+1);
			x+=1;
		}else if(s[i]=='D'){
			mx=max(mx,x-1);
			x-=1;
		}
	}
	printf("%d",mx);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
using P = pair<int,int>;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

int main()
{
    int a;
    cin >> a;
    cout << a + a*a + a*a*a;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
void Sieve(ll n) 
{ 
    ll ans=0;
    bool prime[1000000+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for(ll p=2; p*p<=1000000+1; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=1000000+1; i += p) 
                prime[i] = false; 
        } 
    } 
  
    for (ll p=2; p<=1000000; p++) 
    {
       if (prime[p]) 
          {
              if(n%p!=0)
              continue;
              else
              {
                  ll ele=p;
                  while(n&&n%p==0)
                  {
                      //cout<<"d";
                      if(n%p!=0)
                      break;
                      n/=p;
                      ans++;
                      p*=ele;
                  }
                  p=ele;
              }
          }
    }
    //cout<<n<<endl;
    if(n>1000000)
    ans++;
    cout<<ans;
} 
void solve()
{
    ll n;
    cin>>n;
    if(n==1)
    {
        cout<<0;
        return;
    }
    Sieve(n);
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;

    ll ans = 0, b = 0;
    for (char c: s) {
        if (c == 'B') b++;
        else ans += b;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;

int N, M;
vector<int> adj[100000];
int indegree[100000];
int dp[100000];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b; cin >> a >> b;
		a--, b--;
		adj[a].push_back(b);
		indegree[b]++;
	}

	queue<int> q;
	for (int i = 0; i < N; i++) if (indegree[i] == 0) q.push(i);

	int ans = 0;
	while (q.size()) {
		int cur = q.front(); q.pop();
		for (int i : adj[cur]) {
			dp[i] = max(dp[i], dp[cur] + 1);
			ans = max(ans, dp[i]);
			if (--indegree[i] == 0) q.push(i);
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 6528
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



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

	string s;
	while (cin >> s >> N,s!="0") {
		N++;
		bool flag = true;
		while (flag) {
			int num = 0;
			flag = false;
			for (int i = 0; i < s.size(); i++) {
				if (s[i]<'A' || s[i]>'Z')flag = true;
				if (s[i] <= '9'&&s[i] >= '0') {
					num *= 10;
					num += s[i] - '0';
				}
				else if (num&&s[i] >= 'A'&&s[i] <= 'Z') {
					string t;
					int minus = 0;
					int box = num;
					while (box) {
						box /= 10;
						minus++;
					}
					for (int j = 0; j < i - minus; j++) {
						t.push_back(s[j]);
					}
					for (int j = 0; j < num; j++) {
						t.push_back(s[i]);
					}
					for (int j = i + 1; j < s.size(); j++) {
						t.push_back(s[j]);
					}
					s = t;
					num = 0;
					break;
				}
				else {
					if (s[i] == ')') {
						for (int j = i - 1; j >= 0; j--) {
							if (s[j] == '(') {
								//cout << j << " " << i << endl;
								num = 0;
								int by = 1;
								int minus = 0;
								for (int k = j - 1; k >= 0; k--) {
									if (s[k]<'0' || s[k]>'9')break;
									num += by * (s[k] - '0');
									by *= 10;
									minus++;
								}
								string t;
								for (int k = 0; k < j - minus; k++) {
									t.push_back(s[k]);
								}
								int add = 0;
								for (int k = 0; k < num; k++) {
									for (int l = j + 1; l < i; l++) {
										t.push_back(s[l]);
									}
									add += i - j - 1;
									if (add >= N)break;
								}
								for (int k = i + 1; k < s.size(); k++)t.push_back(s[k]);
								s = t;
								i-=2;
								num = 0;
								break;
							}
						}
					}
					else num = 0;
				}
			}
			//cout << s.size() << endl;
			//cout << s << endl;
		}
		N--;
		if (s.size() <= N) {
			cout << 0 << endl;
			continue;
		}
		cout << s[N] << endl;
	}
}



Measured memory_bytes: 13656
using System;

class Program
{
    enum Pattern { S, H, C, D, Length };

    static void Main()
    {
        int n=0;
        n = int.Parse(Console.ReadLine());
        string[] cardsInHand = new string[n];
        for (var i = 0; i < n; cardsInHand[i++] = Console.ReadLine()) ;

        for (var p = (Pattern)0; p < Pattern.Length; p++)
        {
            for (var i = 1; i <= 13; i++)
            {
                if (!HasFactor(p + " " + i, cardsInHand)) Console.WriteLine(p + " " + i);
            }
        }    
    }

    static bool HasFactor(string factor, string[] strings)
    {
       bool ans = false;
       foreach (var x in strings) if (x == factor) ans = true;
       return ans;
    }
}
  


Measured memory_bytes: 7816
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7

a, v = MAP()
b, w = MAP()
t = INT()

if a == b:
    YES()
    exit()
if w >= v:
    NO()
    exit()

diff = v - w
dist = abs(a-b)
if diff*t >= dist:
    YES()
else:
    NO()


Measured memory_bytes: 9228
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main(void)
{
  int N;
  cin >> N;
  set<string> S;
  string tmp;
  for(int i = 0 ; i < N ; i++)
  {
    cin >> tmp;
    S.insert(tmp);
  }
  cout << S.size() << endl;
  return 0;
}

Measured memory_bytes: 19180
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll MOD=1000000007;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

int main(){
   int n,m;
   cin>>n>>m;
   ll ans=1;

   if(abs(n-m)==1){
      for(int i=1;i<=n;i++){
         ans*=i;
         ans%=MOD;
      }
      for(int i=1;i<=m;i++){
         ans*=i;
         ans%=MOD;
      }
   }
   else if(n-m==0){
      for(int i=1;i<=n;i++){
         ans*=i;
         ans%=MOD;
      }
      for(int i=1;i<=m;i++){
         ans*=i;
         ans%=MOD;
      }
      ans*=2;
      ans%=MOD;
   }
   else ans=0;
   
   cout<<ans;

   return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>

using namespace std;

typedef long long ll;

constexpr ll BLANK = -1;
ll N;
string s;

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

    char animal[2] = {'W', 'S'};
    vector<vector<ll> > V;
    V.push_back(vector<ll>({0, 0}));
    V.push_back(vector<ll>({0, 1}));
    V.push_back(vector<ll>({1, 0}));
    V.push_back(vector<ll>({1, 1}));
    for (auto v : V) {
        vector<ll> ans = v;
        for (ll n = 2; n < N; n++) {
            if ((ans[n - 1] && s[n - 1] == 'o')
            || (!ans[n - 1] && s[n - 1] == 'x')) {
                ans.push_back(ans[n - 2]);
            } else {
                ans.push_back((ans[n - 2] + 1) % 2);
            }
        }

        bool isvalid = true;

        for (ll n = 0; n < N; n++) {
            ll l = (n - 1 + N) % N;
            ll r = (n + 1) % N;
            if ((ans[n] && s[n] == 'o')
            || (!ans[n] && s[n] == 'x')) {
                isvalid &= (ans[l] == ans[r]);
            } else {
                isvalid &= (ans[l] != ans[r]);
            }
        }

        if (isvalid) {
            for (auto a : ans) {
                cout << animal[a];
            }
            cout << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 2276
#include<stdio.h>
#include<math.h>

#define N 100

int main(){
  int n,i,j,k,l,mt[N],a[N][N],q,mt1[N];

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d%d",&mt1[i],&mt[i]);
  }

  mt[0]=mt1[1];

  for(i=1;i<=n;i++){
    a[i][i]=0;
  }

  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      a[i][j]=1919810931;
      for(k=i;k<j;k++){
	q=a[i][k]+a[k+1][j]+mt[i-1]*mt[k]*mt[j];
	if(q<a[i][j]) a[i][j]=q;
      }
    }
  }

  printf("%d\n",a[1][j]);

  return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	for(int n,m;cin>>n>>m,n|m;){
		string s(n,'#');
		while(m--){
			char p; cin>>p;
			if(p=='A'){
				for(int i=0;i<n;i++)
					if(s[i]=='#'){
						s[i]='A';
						break;
					}
			}
			if(p=='B'){
				bool flg=false;
				for(int i=n-1;i>=0;i--){
					if(s[i]=='#' && (i==n-1 || s[i+1]!='A') && (i==0 || s[i-1]!='A')){
						s[i]='B';
						flg=true;
						break;
					}
				}
				if(!flg){
					for(int i=0;i<n;i++)
						if(s[i]=='#'){
							s[i]='B';
							break;
						}
				}
			}
			if(p=='C'){
				if(count(s.begin(),s.end(),'#')==n)
					s[s.size()/2]='C';
				else{
					for(int i=0;i<n;i++){
						if(s[i]=='#')
							continue;
						if(i<n-1 && s[i+1]=='#'){
							s[i+1]='C';
							break;
						}
						if(i>0 && s[i-1]=='#'){
							s[i-1]='C';
							break;
						}
					}
				}
			}
			if(p=='D'){
				int mi=-1,md;
				for(int i=0;i<n;i++){
					if(s[i]!='#')
						continue;
					int d=n;
					for(int j=i-1;j>=0;j--)
						if(s[j]!='#'){
							d=min(d,i-j);
							break;
						}
					for(int j=i+1;j<n;j++)
						if(s[j]!='#'){
							d=min(d,j-i);
							break;
						}
					if(mi==-1 || d>md){
						mi=i;
						md=d;
					}
				}
				s[mi]='D';
			}
		}
		cout<<s<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
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();
		int c = sc.nextInt();

		int max = Math.max(a, b);
		max = Math.max(max, c);

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

	}

}


Measured memory_bytes: 21716
#include<stdio.h>

int main(){
  int x,y,d,tmp;

  scanf("%d %d", &x, &y);

  if(x < y){
    tmp = x;
    x = y;
    y = tmp;
  }
 
  // ユークリッドの互除法
  d = x % y;
  while(d!=0){
    x = y;
    y = d;
    d = x % y;
  }
 
  //最大公約数を出力
  printf("%d\n", y);
 
  return 0;
}
  



Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

pint dp[1<<19];
int main(){
    int n,ai;
    cin>>n;
    rep(i,1<<n){
        cin>>ai;
        dp[i]={ai,0};
    }
    rep(i,n){
        rep(j,1<<n)if(j>>i&1){
            int id=j^(1<<i);
            pint tmp=dp[j];
            if(tmp.first<dp[id].second) tmp=dp[id];
            else if(tmp.second<dp[id].first) tmp={max(tmp.first,dp[id].first),min(tmp.first,dp[id].first)};
            dp[j]=tmp;
        }
    }
    int mx=dp[0].first+dp[0].second;
    FOR(i,1,1<<n){
        mx=max(mx,dp[i].first+dp[i].second);
        cout<<mx<<endl;
    }
    return 0;
}

Measured memory_bytes: 7168
#include<stdio.h>
int main()
{
    int a,b,c,count=0,temp,i;
    scanf("%d%d%d",&a,&b,&c);
    if(a>b)
    {
        temp=b;
        b=a;
        a=temp;
    }
    for(i=a;i<=b;i++)
    {
        if(c%i==0)
            count++;
    }
    printf("%d\n",count);
    return 0;
}



Measured memory_bytes: 2100
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        var parray = new bool[1000000];
        GeneratePrime(parray);
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var x = int.Parse(line[1]);
            if (n == 0 && x == 0) break;
            var a = new int[n];
            for (int i = 0; i < n; i++) a[i] = int.Parse(Console.ReadLine().Trim());
            var dp = new bool[x + 1];
            dp[0] = true;
            for (int i = 0; i < n; i++)
                for (int j = a[i]; j <= x; j++)
                    if (dp[j - a[i]]) dp[j] = true;
            var na = 1;
            for (int i = x; i >=0 ; i--) 
                if (dp[i] && parray[i]) { Console.WriteLine(i); na = 0; break; }
            if (na == 1) Console.WriteLine("NA");
        }
    }
    public static void GeneratePrime(bool[] p)
    {
        int prime;
        var m = p.Length;
        var sqrtMax = Math.Sqrt(m);
        var searchList = Enumerable.Range(2, m - 1).ToList();
        do
        {
            prime = searchList.First();
            p[prime] = true;
            searchList.RemoveAll(n => n % prime == 0);
        }
        while (prime < sqrtMax);
        foreach (var x in searchList)
            p[x] = true;
    }
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

int v[300005];
int w[300005];

ll dp[555][100005];

ll rek(int pos, int l) {
	if (pos < 512) return dp[pos][l];
	if (l < w[pos]) return rek(pos/2, l);
	return max(rek(pos/2, l), rek(pos/2, l-w[pos])+v[pos]);
}

int main() {
	int n;
	scanf("%d", &n);
	for (int i=1 ; i<=n ; i++) {
		scanf("%d%d", v+i, w+i);
	}
	for (int i=1 ; i<512 ; i++) {
		for (int j=0 ; j<=100000 ; j++) {
			dp[i][j] = dp[i/2][j];
			if (j>=w[i]) dp[i][j] = max(dp[i][j], dp[i/2][j-w[i]]+v[i]);
		}
	}
	int q;
	scanf("%d", &q);
	for (int i=0 ; i<q ; i++) {
		int pos, l;
		scanf("%d%d", &pos, &l);
		printf("%lld\n", rek(pos, l));
	}
	return 0;
}

Measured memory_bytes: 405020
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define RREP(i,a) for(int (i)=(a)-1;(i)>=0;(i)--)
#define FORR(i,a,b) for(int (i)=(a)-1;(i)>=(b);(i)--)
#define PI acos(-1.0)
#define DEBUG(C) cout<<C<<endl;
#define VI vector<int>
#define VII vector<VI>
#define VL vector<LL>
#define VLL vector<VL>
#define VD vector<double>
#define VDD vector<VD>
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<LL,LL>
#define VPII vector<PII>
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define REVERSE(a) reverse(ALL(a))
#define MP make_pair
#define FORE(a,b) for(auto &&a:b)

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF=1e9;
const int MOD=INF+7;

int main(void){
    int N,K,X,Y;
    cin >> N >> K >> X >> Y;
    int ans=0;
    if(K>=N) ans=X*N;
    else ans=X*K+Y*(N-K);
    cout << ans << endl;
}


Measured memory_bytes: 764
class Stack
  attr_accessor :top, :array, :max

  def initialize(size)
    @top = 0
    @array = Array.new(size)
    @max = size - 1
  end

  def push(data)
    raise "is full" if is_full?
    @top += 1
    array[top] = data
  end

  def pop
    raise "is empty" if is_empty?
    @top -= 1
    array[top + 1]
  end

  def is_full?
    return top >= max
  end

  def is_empty?
    return top == 0
  end

  def last
    array[top]
  end
end

class String
  def str_int?
    Integer(self)
  rescue
    return false
  end
end

data = gets.split(' ')
stack = Stack.new(data.size)

data.each do |d|
  if d.str_int?
    stack.push(d.to_i)
  else
    second = stack.pop
    first = stack.pop
    result = first.send(d, second)
    stack.push(result)
  end
end

puts stack.last



Measured memory_bytes: 6920
#include <iostream>

using namespace std;

int main()
{
    int num;
    string S;
    string A[7] ={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    cin >> S;
    for (int i=0; i<7; i++){
        if (A[i]==S){
            num=i+1;
            break;
        }
    }
    cout << 7-num+1;

    return 0;
}


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

const int N = 19;
const int mod = 1e9 + 7;

int G[N + 2][N], n, m, k;
int dp[1 << N | 5], swp[1 << N | 5];

inline void Inc(int &x, int y)  {
  if ((x += y) >= mod) x -= mod;
}

inline int lowbit(int x) { return x & (- x); }

int main() {
  memset(G, -1, sizeof G);
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1, x, y; i <= k; i ++) {
    scanf("%d%d", &x, &y);
    scanf("%d", &G[x][y - 1]);
  }
  n --;
  int U = 1 << n;
  int *x = dp, *y = swp;
  x[0] = 1;
  for (int i = 1; i <= m; i ++) {
    for (int j = 0; j < n; j ++) {
      memset(y, 0, sizeof (int) * U);
      for (int k = U - 1; ~ k; k --)
        if (x[k]) {
          Inc(y[k], x[k]);
          if (!((k >> j) & 1)) Inc(y[k - lowbit(k & (U - (2 << j))) + (1 << j)], x[k]);
        }
      swap(x, y);
    }
    int key = 0, save = 0;
    for (int j = 0; j < n; j ++) {
      if (~ G[i][j]) key |= G[i][j] << j;
      else save |= 1 << j;
    }
    for (int j = 0; j < U; j ++)
      if (((j ^ key) | save) != save) x[j] = 0;
  }
  int ans = 0;
  for (int i = 0; i < U; i ++) Inc(ans, x[i]);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD = 1e9+7;

int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
	if(i==4)cout<<" ";
	cout<<s[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
const int N=3005;
int R,G,B,n;
int main()
{
	scanf("%d%d%d%d",&R,&G,&B,&n);
	int ans=0;
	for(int r=0;r*R<=n;r++)
		for(int g=0;r*R+g*G<=n;g++)
		{
			int ret=n-r*R-g*G;
			if(ret%B==0) ans++;
		}
	printf("%d",ans);
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

struct edge{
  int from,to;
  double cost;
};
bool operator<(const edge& a,const edge& b){ return a.cost > b.cost; }

struct UnionFind{ // tuyoi
  vector<int> v;
  UnionFind(int n) : v(n, -1) {}
  int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (-v[x] < -v[y]) swap(x, y);
    v[x] += v[y]; v[y] = x;
    return true;
  }
  bool same(int x,int y){ return find(x)==find(y); }
};

int n,m;
double x[11111],y[11111];
edge es[111111];

int main(){
	cin.sync_with_stdio(false);
  cin>>n>>m;
  rep(i,n){
    cin>>x[i]>>y[i];
  }
  double sum=0;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--; b--;
    es[i]=(edge){a,b,sqrt(pow(x[a]-x[b],2)+pow(y[a]-y[b],2))};
    sum+=es[i].cost;
  }
  sort(es,es+m);
  UnionFind uf(n);
  double mst=0;
  rep(i,m){
    if(!uf.same(es[i].from,es[i].to)){
      uf.unite(es[i].from,es[i].to); mst+=es[i].cost;
    }
  }
  printf("%.10f\n", sum-mst);
	return 0;
}

Measured memory_bytes: 3888
#include<bits/stdc++.h>
using namespace std; 
int cost[35][35],color[505][505];
int one[35],two[35],three[35];
int main()
{
    int n,c;
    int ans = 0,cur;
    scanf("%d%d",&n,&c);
    int i,j;
    int ma = 0;
    for(i=1; i<=c; i++)
    for(j=1; j<=c; j++){
    scanf("%d",&cost[i][j]);
    ma = max(ma, cost[i][j]);
    }
    ans = ma * n * n  + 5; 
    
    for(i=1; i<=n; i++)
    for(j=1; j<=n; j++)
    scanf("%d",&color[i][j]);
        int x,y,z;
    for(x = 1; x<=c; x++)
    {
        for(i=1; i<=n; i++)
        for(j=1; j<=n; j++)
        {
            int xx = (i + j)%3;
            if(xx==1)one[x] += cost[ color[i][j]] [ x];
            else if(xx == 2)two[x] += cost[ color[i][j]][x];
            else three[x] += cost[color[i][j]][x];
        }
    }
    

    for(x=1; x<=c; x++)
    {
        for(y=1; y<=c; y++)
        {
            if(x==y)continue;
            for(z = 1; z<=c; z++)
            {
                if(y==z)continue;
                if(x==z)continue;
                cur = one[x] + two[y] + three[z];
                ans = min(ans, cur);
            }
        }
    }
    printf("%d\n",ans);
}

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

namespace AtCoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] token = line.Split(' ');
            int n = int.Parse(token[0]);
            int m = int.Parse(token[1]);

            int[] a = new int[m];
            int[] b = new int[m];
            int[] road = new int[n];

            for(int i = 0; i < m; i++)
            {
                line = Console.ReadLine();
                token = line.Split(' ');
                a[i] = int.Parse(token[0]);
                b[i] = int.Parse(token[1]);
            }

            for(int i = 0; i < n; i++)
            {
                road[i] = 0;
            }

            for(int i = 0; i < m; i++)
            {
                road[a[i] - 1] += 1;
                road[b[i] - 1] += 1;
            }

            foreach(var r in road)
            {
                Console.WriteLine(r);
            }
            
        }
    }

}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

void solve()
{
    ll a,b,n;
    cin>>a>>b>>n;

    ll lo=1,hi=n;
    ll mx=0;
    while(lo<=hi)
    {
        ll x=lo+(hi-lo)/2;
        if((a*x)/b-a*(x/b)>=mx)
        {
            mx=(a*x)/b-a*(x/b);
            lo=x+1;
        }
        else hi=x-1;
    }
    cout<<mx<<endl;
}

int main()
{
    solve();
    return 0;
}



Measured memory_bytes: 3644
$h, $w = gets.split.map(&:to_i)
$s = []
$h.times do
  $s << gets.chomp
end
$d = [[0, 1], [0, -1], [1, 0], [-1, 0]]

def bfs(sx, sy)
  bfs_map = Array.new($h) { Array.new($w, Float::INFINITY) }
  bfs_map[sy][sx] = 0
  q = []
  q << [sy, sx, 0]
  res = -1

  until q.empty?
    y, x, dist = q.shift
    $d.each do |dy, dx|
      ny = y + dy
      nx = x + dx
      next unless nx >= 0 && nx < $w && ny >= 0 && ny < $h && $s[ny][nx] != "#"
      if bfs_map[ny][nx] > dist + 1
        bfs_map[ny][nx] = dist + 1
        res = dist + 1 if dist + 1 != Float::INFINITY && dist + 1 > res
        q << [ny, nx, dist + 1]
      end
    end
  end
  # res = 0
  # bfs_map.each do |row|
  #   row.each do |c|
  #     if c != Float::INFINITY && c > res
  #       res = c
  #     end
  #   end
  # end
  return res
end

ans = -1
$h.times do |sy|
  $w.times do |sx|
    next if $s[sy][sx] == "#"
    t = bfs(sx, sy)
    ans = t if t > ans
  end
end
p ans


Measured memory_bytes: 1788
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    x = II()
    print(8-(x -400)//200) 

    
main()

Measured memory_bytes: 65120
from operator import itemgetter

N, M = map(int, input().split()) # 横に2個
City = [[i] + list(map(int, input().split())) for i in range(1, M+1)]


City = sorted(City, key=itemgetter(2))
City = sorted(City, key=itemgetter(1))

ans = []
pre = 1
seq = 0
for c in City:
    y = c[1]
    if y > pre:
        seq = 1
        pre = y
    else:
        seq += 1
    ans.append([c[0], y, seq])

ans.sort(key=itemgetter(0))
for a in ans:
    pre = str(a[1])
    seq = str(a[2])
    print('0'*(6-len(pre)) + pre + '0'*(6-len(seq)) + seq)

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

struct Edge{
    ll dst;
    ll weight;
    Edge(ll dst, ll weight): dst(dst), weight(weight) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
const ll INFLL = LLONG_MAX/3;
const ll MAX_V = 101;

ll dist[MAX_V][MAX_V];

void WarhshallFloyd(Graph &G){
	ll V = G.size();
	for(int i=0;i<V;i++){
		for(int j=0;j<V;j++){
			if(i==j) dist[i][j] = 0;
			if(i!=j) dist[i][j] = INFLL;
		}
	}
	for(int i=0;i<V;i++){
		for(int j=0;j<G[i].size();j++){
			Edge e = G[i][j];
			dist[i][e.dst] = e.weight;
		}
	}

	for(int k=0;k<V;k++){
		for(int i=0;i<V;i++){
			for(int j=0;j<V;j++){
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	return;
}

int main(){
	ll N, M;
	cin >> N >> M;
	Graph G(N);
	vector<ll> a(M), b(M), c(M);
	REP(i, M){
		cin >> a[i] >> b[i] >> c[i];
		a[i]--;b[i]--;
		Edge e(b[i], c[i]);
		G[a[i]].push_back(e);
		Edge f(a[i], c[i]);
		G[b[i]].push_back(f);
	}

	WarhshallFloyd(G);

	ll res = 0;
	REP(i, M){
		res += (c[i]>dist[a[i]][b[i]]);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve() {
	float d,t,s;
	cin>>d>>t>>s;
	if(d/s <= t) {
		cout<<"Yes";
	}
	else {
		cout<<"No";
	}
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test = 1;
	while(test--) {
		solve();
	}
}



Measured memory_bytes: 3728
n, m = gets.split.map &:to_i
x = gets.split.map &:to_i

if m <= n then
	puts 0
	exit
end

x = x.sort

diff = []

(0...x.size - 1).each{ |i|
	diff << x[i+1] - x[i]
}

diff = diff.sort.reverse

puts x[-1] - x[0] - diff[0...(n-1)].inject(0, :+)


Measured memory_bytes: 11248
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let n: i32 = input();
    if n % 2 == 0 {
        println!("{}", n / 2 - 1);
    } else {
        println!("{}", n / 2);
    }
}


Measured memory_bytes: 4352
def print_row (nums):
    for i in range(len(nums)):
        if i != len(nums) -1 :
            print(nums[i], end = ' ')
        else:
            print(nums[i])
 
n = int(input())
nums = list(map(int, input().split()))
print_row(nums)

for i in range(1,n):
    v = nums[i]
    j = i - 1
    while (j >= 0 and nums[j] > v):
        nums[j+1] = nums[j]
        j -= 1
    nums[j+1] = v
    print_row(nums)


Measured memory_bytes: 5980
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>
#include <limits>
using namespace std;

int main(){
    string s;
    cin >> s;
    string ans;
    for(size_t i = 0; i < s.size(); i++)
    {
        if(s[i] == 'B'){
            if(i == 0) continue;
            else if(ans == "") continue;
            else ans.erase(ans.size()-1);
        }
        else{
            ans += s[i];
        }
    }
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int n, x[109], y[109];
    long long h[109];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i] >> h[i];
    }
    if(n==0){
        cout << x[0] << ' ' << y[0] << ' ' << h[0] << endl;
    }
    else{
        bool ans = true;
        for(int i=0;i<=100;i++){
            for(int j=0;j<=100;j++){
                ans=true;
                long long H=0;
                for(int k=0;k<n;k++){
                    if(h[k]>0){
                        H = h[k]+abs(i-x[k])+abs(j-y[k]);
                        break;
                    }
                }
                for(int k=0;k<n;k++){
                    if(max(H-abs(i-x[k])-abs(j-y[k]), (long long)0)!=h[k]){
                        ans=false;
                        break;
                    }
                }
                if(ans){
                    cout << i << ' ' << j << ' ' << H << endl;
                    break;
                }
            }
            if(ans)break;
        }
    }
}

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

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};


const int MOD = 1000000007;
using mint = Fp<MOD>;


int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}
int gyaku(int n){
    return modpow(n,MOD-2);
}

//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap
auto pfactor(int n){
  map<int,int> res;
  int t=sqrt(n);
  for(int i=2;i<=t;i++){
    for(;n%i==0;n/=i)res[i]++;
  }
  if(n>1)res[n]++;
  return res;
}
vector<int>kai(0);
void kaizyou(vector<int>&kai){
    rep(i,kai.size()){
        kai[i+1]=kai[i]*(i+1)%MOD;
      }
  }
int comb(int a,int b){
  return (kai[a]*gyaku(kai[a-b]))%MOD*gyaku(kai[b])%MOD;
}
////////////////////////////////////////////////////////////////////////
signed main() {
  int n,d;
  cin>>n>>d;
  int ans=0;
  rep(i,n){
    int x,y;
    cin>>x>>y;
    if(x*x+y*y<=d*d)ans++;
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        String s = sc.next();
        int l = s.length();
        if (k >= l) {
            System.out.println(s);
        } else {
            System.out.println(s.substring(0, k) + "...");
        }
    }
}

Measured memory_bytes: 38656
from collections import deque
INF = 10**9

n, x, y = map(int, input().split())
x, y = x-1, y-1
ans = [0] * n

for sv in range(n):
  dist = [INF] * n
  q = deque()

  def push(v, d):
    if dist[v] != INF: return
    dist[v] = d
    q.append(v)

  push(sv, 0)

  while q:
    v = q.popleft()
    d = dist[v]
    if v-1 >= 0: push(v-1, d+1)
    if v+1 < n: push(v+1, d+1)
    if v == x: push(y, d+1)
    if v == y: push(x, d+1)

  for i in range(n):
    ans[dist[i]] += 1

for i in range(n):
  ans[i] //= 2

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

Measured memory_bytes: 52956
#include <stdio.h>

int main(void){
  int a,b;
  scanf("%d",&a);
  scanf("%d",&b);
  
  int c = a*b;
  
  if(c%2 == 0){
    printf("Even");
  }else{
    printf("Odd");
  }
  
  return 0;
}

Measured memory_bytes: 128
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  int n; cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];

  int q; cin >> q;
  for (int i = 0; i < q; ++i) {
    int k; cin >> k;
    cout << distance(a.begin(), lower_bound(all(a), k)) << " " << distance(a.begin(), upper_bound(all(a), k)) << '\n';
  }

  return 0;
}


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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a
#define lcoutln(a) cout << a << endl
#define lcerr(a) cerr << a
#define lcerrln(a) cerr << a << endl
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007

signed main()
{
	init();
	solve();
}

ll N, T, A, res;

void init()
{
	cin >> N;
}

void solve()
{
	T = A = 1;
	res = 2;
	rep(i, N) {
		CIN(int, t);
		CIN(int, a);
		ll T1, T2, A1, A2;
		T1 = ((T + t - 1) / t) * t;
		A1 = T1 / t * a;
		A2 = ((A + a - 1) / a) * a;
		T2 = A2 / a * t;
		T = max(T1, T2);
		A = max(A1, A2);
	}
	cout << T + A << endl;
}



Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=100000+19;

int A[N];
int n,L,T,x,w,tmp;

int main(){
	n=IN(),L=IN(),T=IN();
	For(i,0,n){
		x=IN(),w=IN();
		if (w==1){
			A[i]=(x+T)%L;
			tmp=(tmp+(x+T-A[i])/L)%n;
		} else{
			A[i]=(x-T%L+L)%L;
			tmp=(tmp+(x-T-A[i])/L)%n;
		}
	}
	sort(A,A+n);
	tmp=(tmp%n+n)%n;
	For(i,tmp,n) printf("%d\n",A[i]);
	For(i,0,tmp) printf("%d\n",A[i]);
}

Measured memory_bytes: 1536