akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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 gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n;
	string s,t;
	map<string,ll> m;
	vs ss;
	cin >> n;
	rep(i,n){
		cin >> s >> t;
		if(s=="insert") m[t]=1;
		else if(s=="find") ss.pb(m[t]?"yes":"no");
	}
	rep(i,SIZE(ss)) cout << ss[i] << endl;
	return 0;
}


Measured memory_bytes: 75796
#include "bits/stdc++.h"
using namespace std;
using ll = long long int;
const ll mod = 1000000007;
const ll M = 1000000000000000000ll;
#define fi first
#define se second
#define pb push_back
inline ll add(ll a,ll b){return ((a%mod+b%mod)%mod);}
inline ll sub(ll a,ll b){return ((a%mod-b%mod+mod)%mod);}
inline ll mult(ll a,ll b){return (((a%mod)*(b%mod))%mod);}
inline ll power(ll n,ll x){ll p=1;while(x!=0){if(x%2==0){n=mult(n,n);x=x/2;}p=mult(p,n);x--;}return p;}
inline ll recurmult(ll a,ll b){ll r = 0;while (b){if (b & 1)r = add(r, a);a = mult(2,a);b >>= 1;}return r%mod;}

int main()
{
    ios::sync_with_stdio(0);   
    cin.tie(0);   
    #ifndef ONLINE_JUDGE   
    freopen("input.txt", "r", stdin);   
    freopen("output.txt", "w", stdout);
    #endif  
    string s;
    cin>>s;
    if(s=="ABC")
        cout<<"ARC\n";
    else
        cout<<"ABC\n";
}

Measured memory_bytes: 3664
//Fast IO + Debug Template
#include <bits/stdc++.h>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define pb push_back
#define gl(x) getline(cin,x)
#define gc(x) cin.get(x)
#define sz(x) (int)(x.size())
#define al(x) (x).begin(),(x).end()
#define ms(a, b) memset(a,b,sizeof(a))
#define sp ' '
#define nl '\n'
#define f first
#define s second
#define lsb(x) ((x)&(-x))
#define mp make_pair
#define m(x, y) (x + y) / 2
#define MOD 1000000007
#define gcd(x,y) __gcd(m,n);
#define perm(x) next_permutation(x.begin(), x.end());
#define bs(x,z) binary_search(x.begin(),x.end(),z);
#define lb(x,z) lower_bound(x.begin(),x.end(),z);
#define ub(x,z) upper_bound(x.begin(),x.end(),z);
#define nl '\n'


void sc(){}template<class T,class...A>void sc(T&t,A&...a){cin>>t,sc(a...);}
void pr(){}template<class T,class...A>void pr(T t,A...a){cout<<t,pr(a...);}
typedef long long ll;
typedef pair<int, int> pi;
//weighted (with adjList[])
typedef vector<pi> vii;
//unweighted (with adjList[])
typedef vector<int> vi;
typedef double db;
typedef long double ld;


const int INF = 0x3f3f3f3f;
const int NINF = -INF;
int TC;
ll b;
ll a;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	cin >> TC;
	vector<ll> use;
	ll smallest = 0;
	ll largest = 0;
	ll total = 0;
	for(int i = 0; i < TC; i ++){
		cin >> b;
		use.pb(b);
	}
	smallest = use[0];
	for(int i = 1; i < (int) use.size(); i ++){
		if (use[i] < use[i-1]) {total += abs(use[i] - use[i-1]); use[i] = use[i-1];}
		if (use[i] == use[i-1] || use[i] > use[i-1]) continue;
	}
	cout << total << endl;
	debug();
	
return 0;
	}

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  
  char ans;
  vector<int> moji(26,0);
  
  rep(i,n) {
    int temp = s[i]-'a';
    moji[temp]++;
  }
  
  rep(i,26) {
    if (moji[i] == 0) {
      ans = 'a' + i;
      cout << ans << endl;
      return 0;
    }
  }
  
  cout << "None" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
//debug
#define vecprint(v) cout << "  vector: ";rep(i,v.size())cout << v[i] << " ";cout << endl;
#define setprint(s) cout << "  set: ";for(auto i=s.begin();i!=s.end();i++)cout << *i << " ";cout << endl;
#define mappairprint(s) cout << "  map: ";for(auto i=s.begin();i!=s.end();i++)cout << i->first << " " << i->second << endl;cout << endl;
//reader
#define r1(a) cin>>(a)
#define r2(a,b) cin>>(a)>>(b)
#define r3(a,b,c) cin>>(a)>>(b)>>(c)
//writer
#define w1(a) cout<<(a)<<" "
#define w2(a,b) cout<<(a)<<" "<<(b)<<" "
#define w3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "
#define wl1(a) cout<<(a)<<endl
#define wl2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wl3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
//variable definition
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
//roop
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define all(c) c.begin(),c.end()
//term
#define elif else if
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
using namespace std;
using ll = long long;
//const


int main() {
  //input
  long double a,b;
  cin >> a >> b;
  
  //ll ans = ((long double)a /(long double)1000000000 * (long double)b * (long double)1000000000);
  
  ll ans = (long double)a * (long double)b;
  
  cout << ans << endl;  
}

Measured memory_bytes: 3708
K, N = map(int, input().split())
houselist = list(map(int, input().split()))
max=0
for i in range(1,N):
  if houselist[i]-houselist[i-1]>max:
    max=houselist[i]-houselist[i-1]
if K+houselist[0]-houselist[N-1]>max:
  max=K+houselist[0]-houselist[N-1]
if max==0:
  print(0)
else:
  print(K-max)


Measured memory_bytes: 26444
import Control.Applicative
inputs = fmap (read :: String -> Int) . words <$> getLine

term a b = [((a+b)*n, (a+b)*n + a) | n <- [0..60]]
cs c = [c + n*60 | n<-[0..60]]
solve lst = if null ans then -1 else head ans
    where
        a = lst !! 0
        b = lst !! 1
        c = lst !! 2
        ncs = cs c
        ts  = term a b
        ans = [nc | t<-ts, nc <- ncs, fst t <= nc, nc <= snd t]


main = inputs >>= \l -> print $ solve l

Measured memory_bytes: 3744
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <algorithm>

using namespace std;

int sort_hogehoge(char *s);

int main(){
  
  int N;
  char S[11];
  std::vector<std::string> S2;
  
  scanf("%d", &N);
  for(int i = 0; i < N; i++){
    scanf("%s", S);
    sort_hogehoge(S);
    S2.push_back(S);
  }
  
  /*for(int i = 0; i < N; i++){
    printf("%s\n", S[i]);
  }*/
  
  std::sort(S2.begin(), S2.end());
  
  std::cerr << "check S2" << std::endl;
  for(int i = 0; i < N; i++){
    std::cerr << S2[i] << std::endl;
  }std::cerr << std::endl;
  
  // count answer
  long long int ans = 0;
  long long int tmp = 0;
  long long int j;
  
  for(long long int i = 0; i < N; i++){
    // count the number of sequences with
    j = i+1;
    tmp = 1;
    while((j < N) &&(S2[j] == S2[i]) ){
      tmp++;
      j++;
      std::cerr << "i = " << i << " j = " << j << "tmp = " << tmp << std::endl;
    }
    ans += (tmp*(tmp-1))/2;
    i = j-1;
  }
  
  std::cerr << "Answer: " << std::endl;
  std::cout << ans << std::endl;
  
  
  return 0;
}

int sort_hogehoge(char *s){
  char tmp;
  for(int i = 0; i < 10; i++){
    for(int j = i+1; j < 10; j++){
      if(s[i] > s[j]){
        tmp = s[i];
        s[i] = s[j];
        s[j] = tmp;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 5748
fun readInts() = readLine()!!.split(' ').map(String::toInt)

fun main(args: Array<String>) {
    val (n, m) = readInts().sorted()
    val ans = if (n == 1) {
        when (m) {
            1 -> 1L
            2 -> 0L
            else -> (m - 2).toLong()
        }
    } else if (n == 2) {
        0L
    } else {
        (n - 2).toLong() * (m - 2).toLong()
    }
    println(ans)
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    cout << ceil(log(n) / log(3)) << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n),q(n);
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];
  vector<int> a(n);
  rep(i,n) a[i]=i+1;
  map <vector<int>,int> mp;
  do{
    mp[a]=mp.size();
  }while(next_permutation(a.begin(),a.end()));
  cout << abs(mp[p]-mp[q]) << endl;
  return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
#include <sstream>
#include <bitset>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int main(){
    string n;
    cin >> n;
    char a = (int)n[(int)n.size()-1];
    if(a=='3') cout << "bon" << endl;
    else if(a=='0' || a=='1' || a=='6' || a=='8') cout << "pon" << endl;
    else cout << "hon" << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; i++)
int main(){
    int n,k,sum;
    sum = 0;
    cin >> n >> k;
    vector<int> p;
    vector<int> pp;
    rep(i,n){
        int x;
        cin >> x;
        p.push_back(x);
    }
    sort(p.begin(), p.end());
    rep(j,k){
        sum += p[j];
    }
    cout << sum << endl;
}

Measured memory_bytes: 3632
MOD = 10 ** 9 + 7

l = input()
p = len(l)
dp = [[0, 0] for _ in range(p)]
dp[0] = [1, 2]

for i, s in enumerate(l[1:], start = 1):
    if s == "1":
        dp[i][0] = dp[i - 1][0] * 3 + dp[i - 1][1]
        dp[i][1] = dp[i - 1][1] * 2
    else:
        dp[i][0] = dp[i - 1][0] * 3
        dp[i][1] = dp[i - 1][1]
    dp[i][0] %= MOD
    dp[i][1] %= MOD
ans = sum(dp[-1])
print(ans % MOD)

Measured memory_bytes: 23932
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[110];
int B[110];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    for(int i=1;i<=n;i++)cin>>A[i];
    for(int i=1;i<=n;i++)cin>>B[i];

    for(int i=1;i<=n;i++)A[i]+=A[i-1];
    for(int i=n;i>=1;i--)B[i]+=B[i+1];

    for(int i=1;i<=n;i++)
        mx = max(mx,A[i]+B[i]);

    cout<<mx<<"\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


vector<int> V[100001];
vector<int> L; // goal から start までの道のり
int color[100001];
bool check[100001]; // dfsのためのマーカー

bool dfs(int start,int goal) {
	check[start] = true;
	bool flag = false;
	if (start == goal) {
		flag = true;
	}
	else {
		for (int x : V[start]) {
			if (!check[x]) flag = (flag || dfs(x, goal));
		}
	}
	if (flag) L.push_back(start);
	return flag;
}

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

	int N; cin >> N;
	
	for (int i = 0; i < N - 1; i++) {
		int a, b; cin >> a >> b;
		V[a].push_back(b);
		V[b].push_back(a);
	}

	dfs(1, N);
	reverse(L.begin(), L.end());
	
	/*
	cout << L.size() << endl;
	for (int i = 0; i < L.size(); i++) cout << L[i] << " ";
	*/


	queue<int> Q;
	for (int i = 0; i < L.size(); i++) {
		if (2 * i < L.size()) {
			color[L[i]] = 1; // 黒
			Q.push(L[i]);
		}
		else color[L[i]] = 2; // 白
	}
	
	int ans = Q.size();
	while (!Q.empty()) {
		int pos = Q.front();
		Q.pop();

		for(int x : V[pos]) {
			if (color[x] == 0) {
				ans++;
				Q.push(x);
				color[x] = 1;
			}
		}
	}

	// cout << ans << endl;

	if (ans > N / 2) cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
	

	return 0;
}

Measured memory_bytes: 11512
n,c=map(int,input().split())
d=[list(map(int,input().split())) for i in range(c)]
grid=[list(map(int,input().split())) for i in range(n)]
lst=[[0]*(c+1) for i in range(3)]
for i in range(n):
    for j in range(n):
        num=grid[i][j]
        a=(i+j)%3
        lst[a][num]+=1
li=[[0]*(c+1) for i in range(3)]
for i in range(3):
    u=lst[i]
    for j in range(1,c+1):
        count=0
        for k in range(1,c+1):
            count+=d[k-1][j-1]*u[k]
        li[i][j]=count
ans=float("inf")
for i in range(1,c+1):
    for j in range(1,c+1):
        for k in range(1,c+1):
            if i!=j and j!=k and k!=i:
                a=li[0][i]+li[1][j]+li[2][k]
                ans=min(ans,a)
print(ans)

Measured memory_bytes: 45916
from collections import Counter
import math

n = int(input())
ab = []
mod = 10**9+7

num_ab0 = 0
num_a0 = 0
num_b0 = 0

for i in range(n):
    A, B = map(int, input().split())
    if A == 0 and B == 0:
        num_ab0 += 1
    elif A == 0:
        num_a0 += 1
    elif B == 0:
        num_b0 += 1
    else:
        g = math.gcd(A, B)
        if A < 0:
            A = -A
            B = -B
        ab.append((A//g, B//g))

c = Counter(ab)

total = 2 ** num_a0 + 2 ** num_b0 - 1
for k, v in c.items():
    if k[1] < 0:
        num = c.get((-k[1], k[0]))
    else:
        num = c.get((k[1], -k[0]))

    if num:
        if k[1] > 0:
            total *= (2 ** v + 2 ** num - 1)
    else:
        total *= 2 ** v

print((total - 1 + num_ab0) % mod)


Measured memory_bytes: 137528
#include<stdio.h>
int main()
{
    int n,i,ar[1000000],s=0;
    scanf ("%d",&n);
    for (i=0;i<n;i++)
    {
        scanf ("%d",&ar[i]);
    }
    for(i=0;i<n;i++)
    {
        s+=ar[i]-1;
    }
    printf ("%d\n",s);
    return 0;
}


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

int main(){
  int A,B;
  cin >> A>>B;
  
  int N;
  if(B<9){N=10*A+B;}
  if(B>9 && B<100){N=100*A+B;}
  if(B==100){N=1000*A+B;}
  
  bool flag=false;
  for(int i=0; i*i<=N;i++){
    if(i*i==N){
      flag=true;
    }
  }
  
  if(flag==true){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

#define reint register int
#define coint const int

using namespace std;

typedef long long ll;

ll a, b, c, d;

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

ll solve(ll x) {
    return x - x / c - x / d + x / lcm(c, d);
}

int main(void) {
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    printf("%lld\n", solve(b) - solve(a - 1));
    return 0;
}



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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

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

    int A[3];
    std::cin >> A[0] >> A[1] >> A[2];

    sort(A, A+3);

    int res = 0;
    int x = A[2] - A[1];
    res += x;
    A[0] += x;

    int y = (A[2] - A[0]) / 2;
    res += y;
    A[0] += 2 * y;

    if(A[0] != A[2]){
        res += 2;
    }
    
    std::cout << res << std::endl;
}


Measured memory_bytes: 256
N = ['0'] + list(input()) + ['0']
# print (N)
n = len(N)
ans = 0
flag = False
count = 0
for i in range(n - 1, 0, -1):
    s = int(N[i])
    
    if flag:
        s += 1
        N[i] = str(s)
    else:
        pass

    if s <= 5:
        next_ = int(N[i - 1])
        if s == 5 and  next_ >= 5:
            # ans -= 1
            ans += s
            flag = True

        else:
            ans += s
            flag = False
    else:
        ans += 10 - s
        flag = True


if flag:
    ans += 1

count = 0
for s in N:
    if s == '5':
        count += 1
    else:
        ans -= max(count -2, 0)
        count = 0


print (ans)

Measured memory_bytes: 66388
#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>;

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  string ans = "";
  int h = ty - sy;
  if (0 < h) {
    rep(i, h) {
      ans += "U";
    }
  } else {
    rep(i, -h) {
      ans += "D";
    }
  }
  int w = tx - sx;
  if (0 < w) {
    rep(i, w) {
      ans += "R";
    }
  } else {
    rep(i, -w) {
      ans += "L";
    }
  }
  if (0 < h) {
    rep(i, h) {
      ans += "D";
    }
  } else {
    rep(i, -h) {
      ans += "U";
    }
  }
  if (0 < w) {
    rep(i, w) {
      ans += "L";
    }
    ans += "L";
  } else {
    rep(i, -w) {
      ans += "R";
    }
    ans += "R";
  }

  if (0 < h) {
    rep(i, h+1) {
      ans += "U";
    }
  } else {
    rep(i, abs(h)+1) {
      ans += "D";
    }
  }

  if (0 < w) {
    rep(i, w+1) {
      ans += "R";
    }
  } else {
    rep(i, abs(w)+1) {
      ans += "L";
    }
  }

  if (0 < h) {
      ans += "D";
  } else {
      ans += "U";
  }

  if (0 < w) {
      ans += "R";
  } else {
      ans += "L";
  }

  if (0 < h) {
    rep(i, h+1) {
      ans += "D";
    }
  } else {
    rep(i, abs(h)+1) {
      ans += "U";
    }
  }

  if (0 < w) {
    rep(i, w+1) {
      ans += "L";
    }
  } else {
    rep(i, abs(w)+1) {
      ans += "R";
    }
  }

  if (0 < h) {
      ans += "U";
  } else {
      ans += "D";
  }






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


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int N = 100;
const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;

int n = 0;
int color[N];
int M[N][N];
int d[N],f[N],tt;

void dfs_visit(int u)
{
    int v;
    color[u] = GRAY;
    d[u] = ++tt;

    for(v=0;v<n;v++)
    {
        if(M[u][v]==0) continue;
        if(color[v]==WHITE)
            dfs_visit(v);
    }

    color[u] = BLACK;
    f[u] = ++tt;//
}

void dfs()
{
    int u;
    for(u=0;u<n;u++) color[u] = WHITE;
    tt = 0;//初始化

    for(u=0;u<n;u++)
    {
        if(color[u]==WHITE)
            dfs_visit(u);
    }
    for(u=0;u<n;u++)
        cout << u+1 << " " << d[u] << " " << f[u] << "\n";
}

int main()
{
    int u,k,v,i,j;
    cin >> n;

    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            M[i][j] = 0;
        }
    }

    for(i=0;i<n;i++)
    {
        cin >> u >> k;
        u--;
        for(j=0;j<k;j++)
        {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    dfs();

    return 0;
}



Measured memory_bytes: 3120
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
  
  string s;
  cin>>s;
  int n=4;
  ll ans,bit;
  vector <char> op(3);
  for (bit=0; bit<(1<<n-1); bit++){
    ans=s[0]-'0';
    for (int i=0; i<n-1; i++){
      if (bit& (1<<i)){
        ans+=(s[i+1]-'0');
        op[i]='+';
      }
      else{
        ans-=(s[i+1]-'0');
        op[i]='-';
      }
    }
    
    if (ans==7)
      break;
  }
  
  cout<<s[0]<<op[0]<<s[1]<<op[1]<<s[2]<<op[2]<<s[3]<<'='<<ans;
}
  
  

Measured memory_bytes: 256
//#include <GOD>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define len length	
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define freo freopen("output.txt","w",stdout)

const ll inf=1e18;
const ll mod=1e9+7;
const ll maxn=1e5+10,maxt=100+10;

ll n,m,cnt;
ll mark[maxn];
vector <ll> nei[maxn];

void dfs(ll u){
	mark[u]=1;
	for(auto v:nei[u]){
		if(!mark[v]){
			dfs(v);
		}
	}
}
int main(){
	FAST_IO;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		ll u,v;
		cin>>u>>v;
		nei[u].pb(v);
		nei[v].pb(u);
	}
	for(int i=1;i<=n;i++){
		if(!mark[i]){
			cnt++;
			dfs(i);
		}
	}
	cout<<cnt-1<<endl;
}


Measured memory_bytes: 11124
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (ll i = (a); i <= (b); ++i)
#define per(i, a, b) for (ll i = (a); i >= (b); --i)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (register int i = head[x]; i; i = edge[i].nex)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, cnt) memset(a, cnt, sizeof(a))
#define cop(a, b) memcpy(a, b, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter putchar('\n')
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long double ldb ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int maxn = 2e5 + 100 ;
const int inf = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int mod = 1e9 + 7 ;
const db eps = 1e-10 ;
template <class T = int> T read()
{
	T f = 1, a = 0;
	char ch = getchar() ;
	while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
	while (isdigit(ch)) { a =  (a << 3) + (a << 1) + ch - '0' ; ch = getchar() ; }
	return a * f ;
}

int n, k;

struct permutations
{
	int pos[maxn];
	permutations(){rep(i, 1, n) pos[i] = i;}
	friend permutations operator * (permutations p, permutations q)
	{
		permutations ret;
		rep(i, 1, n) ret.pos[i] = p.pos[q.pos[i]];
		return ret;
	}
	permutations operator *= (permutations b)
	{
		return *this = *this * b;
	}
};

permutations a, b, mul, ans;

permutations inv(permutations a)
{
	permutations ret;
	rep(i, 1, n) ret.pos[a.pos[i]] = i;
	return ret;
}

permutations power(permutations a, ll b)
{
	permutations ret;
	for (; b; b >>= 1, a *= a) if(b & 1) ret *= a;
	return ret;
}

signed main()
{
	scanf("%d %d", &n, &k);
	rep(i, 1, n) scanf("%d", &a.pos[i]);
	rep(i, 1, n) scanf("%d", &b.pos[i]);
	mul = power(b * inv(a) * inv(b) * a, (k - 1) / 6);
	k = (k - 1) % 6 + 1;
	if(k == 1) ans = mul * a * inv(mul);
	else if(k == 2) ans = mul * b * inv(mul);
	else if(k == 3) ans = mul * b * inv(a) * inv(mul);
	else if(k == 4) ans = mul * b * inv(a) * inv(b) * inv(mul);
	else if(k == 5) ans = mul * b * inv(a) * inv(b) * a * inv(b) * inv(mul);
	else ans = mul * b * inv(a) * inv(b) * a * a * inv(b) * inv(mul);
	rep(i, 1, n) printf("%d%c", ans.pos[i], " \n"[i == n]);
	return 0;
}

Measured memory_bytes: 49792
package main

import (
        "fmt"
)

func main() {
        var a, b, x int
        fmt.Scanf("%d %d %d", &a, &b, &x)
        fmt.Println(judge(a, b, x))
}

func judge(a, b, x int) string {
        if a < 0 || b < 0 || x < 0 {
                return "NO"
        }
        if a > x {
                return "NO"

        } else if a+b < x {
                return "NO"

        } else if a+b >= x {
                return "YES"

        }
        return "NO"
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
const int N = 4e5;
int a[N + 3];
int d[N + 3];
int dp[N + 3][10];
vector<int> b;
int n;
bool cmp(int x, int y) { 
    return x > y; 
}
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    sort(a + 1, a + n + 1, cmp);
    int pos = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i] >= i && a[i + 1] <= i) {
            pos = i;
            break;
        }
    }
    int len1 = 0;
    for (int i = pos + 1; i <= n; i++) {
        if (a[i] > pos - 1)
            len1++;
    }
    int len2 = a[pos] - pos;
    if ((!(len1 & 1)) && (!(len2 & 1)))
        printf("Second");
    else
        printf("First");
    return 0;
}

Measured memory_bytes: 4180
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long int llint;

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

	llint power=1;
	for(int i=1;i<=N;i++){
		power=(power*i)%(1000000000LL+7);
	}
	cout << power << endl;
	return 0;
}


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

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    string S, T;
    ist >> S >> T;

    /* ------- 計算 ------- */

    int ans = 0;

    for (int i = 0; i < S.length(); i++)
    {
        if (S.at(i) != T.at(i))
        {
            ans++;
        }
    }
    cout << ans << endl;
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


Measured memory_bytes: 3848
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X, Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%(m))
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll X;

int main() {

    cin >> X;
    int year = 0;
    ll yokin = 100;
    while (yokin < X) {
        yokin += yokin / 100;
        ++year;
    }

    cout << year << endl;

    return 0;
}


Measured memory_bytes: 3636
while(True):
    n, x = map(int, input().split(" "))

    if (n == 0) and (x == 0):
        exit()

    cnt = 0

    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                if i + j + k == x:
                    cnt += 1

    print(cnt)

Measured memory_bytes: 7604
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()

	fmt.Println(n*n*n)
}

Measured memory_bytes: 640
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

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

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


int main(void) {
	long long int a, b, x;
	long long int count = 0;

	cin >> a >> b >> x;

	if (a % x == 0) {
		a = a / x;
	}
	else {
		a = (a / x) + 1;
	}
	b = b / x;

	//cout << a << " " << b << endl;

	cout << (b - a) + 1 << endl;


	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main{



	public static void main(String[] args) {



		Scanner sc = new Scanner(System.in);			//文字の入力
	int N = sc.nextInt();
	int X = sc.nextInt();
	int[] m = new int[N];
	int ans = N;
	for(int i = 0;i < N;i++){
		m[i] = sc.nextInt();
		X -= m[i];
	}
	Arrays.sort(m);
	if(X == 0){
		System.out.println(ans);
		return;

	}
	while(X>=0){
		X -= m[0];
		ans++;
	}
	

System.out.println(ans-1);


	}

	static long comb(int n,int r){
		long ue = 1;
		for(int i = 0;i < r;i++){
			ue *= n-i;
		}
		long sita = 1;
		for(int i = 1;i <= r;i++){
			sita *= i;
		}
		return ue/sita;


	}





}




class Pair implements Comparable{
	String from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}





Measured memory_bytes: 23252
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int yen;
	cin >> yen;

	if (n * 10000 < yen) {
		printf("-1 -1 -1\n");
		return 0;
	}

	int x = 0, y = 0;
	int t = yen / 1000 - n;

	while (9 * x <= t) {
		if ((t - 9 * x) % 4 == 0 && (t - 9 * x) / 4 >= 0) {
			y = (t - 9 * x) / 4;
			if (n - x - y >= 0) {
				printf("%d %d %d\n", x, y, n - x - y);

				return 0;
			}			
		}
		x++;
	}
	
	printf("-1 -1 -1\n");
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = sum(b)
for i in range(n-1):
  if a[i]+1 == a[i+1]:
    ans += c[a[i]-1]
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include <vector>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;

int main()
{
  long x, y;
  long n,k;
  cin >> n >> k;
  vector<long> a(n);
  vector<long >v(n+1,0);

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

  sort(v.begin(),v.end(),[](const long l,const long r){
    return l > r;
  });

  for (long i = 0; i < n; ++i) {
    cerr << v[i]  << endl;
  }

  long ans = 0;
  for(long i = k; i < n+1; ++i) {
    ans+=v[i];
  }



  cout << ans;

  return 0;
}

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

public class Main 
{ 

	 static FastReader sc=new FastReader(); 
	  public static void main(String[] args) 
    {
    int n=i();
    int A[]=new int[n];
    input(A);
    long s=0;
    for(int i=0;i<n-1;i++){
        if(A[i+1]<A[i]){
            s+=A[i]-A[i+1];
            A[i+1]=A[i];
        }
    }
    System.out.println(s);
        	
			
	
	}    	
    	
   static void input(int A[]) {
	   for(int i=0;i<A.length;i++) {
		   A[i]=sc.nextInt();
	   }
   }
     static int i() {
    	 return sc.nextInt();
     }
     static String s() {
    	 return sc.next();
     }
     static long l() {
    	 return sc.nextLong();
     }
     public static String rev(String str){  
    	    char ch[]=str.toCharArray();  
    	    String rev="";  
    	    for(int i=ch.length-1;i>=0;i--){  
    	        rev+=ch[i];  
    	    }  
    	    return rev;  
    	}  
        static void sort(int[] arr){
        int n = arr.length;
        Random rnd = new Random();
        for(int i=0; i<n; ++i){
            int tmp = arr[i];
            int randomPos = i + rnd.nextInt(n-i);
            arr[i] = arr[randomPos];
            arr[randomPos] = tmp;
        }   
        Arrays.sort(arr);
}
  
        
        
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
} 






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

int main(){
    int n;
    cin >> n;
    
    vector<int> x(n);
    for (int i=0; i<n; i++){
        cin >> x[i];
    }
    
    int cnt = 0;
    
    for (int i=0; i<n-1; i++){
        for (int j = n-1; j>i; j--){
            if (x[j] < x[j-1]) {
                swap(x[j],x[j-1]);
                cnt++;
            }
        }
    }
    
    for (int i=0; i<n; i++){
        if (i) cout << " ";
        cout << x.at(i);
    }
    cout << endl;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3092
#include <cstdio>
#include <iostream>

using namespace std;

struct Dice{
	int q1,q2,q3,q4,q5,q6;
};

int main(){
	Dice d;
	char od;
	
	scanf("%d %d %d %d %d %d", &d.q1, &d.q2, &d.q3, &d.q4, &d.q5, &d.q6);
	
	while( scanf("%c", &od) != EOF ){
		if(od=='N'){
			int tmp=d.q1;
			d.q1=d.q2;
			d.q2=d.q6;
			d.q6=d.q5;
			d.q5=tmp;
		}
		else if(od=='E'){
			int tmp=d.q1;
			d.q1=d.q4;
			d.q4=d.q6;
			d.q6=d.q3;
			d.q3=tmp;
		}
		else if(od=='W'){
			int tmp=d.q1;
			d.q1=d.q3;
			d.q3=d.q6;
			d.q6=d.q4;
			d.q4=tmp;
		}
		else if(od=='S'){
			int tmp=d.q1;
			d.q1=d.q5;
			d.q5=d.q6;
			d.q6=d.q2;
			d.q2=tmp;
		}
	}
	
	printf("%d\n", d.q1);
	
	return 0;
}

Measured memory_bytes: 1188
#include<iostream>

using namespace std;

int main(){
  int n, h, w;
  cin >> n >> h >> w;
  int a[1000], b[1000];
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i];
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(a[i] >= h && b[i] >= w){
      ans++;
    }
  }

  cout << ans << "\n";
}


Measured memory_bytes: 764
import numpy as np
n=int(input())
p=list(map(int,input().split()))
q=[i+1 for i in range(n)]
p=np.array(p)
q=np.array(q)
r=p-q
b=np.count_nonzero(r==0)
if b>=n-2:
  print('YES')
else:
  print('NO')

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	
	for(auto itr = s.begin(); itr != s.end(); itr++)
	{
		if(*itr != ',')
		{
			cout << *itr;
		}
		else
		{
			cout << " ";
		}
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<unordered_map>
using namespace std;


int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }
    for (int i = 0; i < N; i++) {
        sort(S[i].begin(), S[i].end());
    }
    long long ans;
    ans = 0;
    unordered_map<string, long long> map;
    for (int i = 0; i < N; i++) {
        map[S[i]] = 0;
    }
    for (int i = 0; i < N; i++) {
        if (map[S[i]] > 0) {
            ans += map[S[i]];
            map[S[i]] += 1;
        }else{
            map[S[i]] += 1;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 17700
def main():
    grid = [[ int(c) for c in input().split()] for i in range(3)]

    a1 = 0
    a2 = 0
    a3 = 0
    b1 = 0
    b2 = 0
    b3 = 0

    find_a1 = False
    find_a2 = False
    find_a3 = False
    find_b1 = False
    find_b2 = False
    find_b3 = False
    find_all = False

    for a in range(101):
        find_a1 = False
        find_a2 = False
        find_a3 = False
        find_b1 = False
        find_b2 = False
        find_b3 = False

        for b in range(101):
            if a + b == grid[0][0]:
                b1 = b
                find_b1 = True
            
            if a + b == grid[0][1]:
                b2 = b
                find_b2 = True
            
            if a + b == grid[0][2]:
                b3 = b
                find_b3 = True

            if find_b1 and find_b2 and find_b3 :
                a1 = a
                find_a1 = True
                break
   
        for a_ in range(101):
            if (a_ == grid[1][0] - b1) and (a_ == grid[1][1] - b2) and (a_ == grid[1][2] - b3):
                a2 = a_
                find_a2 = True
                break

        for a_ in range(101):
            if (a_ == grid[2][0] - b1) and (a_ == grid[2][1] - b2) and (a_ == grid[2][2] - b3):
                a3 = a_
                find_a3 = True
                break

        if find_a1 and find_a2 and find_a3 and find_b1 and find_b2 and find_b3:
            find_all = True
            break

    if find_all:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        long n = sc.nextLong();
        long ans = (1 + n - 1) * (n - 1) / 2;
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21072
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e4+9;
const int inf = 0x3f3f3f3f;
typedef long long int ll;
typedef pair<int,int> pi;
struct {
    int v,nex,d,c;
}e[maxn*2];
int in[maxn];
int dis[maxn];
int head[maxn];
int tot;
void addedge(int u,int v,int d,int c){
    e[tot] ={v,head[u],d,c};
    head[u] = tot++;
}
int dd[maxn];
priority_queue<pi> qq;
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)){
            tot =0;
        if(n==0 && m==0 ) break;
        memset(head,-1,sizeof(head));
        memset(dd,0x3f,sizeof(dd));
        memset(dis,0x3f,sizeof(dis));
        memset(in,0,sizeof(in));

        while(!qq.empty()){
            qq.pop();
        }
        qq.push(pi(0,1));
        dis[1] =0;
        dd[1] = 0;

        for(int i=1;i<=m;i++){
            int u,v,d,c;
            scanf("%d%d%d%d",&u,&v,&d,&c);
            addedge(u,v,d,c);
            addedge(v,u,d,c);
        }
        while(!qq.empty()){
            pi now = qq.top();
            qq.pop();
            int pp = now.second;
            if(in[pp]==1) continue;
            in[pp] = 1;
            for(int i=head[pp];i!=-1;i=e[i].nex){
                int v= e[i].v;
                int d = e[i].d;
                if(in[v]==1) continue;
                if( dis[pp]+d<dis[v]){
                    dis[v] = dis[pp]+d;
                    dd[v] = e[i].c;
                    qq.push(pi(-dis[v],v));
                }else if(dis[pp]+d==dis[v]){
                    dd[v] = min(dd[v],e[i].c);
                }
            }
        }
        int ans = 0;
        for(int i=1;i<=n;i++){
            ans+=dd[i];
        }
        printf("%d\n",ans);
    }
    return 0;
}



Measured memory_bytes: 4200
<?php
define("inf", 10**15);
list($n, $m) = array_map("intval", explode(" ", trim(fgets(STDIN))));
for($i = 2; $i <= $n; $i++){
  $map[$i][] = [$i-1, 0];
}
for($i = 0; $i < $m; $i++){
  list($from, $to, $d) = array_map("intval", explode(" ", trim(fgets(STDIN))));
  $map[$from][] = [$to, $d];
}
$D[1] = 0;
for($i = 2; $i <= $n; $i++){
  $D[$i] = inf;
}
$pq = new SplPriorityQueue();
$pq->insert(1, 0);
while($pq->count()){
  $f = $pq->extract();
  if(!isset($map[$f]))continue;
  foreach($map[$f] as list($t, $dist)){
    $new = $D[$f] + $dist;
    if($D[$t] > $new){
      $D[$t] = $new;
      $pq->insert($t, -$new);
    }
  }
}
printf("%d", $D[$n] == inf ? -1 : $D[$n]);


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

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  int cha = 0;
  for(int i = 0; i < N-1; i++){
    if(S.at(i) != S.at(i+1)){
      cha++;
    }
  }
  int out = 0;
  if((cha + 1)/2 <= K){
    out = N - 1;
  }else{
    out = N - ((cha + 1) - (2 * K));
  }
  cout << out;
}

Measured memory_bytes: 512
H,W=map(int, input().split())
li=[list(input()) for i in range(H)]

def array_pointer(L,i,j): #配列の１要素を引数に、チェックするべき要素を二重リストで返す
    L_next=[[i-1,j],[i+1,j],[i,j-1],[i,j+1]]
    if j==W-1:
        del L_next[3]
    elif j==0:
        del L_next[2]
    if i==H-1:
        del L_next[1] 
    elif i==0:
        del L_next[0]
    return L_next

def check(L,L_check):
    for k in L_check:
        a,b=k[0],k[1]
        if L[a][b]=='#':
            return True
    return False

ans='Yes'
for i in range(H):
    for j in range(W):
        if li[i][j]=='#':
            li_check=array_pointer(li,i,j)
            if not check(li,li_check):
                ans='No'
                break
print(ans)

Measured memory_bytes: 40684
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;
int a[55];

int cmp(int a,int b)
{
    return a > b;
}

int main()
{
    int n,k;
    int i;
    int sum;

    while(scanf("%d%d",&n,&k) == 2)
    {
        for(i = 0;i < n;i++)
        {
            scanf("%d",&a[i]);
        }
        sort(a,a+n,cmp);
        sum = 0;
        for(i = 0;i < k;i++)
        {
            sum += a[i];
        }
        printf("%d\n",sum);
    }

    return 0;
}


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

int main(void){
    int n ;
    cin >> n ;
    char s[n+2],t[n+2];
    cin >> s >> t ;
    for (int i=0; i<n; i++){
        cout << s[i] << t[i] ;
    }
    cout << endl ;
}

Measured memory_bytes: 256