akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000000000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);ios::sync_with_stdio(false);

signed main()
{
    ll n,ans=0,p=1;cin>>n;
    vector<ll> v(n);
    rep(i,n){
        cin>>v[i];
        if(v[i]==p){
            p++;
        }
        ans+=(v[i]+p-1)/p -1;
        if(p==1){
            p++;
        }
    }
    cout<<ans<<endl;
}

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

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

    float num[2];
    for (int i = 0; i < 2; i++) {
        cin >> num[i];
    }
    float result = (num[0] + num[1]) / 2;
    int cut = result + 0.5;
    if (result >= cut) {
        cout << round(result);
        return 0;
    } else {
        cout << ceil(result);
        return 0;
    }
}

Measured memory_bytes: 256
import itertools
palindromic_numbers = [0] * 100001
for i, j, k in itertools.product(range(1, 10), range(10), range(10)):
    palindromic_numbers[i * 10000 + j * 1000 + k * 100 + j * 10 + i] = 1
A, B = [int(_) for _ in input().split()]
print(sum(palindromic_numbers[A:B + 1]))


Measured memory_bytes: 4468
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

using namespace std;

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

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	ll A, B, C;
	cin >> A >> B >> C;
	if (!(A & 1) || !(B & 1) || !(C & 1))
	{
		cout << 0 << endl;
	}
	else
	{
		cout << min({A * B, B * C, A * C}) << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#define n 3000
int main(void){
	int a[n][2];
	int i=0,j;
	int temp;
	while(i<=n){
		scanf("%d %d",&a[i][0],&a[i][1]);
		if(a[i][0]==0&&a[i][1]==0)break;
		if(a[i][0]>a[i][1]){
			temp=a[i][0];
			a[i][0]=a[i][1];
			a[i][1]=temp;
		}
		i++;
	}
	for(j=0;j<i;j++)printf("%d %d\n",a[j][0],a[j][1]);
	return 0;
}



Measured memory_bytes: 2052
#pragma GCC optimize "-O3"
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define NumberOfOnes __builtin_popcount
#define LSOne(S) (S & (-S))
#define ll long long
#define two pair<int,int>
#define twoll pair<ll,ll>
#define four pair<two,two>
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define y1 y1922
#define INF 1000000000000000000
#define P 1000000007
#define lmax 1000000000
#define nn 1000003
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define vi vector<int>
#define vll vector<ll>
#define vtwo vector<two>
#define ALL(container) (container).begin(), (container).end()
#define sz(container) (int)(container.size())
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define mid(a,b) (a+b>>1)
#define minN 0
#define maxN 10000000
#define na(x) ((x)<P?(x):(x)-P)
#define ab(a) (-(a)<(a)?(a):-(a))
#define FAST std::ios::sync_with_stdio(false)
#define xRand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define rnd rng
#define IT iterator
typedef
tree<
  int,// aq pair<int,int> shegidzlia
  null_type,
  less/*_equal*/<int>,// aqac
  rb_tree_tag,
  tree_order_statistics_node_update>
ordered_set;
// '_equal' mashin ginda roca multiset gchirdeba
template<class key, class value,class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;
ordered_map<int, int> my_map;
inline int rin(){
	int x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
inline int bin(){
	int x=0;char ch=getchar();
	while (ch<'0'||ch>'9') ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x;
}
int n,ans,a,b,w[100004];
vector<int>v[100004];
void go(int sad,int saidan){
	w[sad]=0;
	for(auto i:v[sad]){
		if(i==saidan) continue;
		go(i,sad);
		w[sad]^=w[i]+1;
	}
}
int main(){FAST;xRand;
cin>>n;
for(int i=1;i<n;i++){
	cin>>a>>b;
	v[a].pb(b);
	v[b].pb(a);
	
}
go(1,-1);
if(w[1]==0){
	cout<<"Bob"<<endl;
}else{
	cout<<"Alice"<<endl;
}
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
                 *   *   * *   *
                  *   *   *   *
                   *   * *   *
                     *  *   *
					   *  *


*/



Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int INF = 1e9 + 5;

int main()
{
    ll n, w, wi[102], val[102], sum = 0;
    cin >> n >> w;
    for(ll i = 1; i <= n; i++)
    {
        cin >> wi[i] >> val[i];
        sum += val[i];
    }
    ll dp[n + 1][sum + 1];
    for(ll i = 0; i <= n; i++)
        for(ll j = 0; j <= sum; j++) dp[i][j] = INF;
    for(ll i = 0; i <= n; i++) dp[i][0] = 0;
    for(ll i = 1; i <= n; i++)
    {
        for(ll j = 0; j <= sum; j++)
            dp[i][j] = dp[i - 1][j];
        for(ll j = sum; j >= 0; j--)
        {
            if(j - val[i] >= 0)
                dp[i][j] = min(dp[i - 1][j], wi[i] + dp[i][j - val[i]]);
        }
    }
    for(ll i = sum; i >= 0; i--)
    {
        ll mxw = INF;
        for(ll j = 1; j <= n; j++)
        {
            mxw = min(mxw, dp[j][i]);
        }
        if(mxw <= w)
        {
            cout << i;
            break;
        }
    }
    /*for(ll i = 0; i <= n; i++)
    {
        for(ll j = 0; j <= w; j++)
            cout << dp[i][j] << ' ';
        cout << '\n';
    }*/
}


Measured memory_bytes: 79104
package main

import "fmt"

func main(){
	var N int
	fmt.Scan(&N)
	W := make([]string, N)
	for i := 0 ; i < N ; i++ {
		fmt.Scan(&W[i])
	}
	f:= 0
	for i := 0 ; i < N ; i++ {
		for j := i+1 ; j < N ; j++ {
			if W[i] == W[j] {
				f = 1
				break
			}
		}
		if f == 1 {
			break}
	}

	for i := 1 ; i < N ; i++ {
		// fmt.Println(W[i-1][len(W[i-1])-1])
		if W[i][0] == W[i-1][len(W[i-1])-1]{

		}else {
			f = 1
			break
		}
	}
	if f == 1 {
		fmt.Println("No")
	}else {
		fmt.Println("Yes")
	}
	// fmt.Println(W)
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	int ans = 0;
	ans = max(ans, C - (A - B));
	cout << ans;

	return 0;
}


Measured memory_bytes: 256
import heapq
n,m=map(int,input().split())
a=[int(i) for i in input().split()]
d={}
l,q=[],[]
for i in a:
    if i in d: d[i]+=1
    else: d[i]=1

for i in d: heapq.heappush(q, i)

for i in range(m):
    b,c=map(int,input().split())
    l.append((c,b))
l.sort(reverse=True)

for c,b in l:
    while b:
        if len(q)==0 or c<=q[0]: break
        x=min(b,d[q[0]])
        if c in d:
            d[c]+=x
        else:
            d[c]=x
        b-=x
        d[q[0]]-=x
        if d[q[0]]==0:
            heapq.heappop(q)
ans=0
for i in d:
    ans+=i*d[i]
print(ans)

Measured memory_bytes: 27980
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var s = Console.ReadLine();
            var k = int.Parse(Console.ReadLine());
            var hash = new HashSet<string>();
            for (var i = 0; i < s.Length; i++)
            {
                for (var j = i; j < s.Length; j++)
                {
                    var length = j - i + 1;
                    if (length <= k) hash.Add(s.Substring(i, length));
                }
            }
            var ss = hash.ToList();
            ss.Sort(StringComparer.Ordinal);
            Console.WriteLine(ss[k - 1]);
        }
    }
}


Measured memory_bytes: 14432
A, B = map(int, input().split())
if A == B:
    print(A)
else:
    K = []
    if A % 2 == 1:
        K.append(A)
        A += 1
    if (B - A) % 2 == 0:
        if ((B - A) // 2) % 2 == 0:
            K.append(B)
        else:
            K.append(1)
            K.append(B)
    else:
        if ((B - A - 1) // 2) % 2 == 0:
            K.append(B-1)
            K.append(B)
        else:
            K.append(1)
            K.append(B-1)
            K.append(B)
    ans = 0
    for i in K:
        ans = (ans ^ i)
    print(ans)

Measured memory_bytes: 62008
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<pair<int,int>,null_type, less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
const int N=1e5+10, mod=1e9+7;
ll dp[N][2];
vector<int> g[N];

void dfs(int u,int p){
	
	dp[u][0]=dp[u][1]=1LL;
	for(auto v:g[u]){
		if(v==p) continue;
		dfs(v,u);
		
		dp[u][0]*=dp[v][1]; // black can come only after white
		dp[u][1]*=((dp[v][1]+dp[v][0])%mod) ; // white can come in series with both white and black
		
		dp[u][0]%=mod;
		dp[u][1]%=mod;
	}
	
}

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++){
		int x,y;
		cin>>x>>y;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(1,0);
	cout<<(dp[1][0]+dp[1][1])%mod;
}

// check for any potential overflow before submitting


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

using namespace std;
using LL = long long;

const LL mod = 1e9 + 7;


LL foo(LL n, LL k, LL x, LL y) {
	LL rv = (k * (x + (k * y) % mod)) % mod;
	LL s = (k * (k + 1) / 2) % mod;
	s = s * y % mod;
	rv -= s;
	rv %= mod;
	if (rv < 0) rv += mod;
	return rv;
}

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

	LL n, k;
	cin >> n >> k;

	vector< int> v(n);
	for (int &e : v) cin >> e;

	LL result = 0;
	for (int i = 0; i < n; i ++) {
		LL x = 0;
		LL y = 0;
		for (int j = i + 1; j < n; j ++) {
			if (v[j] < v[i]) x ++;
		}
		for (int j = 0; j < n; j ++) {
			if (v[j] < v[i]) y ++;
		}

		result += foo(n, k, x, y);
		result %= mod;
	}

	cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }

    int n; cin >> n;
    vector<array<ll, 3>> h(n+1);
    for (int i = 1; i <= n; i++) cin >> h[i][0] >> h[i][1] >> h[i][2];

    vector<vector<ll>> dp(n+1, vector<ll>(3, -LINF));

    for (int j = 0; j < 3; j++) dp[0][j] = 0;

    for (int i = 1; i <= n; i++) {
        // a
        dp[i][0] = max({dp[i][0], dp[i-1][1]+h[i][1], dp[i-1][2]+h[i][2]});

        // b
        dp[i][1] = max({dp[i][1], dp[i-1][0]+h[i][0], dp[i-1][2]+h[i][2]});

        // c
        dp[i][2] = max({dp[i][2], dp[i-1][1]+h[i][1], dp[i-1][0]+h[i][0]});
    }

    ll ans = 0;
    for (int i = 0; i < 3; i++) ans = max(ans, dp[n][i]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
using pl = pair<ll,ll>;
#define ci(n,a)   ll a[n]; rep(i,(n)) cin>>a[i];
#define rep(i,n)  for(ll i = 0; i < (n); ++i)
#define red(i,n)  for(ll i = (n)-1; i >= 0; --i)
#define all(a)    begin(a),end(a)
#define pb(a)     push_back(a)
#define mp(a,b)   make_pair(a,b)
#define yn(a)     cout << ( (a)?"AC\n":"WA\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;


int main(int argc,char* argv[]) 
{
    string s;
    cin>>s;
    if(s[0]!='A' || s.substr(2,s.size()-3).find('C')==string::npos) yn(0),exit(0);
    sort(all(s));
    for(int i=2;i<s.size();i++)if(s[i]<97 || s[i]>122) yn(0),exit(0);
    yn(1);
   
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m;
  bool flag = true;
  cin >> n >> m;
  vector<int> a(n,0);
  for(int i = 0; i < m; i++) {
    int s,c;
    cin >> s >> c;
    if(a[s-1] != 0 && a[s-1] != c) {flag = false; break;}
    if(s == 1 && c == 0 && n != 1) {
      cout << "-1" << endl;
      return 0;
    }
    a[s-1] = c;
  }
  if(a[0] == 0 && n != 1) a[0] = 1;
  if(flag) {
    for(int i = 0; i < n; i++) cout << a[i];
    cout << endl;
  }
  else cout << "-1" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n, k;
int a[110];
bool dp[100010];

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

    for (int i = 1; i <= k; i++) {
        for (int j = 0; j < n; j++) {
            if (i - a[j] >= 0) dp[i] |= !dp[i - a[j]];
        }
    }
    if (dp[k]) cout << "First" << endl;
    else cout << "Second" << endl;
}

Measured memory_bytes: 384
N = input()

S = []
for i in range(N):
    S.append(raw_input())

M = input()

T = []
for i in range(M):
    T.append(raw_input())

maximam = 0

for i in S:
    maximam = max(S.count(i)-T.count(i),maximam)

print maximam

Measured memory_bytes: 2568
var
	n,m,i:Longint;
	p,a,c,s:int64;
begin
	read(n,m,p);
	for i:=2 to n do begin
		read(a);
		c:=(c+(i-1)*(n-i+1)mod 1000000007*(a-p)mod 1000000007)mod 1000000007;
		p:=a;
	end;
	read(p);
	for i:=2 to m do begin
		read(a);
		s:=(s+(i-1)*(m-i+1)mod 1000000007*(a-p)mod 1000000007*c mod 1000000007)mod 1000000007;
		p:=a;
	end;
	writeln(s);
end.


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

int main(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    V r,g,b;
    rep(i,s.size()){
        if(s[i]=='R')r.push_back(i);
        else if(s[i]=='G')g.push_back(i);
        else if(s[i]=='B')b.push_back(i);
    }
    ll ans=0;
    for(ll aa:r){
        for(ll bb:g){
            ll z=abs(aa-bb);
            ans+=b.size();
            if(binary_search(b.begin(),b.end(),max(aa,bb)+z)){
                ans--;
            }
            if(binary_search(b.begin(),b.end(),min(aa,bb)-z)){
                ans--;
            }
            if(z%2==0 && binary_search(b.begin(),b.end(),(aa+bb)/2)){
                ans--;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3668
<?php

list($tax8, $tax10) = explode(' ', trim(fgets(STDIN)));

for ($i=1; $i <= 2000; $i++) {
  $price8  = floor($i * 0.08);
  $price10 = floor($i * 0.1);

  if ($price8 == $tax8 && $price10 == $tax10) {
    echo $i;exit;
  }
}

echo -1;


Measured memory_bytes: 4604
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cctype>

#define div 1000000000+7

typedef long long ll;

using namespace std;


int main() {
    ll n, m, count = 0;
    cin >> n >> m;
    if(n > 0 && m >= n*2){
        count += n;
        m -= n*2;
        if(m > 3){
            count += m/4;
        }
    }else if(n == 0 && m > 3){
        count += m/4;
    }else if(n > 0 && m > 0){
        count += m/2;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
main(){
  char string;

//  scanf("%s",string);
  scanf("%c",&string);
  while(string!='\n'){
    if(isupper(string)!=0) printf("%c",tolower(string));
    else printf("%c",toupper(string));
    scanf("%c",&string);
  }
  printf("\n");

  return 0;
}

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

int main () {
int n, w;
cin >> n >> w;
int ans = 0;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
w = w - a[i];
ans++;
}
sort(a, a + n);
while (w >= a[0]) {
ans++;
w = w - a[0];
}
cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use permutohedron::*;
use proconio::*;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let n: usize = read!();
    let m: usize = read!();

    let mut v = vec![vec![]; n];

    for _ in 0..m {
        let xi: usize = read!();
        let yi: usize = read!();

        v[xi - 1].push(yi - 1);
        v[yi - 1].push(xi - 1);
    }

    let p = (0..n).permutations(n).collect_vec();

    let mut ans = 0;

    'par: for pi in p {
        if pi[0] != 0 {
            continue;
        }
        
        let mut now = pi[0];
        for &pii in &pi[1..] {
            if v[now].contains(&pii) {
                now = pii;
            } else {
                continue 'par;
            }
        }

        ans += 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 5944
#include<iostream>
#include<algorithm>
using namespace std;
	
int main(){
	int N;
	cin >> N;
	pair<long long, long long> pairs[200200];
	long long sum;
	sum=0;
	
	for(int i=0; i<N; i++){
		cin >> pairs[i].second;
		cin >> pairs[i].first;
	}
	sort(pairs,pairs+N);
	for(int i=0; i<N; i++){
		sum +=pairs[i].second;
		if(sum>pairs[i].first){
			cout <<"No" << endl;
			return 0;
		}
	}
		cout << "Yes" << endl;
		
		return 0;
}

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

using namespace std;

#define Rep(b, e, i) for (ll i = b; i <= e; i++)
#define Repr(e, b, i) for (ll i = e; i >= b; i--)
#define rep(n, i) Rep(0, n - 1, i)
#define repr(n, i) Repr(n - 1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T, vector<T>, greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false) std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<vec> mat;
typedef vector<vecll> matll;
typedef vector<vecd> matd;

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

const int MAX = 1000010;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1 << 29;
const ll INFL = 1e18;
const ll MOD = 1e9+7;

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

//********************************template END****************************************//

void solve()
{
	int N;
	cin >> N;
	vector<string> S(3);
	rep(3, i) cin >> S[i];
	int ans = 0;
	rep(N, i)
	{
		set<char> s;
		rep(3, j) s.insert(S[j][i]);
		ans += s.size() - 1;
	}
	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long D,N,Drui;
    cin >> D >> N;
    Drui = pow(100,D);
    if (N == 100) {
        if (D == 0) {
            cout << 101;
        } else if (D == 1) {
            cout << 10100;
        } else {
            cout << 1010000;
        }
    } else {
        cout << Drui*N;
    }
    
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
using namespace std;
int main ()
{
	int n,m,i,c=0;
	vector<int> v;
	cin>>n>>m;
	for(i=0;i<m;i++)
	{
		int k;
		cin>>k;
		v.push_back(k);
	}
	for(i=0;i<m;i++)
	{
		c=c+v[i];	
	}
	if(c>n)
	{
		cout<<"-1";
	}
	else
	{
		cout<<n-c;
	}
	return 0;
}

Measured memory_bytes: 3736
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

const int N = 1e5 + 10;

int n, k, ans;
char s[N];

int main(){
    scanf("%d%d", &n, &k);
    scanf("%s", s);
    ans = n - 1;
    for (int i = 1; i < n; i ++ )
        if (s[i] != s[i - 1])
            ans -- ;
    ans = min(n - 1, ans + k * 2);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 384
# inp1 = input()
# n = int(inp1.split(" ")[0])
# k = int(inp1.split(" ")[1])
# q = int(inp1.split(" ")[2])

n,k,q = map(int, input().split())
each_point = []
for i in range(n):
  each_point.append(k-q)
 
for j in range(q):
  each_point[int(input())-1] += 1
 
for x in range(n):
  if (each_point[x] < 1):
    print("No")
  else:
    print("Yes")

Measured memory_bytes: 7860
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		long weight[] = new long[num];
		for(int i = 0; i < num; i ++) {
			weight[i] = sc.nextLong();
		}
		long sum[] = new long[num + 1];
		sum[0] = 0;
		for(int i = 1; i < num + 1; i ++) {
			sum[i] = sum[i - 1] + weight[i - 1];
		}
		long allSum = sum[num];
		long diff[] = new long[num - 1];
		for(int i = 1; i < num; i ++) {
			diff[i - 1] = Math.abs(sum[i] - (allSum - sum[i]));
		}
		long min = Long.MAX_VALUE;
		for(int i = 0; i < num - 1; i ++) {
			min = Math.min(min, diff[i]);
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  vector<int> A(1010);
  for(int i=1;i<=N;i++){
    int n=i;
    for(int j=2;j<=n/j;j++)
      for(;n%j==0;n/=j)
        A[j]++;
    if(n!=1)
      A[n]++;
  }
  int ans=1;
  for(int i:A)
    ans=ans*(i+1)%1000000007;
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	n := sc.NextInt()

	for i := 9; i >= 1; i-- {
		if n%i == 0 {
			if n/i <= 9 {
				fmt.Printf("Yes\n") // output for debug
				return
			}
		}
	}
	fmt.Printf("No\n")

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#define MOD 1000000007

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<long long> vec(61);

    long long cnt = 0;
    for(int i = 0; i < n; ++i)
    {
        long long t;
        cin >> t;
        long long idx = 0;
        while(t > 0)
        {
            if(t%2==1)
            {
                vec[idx] += 1;
            }
            ++idx;
            t = t>>1;
        }
        cnt = max(idx,cnt);
    }

    long long ans = 0;
    long long int num = 1;
    for(int i = 0; i < cnt; ++i)
    {
        long long k = vec[i]*(n-vec[i])%MOD;
        ans += (num*k%MOD);
        ans %= MOD;
        num *= 2;
        num %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    if N<=K:
        print(str(N)*K)
    else:
        print(str(K)*N)




if __name__ == "__main__":
    main()

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

//F(A,B)が最小になるのは約数を均等に近く分割した場合
//→Sqrt(X)以上になる最初の約数をAとすればよい
namespace ABC_C
{
    class C057
    {
        //整数を各桁の数値に分解したベクトルを返す（桁数の若い順に出力)
        public static List<int> GetOrders(long value)
        {
            List<int> list = new List<int>();
            long x = value;
            while (x > 0)
            {
                list.Add((int)(x % 10));
                x /= 10;
            }
            return list;
        }

        //10進桁数
        public static int GetNumberOfDigits(long value)
        {
            return GetOrders(value).Count;
        }

        //全ての約数リストO(√n)
        public static List<long> GetAllDivisors(long x)
        {
            long sx = (long)Math.Sqrt(x);
            List<long> list = new List<long>();
            for (int n = 1; n <= sx; n++)
            {
                if (x % n == 0)
                {
                    long m = x / n;
                    list.Add(n);
                    if (n != m) list.Add(m);
                }
            }
            list.Sort();
            return list;
        }


        static void Main(string[] args)
        {
            long X = long.Parse(Console.ReadLine());

            List<long> divisors = GetAllDivisors(X);
            int i;
            for(i = 0; i < divisors.Count; i++)
            {
                if (divisors[i] >= Math.Sqrt(X)) break;
            }
            long A = divisors[i]; long B = X / A;
            int z = Math.Max(GetNumberOfDigits(A), GetNumberOfDigits(B));
            Console.WriteLine(z);
        }
    }
}


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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> using V = vector<T>;
using P = pair<int, int>;

/*
 *  */

signed main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b and a != c) cout << "Yes" << endl;
  else if(a == c and a != b) cout << "Yes" << endl;
  else if(c == b and a != c) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
'use strict';
(function(stdin) {
  var inputs = stdin.toString().trim().split('\n');
  var params = inputs[0].split(' ').map(Number);

  (function(a, b) {
    // ????????????????????????
    console.log(a * b, (a + b) * 2);

  })(params[0], params[1]);

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15420
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    string S; cin>>S;
    sort(S.begin(), S.end());
 
    if(S[0]==S[1] && S[2]==S[3] && S[0] != S[2]){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin >> s ;
    
    vector<int> c(s.size());
    int oddcnt = 0, evencnt = 0, rp, lp, rcnt = 0, lcnt;
    for(int i = 0; i < s.size(); i++){
        if(s.at(i) == 'R'){
            if(rcnt % 2 != 0){
                oddcnt++;
            } else {
                evencnt++;
            }
            rcnt++;
        } else if (s.at(i) == 'L') {
            if(evencnt != 0){
                if(rcnt % 2 == 0){
                    c.at(i - 1) = oddcnt;
                    c.at(i) = evencnt + 1;
                } else {
                    c.at(i - 1) = evencnt;
                    c.at(i) = oddcnt + 1;
                }
                rcnt = 0;
                evencnt = 0;
                oddcnt = 0;
                rp = i - 1;
                lp = i;
                lcnt = 0;
            } else {
                if(lcnt % 2 != 0){
                    c.at(lp)++;
                } else {
                    c.at(rp)++;
                }
                lcnt++;
            }
        }
        //printf("%d %d\n", evencnt, oddcnt);
    }
    
    for(int i = 0; i < s.size(); i++){
        cout << c.at(i) ;
        if(i == s.size() - 1){
            cout << endl;
        } else {
            cout << " " ;
        }
    }
    
}


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


void solve(long long X){
    vector<int> v(X+1, 0);
    vector<int> w = {100, 101, 102, 103, 104, 105};
    v[0] = 1;
    for(int i = 0;i <= X;i++){
        if(v[i] == 0)continue;
        for(auto a : w){
            if(a + i > X)continue;
            v[i + a] = 1;
        }
    }
    cout<<v.back()<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int N,A;
    cin >> N >> A;
    if(N%500 <=A){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int a[3][3];
  int i, j, n, k, b;
  i = 0;
  while (i < 3)
  {
    j = 0;
    while (j < 3)
    {
      scanf("%d", &a[i][j]);
      j++;
    }
    i++;
  }
  
  scanf("%d", &n);
  
  k = 0;
  while (k < n)
  {
    scanf("%d", &b);
    i = 0;
    while (i < 3)
    {
      j = 0;
      while (j < 3)
      {
        if (a[i][j] == b)
        {
          a[i][j] = 0;
        }
        j++;
      }
      i++;
    }
    k++;
  }
  
  i = 0;
  j = 0;
  while (i < 3 && j < 3)
  {
    if ((a[0][j] + a[1][j] + a[2][j] == 0) || (a[i][0] + a[i][1] + a[i][2] == 0))
    {
      printf("Yes");
      return 0;
    }
    i++;
    j++;
  }
  
  if ((a[0][0] + a[1][1] + a[2][2] == 0) || (a[0][2] + a[1][1] + a[2][0] == 0))
  {
    printf("Yes");
    return 0;
  }
  
  printf("No");
  return 0;
}

Measured memory_bytes: 128
from itertools import accumulate

N,Q=map(int,input().split())
S=input()
count=[0]*(N)
for i in range(N-1):
    if S[i:i+2]=="AC":
        count[i]=1
sums=list(accumulate([0]+count))

for i in range(Q):
    l,r=map(int,input().split())
    l-=1
    r-=1
    print(sums[r]-sums[l])


Measured memory_bytes: 53580
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int a, b;
	cin >> a >> b;
	cout << 6 - a - b << endl;
	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n, m, r;
    cin>>n>>m>>r;
    vl rs(r);
    cin>>rs;
    rep(i, r) rs[i]--;
    vvl ds(n, vl(n, LINF));
    rep(i, m) {
        ll v1, v2, w;
        cin>>v1>>v2>>w; v1--; v2--;
        ds[v1][v2] = w;
        ds[v2][v1] = w;
    }

    rep(k, n) rep(i, n) rep(j, n) chmin(ds[i][j], ds[i][k] + ds[k][j]);

    vvl dp(1<<r, vl(r, LINF));
    rep(i, r) dp[1<<i][i] = 0;
    rep(i, 1<<r) rep(j, r) rep(k, r) {
        if (i>>j&1 == 0) continue;
        if (i>>k&1) continue;
        chmin(dp[i + (1<<k)][k], dp[i][j] + ds[rs[j]][rs[k]]);
    }

    ll ans = LINF;
    rep(i, r) chmin(ans, dp[(1<<r) - 1][i]);
    cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll a, b, c, d;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    ll ab = (a < b) ? a : b;
    ll cd = (c < d) ? c : d;
    cout << ab + cd << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
char buf[1<<20],*p1,*p2;
#define GC (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?0:*p1++)
template<class T> inline void read(T &n){
	char ch=GC;T w=1,x=0;
	while(!isdigit(ch)){if(ch=='-') w=-1;ch=GC;}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=GC;}
	n=x*w;
}
const int maxn=105;
const int maxm=10205;
int n,m,Map[maxn][maxn];
vector <int> col[maxn][maxn];
int last[maxn<<1],Next[maxm<<1],to[maxm<<1],w[maxm<<1],cnt=1;
inline void addedge(int x,int y,int z){
	Next[++cnt]=last[x],last[x]=cnt;
	to[cnt]=y,w[cnt]=z;
}
inline void add(int x,int y,int z){
	addedge(x,y,z),addedge(y,x,0);
}
int dep[maxn<<1],cur[maxn<<1],st,ed;
queue <int> Q;
bool bfs(){
	memset(dep,0,sizeof(dep));
	dep[st]=1,Q.push(st);
	while(!Q.empty()){
		int u=Q.front();Q.pop();
		for(int i=last[u];i;i=Next[i]){
			int v=to[i];
			if(w[i]&&!dep[v]){
				dep[v]=dep[u]+1;
				Q.push(v);
			}
		}
	}
	return dep[ed];
}
const int inf=0x3f3f3f3f;
int dfs(int u,int low){
	if(u==ed) return low;
	int add=0;
	for(int i=cur[u];i&&add<low;i=Next[i]){
		int v=to[i];cur[u]=i;
		if(w[i]&&dep[v]==dep[u]+1){
			int tmp=dfs(v,min(w[i],low-add));
			w[i]-=tmp,w[i^1]+=tmp;
			add+=tmp;
		}
	}
	return add;
}
int dinic(){
	int res=0;
	while(bfs()){
		memcpy(cur,last,sizeof(last));
		res+=dfs(st,inf);
	}
	return res;
}
int ans[maxn][maxn],bot[maxn];
int main(){
	read(n),read(m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			read(Map[i][j]);
			int bel=(Map[i][j]-1)/m+1;
			col[i][bel].push_back(Map[i][j]);
		}
 	ed=n*2+1;
	for(int now=1;now<=m;now++){
		memset(last,0,sizeof(last)),cnt=1;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++)
				if(col[i][j].size()) add(i,j+n,1);
			add(st,i,1);
			add(i+n,ed,1);
		}
		assert(dinic()==n);
		for(int x=1;x<=n;x++)
			for(int i=last[x];i;i=Next[i]){
				int v=to[i];
				if(!w[i]){
					ans[x][now]=col[x][v-n].back();
					col[x][v-n].pop_back();
				}
			}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++) printf("%d ",ans[i][j]);
		printf("\n");
	}
	for(int j=1;j<=m;j++){
		for(int i=1;i<=n;i++) bot[i]=ans[i][j];
		sort(bot+1,bot+n+1);
		for(int i=1;i<=n;i++) ans[i][j]=bot[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++) printf("%d ",ans[i][j]);
		printf("\n");
	}
	return 0;
}

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

class Program
{
	static void Main(string[] args)
	{
		//読み込む
		string S = Console.ReadLine();
		if(S == "hi" || S == "hihi" || S == "hihihi" ||
    S == "hihihihi" || S == "hihihihihi"){
        Console.WriteLine("Yes");
    }else{
        Console.WriteLine("No");
    }

	}
}



Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 222222

vll pr;
bool is[MAX + 1];
ll cou[MAX];

void AllPrime(ll x) {
  rep(i, x + 1) is[i] = true;
  is[0] = false;
  is[1] = false;
  rep(i, x + 1) {
    if (is[i]) {
      pr.pb(i);
      for (ll j = 2 * i; j <= x; j += i) is[j] = false;
    }
  }
}

void factorize(ll num) {
  FOR(i, 2, MAX) {
    if (num == 1) break;
    while (num%i == 0) {
      num /= i;
      cou[i]++;
    }
  }
}

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

  cin >> n;
  AllPrime(MAX);
  FOR(i, 2, n + 1) factorize(i);
  rep(i, 25) rep(j, 25) FOR(k, j + 1, 25) {
    if (i == j || i == k) continue;
    if (cou[pr[i]] < 2) continue;
    if (cou[pr[j]] < 4 || cou[pr[k]] < 4) continue;
    ans++;
  }
  if (cou[2] >= 74) ans++;
  rep(i, 25) {
    if (cou[pr[i]] < 24) continue;
    rep(j, 25) if (cou[pr[j]] >= 2 && i != j) ans++;
  }
  rep(i, 25) {
    if (cou[pr[i]] < 14) continue;
    rep(j, 25) if (cou[pr[j]] >= 4 && i != j) ans++;
  }
  cout << ans << endl;


  return 0;
}



Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	void run() {
		try (Scanner sc = new Scanner(System.in)) {
			int n = Integer.parseInt(sc.next());
			int[] a = new int[3];
			for (int i = 0; i < n; i++) {
				int p = Integer.parseInt(sc.next());
				a[p%3]++;
			}
			
			int cnt = 0;
			if(a[1]!=0 || a[2]!=0) {
				cnt += a[0];
				if(a[1] > a[2]) {
					cnt += a[2]*2;
					cnt += Math.min(3, a[1]-a[2]);
				}else{
					cnt += a[1]*2;
					cnt += Math.min(3, a[2]-a[1]);
				}
			}else{
				cnt = 1;
			}
			System.out.println(cnt);
		}
	}

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

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

int main(){
  vector<int> v(3);
  cin >> v[0] >> v[1] >> v[2];
  sort(v.begin(), v.end());
  if (v[2]==v[0]+v[1]) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(1,n-1):
  if a[i-1]<a[i] and a[i]<a[i+1]:
    ans+=1
  elif a[i-1]>a[i] and a[i]>a[i+1]:
    ans+=1
  else:
    pass
  
print(ans)

Measured memory_bytes: 3064
N = int(input())
def dfs(s):
  if int(s)>N:
    return 0
  if s.count("3")>=1 and s.count("5")>=1 and s.count("7")>=1:
    ans=1
  else:
    ans=0
  for c in "753":
    ans+=dfs(s+c)
  return ans
print(dfs("0"))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> p(n);
  for(int i=0; i<n;i++) cin >> p[i];
  
  int count=0;
  for(int i=0;i<n-2;i++){
    if(p[i]<p[i+1] && p[i+1]<p[i+2]) count++;
    else if(p[i+2]<p[i+1] && p[i+1]<p[i]) count++;
  }
    cout << count << endl;
    return 0;
 }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int A,B;
    cin>> A >> B;
    
    if(A+B == 4){
        cout << 2;
    }else if(A+B == 5){
        cout << 1;
    }else{
        cout << 3;
    }
}

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

int seg[10][7] = {
    {0,1,1,1,1,1,1},
    {0,0,0,0,1,1,0},
    {1,0,1,1,0,1,1},
    {1,0,0,1,1,1,1},
    {1,1,0,0,1,1,0},
    {1,1,0,1,1,0,1},
    {1,1,1,1,1,0,1},
    {0,1,0,0,1,1,1},
    {1,1,1,1,1,1,1},
    {1,1,0,1,1,1,1}
};

int main(){
    while(1){
        int n;
        cin >> n;
        if(n == -1) break;
        
        int now[7] = {};
        
        while(n-- > 0){
            int next;
            cin >> next;
            for(int i = 0; i < 7; i++){
                cout << (now[i] ^ seg[next][i]);
                now[i] = seg[next][i];
            }
            cout << endl;
        }
        
    }
    
    return 0;
}



Measured memory_bytes: 2980
import sys

# C - Walking Takahashi
X, K, D = map(int, input().split())

if D * K <= abs(X):
	print(abs(X) - D * K)
else:
	distance = abs(X) % D

	# 残りの移動回数
	count = K - (abs(X) // D)

	if count % 2 == 1:
		print(abs(D - distance))
	else:
		print(distance)

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

int main(){
  long n,k;
  cin >> n >> k;
  vector<long> a(n),maxnum(51);
  for(long i = 0;i < n;i++){
    cin >> a.at(i);
  }
  for(int i = 0;i <= 50;i++){
    long num0 = 0,num1 = 0;
    for(int j = 0;j < n;j++){
      if(a.at(j) >> i & 1) num1++;
      else num0++;
    }
    if(num0 >= num1) maxnum.at(i) = 0;
    else maxnum.at(i) = 1;
  }
  vector<long> beki(100);
  for(long i = 0;i < 100;i++){
    beki.at(i) = 1;
  }
  for(long i = 1;i <= 50;i++){
    for(long j = 0;j < i;j++){
      beki.at(i) *= 2;
    }
  }
  long ans = 0;
  for(int i = 0;i < n;i++){
    ans += a.at(i)^k;
  }
  for(long i = 50;i >= 0;i--){
    long x = 0;
    for(long j = 50;j > i;j--) x += beki.at(j)*(k >> j & 1);
    if(k >> i & 1){
      for(long j = i-1;j >= 0;j--) x += beki.at(j)*(maxnum.at(j)^1);
      long c = 0;
      for(long j = 0;j < n;j++){
        c += a.at(j)^x;
      }
      if(x <= k) ans = max(ans,c);
    }
    //cout << x << endl;
  }
  //for(long i = 0;i <= 50;i++){
  //  cout << beki.at(i) << ' ' << i << endl;
  //}
  cout << ans << endl;
}

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	long long N,count = 0,a,b;
  cin >> N;
  vector<pair<long long,long long>> c(N);
  froop1(0,N){
	cin >> c.at(i).second >> c.at(i).first;
  }
 sort(c.begin(),c.end());
    froop1(0,N){
      count += c.at(i).second;
      if(count > c.at(i).first){
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
return 0;
}

Measured memory_bytes: 3328