akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int q;
    cin>>q;
    vector<int > v;
    for(int i=0;i<q;i++)
    {
        int t;
        cin>>t;
        v.push_back(t);
    }
    int a;
    cin>>a;
    while(a--)
    {
        int t;
        cin>>t;
        auto p = equal_range(v.begin(), v.end(), t);
        cout<<(p.first-v.begin())<<" "<<(p.second-v.begin())<<endl;
    }

}



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

int main(){
  int n, ans=0; cin>>n;
  vector<int> d(n);
  for(int i=0;i<n;i++)cin>>d[i];
  
  for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++){
    ans += d[i]*d[j];
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h;
string s;
vector<ll> v;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(50, vector<ll>(50, INF));
 
int main() {
  string ss;
  cin >> ss;
  cin >> s;
  cout << "A" << s[0] << "C" << endl;
}

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

int T, N, M, K;
int A, B, C, D;

int main()
{
	scanf("%d %d", &A, &B);
	printf("%d", A*B);
	return 0;
}

Measured memory_bytes: 3828
#include<cmath>
#include<cstdio>
int main()
{
	int n;
	scanf("%d",&n);
	int pd=1;
	for(int i=1;i<=n;i++){
		int t,a,b;
		scanf("%d %d %d",&t,&a,&b);
		if(a+b<=t){
			t-=a+b;
			if(t%2!=0){
				pd=0;
				printf("No\n");
				break;
			}
		}else{
			pd=0;
			printf("No\n");
			break;
		}
	}
	if(pd){
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 128
DBG = !true
n,m = gets.split.map{|z| z.to_i}
a = gets.split.map{|z| z.to_i}

a.reject!{|z| z==6} if a.include?(9)
a.reject!{|z| z==3} if a.include?(5)
a.reject!{|z| z==2} if a.include?(5)
a.reject!{|z| z==2} if a.include?(3)
a.sort!
$a = a
use = [ 0,2,5,5,4,5,6,3,7,6 ]
$use = use
$sortu = a.map{|z| use[z]}.sort
base = $sortu[0]
mass = (n-(base)*(a[-1]))/base
rest = n - mass*base
$ans = Array.new(10, 0)
$best = Array.new(10, 0)
$best[0] = -1

if DBG
  print a
  print $sortu
  puts "base #{base} mass #{mass} rest #{rest}"
end

def better(ans, best)
  return true if best[0] == -1
  asum = ans.inject(:+)
  bsum = best.inject(:+)
  return true if asum > bsum
  return false if bsum > asum
  ($a.size-1).downto(0) { |i|
    u = $use[$a[i]]
    return true if ans[u] > best[u]
    return false if ans[u] < best[u]
  }
  return false # either ok
end

def srch(i,r)
  sz = $sortu.size
  puts "srch i #{i} r #{r} called sz #{sz}" if DBG
  u = $sortu[i]
  if i == sz-1
    return if r % u != 0
    $ans[u] = r / u
    if better($ans, $best)
      $best = $ans.map{|z|z}
      if DBG
        print $best
        puts "updated best"
      end
    end
  else
    for j in 0..(r/u)
      $ans[u] = j
      srch(i+1, r - j*u)
    end
  end
end

srch(0,rest)
print $best if DBG
(a.size-1).downto(0) { |i|
  u = use[a[i]]
  rpt = $best[u] + (u == base ? mass : 0)
  puts "i #{i} ai #{a[i]} u #{u}" if DBG
  rpt.times { print a[i] }
}
puts ""


Measured memory_bytes: 3836
#include<stdio.h>
int main()
{
	char S[]= "aaa";//とりあえず代入
	scanf("%s",&S);//ここで真の値を代入
	//printf("入力された文字列は:%s", S);
	if (S[0] == S[1] || S[1] == S[2] || S[0] == S[2]) {
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}

	return 0;
}

Measured memory_bytes: 128
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;
ll divi[2000006];
signed main()
{
    fast;
  
    ll n,i,j,ans=1;
    cin>>n;
    for(i=1;i<=1000006;i++)
    {
    	for(j=i;j<=1000006;j += i)
    	{
    		divi[j]++;
    	}
    }
    

    for(i=2;i<n;i++)
    {
    	ans += divi[i];
    }
    cout<<ans;
}

Measured memory_bytes: 11460
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
const int INF = 1e9;
using namespace std;

main() {
    int A,B; cin >> A >> B;
    if(A>=0 && B>=0 && B>=A || A<=0 && B<=0 && B>=A){
        cout << abs(abs(A)-abs(B)) << endl; 
    }
    else if(A>0 && B>0 && A>B || A<0 && B<0 && A>B){
        cout << abs(abs(A)-abs(B))+2 << endl;
    }
    else cout << abs(abs(A)-abs(B))+1 << endl;
}

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

int main() {
	string S, Cur;
	long long COUNT = 1;
	cin >> S;
	Cur = S[0];
	for (int i = 1; i < S.size(); i++) {
		if (Cur.size() == 1) {
			if (S[i] != Cur[0]) {
				Cur = S[i];
				COUNT++;
			}
			else {
				if (i == S.size() - 1) {
					break;
				}
				else {
					Cur = S.substr(i, 2);
					i++;
					COUNT++;
				}
			}
		}
		else {
			Cur = S[i];
			COUNT++;
		}
	}
	cout << COUNT << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

ll solve(ll a, ll b){
  if(a==b) return (a-1)*2;
  ll lim = a*b-1;
  ll low = 1, high = 1LL << 31;
  while(high-low>1){
    ll mid = (low+high) / 2;
    ll mul = (mid+1)/2 * (mid+1 - (mid+1)/2);
    if (mul > lim) high = mid;
    else low = mid;
  }
  return low - 1;
}

int main(){
  int q; cin >> q;
  rep(i,q){
    ll a,b; cin >> a >> b;
    cout << solve(a,b) << endl;
  }
  
  return 0;
}

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

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

  ll n;
  cin >> n;

  string ans;

  do {
    --n;
    
    ans += 'a' + (n % 26);
    n /= 26;

  } while (n >= 1);

  reverse(ans.begin(), ans.end());
  cout << ans << '\n';

  return (0);
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<string,int> P;
struct node{
  node *next;
  P v;
  node(){next=NULL;}
  node(P v):v(v){next=NULL;}
};
struct mqueue{
  node *head,*cur;
  mqueue(){
    head=new node();
    cur=NULL;
  }
  void push(P v){
    node *tmp=new node(v);
    if(cur!=NULL) cur->next=tmp;
    cur=tmp;
    if(head->next==NULL) head->next=cur;
  }
  void pop(){
    if(head->next==NULL) return;
    node *tmp=head->next->next;
    if(tmp!=NULL) delete(head->next);
    head->next=tmp;
  }
  P front(){
    return head->next->v;
  }
  bool empty(){
    return head->next==NULL;
  }
};
signed main(){
  int n,q;
  cin>>n>>q;
  string name[n];
  int time[n];
  for(int i=0;i<n;i++) cin>>name[i]>>time[i];
  int cur=0;
  mqueue que;
  for(int i=0;i<n;i++) que.push(P(name[i],time[i]));
  while(!que.empty()){
    P p=que.front();que.pop();
    if(p.second<=q){
      cur+=p.second;
      cout<<p.first<<" "<<cur<<endl;
      continue;
    }
    p.second-=q;
    cur+=q;
    que.push(p);
  }
  return 0;
}

Measured memory_bytes: 7864
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn = null;
		List<Integer> result = new ArrayList<Integer>();
		Map<String, Integer> rome = new HashMap<String, Integer>();
		rome.put("I", 1); rome.put("V", 5); rome.put("X", 10); rome.put("L", 50); rome.put("C", 100);
		rome.put("D", 500); rome.put("M", 1000);
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			while( stdIn.hasNext() ){
				String str = stdIn.next();
				Integer sum = 0;
				for(int i = 0; i < str.length()-1; i++){
					if( rome.get(Character.toString(str.charAt(i))) >= rome.get(Character.toString(str.charAt(i+1))) ){
						sum += rome.get(Character.toString(str.charAt(i)));
					} else {
						sum -= rome.get(Character.toString(str.charAt(i)));
					}
				}
				sum += rome.get(Character.toString(str.charAt(str.length()-1)));
				result.add(sum);
			}
			for(Integer sum : result){
				System.out.println(sum);
			}
		} finally {
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
}

Measured memory_bytes: 12000
import java.util.Scanner;

public class Main {

	static int m;
	static int n;
	static int[] books;

	public static void main(String[] args) {
		doIt();

	}
	static void doIt(){
		Scanner sc = new Scanner(System.in);
		m = sc.nextInt();
		n = sc.nextInt();
		while(0 < m + n){
			books = new int[n];
			for(int i = 0; i < n; i++) books[i] = sc.nextInt();
			int max = 1500000;
			int min = 0;
			int mid = 0;
			while(min < max){
				mid = (max + min) / 2;
				if(check(mid)) max = mid;
				else min = mid + 1;
			}
			System.out.println(max);
			m = sc.nextInt();
			n = sc.nextInt();
		}
	}

	static boolean check(int len){
		boolean ret = false;
		int index = 0;
		int l = 0;
		for(int i = 0; i < m; i++){
			l = len;
			while(0 < l){
				if(books[index] <= l){
					l -= books[index++];
					if(index == n) return 0 <= l? true : false;
				}
				else break;
			}
		}
		return false;
	}

}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
#include <cmath> 
using namespace std;
const int p=31;
const int m=1e9+9;
typedef long long ll;

//return res.empty() ? "0" : res;
/* istringstream ss(text);
    string s;
    while(ss>>s)*/
static auto speedup = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return nullptr;
}();

int main (){

    #ifndef ONLINE_JUDGE					
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n;
    cin>>n;
    int x;
    x=n%10;
    if(x==2||x==4||x==5||x==7||x==9)
    	cout<<"hon"<<'\n';
    else if(x==0||x==1||x==6||x==8)
    	cout<<"pon"<<'\n';
    else
    	cout<<"bon"<<'\n';
}


Measured memory_bytes: 3612
a,b,c,d = map(int,input().split())
if a == 0 and a!=b:
    a += 1
if b == 0 and a!=b:
    b -= 1
if c == 0 and c!=d:
    c += 1
if d == 0 and c!=d:
    d -= 1
num1 = a*c
num2 = a*d
num3 = b*c
num4 = b*d
print(max(num1,num2,num3,num4))

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

int main ()
{
	int x, y;
	while ((cin >> x >> y), x, y) {
	
	
	for (int i=1; i<=x; i++)
	{
		if (i==1 || i==x)
		{
			for (int k=1; k<=y; k++)
			{
				cout << "#";
				if (k==y)
					cout << endl;
			}
		} else
		{
			for (int k=1; k<=y; k++)
			{
				if (k==1 || k==y)
					cout << "#";
				else
					cout << "."	;
				if (k==y)
					cout << endl;	
			}
		}
	}
	cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3044
#include "bits/stdc++.h"

using namespace std;

#define int long long int
#define cont continue;
#define ff first
#define ss second
#define pb push_back
#define ins insert
#define mp make_pair
#define endl '\n'


typedef vector<int> vi;
typedef set<int> si;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
typedef map<int, int> mi;

//const
#define EPS 1e-9
#define INF LLONG_MAX
const int mod = 1000 * 1000 * 1000 + 7; //1e9+7
const double PI = 3.14159265358979323846264;
const pi steps[] = {{1, 0}, {0, 1}, { -1, 0}, {0, -1}, {1, -1}, {1, 1}, { -1, -1}, { -1, 1}}; //for (auto [dx,dy] : steps)
//const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};

// inputs & output & debug
#define w(t) int t; cin>> t; while(t--)

#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

//useful functions
//#define deb(x) cout<<#x<<": "<<x<<endl;
#define isPowOfTwo(x) return (x && (!(x&(x-1))));
#define sz(a) (int)((a).size())
#define present(c,x) ((c).find(x) != (c).end())
#define ip_arr(a,n)   for(int i=0;i<n;i++) cin>>a[i];
#define op_arr(arr,n) for(int i=0;i<n;i++) cout<<arr[i]<<"\n"; cout<<endl;
#define fill_arr(arr,n,i) fill(arr,arr+n,i)
#define fill_vec(v,n,i) fill(v.begin(),v.begin()+n,i);
#define sortv(a) sort(a.begin(),a.end())

void fio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
void setUpLocal()
{
#ifndef ONLINE_JUDGE
	freopen("/Users/asuryana/Documents/CP/input.txt", "r", stdin);
	freopen("/Users/asuryana/Documents/CP/output.txt", "w", stdout);
#else
#define cerr if(0) cerr
#endif
}

const int maxN = 1e7;
// vi gp[gp_size];
// int vis[gp_size];
// int cnt[gp_size];
int n, W;
int w[101], v[101];

int dp[100007][107]; // vSumMax=vMax*n : 1000*100

//https://www.youtube.com/watch?v=mtC0Y_uyeVY

int knap(int valRemaining, int ele)
{
	if (ele == n)
		return valRemaining == 0 ? 0 : INT_MAX; // because we want knap(v,ele) to return w to reach EXACTLY 'v' value
	//return 0;

	if (dp[valRemaining][ele] != -1)
		return dp[valRemaining][ele];

	int ans = knap(valRemaining, ele + 1); // dont pick element number 'ele'

	if (v[ele] <= valRemaining)
	{
		ans = min(ans, w[ele] + knap(valRemaining - v[ele], ele + 1));
	}

	return dp[valRemaining][ele] = ans;

}
int helper(int vmax)
{
	for (int val = vmax; val >= 0; val--)
	{
		if (knap(val, 0) <= W) { // knap(val,0) = w : get value of val with weight w
			return val;
		}
	}

	return 0;

}
void solve()
{
	cin >> n >> W;

	for (int i = 0; i < n; i++)
	{
		cin >> w[i] >> v[i];
	}

	memset(dp, -1, sizeof(dp));

	int vmax = 0;
	for (int i = 0; i < n; i++) vmax += v[i];

	cout << helper(vmax);
}

int32_t main()
{
	fio();
	//setUpLocal();
	return solve(), 0;
}


Measured memory_bytes: 87272
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))
X.sort()
#print(X)

X_diff = [X[i+1] - X[i] for i in range(M-1)]
X_diff.sort(reverse=True)
#print(X_diff)

if M<=N:
  print(0)
else:
  print(X[-1] - X[0] - sum(X_diff[:N-1]))

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

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

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

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

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
int main(){
    CIN(A);CIN(B);CIN(C);
    CIN(K);
    I vec;
    vec.pb(A);
    vec.pb(C);
    vec.pb(B);
    sort(ALL(vec));
    int ans = max({A,B,C});
    for(int a = 0;a <K;a++){
        ans*=2;
    }
    COUT(ans+vec.at(0)+vec.at(1));
    return 0;
}


Measured memory_bytes: 256
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

f(X, A, B) :- B mod A =:= 0, X is A + B, !.
f(X, A, B) :- X is B - A, !.

main :-
    get_number(A),
    get_number(B),
    f(X, A, B),
    writeln(X).


Measured memory_bytes: 8176
n, m, c = [int(i) for i in input().split()]
b_list = [int(i) for i in input().split()]

answer = 0
for j in range(n):
  a_list = [int(i) for i in input().split()]
  sum_of_feature = c
  for (b, a) in zip(b_list, a_list):
    sum_of_feature += b * a
  if sum_of_feature > 0:
    answer += 1

print(answer)


Measured memory_bytes: 3060
#include <stdio.h>

using namespace std;

int max(int a, int b){
	if(a > b) return a;
	return b;
}

int main(){
	long long n, m;
	scanf("%lli %lli", &n, &m);
	long long res = 1;
	for(long long i=1; i*i<=m; i++){
		if(m % i == 0){
			if(i >= n){
				res = max(res, m/i);
			}
			if(m/i >= n){
				res = max(res, i);
			}
				
		}
	} 
	printf("%lli", res);
	return 0;
}

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

#define endl '\n'

using namespace std;

const int MAXN=3e3+3;
int dp[MAXN][MAXN];
char res[MAXN];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string a,b;
    cin>>a>>b;
    int n=a.size(),m=b.size();
    for(int i=1;i<=n;++i){
        for(int i2=1;i2<=m;++i2){
            if(a[i-1]==b[i2-1]){
                dp[i][i2]=dp[i-1][i2-1]+1;
            }else{
                dp[i][i2]=max(dp[i-1][i2],dp[i][i2-1]);
            }
        }
    }
    int ind=dp[n][m]-1,i=n,i2=m;
    while(i>0 and i2>0){
        if(a[i-1]==b[i2-1]){
            res[ind--]=a[i-1];
            --i;
            --i2;
        }else if(dp[i-1][i2]>dp[i][i2-1]){
            --i;
        }else{
            --i2;
        }
    }
    for(int i=0;i<dp[n][m];++i){
        cout<<res[i];
    }
    cout<<endl;
return 0;
}

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

ll mod=pow(10,9)+7;

ll mp(ll x,ll y){
  long long res = 1;
  while (y>0) {
    if (y&1)res=res*x%mod;
    x=x*x% mod;
    y>>=1;
  }
  return res;
}

int main(){
  string S;
  cin >> S;
  ll ans=0;
  ll cnt=0;
  int len=S.size();
  rep(i,len){
    if(S[i]=='1'){
      ans=(ans+mp(2,cnt)*mp(3,len-i-1)%mod)%mod;
      cnt++;
    }
  }
  ans=(ans+mp(2,cnt))%mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
a = (65..90).map(&:chr) + (97..122).map(&:chr)
loop do
    n = gets.to_i
    break if n == 0
    k = gets.split.map(&:to_i)
    s = gets.strip
    puts s.each_char.map.with_index{|c,i|
        id = a.index(c) - k[i%n]
        id += 52 if id < 0
        a[id]
    }.join
end

Measured memory_bytes: 6128
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int n, h[100007], dp[100007];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> h[i];
	}
	dp[1] = 0;
	dp[2] = dp[1] + abs(h[2] - h[1]);
	for(int i = 3; i <= n; i++){
		dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
	}
	cout << dp[n];
}


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

int min(int x,int y){
	if (x<=y){
		return x;
	}else{
		return y;
	}
	
}

int max(int x,int y){
	if (x>=y){
		return x;
	}else{
		return y;
	}
	
}

int main(){
	int N,m,range,a1,a2,a,i;
	cin >> N;
	cin >> a1;
	cin >> a2;
	m=min(a1,a2);
	range=a2-a1;
	for (i=3;i<=N;i++){
		cin >> a;
		range=max(range,a-m);
		m=min(m,a);
	}
	cout << range << endl;
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int main()
{
double b,d;
cin>>b>>d;
double si(b/0.08);
double kl=si*0.1;
double mcit(-1);
if(floor(kl)==d)
mcit=si;
double spot(d/0.1);
double bobby=spot*0.08;
if(floor(bobby)==b&&bobby>mcit)
mcit=spot;
cout<<ceil(mcit);
}


Measured memory_bytes: 256
a=int(input())
a_keta=len(str(a))
if a_keta==1:print(a)
if a_keta==2:print(9)
if a_keta==3:print(9+a-100+1)
if a_keta==4:print(909)
if a_keta==5:print(909+a-10000+1)
if a_keta==6:print(90909)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
	  result=(result*base)%modulus;
	  exponent=exponent>>1;
	  base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll g[301][301];
pll pos[MAX];
ll pre[MAX];
ll n,m,D;
ll ans[MAX];
vector<vl> ask[MAX];
int main(){FAST;
cin>>n>>m>>D;
for(ll i=1;i<=n;i++){
	for(ll j=1;j<=m;j++){
		cin>>g[i][j];
		pos[g[i][j]]={i,j};
	}
}
ll q;
cin>>q;
for(ll i=1;i<=q;i++){
	ll l,r;cin>>l>>r;
	ll rem = l%D;
	if(rem == 0)rem = D;
	ask[rem].pb({l,r,i});
}
for(ll i=1;i<=D;i++){
	ll prex = pos[i].first;
	ll prey = pos[i].second;
	for(ll j=i,k=1;j<=n*m;j+=D,k++){
		ll MH = abs(pos[j].first-prex)+abs(pos[j].second-prey);
		pre[k]=pre[k-1]+MH;
		prex=pos[j].first;
		prey=pos[j].second;
	}
	for(auto it:ask[i]){
		ll idx = it[2];
		ll L = it[0];
		ll R = it[1];
		ll l = (L-i)/D+1;
		ll r = (R-i)/D+1;
		ans[idx]=pre[r]-pre[l];
	}
}
for(ll i=1;i<=q;i++)cout<<ans[i]<<'\n';
return 0;
}

Measured memory_bytes: 13184
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,temp1,temp2;
	cin>>a>>b>>c;
	temp1=a;

	a=b;
	b=temp1;
	
	temp2=a;
	a=c;
	c=temp2;
	cout<<a<<" "<<b<<" "<<c<<endl;

}


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

int main() {
	int l,r;
	cin>>l>>r;
	bool a[2019] = {};
	for(int i = l; i <= min(l+2019,r); i++) {
		a[i%2019] = true;
	}
	int ans = 1<<25;
	for(int i = 0; i < 2019; i++) {
		for(int j = i+1; j < 2019; j++) {
			if(a[i]&&a[j]) {
				int temp = (i*j)%2019;
				ans = min(ans,temp);
			}
		}
	}
	cout << ans << endl;
}


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

const ll INF = 1001001001;

int main(){
    int n, k; cin >> n >> k;
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    int ans = -INF;
    for(int i = 0; i <= n; i++){
        for(int j = 0 ; j <= n; j++){
            if(i + j > n) continue;
            int cnt = j + i;
            if(cnt > k) continue;
            int sum = 0;
            priority_queue<int, vector<int>, greater<int>> que;
            for(int l = 0; l < i; l++){
                que.push(v[l]);
                sum += v[l];
            }
            for(int r = n-1; r >= n - j; r--){
                que.push(v[r]);
                sum += v[r];
            }
            while(!que.empty() && cnt < k){
                int tmp = que.top(); que.pop();
                if(tmp < 0){
                    sum -= tmp;
                    cnt++;
                }
                else break;
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3612
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
#define All(a) (a).begin(),(a).end()
#define RAll(a) (a).rbegin(),(a).rend()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
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 (a > b) { a = b; return 1; }
	return 0;
}

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

	int n;
	cin >> n;

	int pre;
	cin >> pre;

	ll ans = 0;
	REP(i, n - 1) {
		int a;
		cin >> a;

		if (a < pre) {
			ans += pre - a;
		}
		else {
			pre = a;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3604
from collections import defaultdict

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    
    divisors.sort()
    return divisors

n = int(input())
a = list(map(int, input().split()))

div1 = set(make_divisors(a[0]))
div2 = set(make_divisors(a[1]))
common = div1 | div2

cnt = defaultdict(int)
for i in range(n):
    for j in common:
        if a[i] % j == 0:
            cnt[j] += 1

for k, v in sorted(cnt.items(), reverse=True):
    if v == n or v == n-1:
        print(k)
        exit()

Measured memory_bytes: 63856
#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)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int Z_Algo(string str,int offset)
{
    int n = (int)str.size() - offset;
    int res=0;
    vector<int> a(n);
    a[0] = n;
    int start = -1, end = -1;
    for (int i = 1; i < n; i++)
    {
        int &same = a[i];
        if(start != -1)
        {
            same = min(end - i,a[i-start]);
            same = max(0,same);
        }
        while (same < n and str[same + offset] == str[i + same + offset])
            same++;

        if(end < i+same)
        {
            end = i+same;
            start = i;
        }
        if(i >= same)
        chmax(res,same);
    }
    return res;
}

int main()
{
    int N,ans=0;
    cin>>N;
    string str;
    cin>>str;
    for (int i = 0; i < N; i++)
    {
        chmax(ans,Z_Algo(str,i));
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define int long long
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    int n, k;
    int a[222222], d[222222];
    cin>>n>>k;
    for (int i = 0; i < n; i++) {
        cin>>a[i];
        a[i]--;
        d[i] = a[i];
    }
    int now = 0;
    while (k) {
        if (k % 2) now = a[now];
        for (int i = 0; i < n; i++) {
            d[i] = a[a[i]];
        }
        for (int i = 0; i < n; i++) {
            a[i] = d[i];
        }
        k /= 2;
    }
    cout<<now + 1<<endl;
}

Measured memory_bytes: 6776
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int a,b; 
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	in(a);in(b);printf("%d\n",max(0,a-2*b));
	return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int main() {
    int n, a[20], b[20], c[20], sum = 0;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < n; ++i)
        cin >> b[i];
    for (int i = 0; i < n - 1; ++i)
        cin >> c[i];
    for (int i = 0; i < n; ++i) {
        sum += b[a[i] - 1];
        if (i > 0 && a[i] - a[i - 1] == 1)
            sum += c[a[i - 1] - 1];
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <limits>//setprecision
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#include <numeric> //accumulate,,,
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
long long MOD = 1000000007;

void chmax(long long &a,long long b){if(a < b) a = b;}
void chmin(long long &a,long long b){if(a > b) a = b;}

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a; else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

//dist[i][j]:iからjまで行く最短距離
int dist[205][205];
vector<int> color(205,-1);
vector<vector<int>> Edge(205);
vector<bool> seen(205);
bool ok = true;

void dfs(int from,int nowColor){
    seen.at(from) = true;
    for(int to : Edge.at(from)){
        if(color.at(to) != -1 && color.at(to) != nowColor){
            ok = false;
        }
        if(color.at(to) == -1){
            color.at(to) = nowColor;
        }
        if(seen.at(to)) continue;
        dfs(to,(nowColor^1));
    }
    return;
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N;cin >> N;
    for(int i = 0;i<205;i++) for(int j = 0;j<205;j++) dist[i][j] = inf;
    for(int i = 0;i<205;i++) dist[i][i] = 0;
    
    for(int i = 0;i<N;i++){
        for(int j = 0;j<N;j++){
            char C;cin >> C;
            int S = C-'0';
            if(S == 1){
                Edge.at(i).push_back(j);
                dist[i][j] = 1;
            }
        }
    }
    //二部グラフじゃないなら-1（それはそう）
    dfs(0,0);
    if(!ok){
        cout << -1 << endl;
        return 0;
    }
    //BFSで所属番号を決めていくのが良いが、次数が低いものから決めると、無駄が出来なくて良い
    //これは、嘘で、破滅する場合がある（それはそう）
    //単純に距離が一番遠い頂点を探せばよいので、O(N^3)のwarshall-floydでよさそう

    for(int k = 0;k<N;k++){
        for(int i = 0;i<N;i++){
            for(int j = 0;j<N;j++){
                if(dist[i][j] > dist[i][k]+dist[k][j]){
                    dist[i][j] = dist[i][k]+dist[k][j];
                }
            }
        }
    }
    int ans = 0;
    for(int i = 0;i<N;i++){
        for(int j = 0;j<N;j++){
            ans = max(ans,dist[i][j]+1);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3880
let id x = x
let n = Scanf.scanf "%d\n" id

let array = Array.init n (fun _ -> Scanf.scanf "%d " id)
let () = Array.sort compare array  
let list = Array.to_list array

let rec func list list' list'' =
  match list with
  | [] -> (list',list'')
  | hd :: rest ->
     if hd <= 399 && not (List.mem 1 list') then func rest (1::list') list'' else
       if hd >= 400 && hd <= 799 && not (List.mem 2 list') then func rest (2::list')  list'' else
         if hd >= 800 && hd <= 1199 && not (List.mem 3 list') then func rest (3::list')  list'' else
           if hd >= 1200 && hd <= 1599 && not (List.mem 4 list') then func rest (4::list') list'' else
             if hd >= 1600 && hd <= 1999 && not (List.mem 5 list') then func rest (5::list') list'' else
               if hd >= 2000 && hd <= 2399 && not (List.mem 6 list') then func rest (6::list') list'' else
                 if hd >= 2400 && hd <= 2799 && not (List.mem 7 list') then func rest (7::list') list'' else
                   if hd >= 2800 && hd <= 3199 && not (List.mem 8 list') then func rest (8::list')  list'' else
                     if  hd >= 3200 then func rest list' (1::list'') else func rest list' list''
                       
let (x',y') = func list [] [] 
let (x,y) = (List.length x',List.length y')

let min = if x = 0 then 1 else x
let max = x + y

let () =
  Printf.printf "%d %d\n" min max

Measured memory_bytes: 384
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}
int dp[(int)1e6 + 1] = {0};

int main()
{
        //input->compute->output//
        int N;
        cin >> N;

        vector<int> vec(N), copy(N);
        for (int i = 0; i < N; i++)
        {
                cin >> vec[i];
        }

        for (int i = 0; i < N; i++)
        {
                copy[i] = vec[i];
        }

        sort(copy.begin(), copy.end());

        for (int i = 0; i < N; i++)
        {
                if (vec[i] == copy[N - 1])
                {
                        cout << copy[N - 2] << endl;
                }
                else
                {
                        cout << copy[N - 1] << endl;
                }
        }

        return 0;
}


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

#define ll long long
#define lp(i,n) for(int i=0; i<n; i++)
#define pb push_back
const long double pi=3.141592654;
#define OSOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

const ll inf = 1e9 +5, mod = 1e9+7,N = 1e5+5;

    int val[N],weights[N];
    ll dp[102][N];
int main()
{
    OSOS
	ll n,w;
    cin>>n>>w;

    for(int i=1; i<=n; i++)
    	cin>>weights[i]>>val[i];

    	for(int item = 1; item <= n; item++)
    for(int rem = 1; rem <= w; rem++)
    	{
    		ll op1,op2;
    		op1 = dp[item-1][rem];
    		op2 = 0;
    		if(rem >= weights[item])
    		{
    			op2 = val[item] + dp[item-1][rem - weights[item]];
    		}
    		dp[item][rem] = max(op1,op2);
    	}

    cout<<dp[n][w];

    return 0;
}



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

int main(){
  
  int S[5],A[5],ans=0;
  int Q=1000000;
  cin>>S[0]>>S[1]>>S[2]>>S[3]>>S[4];
  
  if(S[0]==S[1] && S[1]==S[2] && S[2]==S[3] && S[3]==S[4]){
    if(S[0]%10==0){ans += 10;}
    ans += ((S[0]+9)/10)*50;
    ans -= 10;
    ans += S[0]%10;
    cout<<ans<<endl;
  }
  
  else{
  if(S[0]%10==0 && S[1]%10==0 && S[2]%10==0 && S[3]%10==0 && S[4]%10==0) ans += 10;
  for(int i=0; i<5; ++i){
    A[i]=(S[i]+9)/10*10;
    ans += A[i];
    if(Q>=(S[i]%10) && S[i]%10>0) Q=S[i]%10;
  }
    if(S[0]%10==0 && S[1]%10==0 && S[2]%10==0 && S[3]%10==0 && S[4]%10==0) Q=0;
  ans -= 10;
  ans += Q;
  cout<<ans<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

vl calc_divisor(ll n) {
  vl res;
  for (ll i = 1; i*i <= n; i++) {
    if (n%i == 0) {
      res.push_back(i);
      if (i != n/i) res.push_back(n/i);
    }
  }
  return res;
}

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

  ll n;
  cin >> n;
  ll ans = 0;
  auto f = [&](ll x) {
    x--;
    if (x == 0) return;
    if (n/x == n%x) {
      ans += x;
    }
  };
  auto vec = calc_divisor(n);
  for_each(all(vec), f);
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define REP(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int
main(int argc, char *argv[])
{
  int h, w;
  scanf("%d %d", &h, &w);
  
  char a[1001][1001];
  int **que; int first = 0, tail = 0;
  que = malloc(sizeof(int *) * (2 * h * w));
  REP(i, 2 * h * w) que[i] = malloc(sizeof(int) * 2);

  REP(i, h){
    scanf("%s", a[i]);
    REP(j, w){
      if(a[i][j] == '#'){
	que[tail][0] = i;
	que[tail][1] = j;
	tail++;
      }
    }
  }
  que[tail][0] = h;
  que[tail][1] = w;
  tail++;

  int d[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

  int x, y, ans = 0;
  while(first < tail){
    REP(i, 4){
      x = que[first][0] + d[i][0];
      y = que[first][1] + d[i][1];
      if(x >= 0 && x < h && y >=0 && y < w && a[x][y] == '.'){
	a[x][y] = '#';
	que[tail][0] = x;
	que[tail][1] = y;
	tail++;
      }
    }
    if(que[first][0] == h && que[first][1] == w){
      if(first < tail - 1){
	ans++;
	que[tail][0] = h;
	que[tail][1] = w;
	tail++;
      }
      else break;
    }
    first++;
  }

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

  REP(i, 2 * h * w) free(que[i]);
  free(que);
  return 0;
}

  

  
  
  
  


Measured memory_bytes: 79232
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <queue>
#include <set>

using namespace std;

typedef unsigned long long int ULL;
typedef long long LL;
typedef long double LD;

const LL inf = 1000000000000000;
const LL mod = 1000000007;

int main()
{
	
	LL h, w;
	cin >> h >> w;

	char g[h][w];

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			cin >> g[i][j];
		}
	}

	LL v[h][w];

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			v[i][j] = 0;
		}
	}

	for (int i = h-1; i >= 0; --i) {
		if (g[i][w-1] != '#') {
			v[i][w-1] = 1;
		}
		else {
			break;
		}
	}
	for (int i = w-1; i >= 0; --i) {
		if (g[h-1][i] != '#') {
			v[h-1][i] = 1;
		}
		else {
			break;
		}
	}

	for (int i = h-2; i >= 0; --i) {
		for (int j = w-2; j >= 0; --j) {
			if (g[i][j] == '.') {
				if (g[i+1][j] != '#') {
					v[i][j] += v[i+1][j];
				}
				if (g[i][j+1] != '#') {
					v[i][j] += v[i][j+1];
				}
				v[i][j] %= mod;
			}
		}
	}

	cout << v[0][0] << endl;

	 
}

Measured memory_bytes: 9088
X,K,D=map(int,input().split())
X=abs(X)
s=X//D
if s>=K:
  print(X-(D*K))
  exit()
n=K-s
n=n%2
if n==0:
  print(X-(D*s))
  exit()
else:
  print(abs(X-(D*s)-D))
  exit()

Measured memory_bytes: 9180
# -*- coding: utf-8 -*-
N = int(input())
A_list = list(map(int, input().split()))

ans_list = [0 for _ in range(N)]

for i in range(N - 1):
    ans_list[A_list[i] - 1] += 1

print("\n".join(map(str, ans_list)))

Measured memory_bytes: 33828
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;



ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}



int main() {
	int i, j, k;
	//ll N, M, K;
	int N, M, K;
	string S;
	string T, R;
	cin >> S;
	string S1 = S;
	reverse(S1.begin(), S1.end());
	N = S.size();
	if (S.compare(S1) != 0) {
		cout << "No";
		return 0;
	}
	rep(i, 0, (N - 1) / 2) {
		T.push_back(S[i]);
	}
	rep(i, (N + 3) / 2 -1, N) {
		R.push_back(S[i]);
	}
	string T1 = T;
	string R1 = R;
	reverse(T1.begin(), T1.end());
	reverse(R1.begin(), R1.end());
	if (T.compare(T1) != 0 || R.compare(R1) != 0) {
		cout << "No";
		return 0;
	}
	cout << "Yes";
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  map<int,int>m;
  long long ans=0;
  for(int i=1;i<=n;i++)
  {
    long long t=n/i;
    ans+=(t*(t+1)/2)*i;
  }
 
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
int main(){
  ll N,K,i;scanf("%lld%lld",&N,&K);
  ll A[N];
  for(i=0;i<N;i++) scanf("%lld",&A[i]);
  ll left = 0,right = *max_element(A,A+N),mid,cut;//(left,right]
  while(right-left > 1){
    mid = (left+right)/2;cut = 0;
    for(i=0;i<N;i++) cut += (A[i]-1)/mid;
    if(cut <= K) right = mid;
    else left = mid;
  }
  printf("%lld\n",right);
}

Measured memory_bytes: 5384
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int> G[N];
int a[N], m, ans;
int dfs(int x) {
	int tmp = 0;
	for (int u : G[x]) {
		tmp = max(tmp, dfs(u));
	}
	if (x == 1) return 0;
	if (tmp + 1 == m && a[x] != 1) {
		ans ++;
		tmp = -1;
	}
	return tmp + 1;
}
int main() {
	int n;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++ i) scanf("%d", &a[i]);
	if (a[1] != 1) {
		a[1] = 1;
		ans ++;
	}
	for (int i = 2; i <= n; ++ i) G[a[i]].push_back(i);
	dfs(1);
	printf("%d\n", ans);
}



Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
  unsigned long long a,b,c;
  unsigned long long count = 0;
   cin >> a>> b>> c;
    --a;
    if(a==-1) count = b/c+1;
    else count = b/c-a/c;
    cout << count << endl;
   return 0;
  }

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

using namespace std;

class oneDimensionReverse
{
private:
	string s;
	int ans;
public:
	oneDimensionReverse(){
		cin >> s;
	}
	void execute();
	void output();
};

void oneDimensionReverse::execute(){
	char start = s[0];
	this->ans = 0;
	for (int i = 0; i < this->s.length(); ++i)
	{
		if(start != s[i]){
			ans++;
			start = s[i];
		}
	}
	cout << ans << endl;
}

int main(){
	oneDimensionReverse oDR = oneDimensionReverse();
	oDR.execute();
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;

ll gcd(ll a, ll b)
{
  if(a>b)swap(a,b);
  if(a==0)return b;
  return gcd(b%a,a);
}
ll lcm(ll a,ll b)
{
  return (a/gcd(a,b))*b;
}


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  int n;
  cin>>n;
  ll res=1;
  rep(i,n)
  {
    ll t;
    cin>>t;
    res=lcm(res,t);
    //cout<<t<<endl;
    //cout<<res<<endl;
  }
  cout<<res<<endl;
  return 0;

}


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

int main() {
  long long int n,tmp,ans=0;
  vector<long long int> a;
  vector<long long int> b;
  vector<long long int> c;

  cin>>n;
  rep(i,0,n){cin>>tmp;a.emplace_back(tmp);}
  rep(i,0,n){cin>>tmp;b.emplace_back(tmp);}
  rep(i,0,n){cin>>tmp;c.emplace_back(tmp);}

  sort(a.begin(),a.end());
  //sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  
  rep(i,0,n) {
    long long int tmpa=0;
    long long int tmpc=0;
    auto j = lower_bound(a.begin(),a.end(),b[i]);
    tmpa=j-a.begin();
    //小さい値の個数
    //cout<<tmpa<<endl;
    auto k = lower_bound(c.begin(),c.end(),b[i]+1);
    tmpc=k-c.begin();
    //大きい値の個数
    //cout<<n-tmpc<<endl;
    ans+=tmpa*(n-tmpc);
  }
  
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3444