akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;
    
    public static void main(String[] args) {
        int n = ni();
        Task[] tasks = new Task[n];
        for (int i = 0; i < n; i++) {
            tasks[i] = new Task(ni(), ni());
        }
        Arrays.sort(tasks);
        int time = 0;
        for (int i = 0; i < n; i++) {
            time += tasks[i].cost;
            if (time > tasks[i].due) {
                so.println("No");
                return;
            }
        }
        so.println("Yes");
    }
    
    static class Task implements Comparable<Task>{
        public int cost;
        public int due;
        public Task(int cost, int due) {
            this.cost = cost;
            this.due = due;
        }
        @Override
        public int compareTo(Task that) {
            return this.due - that.due;
        }
        
        @Override
        public String toString() {
            return "cost: " + cost + ", due: " + due;
        }
    }
    
    
    static int gcd(int m, int n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
    
    static long lcm(int m, int n) {
        return (long) m * (long) n / gcd(m, n);
    }

    private static long nl() {
        return sc.nextLong();
    }

    private static int ni() {
        return sc.nextInt();
    }

    private static String ns() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0);
    }

    private static long[] nlongs(int n, int offset) {
        long[] a = new long[offset + n];
        for (int i = 0; i < n; i++)
            a[offset + i] = nl();
        return a;
    }
}


Measured memory_bytes: 103428
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n;
    cin >> n;
    int t[100000], x[100000], y[100000];
    rep(i, n){
        cin >> t[i] >> x[i] >> y[i]; 
    }

    int tmp;
    bool judge = true;
    rep(i, n){
        if(i == 0){
           if(t[i] < x[i] + y[i]){
               judge = false;
           } 
        }
        else{
           if((t[i]-t[i-1]) < abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]) 
           || ((t[i]-t[i-1]) - abs(x[i]-x[i-1]) - abs(y[i]-y[i-1]))%2 != 0){
               
               judge = false;
           }            
        }
    }
    if(judge){
        cout << "Yes";
    }
    else{
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {

    ll n, m;
    cin >> n >> m;
    map<ll, ll, greater<ll>> mm;
    for (int i = 0; i < n; ++i)
    {
        ll a;
        cin >> a;
        mm[a]++;
    }
    
    for (int i = 0; i < m; ++i)
    {
        ll b, c;
        cin >> b >> c;
        mm[c] += b;
    }
    
    ll c = n;
    ll ret = 0;
    for (auto itr = mm.begin(); itr != mm.end(); ++itr)
    {
        if (itr->second > c)
        {
            ret += c * itr->first;
            break;
        }
        ret += itr->second * itr->first;
        c -= itr->second;
    }
    
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 12800
let s=readLine()!
var seta:Set<Character>=[]
var judge=0
for x in s{
  seta.insert(x)
}
if seta.count==2{
  judge+=1
}
for x in seta{
  var count=0
  for y in s{
    if x==y{
      count+=1
    }
  }
  if count==2{
    judge+=1
  }
}

if judge==3{
  print("Yes")
}else{
  print("No")
}


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

void swap(int& a, int& b){
	int temp = a;
	a = b;
	b = temp;
}

void shell_sort(vector<int> &p,int n)
{
    int op=0;
    int h_count = 0;
    vector<int> h_array;
    int h,i,j,t,temp;
//    for(h=1;h<=n/9;h=h*3+1);
//    for(h;h>0;h=h/3)
//	{
//        h_count++;
//        h_array.push_back(h); 
//	}
//	cout<<"h's num is' "<<h_count<<endl;

	for(h=1; h<=n; h=h*3+1)
	{
		h_count++;
        h_array.push_back(h); 
	}
	cout<<h_count<<endl;
//	}
	for(int k = h_array.size()-1; k>=0; k--)
	{
		cout<<h_array[k]<<" ";
		if(k==0) cout<<endl;
		
        for(i=h_array[k];i<n;i++)
		{     //???h???1?????¶?????????????????\?????? 
            temp=p[i];
            for(j=i-h_array[k];j>=0&&p[j]>temp;j-=h_array[k])
			{
                p[j+h_array[k]]=p[j];
                op++;
            }
            p[j+h_array[k]]=temp;
        }
	}
	cout<<op<<endl;
}


int main(int argc, char** argv) {	
	int n = 0;
	int count = 0;
	cin>>n;
	vector<int> array;
	while(count<n)
	{
		int input;
		cin>>input;
		count++;
		array.push_back(input);
	}
	
	shell_sort(array, n);   
	
	
	for(int index1 = 0; index1<n; index1++){
		cout<<array[index1]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 6200
N = int(input())
A = list(map(int, input().split()))
mod0 = 0
mod2 = 0
mod13 = 0

for a in A:
  mod = a % 4
  if mod == 0:
    mod0 += 1
  elif mod == 2:
    mod2 += 1
  else:
    mod13 += 1
    
if mod2 > 0:
  if mod13 <= mod0:
    print('Yes')
  else:
    print('No')
else:
  if mod13-1 <= mod0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 20000
#include<stdio.h>
int main(){
	char s[102];
	int i=0,no=0;
	scanf("%s",s);
	while(s[i]!='\0'){
		if(s[i]=='L'){
			no++;
			break;
		}
		i++;
		if(s[i]=='\0'){
			break;
		}
		if(s[i]=='R'){
			no++;
			break;
		}
		i++;
	}
	if(no>0){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main() {
    int B[3][3] = {};
    rep(i,3){
        rep(j,3){
            cin >> B[i][j];
        }
    }
    int N;
    cin >> N;
    rep(k,N){
        int b;
        cin >> b;
        rep(i,3){
            rep(j,3){
                if(B[i][j] == b) B[i][j] = 0;
            }
        }
    }
    rep(i,3){
        bool flag = true;
        rep(j,3){
            if(B[i][j] != 0){
                flag = false;
                break;
            }
        }
        if(flag){
            cout << "Yes" << endl;
            return 0;
        }
    }
    rep(i,3){
        bool flag = true;
        rep(j,3){
            if(B[j][i] != 0){
                flag = false;
                break;
            }
        }
        if(flag){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(B[0][0] == 0 && B[1][1] == 0 && B[2][2] == 0){
            cout << "Yes" << endl;
            return 0;
    }
    if(B[2][0] == 0 && B[1][1] == 0 && B[2][0] == 0){
            cout << "Yes" << endl;
            return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	int b[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
		cin>>b[i];
	long long aa=0,bb=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]>b[i])
			bb+=a[i]-b[i];
		else if(a[i]<b[i])
			if((b[i]-a[i])%2==0)
				aa+=(b[i]-a[i])/2;
			else
			{
				aa+=(b[i]-a[i]+1)/2;
				bb++;
			}
	}
	if(aa>=bb)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
 } 

Measured memory_bytes: 384
n = int(input())
if n == 0:
    print(0)
    exit()
flag = True
ans_str = ''
while True:
    if n == 1:
        ans_str = '1' + ans_str
        print(int(ans_str))
        exit()
    if n < 0 and (-n)%2 == 1:
        ans_str = '1' + ans_str
        n = -(n-1)//2
    elif n < 0 and (-n)%2 == 0:
        ans_str = '0' + ans_str
        n = -n//2
    elif n > 0 and n%2 ==1:
        ans_str = '1' + ans_str
        n = -(n//2)
    elif n > 0 and n%2 ==0:
        ans_str = '0' + ans_str
        n = -(n//2)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int X, Y;
int main() {
    while (cin >> X >> Y) {
        if (X % Y == 0) cout << -1 << endl;
        else cout << X << endl;
    }
}

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

using namespace std;

const int N = 110;

char s[N], t[N];

int main() {
  scanf("%s", s);
  int n = strlen(s);
  int k = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '0' || s[i] == '1') {
      t[k++] = s[i];
    }
    else {
      if (k)
        t[--k] = 0;
    }
  }
  puts(t);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

void sub(vector<ll>& arr, char pre, char post, string s) {
    ll cur = 0;
    for(int i = 0; i < s.size(); i++) {
        if (s[i] == pre) {
            if (i == 0 || s[i-1] == post) {
                cur = 0;
            }
            arr[i] = cur++;
        } else if (s[i] == post) {
            arr[i] = max(arr[i], cur);
            cur = 0;
        }
    }
    if (s.back() == pre)
        arr[arr.size()-1] = cur;
}

int main() {
    string s;
    cin >> s;
    vector<ll> arr(s.size()+1, INT_MIN);
    sub(arr, '<', '>', s);
    reverse(arr.begin(), arr.end());
    reverse(s.begin(), s.end());
    sub(arr, '>', '<', s);
    reverse(arr.begin(), arr.end());
    
    cout << accumulate(arr.begin(), arr.end(), 0LL) << endl;
    return 0;
}




Measured memory_bytes: 5276
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define y1 fdhjksa
using namespace std;
const int N=105;
int n,m,k,mo;
int inv[N],Inv[N];
int P[N][N*N],IP[N][N*N];
int f[N][N][N],g[N][N],h[N][N];
int main(){
	scanf("%d%d%d%d",&n,&m,&k,&mo);
	inv[0]=inv[1]=Inv[0]=1;
	For(i,2,N-1) inv[i]=1ll*inv[mo%i]*(mo-mo/i)%mo;
	For(i,0,k) P[i][0]=IP[i][0]=1;
	For(i,0,k) For(j,1,n*m) P[i][j]=1ll*P[i][j-1]*i%mo;
	For(i,0,k) For(j,1,n*m) IP[i][j]=1ll*IP[i][j-1]*inv[i]%mo;
	For(i,1,N-1) Inv[i]=1ll*Inv[i-1]*inv[i]%mo;
	f[0][0][0]=1;
	For(i,1,::k){
		For(j,0,n) For(k,0,m) g[j][k]=1ll*P[i][(n-j)*(m-k)]*f[i-1][j][k]%mo;
		For(j,0,n) For(k,0,m) h[j][k]=0;
		For(k,0,m) For(jj,0,n){
			int tr=1ll*Inv[jj]*P[::k-i+1][jj*k]%mo;
			For(j,0,n-jj) h[j+jj][k]=(h[j+jj][k]+1ll*g[j][k]*tr)%mo;
		}
		For(j,0,n) For(k,0,m) g[j][k]=0;
		For(j,0,n) For(kk,0,m){
			int tr=1ll*Inv[kk]*P[::k-i+1][j*kk]%mo;
			For(k,0,m-kk) g[j][k+kk]=(g[j][k+kk]+1ll*h[j][k]*tr)%mo;
		}
		For(j,0,n) For(k,0,m) h[j][k]=0;
		For(k,0,m) For(jj,0,n){
			int tr=1ll*(jj&1?mo-Inv[jj]:Inv[jj])*P[::k-i][jj*k]%mo;
			For(j,0,n-jj) h[j+jj][k]=(h[j+jj][k]+1ll*g[j][k]*tr)%mo;
		}
		For(j,0,n) For(k,0,m) g[j][k]=0;
		For(j,0,n) For(kk,0,m){
			int tr=1ll*(kk&1?mo-Inv[kk]:Inv[kk])*P[::k-i][j*kk]%mo;
			For(k,0,m-kk) g[j][k+kk]=(g[j][k+kk]+1ll*h[j][k]*tr)%mo;
		}
		For(j,0,n) For(k,0,m)
			f[i][j][k]=1ll*g[j][k]*IP[i][(n-j)*(m-k)]%mo;
	}
	int ans=f[k][n][m];
	For(i,1,n) ans=1ll*ans*i%mo;
	For(i,1,m) ans=1ll*ans*i%mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 13696
#include <iostream>
#include <vector>

using namespace std;

#define MOD (((int) 1e9 + 7))

int main(void) {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w, 0));
    char t;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> t;
            if (t == '#') {
                a[i][j] = 1;
            }
        }
    }

    vector<vector<int>> dp(h, vector<int>(w, 0));
    dp[0][0] = 1;
    for (int i = 1; i < h; i++) {
        if (a[i][0] == 0) {
            dp[i][0] = dp[i - 1][0];
        } else {
            break;
        }
    }
    for (int j = 1; j < w; j++) {
        if (a[0][j] == 0) {
            dp[0][j] = dp[0][j - 1];
        } else {
            break;
        }
    }
    for (int i = 1; i < h; i++) {
        for (int j = 1; j < w; j++) {
            if (a[i][j] == 0) {
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
            }
        }
    }

    cout << dp[h - 1][w - 1] << endl;

    return 0;
}


Measured memory_bytes: 11344
#include<stdio.h>
#include<math.h>
int main(){
	int a;
	scanf("%d",&a);
	while(a--){
		double x1,y1,x2,y2,x3,y3;
		scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
		double a1=2*(x2-x1);
		double b1=2*(y2-y1);
		double c1=x1*x1-x2*x2+y1*y1-y2*y2;
		double a2=2*(x3-x1);
		double b2=2*(y3-y1);
		double c2=x1*x1-x3*x3+y1*y1-y3*y3;
		double x=(b1*c2-b2*c1)/(a1*b2-a2*b1);
		double y=(c1*a2-c2*a1)/(a1*b2-a2*b1);
		double r=hypot(x-x1,y-y1);
		printf("%.3lf %.3lf %.3lf\n",x,y,r);
	}
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int fun(char *);
int fun(char *s)
{
    int n=strlen(s);
    int i=0,j=n-1;
    while(s[i]!='A')
    {
        i++;
    }
    while(s[j]!='Z')
    {
        j--;
    }
    if(i>=j)
    {
        return 0;
    }
    return j-i+1;
}
int main()
{
    char a[200005];
    scanf("%s",a);
    printf("%d\n",fun(a));
    return 0;
}

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

int main() {
    ll H, W;
    cin >> H >> W;
    ll x0 = W / 2 + W % 2, x1 = W / 2;
    ll ans = 0;
    if (H == 1)
        ans = 1;
    else if (W == 1)
        ans = 1;
    else
        ans = x0 * (H / 2 + H % 2) + x1 * (H / 2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 300000;
const int mod = 998244353;
const int K = 60;
const int M = 16;
int a[N], p[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s;
    int n;
    cin >> n;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < n; i++){
        if (s[i] == 'G') a[i] = 0;
        if (s[i] == 'B') a[i] = 1;
        if (s[i] == 'R') a[i] = 2;
    }
    for (int i = 0; i < 3; i++) p[i] = i;
    for (int i = 0; i < 6; i++){
        next_permutation(p, p + 3);
        for (int j = 0; j < n; j++){
            int cnt1 = 0;
            int cnt2 = 0;
            int cnt3 = 0;
            if (a[j] != p[1]) continue;
            for (int l = 0; l < j; l++){
                if (a[l] != p[0]) continue;
                cnt1++;
                if (a[l] != a[j + j - l] && j + j - l < n && a[j + j - l] == p[2]) cnt3++;
            }
            for (int l = j + 1; l < n; l++){
                if (a[l] != p[2]) continue;
                cnt2++;
            }
            ans += cnt2 * cnt1 - cnt3;
        }
    }
    cout << ans;
}


Measured memory_bytes: 3652
date = input()
tdate=[]
 
for s in date:
  tdate.append(s)
  
if tdate[5] != "0":
  mon = int(tdate[5] + tdate[6])
else:
  mon = int(tdate[6])


if mon <= 4:
  print("Heisei")
else:
  print("TBD")

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

int main(){
  int n,ac=0,wa=0,tle=0,re=0;
  string str;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> str;
    if(str=="AC"){
      ac++;
    }
    else if(str=="WA"){
      wa++;
    }
    else if(str=="TLE"){
      tle++;
    }
    else if(str=="RE"){
      re++;
    }
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  return 0;
}

Measured memory_bytes: 3624
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main(){
    ll d;
    cin >> d;
    vector<ll> c(26),num(26);
    rep(i,26){
        cin >> c[i];
    }
    vector<vector<ll>> s(d,vector<ll>(26));
    rep(i,d){
        rep(j,26){
            cin >> s[i][j];
        }
    }
    rep(i,d){
        cout << rand()%26+1 << endl;
    }
    return 0;
} 

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
void solve(){
    int n,w;
    cin>>n>>w;
    vector<ll> wt(n),val(n);
    for(int i=0;i<n;i++)
        cin>>wt[i]>>val[i];
    ll sum=accumulate(val.begin(),val.end(),0);
    vector<ll> dp(sum+1,LLONG_MAX);
    dp[0]=0;
    for(int i=0;i<n;++i){
        vector<ll> new_dp(sum+1,LLONG_MAX);
        for(int j=0;j<=sum;++j){
            new_dp[j]=min(new_dp[j],dp[j]);
            if(j-val[i]>=0 && dp[j-val[i]]!=LLONG_MAX)
                new_dp[j]=min(new_dp[j],((i>0)?dp[j-val[i]]:0)+wt[i]);
        }
        dp=new_dp;
    }
    int ans=0;
    for(int i=sum;i>=0;--i){
        if(dp[i]<=w){
            ans=i;
            break;
        }
    }
    cout<<ans;
}

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

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

int n, x, l[105], d[105], t;

int main(){
    cin >> n >> x;
    for(int i=0; i<n; i++) cin >> l[i];

    d[0] = 0;

    for(int i=1; i<n+1; i++){
        d[i] = d[i-1] + l[i-1];
        if(d[i] <= x){
            t++;
        }
    }

    cout << t+1;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
					  cerr << "\n\n" << "Time elapsed: " << \
					  (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
					  return 0
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define pii pair<int , int>
#define pdd pair<db , db>
#define pll pair<ll , ll>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define inf 100000000000000007
#define eps 0.000001
#define stp fixed<<setprecision(20)
#define endl '\n'

ll dp[105][100005];

int main()
{
	start_routine();
	fastio;
	

    ll n,W;cin>>n>>W;
    ll w[n+1],v[n+1];
    for(ll i=1;i<=n;i++)
    	cin>>w[i]>>v[i];

    for(ll i=0;i<=n;i++)
    {
    	for(ll j=0;j<=W;j++)
    	{
    		if(i==0 || j==0)
    			dp[i][j]=0;
    		else if(j>=w[i])
    			dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]);
    		else
    			dp[i][j]=dp[i-1][j];
    	}
    }

    cout<<dp[n][W];
	end_routine();
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;
const int MAX = 1000000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {  
  int N,K; 
  cin>>N>>K;
  vector<int>a(N);
  rep(i,N){
    cin>>a.at(i);
  }
  COMinit();
  sort(a.begin(),a.end());
  long bi=0;
  long sm=0;
  rep(i,N){
    bi+=(a.at(i)*COM(i,K-1))%MOD;
    bi%=MOD;
    sm+=(a.at(i)*COM(N-1-i,K-1))%MOD;
    sm%=MOD;
  }
   
  cout<<(bi-sm+MOD)%MOD<<endl;
}




Measured memory_bytes: 24064
#include<stdio.h>

int main(){
	int A, B, C, D;
	scanf("%d %d %d %d", &A, &B, &C, &D);

	while (1){
		A = A - D;
		C = C - B;

		if (A <= 0 || C <= 0) break;
	}
		if (C <= 0){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	return 0;
}

Measured memory_bytes: 1644
package main

import "fmt"

func main() {
	var s, t string
	var a, b  int
	var u string
	fmt.Scan(&s, &t, &a, &b, &u)

	if s == u {
		a--
	}
	if t == u {
		b--
	}
	fmt.Println(a, b)
}


Measured memory_bytes: 512
#include<stdio.h>

int main()
{
	long long int r,D,x,i;
	scanf("%lld %lld %lld",&r,&D,&x);
	for(i=0;i<10;i++)
	{
		x=x*r-D;
		printf("%lld\n",x);
	}
	return 0;
}

Measured memory_bytes: 128
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

s = gets.chomp
puts "#{s[0]}#{s.size-2}#{s[-1]}"


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\n"
#define all(v) v.begin(),v.end()
#define mp make_pair
#define mm(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define repn(i,a,b) for(ll i = a; i >= b; i--)
#define pb push_back
#define ff first
#define ss second
#define in_edges(m) repp(i, 1, m){ ll a, b; cin >> a >> b; adj[a].pb(b), adj[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define MOD 1000000007
// template<class _EuclideanRigElement> _EuclideanRingElement std::__gcd(_EuclideanRingElement __m, _EuclideanRingElement __n);
//atoi() = char to int
// stoi() = int to char
//string g(1,"1"); char to string
//f[stoi(g)] = '0';
//cout.precision(14);
ll power(ll x,ll y);

int main()
{
	    // freopen("in.txt","r",stdin);
	    // freopen("out","w",stdout);
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	    ll t;t=1;
	    // cin >> t;
		// 61 62
	    while(t--)
	    {
			ll n; cin >> n;
			ll sum = 0;
			rep(i,1,n+1)
			{
				rep(j,1,n+1)
				{
					rep(k,1,n+1)
					{
						sum+=__gcd(__gcd(i,j),k);
					}
				}
			}
			cout << sum <<endl;
		}
}
/* 
72 140
ll power(ll x, ll y)
{ 
	// x ka power ke liye:power(x,y);
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}*/

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
long long dp[100001]={-1};
void ini()
{
for(int i=0;i<100001;i++)
dp[i]=-1;
}

long long ans(int n,int a[],int k)
{

if(dp[n]!=-1)
return dp[n];
else if(n==0)
dp[n]=0;
else if(n<k)
{
long long m=1000000000000;
for(int i=1;i<=n;i++)
m=min(m,abs(a[n]-a[n-i])+ans(n-i,a,k));
dp[n]=m;
 
}
else
{
long long m=1000000000000;
for(int i=1;i<=k;i++)
m=min(m,abs(a[n]-a[n-i])+ans(n-i,a,k));
dp[n]=m; 

}


return dp[n];
}
int main()
{
ini();
//cout<<dp[0]<<" "<<dp[1]<<endl;
int n;
int k;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
long long k1=ans(n-1,a,k);
cout<<k1<<endl;
return 0;
}



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

using namespace std;

int main()
{
    int N, K, p[1005];

    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> p[i];
    }
    sort(p, p + N);
    int ans = 0;
    for (int i = 0; i < K; i++) {
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
N, K = map(int, input().split())
A = list(map(int, input().split()))
r = [None] * N
i = 0
cur = 0
m = None
while True:
    if m is None and r[cur] is not None:
        m = i - r[cur]
        K = i + (K-i)%m
    else:
        r[cur] = i
    if i == K:
        print(cur+1)
        exit()
    i += 1
    cur = A[cur] - 1

Measured memory_bytes: 32380
#include<stdio.h>

int main(void)
{
	int i,j,high[11];
	int change,judge;
	
	for(i=0;i<10;i++){
			scanf("%d",&high[i]);
	}
	for(j=0;j<20;j++){
	for(i=0;i<9;i++){
		judge = high[i]-high[i+1];
		if(judge < 0){
			change = high[i];
			high[i] = high[i+1];
			high[i+1] = change;
		}
	}
	}
		printf("%d\n",high[0]);
		printf("%d\n",high[1]);
		printf("%d\n",high[2]);
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
char *P[]={"Impossible","Possible"};
char c;
char h, w, a;
int main(void){
  h=getchar()-'0';
  getchar();
  w=getchar()-'0';
  getchar();
  while((c=getchar())!=EOF){
    if(c=='#'){a++;}
  }
  puts(P[h+w==a+1]);
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
using namespace std;
int mod = 1e9+7;

int main() {

  int n;
  cin >> n;
  vector<int> a(3*n);
  for(int i=0; i<3*n; i++) cin >> a[i];

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

  long long int sum = 0;
  for(int i=n; i<3*n; i+=2){
    sum += a[i];
  }
  cout << sum << endl;

  return 0;
}

//


Measured memory_bytes: 1408
import kotlin.math.*

fun list() = readLine()!!.split(" ").map {it.toInt()}

fun binarySearch(ok:Int,ng:Int,eps:Int,f:(Int)->Boolean):Int {
	var _ok = ok
	var _ng = ng
	while(abs(_ok-_ng)>eps) {
		val mid = (_ok+_ng)/2
		if(f(mid))
			_ok = mid
		else
			_ng = mid
	}
	return _ok
}

fun main() {
	val (n,k) = list()
	val a = list()
	println(binarySearch(1000000000,0,1) {l->
		a.map {(it+l-1)/l-1}.sum()<=k
	})
}


Measured memory_bytes: 72432
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=1e5+10;
int a[maxn]; 
int main()
{
	memset(a,0,sizeof(a));
	int n,tmp;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>tmp;
		a[tmp]=i;
	}
	for(int i=1;i<n;i++)
		cout<<a[i]<<" ";
	cout<<a[n]<<endl;
	return 0;
}


Measured memory_bytes: 1280
S = gets.chomp

left = 0
right = S.size - 1
cnt = 0
while left < right
  l = S[left]
  r = S[right]
  # puts [l,r].join(",")
  if l == r
    left += 1
    right -= 1
  else
    if l == "x"
      left += 1
      cnt += 1
    elsif r == "x"
      right -= 1
      cnt += 1
    else
      # puts cnt
      puts(-1)
      exit(0)
    end
  end
end
puts(cnt)


Measured memory_bytes: 3964
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	double a_d,b_d;
	scanf("%d %d",&a,&b);
	a_d = static_cast<double>(a);
	b_d = static_cast<double>(b);
	printf("%d %d %.5f\n",a/b,a%b,a_d/b_d);
}


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

template <typename T> T gcd(T x, T y) { return( y ? gcd(y, x % y) : x); }
template <typename T> T lcm(T x, T y) { return( x / gcd(x, y) * y); }
template <typename T> void printVec(vector<T> &vec) {
  cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    cout << *it << " ";
  }
  cout << endl;
}

int main() {
  int n;

  cin >> n;
  if ((n - (n / 1000) * 1000) == 0) {
    cout << 0 << endl;
  } else {
    int ans = 1000 - (n - (n / 1000) * 1000);
    cout << ans << endl;
  }
	return 0;
}

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

// どういうDPか
// dp[i] := 頂点iの子ノードの最大の長さ + 1

// 計算方法
// dp[i] = max(dp[j]) + 1 (jは頂点iの子ノード)

// どういう順番
// DFS
// 復元
//

ll dp[101010];
bool flag[101010];

vector<int> g[101010];

ll solve(int v) {

    if (flag[v]) return dp[v];
    flag[v] = true;

    for (auto u : g[v]) {
        dp[v] = max(dp[v], solve(u) + 1);
    }
    return dp[v];
}

int main() {
    int N, M;
    cin >> N >> M;
    rep(i, M) {
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
    }
    ll ans = 0;
    for (int i=1; i<=N; ++i) {
        ans = max(ans, solve(i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<char,LL> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<30;

vector<vector<int>> nextIndex(const string &s){
    int n = s.length();
    vector<vector<int>> ret(n+1,vector<int> (26,n));
    for (int i = n-1; i >= 0; i--) {
        for (int j = 0; j < 26; j++) ret[i][j] = ret[i+1][j];
        ret[i][s[i]-'a'] = i;
    }
    return ret;
}


int main(){
    string s;cin >> s;
    int n = s.length();
    auto p = nextIndex(s);
    vector<int> dp(n+2,INF);
    vector<P> res(n+2,make_pair('a',n));
    dp[n+1] = 0;
    for (int i = n; i >= 0; i--) {
        for (int j = 0; j < 26; j++) {
            int ni;
            if(i>=n) ni = n;else ni = p[i][j];
            if(dp[i] > dp[ni+1]+1){
                dp[i] = dp[ni+1]+1;
                res[i] = make_pair('a'+j,ni+1);
            }
        }
    }
    int indx = 0;
    string ans = "";
    for (int k = 0; k < dp[0]; k++) {
        ans += res[indx].fs;
        indx = res[indx].sc;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 30980
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<int>> HW(H, vector<int>(W)), HW2(H, vector<int>(W));

    rep(i, H) {
        rep(j, W) {
            char c;
            cin >> c;
            HW[H - i - 1][j] = c - '0';
            HW2[H - i - 1][j] = HW[H - i - 1][j];
        }
    }

    ll ans = 0;
    rep(i, H) {
        rep(j, W) {
            ll res = 0;
            repd(k, i + 1, H) {
                HW[k - 1][j] = HW[k][j];
            }
            HW[H - 1][j] = -1;
            ll cnt = 1;
            while (1) {
                vector<vector<int>> check(H, vector<int>(W, 0));
                rep(k, H) {
                    repd(l, 1, W) {
                        if (HW[k][l] == -1) continue;
                        if (HW[k][l] == HW[k][l - 1]) {
                            check[k][l] = check[k][l - 1] + 1;
                        }
                    }
                }

                bool flag = false;
                ll point = 0;
                rep(k, H) {
                    for (int l = W - 1; l >= 0; l--) {
                        if (check[k][l] + 1 >= K) {
                            repd(m, l - check[k][l], l + 1) {
                                point += HW[k][m];
                                HW[k][m] = -1;
                            }
                            l -= check[k][l];
                            flag = true;
                        }
                    } 
                }

                if (!flag) break;
                else res += cnt * point;
                
                bool fall = true;
                while (fall) {
                    fall = false;
                    repd(k, 1, H) {
                        rep(l, W) {
                            if (HW[k][l] == -1) continue;
                            if (HW[k - 1][l] == -1) {
                                HW[k - 1][l] = HW[k][l];
                                HW[k][l] = -1;
                                fall = true;
                            }
                        }
                    }
                }

                cnt *= 2;
            }
            chmax(ans, res);

            rep(k, H) {
                rep(j, W) {
                    HW[k][j] = HW2[k][j];
                }
            }
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main(){
	int a,b,c,d,e,k;
	cin>>a>>b>>c>>d>>e>>k;
	if(e-a>k)cout<<":("<<endl;
	else cout<<"Yay!"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,t,i;
	for(i=1;i<=4;i++){
		scanf("%d %d",&a,&b);
		if(a==1){
			a=6000;
		}
		else if(a==2){
			a=4000;
		}
		else if(a==3){
			a=3000;
		}
		else if(a==4){
			a=2000;
		}
		c=a*b;
		printf("%d\n",c);
	}
	
		
	return 0;
}

Measured memory_bytes: 1028
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<numeric>
#include<deque>
using namespace std;
typedef long long ll;
int main()
{
	int n,r;
	cin>>n>>r;
	if(n>10)
		cout<<r<<endl;
	else
		cout<<r+100*(10-n)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair  
#define fi first
#define se second
#define pii pair<int,int> 
#define vi vector<int>
#define vpii vector<pii> 
#define vvpii vector<vetcor<pii>>
#define sz(V) ((int)V.size())
#define zeros(arr) memset(arr,0,sizeof(arr))
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define n1 "\n"
const int maxx  = 1e5+10 , limit = 1e17 , M=1e9+7 , max1 = 1e6;
#define PI 3.14159265
int pow(int x,int n){ if(n==0) return 1;  int res=pow(x,n/2); res=(res*res)%M;  if(n&1) res= (res*x)%M; return res;}
int calcInverse(int x,int n){ int res=1; while(n>0) { if(n&1)res=(res*x)%M;  x=(x*x)%M; n=n/2;} return res;}
#define test int t; cin>>t; while(t--)

int32_t main(){
    IOS       
    int n,d,x,y,ans=0,i;
    cin>>n>>d;
    rep(i,n){
    cin>>x>>y;
    if(sqrt(x*x + y*y)<=d)
    ans++;
    }
    cout<<ans;
}
    

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
  int N,i,j,h,t,ht,sum,mojisu,sho,dai;
  h=0;
  t=0;
  ht=0;
  cin>>N;
  sum=0;
  string S[N];
  for(i=0;i<N;i++){
  cin>>S[i];
    mojisu=S[i].length();
    if(S[i].at(0)=='B'&&S[i].at(mojisu-1)=='A'){
    ht++;
    }else if(S[i].at(0)=='B'){
    h++;
    }else if(S[i].at(mojisu-1)=='A'){
    t++;
    }
    for(j=0;j<(mojisu-1);j++){
    if(S[i].at(j)=='A'&&S[i].at(j+1)=='B') sum++;
    }
  }
  sho=min(h,t);
  dai=max(h,t);
  if(dai>=sho+ht){
  sum=sum+sho+ht;
  }else{
  sum=sum+sho+ht;
  }
  if(h<1&&t<1&&ht>0) sum--;
  cout<<sum<<endl;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(cin.hasNext()) {
			int a = cin.nextInt();
			int b = cin.nextInt();
			System.out.println((int)(Math.log10(a+b)+1));
		}
	}
}


Measured memory_bytes: 26256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ci cin >>
#define co cout <<
int N, M, H, W;
int A[1000], B[1000];
string S;
int ans = 0;
int main() {
	ci N >> H >> W;
	REP(i, N)ci A[i] >> B[i];
	REP(i, N) {
		if (A[i] >= H) {
			if (B[i] >= W)ans++;

		}

	}
	






	co ans;
	return 0;

}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
//typedef long long ll;
#include "boost/multiprecision/cpp_int.hpp"
typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
ll i_7=1;
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
////////////////////////////

ll po(ll i,ll p){
    if(p==0)return 1;
    else{
        i=mod(i);
        if(p==1)return i;
        if(p%2==0)return po(mod(i*i),p/2);
        return mod(i*po(i,p-1));
    }
}
typedef vector<ll> vec;
typedef vector<vec> mat;
mat mul(mat a,mat b){/*行列aと行列bの積*/
    mat c(a.size(),vec(b[0].size()));
    for(int i=0;i<a.size();i++){
        for(int j=0;j<b[0].size();j++){
            for(int k=0;k<a[0].size();k++){
                c[i][j]=mod(c[i][j]+a[i][k]*b[k][j]);
            }
        }
    }
    return c;
}
ll pow(ll a,ll p){
    ll res=1;
    rep(i,1,p)res=res*a;
    return res;
}

mat pow(mat a,ll n){/*行列aのn乗*/
    mat b(a.size(),vec(a.size()));
    for(int i=0;i<a.size();i++){
        b[i][i]=1;
    }
    while(n>0){
        if(n&1)b=mul(b,a);
        a=mul(a,a);
        n>>=1;
    }
    return b;
}
//////////////////////////////////////////
int main(){
    //最後にタバイチョウに直す
    ll l,a,d;cin>>l>>a>>d>>i_7;
    ll S=1;
    ll num[20];for(int i=0;i<=19;i++)num[i]=0;
    num[19]=l;
    for(int t=1;t<=18;t++){
        if(pow((ll)10,t)<=a)continue;
        ll ok=l,ng=-1;
        
        while(abs(ok-ng)>1){
            ll mid=(ok+ng)/2;
            if(a+(mid)*d>=pow((ll)10,t-1))ok=mid;
            else ng=mid;
        }
         
        num[t]=ok;
    }
    /*
    for(int i=0;i<=19;i++){
        cout<<i<<" "<<num[i]<<endl;
    }*/
  
    ll ans=0;
    for(int t=18;t>=1;t--){
        if(num[t]==num[t+1])continue;
        mat B(3,vec(1));
        B={{a+(num[t])*d},{a+(num[t])*d},{1}};
        mat A(3,vec(3));
        A={ {po(10,t),1,d},
            {0,1,d},
            {0,0,1}};
        ll n=num[t+1]-num[t];
        A=pow(A,n-1);
        B=mul(A,B);
        Add(ans,mod(B[0][0]*S));
        S=mod(S*(ll)po(10,n*t));
        //cout<<ans<<" ";
    }
    cout<<mod(ans)<<endl;
    
    
    return 0;
}


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

int gcm(int x,int y){
	if(x<y)swap(x,y);
	int r=x%y;
	while(r!=0){
		x=y;
		y=r;
		r=x%y;
	}
	return y;
}

int main(){
	int N,K,m=0,g;
	cin >> N >> K;
	for(int i=0;i<N;i++){
		int A;
		cin >> A;
		m=max(m,A);
		if(i==0)g=A;
		else g=gcm(g,A);
	}
	if(K<=m && (m-K)%g==0)cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3005;
const ll mod=1000000007;
const ll half=500000004;
int n,m;
ll dp[N][N];
ll a[N];
struct node{
	int x,y;ll w;
	node(int x,int y,ll w):x(x),y(y),w(w){}
};
vector<node> v;
int main(){
	int i,j;
	cin>>n>>m;
	for(i=1;i<=n;i++) cin>>a[i];
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++)
			if(a[i]>a[j]) dp[i][j]=1;
	}
	ll po2=1;
	for(i=1;i<=m;i++) po2=po2*2%mod;
	while(m--){
		v.clear();
		int x,y;cin>>x>>y;
		for(i=1;i<=n;i++){
			if(i!=x&&i!=y){
				v.push_back(node(i,x,dp[i][y]*half%mod));
				v.push_back(node(x,i,dp[y][i]*half%mod));
				v.push_back(node(i,y,dp[i][x]*half%mod));
				v.push_back(node(y,i,dp[x][i]*half%mod));
			}
		}
		v.push_back(node(x,y,dp[y][x]*half%mod));
		v.push_back(node(y,x,dp[x][y]*half%mod));
		for(auto p:v)
			dp[p.x][p.y]=(dp[p.x][p.y]*half+p.w)%mod;
	}
	ll ans=0;
	for(i=1;i<=n;i++){
		for(j=i+1;j<=n;j++)
			ans=(ans+dp[i][j]*po2)%mod;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 71040
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

X = inputI()

def sign(i):
  if i>=0:
    return 1
  else:
    return -1
  
l = [pow(i,5) for i in range(-500,500)]

for i in l:
  for j in l:
    if i-j == X:
      print(int(pow(abs(i),0.2)*sign(i)) ,int(pow(abs(j),0.2)*sign(j)))
      exit()

Measured memory_bytes: 73384
#include <iostream>
#include <string>
#include <cstring>
using namespace std;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int ret=0;
bool chked[12][12];
bool f[12][12]; //0:sea 1:land

void bfs(int x, int y){
  //chk lands
  chked[x][y] = true;

  //cout << "(x,y) = (" << x << "," << y << ")" << endl;
  for(int i=0;i<4;i++){
    if((0 <= x+dx[i] && x+dx[i] <= 11 && 0 <= y+dy[i] && y+dy[i] <= 11) &&
       chked[x+dx[i]][y+dy[i]] == false && f[x+dx[i]][y+dy[i]] == 1){
      bfs(x+dx[i], y+dy[i]);
    }
  }
}


int main(void){
  string str;

  while(getline(cin,str)){
    memset(chked, false, sizeof(chked));
    ret = 0;

    if(str.empty()) continue;
    for(int i=0;i<12;i++){
      for(int j=0;j<12;j++){
	f[i][j] = str[j] - '0';
      }
      getline(cin,str);
    }

    for(int i=0;i<12;i++){
      for(int j=0;j<12;j++){
	if(f[i][j] == 1 && chked[i][j] == false){
	  bfs(i,j);
	  ret++;
	}
      }
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    private struct Pair { public int x, y; }
    public static void Main()
    {
        string s = NextString();
        string t = NextString();
        int a = s.Length;
        int b = t.Length;
        int[,] dp = new int[a + 1, b + 1];
        for (int i = 0; i < a; i++)
            for (int j = 0; j < b; j++)
            {
                if (s[i] == t[j]) dp[i + 1, j + 1] = dp[i, j] + 1;
                else dp[i + 1, j + 1] = Math.Max(dp[i, j + 1], dp[i + 1, j]);
            }
        int y = a;
        int x = b;
        string ans = "";
        while (dp[y, x] != 0)
        {
            if (dp[y, x] == dp[y - 1, x - 1]) { y--; x--; continue; }
            if (dp[y, x] == dp[y - 1, x]) { y--; continue; }
            if (dp[y, x] == dp[y, x - 1]) { x--; continue; }
            ans = s[y - 1].ToString() + ans;
            x--; y--;
        }
        Console.WriteLine(ans);
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 50232
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = str(input())
    bf =""
    count =0
    countstr=""
    for i in a:
        if bf == i:
            if count ==0:
                countstr=i
                count =2
            elif countstr==i:
                count+=1
        bf=i
    if count>2:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3956
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = long long;

ll nc2(ll n) { return (n * (n - 1)) / 2; }

int main(void) {
        ll n;
        cin >> n;

        vector<ll> v(n);
        unordered_map<ll, ll> freq;

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

        ll total = 0;
        for (auto kv : freq) total += nc2(kv.second);

        for (int i = 0; i < n; i++)
                cout << total - nc2(freq[v[i]]) + nc2(freq[v[i]] - 1) << endl;
}


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

int main() {
	long long a,s,d;
	cin>>a>>s>>d;
  long long c=d-a-s;
	if(c>0&&4*a*s<c*c)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256