akhauriyash/Code-Regression huggingface dataset:
N = int(input())
x, y, h = [0] * N, [0] * N, [0] * N
for i in range(N):
    x[i], y[i], h[i] = map(int, input().split())

for cx in range(0, 101):
    for cy in range(0, 101):
        for i in range(N):
            if h[i] > 0:
                H = h[i] + abs(x[i] - cx) + abs(y[i] - cy)

        for i in range(N):
            if h[i] != max(0, H - abs(x[i] - cx) - abs(y[i] - cy)):
                break
        else:
            print(cx, cy, H)
            exit()

Measured memory_bytes: 3064
nab = gets.chomp.split(" ").map(&:to_i)
s = gets.chomp.split("")

kakutei = 0
kaigai = 0

nab[0].times do |i|
  if s[i] == 'a'
    if kakutei < nab[1]+nab[2]
      puts "Yes"
      kakutei +=1
    else
      puts "No"
    end
  elsif s[i] == 'b'
    if kaigai < nab[2] && kakutei < nab[1]+nab[2]
      puts "Yes"
      kaigai += 1# if kaigai < n
      kakutei +=1
    else
      puts "No"
    end
  else
    puts "No"
  end
end


Measured memory_bytes: 9852
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs

const int MAXN = 3050;

string a, b;
int n, m;
int dp[MAXN][MAXN];
string ans;

int main() {

  getline(cin, a);
  getline(cin, b);

  n = sz(a); m = sz(b);

  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j]);
      dp[i][j + 1] = max(dp[i][j + 1], dp[i][j]);
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
      if (i < n && j < m && a[i] == b[j]) {
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
      }
      // cerr << dp[i][j] << " ";
    }
    // cerr << endl;
  }

  // cerr << dp[n][m] << endl;

  while (n && m) {
    if (a[n - 1] == b[m - 1] && dp[n][m] == dp[n - 1][m - 1] + 1) {
      ans.append(1, a[n - 1]);
      n--; m--;
      continue;
    }
    if (dp[n - 1][m - 1] == dp[n][m]) {
      n--; m--;
    } else if (dp[n - 1][m] == dp[n][m]) {
      n--;
    } else {
      m--;
    }
  }

  reverse(all(ans));
  cout << ans << endl;

  return 0;
}


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

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>


using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

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

	int A, B, C, D;
	cin >> A >> B >> C >> D;

	cout << max({ A*C,A*D,B*C,B*D }) << endl;

	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define PUTS(x) cout << (x) << endl;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
int main() {
    int n;
    string s;
    cin >> n >> s;
    auto dp = vector<vector<int>>(n, vector<int>(n, 0));
    auto ans = 0;
    rep(i, n) {
        rep(j, n) {
            if (i == j || s[i] != s[j]) continue;
            if (i == 0 || j == 0) {
                dp[i][j] = 1;
                continue;
            }
            dp[i][j] = min(dp[i - 1][j - 1] + 1, abs(i - j));
            ans = max(ans, dp[i][j]);
        }
    }
    PUTS(ans);
}


Measured memory_bytes: 98176
def call(n):
    s = ''
    for i in range(1,n+1):
        if i%3==0:
            s += ' ' + str(i)
        else:
            x = i
            while x:
                if x%10==3:
                    s += ' ' + str(i)
                    break
                x //= 10
    print(s)

if __name__ == "__main__":
    call(int(input()))


Measured memory_bytes: 5628
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

#define lsc(x)      scanf("%lld",&x)
#define sc(x)       scanf("%d",&x)
#define lpr(x)      printf("%lld ",x)
#define pr(x)       printf("%d ",x)
#define n_l         printf("\n")
#define VI          vector<int>
#define VII         vector<long long int>
#define MI          map<int, int>
#define PI          pair<int, int>
#define m_p         make_pair
#define pb          push_back
#define fi           first
#define se           second
#define mset(x,y)   memset(x,y,sizeof(x))
#define sz(v)       (int)v.size()
#define all(v)      v.begin(), v.end()
#define fr(i, a, n) for(int i=a;i<=n;i++)
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
const int N=(int)4e2+5;
const int mod = 1000000007;
typedef long long ll;
// order_of_key (val): returns the no. of values strictly less than val
// find_by_order (k): returns the kth largest element iterator.(0-based)
// vector<int>::iterator itr=lower_bound(v.begin(),v.end(),x);
// s.substr(pos[0-indexed], len(default=till end))
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
ll dp[N][N], a[N], sum[N][N];
int main(){
    int n;sc(n);fr(i,1,n)lsc(a[i]);
    fr(i,1,n) fr(j, 1, i) sum[j][i] = sum[j][i-1]+a[i];
    fr(i,1,n) fr(j,1,n) dp[i][j]=1e18;
    fr(len,1,n){
        fr(i,1,n-len+1){
            int k=i+len-1;
            if (i==k) dp[i][i]=0;
            fr(j,i,min(k, n)-1){
                dp[i][k] = min(dp[i][k], dp[i][j] + sum[i][j] + sum[j+1][k] + dp[j+1][k]);
            }
        }
    }
//    fr(i, 1, n) {fr(j, 1, n) lpr(dp[i][j]);n_l;}
    lpr(dp[1][n]);n_l;

    return 0;
}



Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define input1  freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); 
const ll nax =1e9+7;



void solve()
{
    int n,k;
    cin>>n>>k;
    vector<int>a;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        a.push_back(x);
    }
    sort(a.begin(),a.end());
    int ans=0;
    for(int i=0;i<k;i++)
    {
        ans+=a[i];
    }
    cout<<ans;
    
}

int main()
{
    //input1;

    solve();
    return 0;
}

Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	class V {
		int w;
		int h;
	}

	void run() {

		List<V> list = new LinkedList<V>();
		for (int i = 1; i < 151; i++) {
			for (int j = i + 1; j < 151; j++) {
				V v = new V();
				v.h = i;
				v.w = j;
				list.add(v);
			}
		}

		V[] v = list.toArray(new V[0]);
		Arrays.sort(v, Main::compare);
		for (;;) {
			int h = sc.nextInt();
			int w = sc.nextInt();
			if (w == 0 && h == 0) {
				break;
			}

			V vv = new V();
			vv.h = h;
			vv.w = w;

			int ind = Arrays.binarySearch(v, vv, Main::compare);
			System.out.println(v[ind + 1].h + " " + v[ind + 1].w);
		}

	}

	static int compare(V v1, V v2) {
		return v1.w * v1.w + v1.h * v1.h != v2.w * v2.w + v2.h * v2.h
				? v1.w * v1.w + v1.h * v1.h - v2.w * v2.w - v2.h * v2.h : 
					v1.h - v2.h;
	}

}



Measured memory_bytes: 32448
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
a.sort()
b = 1
ans = 0
for i in range(k - 1, n):
    ans += b * (a[i] - a[n - i - 1])
    ans %= mod
    b = (i + 1) * b
    c = i + 1 - (k - 1)
    b = pow(c, mod - 2, mod) * b % mod
print(ans)

Measured memory_bytes: 14044
n,a,b,c,d=map(int,input().split())
a-=1
b-=1
c-=1
d-=1
s=input()
bl_bl=[]
jump=[]
ans=1

for i in range(1,n-1):
    if s[i-1:i+1]=="##":
        if a<i<c or b<i<d:
            ans=2
            break
    if s[i-1:i+2]=="...":
        jump.append(i)

if ans!=2:
    if c<d:
        ans=0
    else:
        for i in jump:
            if b<=i<=d:
                ans=0
                break

print("Yes" if ans==0 else "No") 

Measured memory_bytes: 3572
/*
* @author:  codancer
* @createTime:  2020-03-28, 20:32:11
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(ll i=(a);i<=(b);i++)
#define fep(i,a,b) for(ll i=(a);i>=(b);i--)
typedef vector<int> VI;
typedef vector<ll> VII;
typedef pair<int,int> pii;
const int N = 2e5+100;
ll dis[N];
int main(){
	ll n,x,y;
	cin>>n>>x>>y;
	rep(i,1,n){
		rep(j,i,n){
			ll d=min(j-i,abs(i-x)+1+abs(j-y));
			++dis[d];
		}
	}
	rep(i,1,n-1){
		cout<<dis[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
High = list(map(int,input().split()))
Path = [None]*M
for i in range(M):
    #hyoujun-ka
    Path[i] =list(map(int,input().split()))
    Path[i][0]-=1
    Path[i][1]-=1

Graph = [None]*N
for i in range(N):
    Graph[i] =[]
for i in range(M):
    Graph[Path[i][0]].append(Path[i][1])
    Graph[Path[i][1]].append(Path[i][0])
for i in range(N):
    Graph[i] = set(Graph[i])
    Graph[i] = list(Graph[i])


ans=0
for i in range(N):
    if len(Graph) == 0:
        ans+=1
    else:
        for j in range(len(Graph[i])):
            if High[i] <= High[Graph[i][j]]:
                break
        else:
            ans+=1
print(ans)


Measured memory_bytes: 44120
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lowbit(a) ((a) & -(a))
#define clean(a, b) memset(a, b, sizeof(a))
#define eps (-1e8)
#define make_pair P
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int maxn = 3e5 + 9;

int _;


ll a[maxn],sum[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
    	scanf("%d",&a[i]);
	}
	ll ans=0;
	for(int i=n;i>=1;i--)
	{
		sum[i]=(sum[i+1]+a[i])%mod;
	}
	for(int i=n-1;i>=1;i--)
	{
		ans=(a[i]*sum[i+1]%mod+ans)%mod;
	}
	printf("%lld\n",ans);
    return 0;
}
 

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

class Cube{
public:
    int f[6];
    Cube(){}
    void roll_z(){ roll(1,2,4,3);}//
    void roll_y(){ roll(0,2,5,3);}// to W
    void roll_x(){ roll(0,1,5,4);}// to N
    void roll(int i, int j,int k,int l){
        int t = f[i]; f[i]=f[j]; f[j]=f[k]; f[k]=f[l]; f[l]=t;
    }
    void move(char ch){
        if( ch=='E') for (int i=0; i<3; i++)roll_y();
        if( ch=='W') roll_y();
        if( ch=='N') roll_x();
        if( ch=='S') for(int i=0; i<3; i++) roll_x();
    }
};

int main(){
    Cube c;
    string com;
    
    for(int i=0; i<6; i++) cin >> c.f[i];
    cin >> com;
    
    for(int i=0; i<com.size(); i++) c.move(com[i]);
    
    cout << c.f[0] << endl;
    
    return 0;
}


Measured memory_bytes: 3208
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		// String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);

		char[] carr = new char[str.length()];
		for (int i = 0; i < str.length(); i++) {
			switch (str.charAt(i)) {
			case 'A':
				carr[i] = str.charAt(i);
				break;
			case 'T':
				carr[i] = str.charAt(i);
				break;
			case 'C':
				carr[i] = str.charAt(i);
				break;
			case 'G':
				carr[i] = str.charAt(i);
				break;
			default:
				carr[i] = ' ';
			}
		}

		String[] strArr = new String(carr).split(" ");
		int ans = 0;
		for (String s : strArr) {
			if (ans < s.length())
				ans = s.length();
		}
		System.out.println(ans);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 21332
import java.util.Scanner;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author User
 */
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String iu = input.next();
        StringBuffer inu = new StringBuffer(iu);
        System.out.println(inu.reverse());
    }
}

Measured memory_bytes: 15276
#include <stdio.h>
int main(void)
{
    int h, w;
    while (1) {
	scanf("%d %d", &h, &w);
	if (h == 0 && w ==0) {
	    break;
	} else {
	    for (int i = 0; i < w; i ++) {
		printf("#");
	    }
	    printf("\n");
	    for (int j = 0; j < h - 2; j ++) {
		printf("#");
		for (int i = 0; i < w - 2; i ++) {
		    printf(".");
		}
		printf("#\n");
	    }
	    for (int i = 0; i < w; i ++) {
		printf("#");
	    }
	    printf("\n\n");
	}
    }
    return 0;
}

Measured memory_bytes: 1016
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n, T;
	cin >> n >> T;
	vi t(n);
	rep(i, 0, n) {
		cin >> t[i];
	}
	i64 ans = T;
	rep(i, 1, n) {
		if (t[i] - t[i - 1] < T) {
			ans += t[i] - t[i - 1];
		}
		else {
			ans += T;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
# 標準入力
N = int(input())
H = list(map(int, input().split()))
H.append(10**10)
count = [0 for i in range(N)]
i = 0
# 左からi番目に降り立って(iは0~N-1)、H[i]>=H[i+1]が続くまでcountを増やす。count[i]=5なら次はi+6から繰り返す
while i <= N-1:
  j = i
  while H[j] >= H[j+1]:
    count[i] += 1
    if j <= N-3:
      j += 1
    else:
      break
  i += count[i]+1
#max(count)を出力しよう
print(max(count))

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

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

vector< pair<int,int> > v(N+1);

for(int i=0;i<N;i++){
    int x,y;
    cin>>x>>y;
    v[i+1].first=x;
    v[i+1].second=y;
}

long long dp[N+1][W+1];
for(int i=0;i<N;i++)dp[i][0]=0;
for(int j=0;j<=W;j++)dp[0][j]=0;

for(int i=1;i<=N;i++){
 for(int j=1;j<=W;j++){
     if(v[i].first > j){
        dp[i][j]=dp[i-1][j];
     }else{
        dp[i][j]=max(dp[i-1][j-v[i].first]+v[i].second , dp[i-1][j]);
     }
   }
}

cout<<dp[N][W]<<endl;
    return 0;
}


Measured memory_bytes: 79104
#include <stdio.h>

int main()
{
    int a, b, sum;

    scanf("%d%d", &a, &b);
    char str[] = "error";

    sum = a + b;

    if(sum >= 10){
        printf("%s\n", str);
    }

    else{
        printf("%d\n", sum);
    }


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;


ll N, K;

ll bin_search(ll l, ll r, vector<ll> &pos, vector<ll> &neg){
    ll mid=(l+r)/2+(l+r)%2;
    if(mid==r){
        return mid;
    }

    ll cnt=0;
    for(auto it=neg.begin(); it!=neg.end(); it++){
        ll num=*it;
        cnt+=(ll) (upper_bound(neg.begin(), it, mid/num)-neg.begin());
        if(cnt>=K){
            //cout << mid << ' ' << *it << ' ' << (upper_bound(neg.begin(), it, mid/num)-neg.begin())<< endl;
            return bin_search(l, mid, pos, neg);
        }
    }
    for(auto it=pos.begin(); it!=pos.end(); it++){
        ll num=*it;
        cnt+=(ll) (upper_bound(pos.begin(), it, mid/num)-pos.begin());
        if(cnt>=K){
            //cout << mid << ' ' << *it << ' ' << (upper_bound(pos.begin(), it, mid/num)-pos.begin())<< endl;
            return bin_search(l, mid, pos, neg);
        }
    }
    return bin_search(mid, r, neg, pos);
}

ll bin_search_neg(ll l, ll r, vector<ll> &neg, vector<ll> &pos){
    ll mid=(l+r)/2;
    if(mid==l){
        return mid;
    }

    ll cnt=0;
    for(int i=0; i<(int)neg.size(); i++){
        cnt+=(ll) (pos.end()-lower_bound(pos.begin(), pos.end(), mid/neg[i]+(mid%neg[i]>0)));
        if(cnt>=K){
            return bin_search_neg(mid, r, neg, pos);
        }
    }
    return bin_search_neg(l, mid, neg, pos);
}

int main(){
    cin >> N >> K;
    vector<ll> vecp(0);
    vector<ll> vecn(0);
    ll zero=0;

    for(int i=0; i<N; i++){
        ll a;
        cin >> a;
        if(a>0){
            vecp.push_back(a);
        }else if(a==0){
            zero++;
        }else{
            vecn.push_back(-a);
        }
    }
    ll neg;
    neg=0;
    zero=(ll) zero*(vecp.size()+vecn.size())+zero*(zero-1)/2;
    neg=(ll) vecp.size()*vecn.size();
    
    
   sort(vecn.begin(), vecn.end());
    sort(vecp.begin(), vecp.end());

    if(K<=neg){
        cout << -bin_search_neg(0, MOD*MOD, vecn, vecp) << endl;;
    }else if(K<=zero+neg){
        cout << 0 << endl;
    }else{
        K-=neg+zero;
        //cout << K << endl;
        cout << bin_search(0, MOD*MOD, vecp, vecn) << endl;;
    }
}

Measured memory_bytes: 2420
#include <iostream>
 using namespace std;
int main(){
  int N;
  cin >>N;
  int ans;
  ans = 0;
  for(int i=1;i<=N;i++){
    int p;
    cin >> p;
    if(i%2==1 && p%2==1){
      ans++;
    }
  }
  cout << ans<<endl;
}

Measured memory_bytes: 3552
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 1
if n % 2:
    # 0.2,2,,4,4,6,6..
    if a[0] == 0:
        for i in range(n // 2):
            if a[i * 2 + 1] == a[i * 2 + 1] and a[i * 2 + 1] == i * 2 + 2:
                pass
            else:
                ans = 0
                break
    else:
        ans = 0
else:
    for i in range(n // 2):
        if a[i * 2 + 1] == a[i * 2] and a[i * 2 + 1] == i * 2 + 1:
            pass
        else:
            ans = 0
            break
if ans == 0:
    print(ans)
else:
    print(pow(2, n // 2, 10 ** 9 + 7))


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


string divide[4] = {"dream", "dreamer", "erase", "eraser"};
bool dp[100010];

int main() {
  string S;
  cin >> S;
  
  dp[0] = 1;
  for (int i = 0; i < S.size(); i++) {
    if (!dp[i]) continue;  // そこまでで矛盾があったらとりあえず無視
    for (string s : divide) { // 文字列を1つずつfor文で取り出す
      if (S.substr(i, s.size()) == s) { // うまく切れたら先に進む
        dp[i + s.size()] = 1;
      }
    }
  }
  cout << (dp[S.size()] ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		int k,p;
		cin >> k >> p;
		if(k%p != 0){
			cout << k%p << endl;
		}
		else{
			cout << p << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <cstdlib>
#include <iomanip>

 
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
 
using namespace std;
 
typedef long long ll;

int main(int argc, char const *argv[])
{
  std::setprecision(14);
  long double res = 0.0L;
  ll n, k;
  cin >> n >> k;
  if (n >= k) {
  res = (long double)((long double)(n-k+1.0L)/(long double)n);
  }
    long double tmpres = 0.0L;
  for (int i = 1; i <= (n>=k ? k-1 : n); i++) {
    int tmp = i;
    int pown = 0;
    while(true){
      tmp = tmp*2;
      pown++;
      if (tmp >= k) {
      tmpres +=1.0L/powf(2.0L,(long double)pown);
        break;
      }   
    }
  
  }
  tmpres = tmpres/(long double)n;
  std::cout<<std::fixed<<std::setprecision(11);
  res+= tmpres;
  
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
s = input() # sを取得し、strに値を入れる
index = -1
cnt=0
for char in s:
    target = char
    
    while True:
        index = s.find(target, index + 1)
        if index == -1:
            break
        #print('start=%d' % index)
        cnt=cnt+1

if(cnt==8):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl

using namespace std;
typedef long long  ll;

const long long MOD = 1e9+7;

int main(){

    ll n, a, b;
    cin >> n >> a >> b;

    ll count = 0;
    ll ans = 0;

//    while(count <= n){
//        ans += a;
//        count += a + b;
//    }

    ll time;
    time = (n / (a + b) ) + 1;
    ans = a*time;
    count = (a+b) * time;

    if(count - n > b){
        ans -= count - n - b;}

    p(ans);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define li long long int
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i = 0; i< n ; i++){
    cin>>a[i];
  }
 sort(a.begin() , a.end());
 //li count=0 , count1=0;
 if(n%2 != 0)
    cout<<0<<endl;
 else {
    if(a[n/2]==a[n/2 - 1])
        cout<<0<<endl;
    else {
        cout<<a[n/2] - a[n/2 - 1]<<endl;
    }

 }





}


Measured memory_bytes: 640
borders = []
n = 0
for i in range(1, 12):
    n += 26 ** i
    borders.append(n)
borders.sort(reverse=True)
chars = [chr(97 + i) for i in range(26)]

N = n = int(open(0).read())
keta = {}
for i, b in enumerate(borders):
    j = 0
    k = 26 ** (11 - i)
    while n > b:
        n -= k
        j += 1
    if j > 0:
        keta[11 - i] = chars[j - 1]
if n > 0:
    keta[0] = chars[n - 1]
ret = [keta[i] if i in keta else '_' for i in range(12, -1, -1)]
print("".join(ret[12 - max(keta.keys()):]))

Measured memory_bytes: 9272
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()

using namespace std;

const int MAX = 510000;
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()
{
    COMinit();
    int n, k;
    cin >> n >> k;
    vector<ll> v(n, 0);
    rep(i, n) cin >> v[i];
    sort(ALL(v));
    ll ans = 0;
    rep(i, n)
    {
        ans += COM(i, k - 1) * v[i];
        ans -= COM(n - 1 - i, k - 1) * v[i];
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12928
using System;
using System.Collections.Generic;
using System.Linq;

class B
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var ss = new int[n].Select(_ => Console.ReadLine()).OrderBy(s => s.Length).ToArray();

		var r = 0L;
		var nodes = new List<int[]> { new int[26] };
		var ends = new List<int[]> { new int[26] };

		foreach (var s in ss)
		{
			var id = 0;
			for (int i = s.Length - 1; i >= 0; i--)
			{
				if (i == 0)
					ends[id][s[i] - 'a']++;
				else
					for (int j = 0; j < 26; j++)
					{
						if (ends[id][j] == 0) continue;
						var c = (char)('a' + j);
						if (s.IndexOf(c, 0, i + 1) >= 0)
							r += ends[id][j];
					}

				var nid = nodes[id][s[i] - 'a'];
				if (nid == 0)
				{
					nodes[id][s[i] - 'a'] = nid = nodes.Count;
					nodes.Add(new int[26]);
					ends.Add(new int[26]);
				}
				id = nid;
			}
		}
		Console.WriteLine(r);
	}
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 5e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int n, x[maxn], a[maxn];
bool alpha[maxn], valid = true;

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

	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> x[i], x[i]--;

	for (int i = 0; i < n; i++)
	{
		if (a[x[i]])
			valid = false;
		a[x[i]] = i + 1;
		alpha[x[i]] = true;
	}
	int pos = 0;
	for (int i = 0; i < n * n; i++)
	{
		if (a[i])
		{
			int cnt = a[i] - 1;
			while (cnt && pos <= i)
			{
				if (a[pos])
					pos++;
				else
					a[pos] = a[i], cnt--, pos++;
			}
			if (cnt)
				valid = false;
		}
	}

	pos = n * n - 1;
	for (int i = n * n - 1; i >= 0; i--)
	{
		if (alpha[i])
		{
			int cnt = n - a[i];
			while (cnt && pos >= i)
			{
				if (a[pos])
					pos--;
				else
					a[pos] = a[i], cnt--, pos--;
			}
			if (cnt)
				valid = false;
		}
	}

	if (valid)
	{
		cout << "Yes" << endl;
		for (int i = 0; i < n * n; i++)
			cout << a[i] << ' ';
		cout << endl;
	}
	else
		cout << "No" << endl;
}


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

// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> P;
typedef pair<lint, lint> Plint;
 
const int MOD = 1e9+7;
const int INF = 1<<18;
const lint INFLINT = 1LL<<60;
const double PI=acos(-1.0);
 
// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;
 
// 繰り返し
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define reps(i,n) for(lint i=0;i<=(lint)(n);i++)
#define rrep(i,n) for(lint i=(lint)(n)-1;i>0;i--)
#define rreps(i,n) for(lint i=(lint)(n)-1;i>=0;i--)

#define pb push_back

#define ALL(s) (s.begin(), s.end())
#define SZ(s) (s.size())

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

// Union-Find-Tree
class UnionFind {
	vector<int> par;
	UnionFind(int n):par(n){rep(i,n)par[i]=i;}
	int root(int x){if(par[x]==x)return x;return par[x]=root(par[x]);}
	void unite(int x,int y){int rx=root(x);int ry=root(y);if(rx==ry)return;par[rx]=ry;}
	bool same(int x,int y){return root(x)==root(y);}
};

// Final Weapon!
// #define int lint

int main() {
    lint h, w;
    cin >> h >> w;
    
    if(h == 1 || w == 1) {
        cout << 1 << endl;  
    } else if(h % 2 == 0) {
        cout << h / 2 * w << endl;
    } else {
        cout << h / 2 * w + w / 2 + (w % 2 == 0 ? 0 : 1) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <iostream> 
#include <iomanip>  
#include <string>
#include <sstream>  
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <cstring>
#include <cmath>
#include <cassert>


#define INF              (int)1000000007
#define EPS              1e-9
#define pb               push_back
#define mp               make_pair
#define all(c)           c.begin(), c.end()
#define forall(i,a,b)    for(int i=a;i<(b);++i)
#define trav(a,x)        for(auto & a: x)
#define in(a,b)          ((b).find(a) != (b).end())
#define sz(c)            (int)(c).size()
#define input(a)         for(auto & x : a) cin >> x;

using namespace std;

typedef vector<int>      vi;
typedef pair<int,int>    ii;
typedef vector<vi>       vvi;
typedef vector<ii>       vii;
typedef vector<vector<ii>> vvii;
typedef long long        ll;

#ifdef DEBUG
#define trace(...)       __f(#__VA_ARGS__, __VA_ARGS__)
#define debug(args...)   {dbg,args; clog<<endl;}
#define print_( a )      for( auto & x : a ) clog << x << ' '; clog << '\n';
#define printPair_( a )  for( auto & x : a ) clog << '(' << x.first << ',' << x.second << ')' << ' '; clog << '\n';
#else
#define trace(...)       
#define debug(args...)            
#define print_( a )               
#define printPair_( a )           
#endif

struct debugger {
  template<typename T> debugger& operator , (const T& x) {    
    clog << x << " ";    return *this;    
  }
}dbg;

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " | ";
    __f(comma + 1, args...);
}

auto ____ =[]() { std::ios::sync_with_stdio(0); cin.tie(0); return nullptr; }();

int n,m,L;
int main( int argc, char * argv[] ){
  cin >> n >> m >> L; 
  vector<vector<ll>> edges(m, vector<ll>(3));
  vector<vector<ll>> dp(n, vector<ll>(n, 1e15));
  forall(i,0,n) dp[i][i] = 0;

  forall(i,0,m){
    int a,b,c;
    cin >> a >> b >> c;
    --a, --b;
    dp[a][b] = c;
    dp[b][a] = c;
  }

  forall(k,0,n){
    forall(i,0,n){
      forall(j,0,n){
        if( dp[i][j] > dp[i][k] + dp[k][j] )
          dp[i][j] = dp[i][k] + dp[k][j];
      }
    }
  }

  vvi dp2(n, vi(n, INF));
  forall(i,0,n) dp2[i][i] = 0;
  forall(i,0,n){
    forall(j,0,n){
      if(i!=j and dp[i][j] <= L){
        dp2[i][j] = 1;
      }
    }
  }
  forall(k,0,n){
    forall(i,0,n){
      forall(j,0,n){
        if( dp2[i][j] > dp2[i][k] + dp2[k][j] )
          dp2[i][j] =  dp2[i][k] + dp2[k][j] ;
      }
    }
  }
  int T; cin >> T;
  while(T--){
    int s,t; 
    cin >> s >> t;
    --s, --t;
    cout << (dp2[s][t] == INF ? -1 : dp2[s][t]-1) << '\n';
  }

  return 0;
}


Measured memory_bytes: 3968
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		boolean flag = true;
		List<String> list = new ArrayList<>();
		String first = in.next();
		list.add(first);
		char lastChar = first.charAt(first.length()-1);
		for(int i=1;i<n;i++) {
			String str = in.next();
			if(list.contains(str)) {
				flag = false;
			}
			if(str.charAt(0)!=lastChar) {
				flag = false;
			}
			lastChar = str.charAt(str.length()-1);
			list.add(str);
		}
		
		if(flag) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		

	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,n) for(int i=1; i<=(n); i++)

int main() {
    int n,m,tmp,bit,ans=0,num;
    bool cor;
    cin>>n>>m;
    vector<int>sw(m),swnum(m),on(m);
    rep(i,m){
        cin>>swnum[i];
        rep(j,swnum[i]){
            cin>>tmp;
            sw[i]|=(1<<(tmp-1));
        }
    }
    
    rep(i,m)cin>>on[i];
    rep(i,(1<<n)){
        cor=true;
        rep(j,m){
            num=__builtin_popcount(i&sw[j]);
            if((num+on[j])%2)cor=false;
        }
        if(cor)ans++;
    }
    
    cout<<ans;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<double,double> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int n;
  int cas = 1;
  while(cin>>n){
    if(n==0) break;
    vector<P> p;
    REP(i,n){
      double x,y;
      cin>>x>>y;
      p.push_back(P(x,y));
    }
    p.push_back(p[0]);
    double ans = 0;
    REP(i,p.size()-1){
      ans += 0.5*(p[i+1].first-p[i].first)*(p[i].second+p[i+1].second);
    }
    printf("%d %.1lf\n",cas++,ans);
  }
    
  return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int N=sc.nextInt();
        sc.nextLine();
        String[] s=new String[N];
        for(int i=0;i<N;i++){
            s[i]=sc.nextLine();
        }
        int M=sc.nextInt();
        sc.nextLine();
        String[] t=new String[M];
        for(int i=0;i<M;i++){
            t[i]=sc.nextLine();
        }
        int max=0;
        for(int i=0;i<N;i++){
            int cnt=1;
            for(int k=i+1;k<N;k++){
                if(s[i].equals(s[k])){
                    cnt=cnt+1;
                }
            }
            for(int k=0;k<M;k++){
                if(s[i].equals(t[k])){
                    cnt=cnt-1;
                }
            }
            if(max<cnt){
                max=cnt;
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 24660
#include<stdio.h>
int min(int a,int b){
    if(a>b) return b;
    else return a;
}

int gcd(int a,int b){
    if(a>=b){
        if(b == 1) return 1;
        if(a%b == 0) return b;
        else
            return gcd(b,a%b);
    }
    else{
        if(a == 1) return 1;
        if(b%a == 0) return a;
        else
            return gcd(a,b%a);
    }
}

int main(){
    int K;
    scanf("%d",&K);
    int sum=0;
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            for(int k=1;k<=K;k++){
                int x=gcd(i,j);
                sum += min(x,gcd(x,k));
            }
        }
    }
    printf("%d",sum);
}


Measured memory_bytes: 1732
s = input()
t = input()

stri = []
mincount = -1
for i in range(len(s)-len(t)+1):
    count = 0
    for j in range(len(t)):
        if(s[i+j] == t[j]):
            count+= 1
    mincount = max(mincount,count) 
print(len(t) - mincount)


Measured memory_bytes: 9076
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)

	var answer string

	if a == b && a != c || a == c && a != b || b == c && b != a  {
		answer = "Yes"
	} else {
		answer = "No"
	}
	fmt.Println(answer)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    int N;
    cin >> N;
    cout << N*N*N << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int a_idx = s.indexOf("A");
    int z_idx = s.lastIndexOf("Z");
    System.out.println(z_idx - a_idx + 1);
  }
}

Measured memory_bytes: 27164
X = int(input())
DP = [[0]*(X+1) for i in range(6)]
A = [100+i for i in range(6)]
DP[0][0] = 1
for i in range(6):
    for x in range(X+1):
        if i==0:
            if x>=100:
                DP[i][x] = DP[i][x-100]
        else:
            a = A[i]
            DP[i][x] = DP[i-1][x]
            if x>=a:
                DP[i][x] = max(DP[i][x],DP[i][x-a])
print(DP[5][X])

Measured memory_bytes: 7796
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
    int n,l;cin>>n>>l;string x;
    vector<string> vec(n);
    for(int i=0;i<n;i++){
        cin>>x;vec[i]=x;
    }
    sort(all(vec));
    string ans="";
    for(string x:vec)ans+=x;
    cout<<ans<<endl;
}


Measured memory_bytes: 3656
import math
import sys
S=input()
count=0
for i in range(len(S)):
    if S[i]=="o":
        count+=1
    if count>=8:
        print("YES")
        sys.exit()
if len(S)<15:
    count+=15-len(S)
    if count>=8:
        print("YES")
        sys.exit()
print("NO")

Measured memory_bytes: 3060
def solve(N, As):
    As.sort()
    for i in range(1, N):
        if As[i - 1] == As[i]:
            print('NO')
            return
    print('YES')


if __name__ == '__main__':
    N = int(input())
    As = [int(i) for i in input().split()]
    solve(N, As)


Measured memory_bytes: 25172
from itertools import permutations
N,M = list(map(int,input().split()))
e = [list(map(int,input().split())) for i in range(M)]
a = 0

for p in permutations(range(1,N+1)):
  f = True
  if p[0]==1:
    for i in range(N-1):
      if sorted([p[i],p[i+1]]) not in e:
        f = False
    if f:
      a+=1

print(a)

Measured memory_bytes: 3060
from itertools import *

if __name__=="__main__":
    n,k = map(int,input().split(' '))
    d = list(map(int,(input().split(' '))))
    d = [i for i in range(10) if i not in d]
    ans = 1e10
    keta = len(str(n))
    for k in range(1,keta+2):
        for perm in product(d,repeat=k):
            num = 0
            for v in perm:
                num = 10*num+v
            if n <= num and num < ans:
                ans = num
    print(ans)



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

int main() {
	int N,A,B,C;
	cin >> N >> A >> B >> C;
	vector<int> vi(N);
	int sum=C;
	for(int i=0; i<N; ++i){
		cin >> vi[i];
	}
	sort(vi.begin(),vi.end(),greater<int>());
	int result=sum/A;
	for(int i=0; i<N; ++i){
		sum+=vi[i];
		if(result<sum/(A+B*(i+1))) result=sum/(A+B*(i+1));
		//else break;
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 1216
import copy
a = list(input())
if len(a) == 5:
  print("No")
  exit()
else:
  b = copy.copy(a)
  b.reverse()
  x = int((len(a)/2))
  for i in range(x):
    if a[i] != b[i]:
      print("No")
      exit()
  c = a[:x]
  d = a[x+1:]
  y = int((len(c)/2))
  for i in range(y):
    if c[i] != c[-(i+1)] or d[i] != d[-(i+1)]:
      print("No")
      exit()
  print("Yes")

Measured memory_bytes: 9288
# import bisect
# import heapq
# from copy import deepcopy
# from collections import deque
# from collections import Counter
# from itertools import accumulate
# from itertools import permutations
# import numpy as np
import math
# mod = 10**9 + 7

n = int(input())
d = list(map(int, input().split()))
# n = int(input())
ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        ans += d[i] * d[j]

print(ans)

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

  if (S === T.slice(0, T.length - 1)) {
    console.log('Yes');
  } else {
    console.log('No');
  }
}

// デバッグ用
function debug() {
  var input = document.getElementById("input").value;
  Main(input);
}

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

Measured memory_bytes: 29500
//QWsin
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=next[i])
#define repvc(i,vc) for(int i=0,_sz=vc.size();i<_sz;++i)
using namespace std;

const int INF=1<<30;
typedef long long ll;

inline int read()
{
	int ret=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0'&&ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

struct Edge{
	int a,b;
	Edge(int a=0,int b=0):a(a),b(b){}
};

vector<Edge>vc;

int main()
{
	int n,k;cin>>n>>k;
	if(k>(n-1)*(n-2)/2) {
		cout<<-1<<endl;
		return 0;
	}

	int cur=0;
	rep(i,2,n)
	{
		vc.push_back(Edge(i,1));
		cur=cur+i-2;
		if(cur==k){
			rep(j,i+1,n) rep(k,1,j-1) vc.push_back(Edge(j,k));
			break;
		}
		if(cur>k)
		{
			rep(j,2,2+(cur-k)-1) vc.push_back(Edge(i,j));
			rep(j,i+1,n) rep(k,1,j-1) vc.push_back(Edge(j,k));
			break;
		}
	}
	printf("%d\n",vc.size());
	rep(i,0,vc.size()-1) printf("%d %d\n",vc[i].a,vc[i].b);
	return 0;
}


Measured memory_bytes: 384
N, X, M = map(int, input().split())

count = X
bef = X
_sum = [bef]
dic = {}

for i in range(1, N):
    bef = pow(bef, 2, M)
    if bef in dic:
        posi = dic[bef]
        l = len(_sum) - posi
        plus = sum(_sum[posi:])
        count += plus * ((N - i) // l)
        mod = ((N - i) % l)
        count += sum(_sum[posi:posi + mod])
        break
    else:
        dic.setdefault(bef, i)
        _sum.append(bef)
    count += bef

print(count)

Measured memory_bytes: 77528
#include <stdio.h>
//#include <math.h>
#define MIN(x,y) (((x) > (y)) ? (y) : (x))
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))
int main() {
  char s[4];
  scanf("%s", s);
  if (s[1] == 'B') {
    printf("ARC");
  } else {
    printf("ABC");
  }
  return 0;
}

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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while (1) {
        C -= B;
        if (C <= 0) { cout << "Yes\n"; break; }
        A -= D;
        if (A <= 0) { cout << "No\n"; break; }
    }
    return 0;
}

Measured memory_bytes: 3616
from collections import defaultdict, deque

MOD = int(1e9+7)
N, K = map(int, input().split())
# def dfs(s, E):
E = defaultdict(list)
for i in range(N-1):
    a, b = map(int, input().split())
    E[a].append(b)
    E[b].append(a)
visited = [False] * N
q = deque()
q.append(1)
visited[0] = True
ans = K
while q:
    now = q.pop()
    if now == 1:
        available = K-1
    else:
        available = K-2
    for nxt in E[now]:
        if not visited[nxt-1]:
            if available <= 0:
                print(0)
                exit()
            ans = (ans * available) % MOD
            available -= 1
            q.append(nxt)
            visited[nxt - 1] = True
print(ans)

Measured memory_bytes: 29268
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int n;
    cin>>n;
    int a[n+1],d[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        d[a[i]]=i;
    }
    sort(a,a+n);
    for(int i=1;i<=n;i++){
        if(i==n)cout<<d[i]<<endl;
        else cout<<d[i]<<" ";
    }
    return 0;
}

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

int main(){
    ll n,k;cin>>n>>k;
    ll x=n-n%2019;
    ll km=k-x;
    ll nm=n%2019;
    ll ans=2018;
bool more =0;
    if(km-nm>=2019){more=1;ans=0;}
    
 if(!more) {  for(ll i=nm;i<km;i++){
        for(ll j=nm+1;j<km+1;j++){
if(ans>(i*j)%2019){ans=(i*j)%2019;}
        }
    }}//差が2019以内

cout<<ans<<endl;



}

Measured memory_bytes: 256
import sys
from collections import defaultdict

input = sys.stdin.readline
n = int(input())
v_list = list(map(int, input().split()))
even_dic = defaultdict(int)
odd_dic = defaultdict(int)
for i in range(n):
    if i % 2 == 0:
        even_dic[v_list[i]] += 1
    else:
        odd_dic[v_list[i]] += 1
even = sorted(even_dic.items(), key=lambda x:x[1], reverse=True)
odd = sorted(odd_dic.items(), key=lambda x:x[1], reverse=True)
if even[0][0] == odd[0][0]:
    if len(even) > 1 and len(odd) > 1:
        ans = min((n-even[1][1]-odd[0][1]), (n-even[0][1]-odd[1][1]))
    elif len(even) > 1:
        ans = int(n/2) - even[1][1]
    elif len(odd) > 1:
        ans = int(n/2) - odd[1][1]
    else:
        ans = int(n/2)
else:
    ans = n - even[0][1] - odd[0][1]
print(ans)


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

lint N, C, K;
vector<lint> Ts;
int main()
{
    cin >> N >> C >> K;
    lint dep = -1, cap = 0;

    int ans = 0;
    Ts.resize(N);
    cin >> Ts;
    sort(Ts.begin(), Ts.end());
    for (auto T : Ts)
    {
        if (cap == 0 || T > dep) ans++, dep = T + K, cap = C - 1;
        else cap--;
    }
    cout << ans << endl;
}


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

using namespace std;
int main(){
    char b;
    cin >> b;
    if(b=='A') cout << "T" << endl;
    else if(b=='T') cout << "A" << endl;
    else if(b=='C') cout << "G" << endl;
    else if(b=='G') cout << "C" << endl;
    return 0;
}

Measured memory_bytes: 3568
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

int n, m;

void solve() {
    vector<pair<int, int>> vec;
    int ans = 0;

    for (int i = 0; i < n; i++) {
        int d, p;
        cin >> d >> p;
        // -p ??¨??????????????????????????°???????????????????????§??????
        vec.push_back(make_pair(-p, d));
    }
    sort(vec.begin(), vec.end());

    for (auto e : vec) {
        int p = -e.first;
        int dist = e.second;
        if (m - dist < 0) {
            ans += (dist - m) * p;
            m = 0;
        } else {
            m -= dist;
        }
    }
    cout << ans << endl;
}

int main() {
    while (cin >> n >> m) {
        if (n + m == 0) return 0;
        solve();
    }

    return 0;
}

Measured memory_bytes: 3140
N, M = map(int, input().split())

ans = []
n = M // 2
m = 2 * n + 1
l = 2 * M + 1
for i in range(n):
    ans.append([i + 1, m - i])

for i in range(M - n):
    ans.append([m + i + 1, l - i])

for v in ans:
    print(*v)


Measured memory_bytes: 80924