akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll a,b,c,d,e,i,j,k,l,n,m,x,y,t,p;
    cin>>a>>b>>c;
    b=b*c;
    if(b>=a)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
}


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

#define db(x) cerr << #x ": " << (x) << '\n';

#define int long long

using namespace std;

typedef long long ll;

typedef long double ld;

const int oo = 1e18;

int X, Y, A, B, C;

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> X >> Y >> A >> B >> C;

    vector<int> va, vb, vc;

    for(int i = 0 ; i < A ; i++)
    {
        int n;
        cin >> n;
        va.push_back(n);
    }

    for(int i = 0 ; i < B ; i++)
    {
        int n;
        cin >> n;
        vb.push_back(n);
    }

    for(int i = 0 ; i < C ; i++)
    {
        int n;
        cin >> n;
        vc.push_back(n);
    }

    sort(va.begin(),va.end());
    reverse(va.begin(),va.end());
    sort(vb.begin(),vb.end());
    reverse(vb.begin(),vb.end());
    sort(vc.begin(),vc.end());
    reverse(vc.begin(),vc.end());

    while(va.size() > X)va.pop_back();
    while(vb.size() > Y)vb.pop_back();

    int sumA = 0, sumB = 0;

    for(auto x : va)sumA += x;
    for(auto x : vb)sumB += x;

    int sumC = 0;

    int res = sumA+sumB;

    for(int i = 0 ; i < C ; i++)
    {
        sumC += vc[i];
        if(va.size() && vb.size())
        {
            if(va.back() < vb.back())
            {
                sumA -= va.back();
                va.pop_back();
            }
            else
            {
                sumB -= vb.back();
                vb.pop_back();
            }
        }
        else if(va.size())
        {
            sumA -= va.back();
            va.pop_back();
        }
        else if(vb.size())
        {
            sumB -= vb.back();
            vb.pop_back();
        }
        else
        {
            break;
        }
        res = max(res,sumA+sumB+sumC);
    }

    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define all(x) (x).rbegin(), (x).rend()
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    if(n%1000==0)
    {
        cout<<0;
    }else{
    cout<<(((n/1000)+1)*1000)-n;
    }
    return 0;

}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n,t,a;
  cin>>n>>t>>a;
  int ans=-1;
  double cur=1e9;
  rep(i,0,n){
    int h;
    cin>>h;
    double temp=t-h*0.006;
    if(abs(temp-a)<cur){
      cur=abs(temp-a);
      ans=i;
    }
  }
  cout<<ans+1<<endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    int h,w;
    cin >> w >> h;
    if(h==0) return 0;
    vector<string> f(h);
    vector<vector<int>> c(h,vector<int>(w,0));
    rep(i,h){
      cin >> f[i];
    }
    int v[5]={0,1,0,-1,0};
    queue<pair<int,int>> q;
    rep(i,h){
      rep(j,w){
        if(f[i][j]=='B'){
          q.push({i,j});
        }
      }
    }
    while(!q.empty()){
      auto now=q.front();
      q.pop();
      rep(i,4){
        int nx = now.second+v[i];
        int ny = now.first+v[i+1];
        if(0<=nx&&nx<w&&0<=ny&&ny<h){
          if(f[ny][nx]=='.'&&((c[ny][nx]&1)==0)){
            c[ny][nx]++;
            q.push({ny,nx});
          }
        }
      }
    }
    rep(i,h){
      rep(j,w){
        if(f[i][j]=='W'){
          q.push({i,j});
        }
      }
    }
    while(!q.empty()){
      auto now=q.front();
      q.pop();
      rep(i,4){
        int nx = now.second+v[i];
        int ny = now.first+v[i+1];
        if(0<=nx&&nx<w&&0<=ny&&ny<h){
          if(f[ny][nx]=='.'&&((c[ny][nx]&2)==0)){
            c[ny][nx]+=2;
            q.push({ny,nx});
          }
        }
      }
    }
    int b=0,ww=0;
    rep(i,h){
      rep(j,w){
        if(c[i][j]==1) b++;
        else if(c[i][j]==2) ww++;
      }
    }
    cout << b SP ww << endl;
  }
  return 0;
}



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

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

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 6100000;
const int K = 19;
const int mod = 998244353;
int dp[N], s[N], a[N], tl[N], tr[N], n, x[N], y[N];
set < int > s1, s2;
map < int, int > nx, ny;
int sumr (int r)
{
	int result = 0;
	for (; r >= 0; r = (r & (r+1)) - 1)
		result += tr[r];
	return result;
}

void incr (int i, int delta)
{
	for (; i < n; i = (i | (i+1)))
		tr[i] += delta;
}

int sumr (int l, int r)
{
	return sumr (r) - sumr (l-1);
}
int suml (int r)
{
	int result = 0;
	for (; r >= 0; r = (r & (r+1)) - 1)
		result += tl[r];
	return result;
}

void incl (int i, int delta)
{
	for (; i < n; i = (i | (i+1)))
		tl[i] += delta;
}

int suml (int l, int r)
{
	return suml(r) - suml (l-1);
}
int binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> x[i] >> y[i];
        s1.insert(x[i]);
        s2.insert(y[i]);
    }
    int cnt1 = 0;
    while(!s1.empty()){
        nx[*s1.begin()] = cnt1;
        cnt1++;
        s1.erase(s1.begin());
    }
    int cnt2 = 0;
    while(!s2.empty()){
        ny[*s2.begin()] = cnt2;
        cnt2++;
        s2.erase(s2.begin());
    }
    for (int i = 1; i <= n; i++){
        x[i] = nx[x[i]];
        y[i] = ny[y[i]];
        a[x[i]] = y[i];
     //   cout << x[i] << " " << y[i] << endl;
        incr(y[i], 1);
    }
    int ans = 0;
    for (int i = 0; i < cnt1; i++){
        incl(a[i], 1);
        int p1 = suml(a[i]);
        int p2 = suml(a[i], cnt2 - 1);
        int p3 = sumr(a[i]);
        int p4 = sumr(a[i], cnt2 - 1);
        for (int j = 0; j < 16; j++){
            int v1, v2, v3, v4;
            if (j & 1) v1 = (binpow(2, p1 - 1) - 1); else v1 = 1;
            if (j & 2) v2 = (binpow(2, p2 - 1) - 1); else v2 = 1;
            if (j & 4) v3 = (binpow(2, p3 - 1) - 1); else v3 = 1;
            if (j & 8) v4 = (binpow(2, p4 - 1) - 1); else v4 = 1;
            int c = 1;
            if ((j & 9) == 9 || (j & 6) == 6) c++;
            ans = (ans + c * v1 % mod * v2 % mod * v3 % mod * v4) % mod;
        }
      //  cout << ans << endl;
       // cout << p1 << " " << p2 << " " << p3 << " " << p4 << " " << cnt2 << " " << a[i] << " " << suml(cnt2 - 1) << endl;
        incr(a[i], -1);
    }
    cout << ans;
}


Measured memory_bytes: 47488
#include <iomanip>
#include<iostream>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	cout << a / b << " " << endl;
	cout << a % b << " " << endl;
	cout << fixed << setprecision(5) << static_cast<double>(a) / static_cast<double>(b) << endl;

	return 0;
}


Measured memory_bytes: 3288
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

    int n, d; cin>>n>>d;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int x, y; cin>>x>>y;
        if((double)sqrt((ll)x * x + (ll)y * y) <= d){
            ans++;
        }
    }

    cout<<ans<<'\n';

    





}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1) res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 3696
import sys
readline = sys.stdin.readline

A, B, C, D = map(int, readline().split())

ans = 'Yes'
for i in range(10000):
    if i%2 == 0:
        C -= B
        if C <= 0:
            break
    else:
        A -= D
        if A <= 0:
            ans = 'No'
            break
print(ans)

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll N; cin >> N;
    ll ichi = N % 10;
    string res;
    if (ichi == 3) {
        res = "bon";
    }
    else if (ichi == 0 || ichi == 1 || ichi == 6 || ichi == 8) {
        res = "pon";
    }
    else {
        res = "hon";
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include<cstdlib>
#include<queue>
#include<cmath>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll long long
int n;
int t[1111];

int main(){
	cin>>n;
	rep(i,n)cin>>t[i];
	int ans=0;
	for(int i=0;i<n-2;i++){
		if(t[i]==t[i+1]&&t[i]==t[i+2]){
			ans++;
			t[i+1]=-1;
		}
	}

	for(int i=0;i<n-1;i++){
		if(t[i]!=-1&&t[i]==t[i+1]){
			ans++;

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


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

int main(){
    ll m,n;
    char k;
    cin >> m >> n;
    vector< vector<char> > grid(m,vector<char>(n,'1'));
    vector< vector<int> > ways(m,vector<int>(n,0));
    for(ll i=0;i<m;i++){
        for(ll j=0;j<n;j++){
            cin >> grid[i][j];
        }
    }
    for(ll i=0;i<m;i++){
        for(ll j=0;j<n;j++){
            if(grid[i][j]=='#'){
                ways[i][j]=-1;
            }
        }
    }
    for(ll i=0;i<m;i++){
        if(grid[i][0]=='.'){
            ways[i][0]=1;
        }
        else{
            break;
        }
    }
    for(ll i=0;i<n;i++){
        if(grid[0][i]=='.'){
            ways[0][i]=1;
        }
        else{
            break;
        }
    }
    for(ll i=1;i<m;i++){
        for(ll j=1;j<n;j++){
            if(ways[i][j]==-1){
                continue;
            }
            if(ways[i-1][j]>0){
                ways[i][j] = (ways[i][j]%MOD + ways[i-1][j]%MOD)%MOD;
            }
            if(ways[i][j-1]>0){
                ways[i][j] = (ways[i][j]%MOD + ways[i][j-1]%MOD)%MOD;
            }
        }
    }
    cout << ways[m-1][n-1] << endl;
}

Measured memory_bytes: 5248
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>

using namespace std;

int main(void) {
    int N = 0;

    cin >> N;

    pair<pair<string, int>, int> p[N];

    for (int i=0; i<N; i++) {
        string city;
        int val;

        cin >> city >> val;

        p[i] = make_pair(make_pair(city, -val), i);
    }

    sort(p, p+N);

    for (int i=0; i<N; i++) {
        cout << p[i].second+1 << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	long long n,s=0;
	cin>>n;
	long long a[n+1],f[n+1],ans=0LL;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		s+=a[i];
		f[i]=s;
	}
	for(int i=1;i<n;i++)
	{
		ans+=((a[i]%1000000007)*\
		((s-f[i])%1000000007))%1000000007;
		ans%=1000000007;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 6740
cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
}
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    cards[s][int(r) - 1] = 1

for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print(s, r + 1)

Measured memory_bytes: 6724
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
??´?????????
"""

rooms = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]

number = int(input())

for n in range(number):
    inp = input().split(" ")
    b = int(inp[0]) - 1
    f = int(inp[1]) - 1
    r = int(inp[2]) - 1
    v = int(inp[3])
    rooms[b][f][r] += v

for b in range(4):
    if b > 0:
        print("####################")
    for f in range(3):
        print(""," ".join(map(str,rooms[b][f])))

Measured memory_bytes: 7676
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
    ll n,m;
    cin >> n >> m;
    ll bulbs[m][12];
    ll t[m];
    for(ll i=0;i<m;i++)
    {
        
        cin >> t[i];
        for(ll j=0;j<t[i];j++)
        {
            cin >> bulbs[i][j];
            bulbs[i][j]--;
        }
    }
    ll parity[m];
    for(ll i=0;i<m;i++)
    {
        cin >> parity[i];
    }
    ll ans=0;
    for(ll i=0;i<pow(2,n);i++)
    {
        ll counter=0;
        for(ll q=0;q<m;q++)
        {
            ll count=0;
            for(ll j=0;j<t[q];j++)
            {
                if(1<< bulbs[q][j] & i)
                {
                    count++;

                }
            }
            if(count%2==parity[q])
            {
                counter++;
            }
        }
        if(counter==m)
        {
            ans++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define second sec
#define first fir
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



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

	int a[3];
	rep(i, 3) cin >> a[i];
	sort(a, a + 3);
	if(a[0] == a[1] && a[1] != a[2]) puts("Yes");
	else if(a[1] == a[2] && a[0] != a[1]) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
# for #!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion
class union_find:
    def __init__(self, n):
        self.n = n
        self.rank = [0]*n
        self.parent = [int(j) for j in range(n)]
    
    def union(self,i,j):
        i = self.find(i)
        j = self.find(j)
        if self.rank[i] == self.rank[j]:
            self.parent[i] = j
            self.rank[j] += 1

        elif self.rank[i] > self.rank[j]:
            self.parent[j] = i
        else:
            self.parent[i] = j

    def find(self, i):
        temp = i
        if self.parent[temp] != temp:
            self.parent[temp] = self.find(self.parent[temp])
        return self.parent[temp]
def main():
# Enter your code here. Read input from STDIN. Print output to STDOUT
    n,k = [int(j) for j in input().split()]
    s = list(input())
    s[k-1] = s[k-1].lower()
    print("".join(s))
        





        
                # ls[i+1]=
            # base = f
        # print()


        
        




        # l = [int(j) for j in input().split()]




if __name__ == "__main__":
    main()

Measured memory_bytes: 62560
#include <bits/stdc++.h>
using namespace std;
int n,q,a,b,cnt[200001];
vector<int> v[200001];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>q;
	for (int i=1;i<n;++i)
	{
		cin>>a>>b;
		if (a>b) swap(a,b);
		v[a].push_back(b);
	}
	for (int i=1;i<=q;++i)
	{
		cin>>a>>b;
		cnt[a]+=b;
	}
	for (int i=1;i<=n;++i)
	{
		for (int j=0;j<v[i].size();++j)
			cnt[v[i][j]]+=cnt[i];
	}
	for (int i=1;i<=n;++i) cout<<cnt[i]<<" ";
	return 0;
}

Measured memory_bytes: 14080
// D.

#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

LL pat[51] = { 1 };
LL len[51] = { 1 };

LL patties(LL level, LL e) {
	if (level <= 0) {
		return e > 0;
	}
	--e;
	LL tot = 0;
	if (e > len[level - 1]) {
		tot = pat[level - 1];
		e -= len[level - 1];
		if (e > 0) {
			--e;
			++tot;
		}
	}
	return tot + patties(level - 1, e);
}

int main(int argc, char *argv[])
{
	for (int i = 1; i <= 50; ++i) {
		pat[i] = pat[i - 1] * 2 + 1;
		len[i] = len[i - 1] * 2 + 3;
	}
	LL n, x;
	cin >> n >> x;
	LL ans = patties(n, x);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
   char s[101];
 	cin >> s;
 	int res = 0;
 	int n = strlen(s);
 	for(int i = 0; i < n; i++) {
 	if(s[i] != s[n - 1 - i]) 
      res++;
 }
	cout <<  (res / 2) << endl;
   return 0;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a), t(b), x(q);
    rep (i, a) cin >> s[i];
    rep (i, b) cin >> t[i];
    rep (i, q) cin >> x[i];

   
    rep (i, q) {
        vector<int> useSIdx, useTIdx;
        int tmp1;
        tmp1 = lower_bound(rng(s), x[i]) - s.begin();
        if (tmp1 == a) {
            useSIdx.pb(tmp1 - 1);
        }
        else if (tmp1 == 0) {
            useSIdx.pb(tmp1);
        }
        else {
            useSIdx.pb(tmp1);
            useSIdx.pb(tmp1 - 1);
        }
        tmp1 = lower_bound(rng(t), x[i]) - t.begin();
        if (tmp1 == b) {
            useTIdx.pb(tmp1 - 1);
        }
        else if (tmp1 == 0) {
            useTIdx.pb(tmp1);
        }
        else {
            useTIdx.pb(tmp1);
            useTIdx.pb(tmp1 - 1);
        }

        ll ans = 1000000000000LL;

        rep (p1, useSIdx.size()) rep (p2, useTIdx.size()) {
            ll dist = min(abs(x[i] - s[useSIdx[p1]]), abs(x[i] - t[useTIdx[p2]])) + abs(t[useTIdx[p2]] - s[useSIdx[p1]]);
            chmin(ans, dist);
        }

        cout << ans << endl;
    }   
    
   

    return 0;
}

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

using namespace std;

int main(int argc, char const *argv[]) {
  int n, j;
  cin >> n;
  vector<int> a(n), v(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = n; i > 0; i--) {
    j = i;
    v[i - 1] = a[i - 1];
    j += i;
    while (j <= n) {
      v[i - 1] ^= v[j - 1];
      j += i;
    }
  }
  queue<int> q;
  for (int i = 0 ; i < n; i++) {
    if (v[i]) {
      q.push(i+1);
    }
  }

  cout << q.size() << endl;
  if (!q.empty()) {
    while (!q.empty()) {
      cout << q.front() << endl;
      q.pop();
    }
  }
  return 0;
}


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

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;
 
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;

int main() {
  
  int n,m;
  cin >> n >> m;
  
  vector<int> t(m+1,0);
  
  for ( int i = 0; i < n; i++){
    int k;
    cin >> k;
    for ( int j = 0; j < k; j++){
      int a;
      cin >> a;
      t[a]++;
    }
  }
  
  int count = 0;
  
  for ( int i = 0; i < m + 1; i++){
    if ( t[i] == n ){
      count++;
    }
  }
  
  cout << count << endl;

}

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

#define ll long long
#define pb push_back

int main(){

	int X;
	cin >> X;
	if(X == 3 || X == 5 || X == 7)cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    string s;
    while(cin>>s)
    {
        int ans=0;
        int n=s.size();
        int l=0;
        int r=n-1;
        while(l<=r)
        {
            if(s[l]!=s[r])ans++;
            l++;r--;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
	int a=read(),b=read(),c=read(),d=read();
	puts((abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d))?"Yes":"No");
	return 0;
}



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

int main() {
  string S;
  cin >> S;
  int cnt_A = 0, cnt_B = 0;
  for (int i = 0; i < 3; i++) {
    if (S[i] == 'A') cnt_A++;
    if (S[i] == 'B') cnt_B++; 
  }
  if (cnt_A > 0 && cnt_B > 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e5+233;


int main(){
    
    ll a;
    double b;
    cin>>a>>b;
    b+=0.0000001;
    b*=100;
    ll ans = a*(int)b/100;
    cout<<ans<<endl;
    
    return 0;
}

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

public class Main {


	public static void main(String[] args) throws IOException {
		BufferedReader bf = null;
		bf = new BufferedReader(new InputStreamReader(System.in));
		int n,k;
		String ans = "";
		String str;
		String[] s;
		str = bf.readLine();
		n = Integer.parseInt(str);
		str = bf.readLine();
		ans = str;
		str = bf.readLine();
		k = Integer.parseInt(str);
		String p = "[^" + ans.charAt(k-1) + "]";
		ans = ans.replaceAll(p, "*");
		System.out.println(ans);
	}
}

Measured memory_bytes: 20820
#include <stdio.h>
int main (void)
{
    char a,b,c,d;
    scanf("%c%c%c%c", &a, &b, &c, &d);
    if ( a == b )
    {
        if ( c == d && a != c)
        {
            printf("Yes");
        }
        else
        {
            printf("No");
        }
    }
    else if ( a == c )
    {
        if ( b == d && a != d)
        {
            printf("Yes");
        }
        else
        {
            printf("No");
        }
    }
    else if ( a == d )
    {
        if ( b == c && a != b)
        printf("Yes");
        else
        printf("No");
    }   
    else
    {
        printf("No");
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n,a[100001];
void read(int& x){
    x=0;
    int y=1;
    char ch=getchar();
    while (ch<'0'||ch>'9'){
        if (ch=='-') y=-1;
        ch=getchar();
    }
    while (ch>='0'&&ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    x=x*y;
}
int main(){
	int i,t=0;
	read(n);
	for (i=1;i<=n;++i) read(a[i]);
	sort(a+1,a+n+1);
	if (a[1]==a[n]&&(a[1]<<1<=n||a[1]+1==n)) t=1;
	else if (a[1]+1==a[n]){
		for (i=1;a[i]==a[1];++i);
		if (a[n]-i+1>0&&a[n]-i+1<<1<=n-i+1) t=1;
	}
	if (t) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

#define N 200010
#define MAX 1000000000000000000
#define MOD 1000000007

#include <stdio.h>

int main (void) {
    long n, k;

    scanf("%ld %ld", &n, &k);

    printf("%ld", (long)(log(n) / log(k)) + 1);

    return 0;
}



Measured memory_bytes: 2244
console.log((args=>{
  const [S,T] = args.trim().split('\n');
  let c = 0;
  for ( let i = 0, l = S.length; i < l; i++ ) {
    if ( S[i] !== T[i] ) c++;
  }
  return `${c}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 32936
n, y = map(int, input().split())
y //= 1000
for i in range(n + 1):
    for j in range(n + 1 - i):
        if i * 10 + j * 5 + n - i - j == y:
            print(i, j, n - i - j)
            exit()
else:
    print(-1, -1, -1)

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

using ll = long long int;

const int MAX_N = (int)(1e5 + 5);

int N;
int A[MAX_N], B[MAX_N], C[MAX_N];
ll ans;

int main(void){
    // Here your code !
    scanf("%d", &N);
    for (int i = 0; i < N; ++i) {scanf("%d", &A[i]);}
    for (int i = 0; i < N; ++i) {scanf("%d", &B[i]);}
    for (int i = 0; i < N; ++i) {scanf("%d", &C[i]);}

    sort(A, A + N);
    sort(C, C + N);

    for (int i = 0; i < N; ++i) {

      int a = lower_bound(A, A + N, B[i]) - A;
      int c = N - (upper_bound(C, C + N, B[i]) - C);
      ans += 1LL * a * c;
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 1408
sa=input()
sb=input()
sc=input()

turn="a"
while True:
    if turn == "a" and sa=="":
        print("A")
        break
    elif turn == "b" and sb=="":
        print("B")
        break
    elif turn == "c" and sc=="":
        print("C")
        break

    if turn == "a":
        turn=sa[0]
        sa=sa[1:]
    elif turn == "b":
        turn=sb[0]
        sb=sb[1:]
    elif turn == "c":
        turn=sc[0]
        sc=sc[1:]

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

int main() {
  int N;
  int M;
  int max;
  max = 0;
  
  cin >> N;
  vector<string>red(N);
  for(int i = 0; i < N ; i++ ){
    cin >> red.at(i);
  }
  
  cin >> M;
  vector<string>blue(M);
  for(int i = 0; i < M ; i++ ){
    cin >> blue.at(i);
  }
  
  for(int i = 0; i < N ; i++){
    int r , b;
    r = 0;
    b = 0;
    for(int j = 0; j < N ; j++){
      if(red.at(i) == red.at(j)){
        r++;
      }
    }
    for(int j = 0; j < M ;j++){
      if(red.at(i) == blue.at(j)){
        b++;
      }
    }
    if(r-b > max){
      max = r-b;
    } 
  }
  cout << max << endl;
}


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

using namespace std;

const int MAX_SIZE = 26;

int main() {
	int num = 0;
	cin >> num;
	string strBase = "";
	cin >> strBase;
	for (int i = 0; i < strBase.size(); ++i) {
		strBase[i] += num;
		if (strBase[i] > 'Z') {
			strBase[i] -= MAX_SIZE;
		}
	}

	cout << strBase << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int Inf = 1e9;
const ll INF = 9223372036854775807;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    int H,A;
    cin >> H >> A;
    cout << (H + A - 1) / A << endl;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: i32,
        p: [(i32, i32, i32);n],
    }

    let mut ct = 0;
    let mut cx = 0;
    let mut cy = 0;

    for (t, x, y) in &p {
        let n = t - ct;
        let dx = (x - cx).abs();
        let dy = (y - cy).abs();

        let dt = n - dx - dy;
        if dt < 0 || dt % 2 == 1 {
            println!("No");
            return;
        }

        ct = *t;
        cx = *x;
        cy = *y;
    }

    println!("Yes")
}


Measured memory_bytes: 4448
#include<bits/stdc++.h>
using namespace std;
const int sq=30000;
int sg(int x,int k){
	if (x%k==0)return x/k;
	if (x/k>sq)return sg(x-x/k-1,k);
	else {
		int m1=x%k;
		return sg(x-max(x/k+1,m1-m1%(x/k+1)),k);
	}
}
int ans,n;
int main(){
	cin>>n;
	for (int i=1;i<=n;i++){
		int x,k;
		scanf("%d%d",&x,&k);
		ans^=sg(x,k);
	}
	cout<<(ans?"Takahashi":"Aoki")<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
using namespace std;
int gcd(int a, int b){
    if(b==0) return a;
    else return gcd(b,a%b);
}
signed main(){
    string s; cin>>s;
    int a=0, b=0;
    rep(i,s.size()){
        if(s.at(i)=='0') a++;
        else b++;
    }
    cout<<min(a,b)*2<<endl;
}

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

int main() {
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  int dx=x2-x1;
  int dy = y2-y1;
  char U='U',R='R',D='D',L='L';
  //path1
  for(int i=0;i<dx;i++){
    cout<<R;
  }
  for(int i=0;i<dy;i++){
    cout<<U;
  }
  //path2
  for(int i=0;i<dx;i++){
    cout<<L;
  }
  for(int i=0;i<dy;i++){
    cout<<D;
  }
  //path3
  cout<<D; 
  for(int i=0;i<dx+1;i++){
    cout<<R;
  }
  for(int i=0;i<dy+1;i++){
    cout<<U;
  }
  cout<<L;
  //path4
  cout<<U;
  for(int i=0;i<dx+1;i++){
    cout<<L;
  }
  for(int i=0;i<dy+1;i++){
    cout<<D;
  }
  cout<<R;
  
  cout<<endl;
}

Measured memory_bytes: 256
n = int(raw_input())

count = 0
for i in range(1, n+1):
    if i % 2 == 0:
        continue

    c = 0
    for j in range(1, n+1):
        if i % j == 0:
            c += 1
    if c == 8:
        count += 1
print(count)


Measured memory_bytes: 2568
#include <iostream>
using namespace std;
int main(){

   int s,a,c,v,b;
    cin>>s>>a>>c;

    if(s>a)
    {
      v=s-a;
    }

      if (s<a)
     {
         v=a-s;
     }
     if(s>c)
    {
      b=s-c;
    }

     if (s<c)
     {
         b=c-s;
     }
     if(b>v)
    {
        cout<<"A";
    }if(v>b)
    {
        cout<<"B";
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define M_PI 3.14159265358979323846

struct point {
  double x, y;
};
typedef struct point Point;

void co(int n,Point p1,Point p2){
  if(n==0)return;
  Point a,b,c;
  double t=M_PI*60.0/180.0;
  a.x=(2.0*p1.x+1.0*p2.x)/3.0;
  a.y=(2.0*p1.y+1.0*p2.y)/3.0;
  b.x=(1.0*p1.x+2.0*p2.x)/3.0;
  b.y=(1.0*p1.y+2.0*p2.y)/3.0;
  c.x=(b.x-a.x)* cos(t)-(b.y-a.y)* sin(t)+a.x;
  c.y=(b.x-a.x)* sin(t)+(b.y-a.y)* cos(t)+a.y;

  co(n-1,p1,a);
  printf("%.8f %.8f\n",a.x,a.y);
  co(n-1, a, c);
  printf("%.8f %.8f\n",c.x,c.y);
  co(n-1,c, b);
  printf("%.8f %.8f\n",b.x,b.y);
  co(n-1,b,p2);
}

int main(){
  Point p1,p2;
  int n;

  scanf("%d",&n);
  p1.x=0;
  p1.y=0;
  p2.x=100;
  p2.y=0;

  printf("%.8f %.8f\n",p1.x, p1.y);
  co(n,p1,p2);
  printf("%.8f %.8f\n",p2.x, p2.y);

  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    string s; cin >>s;
    string a = "ABC" + s;

    cout << a << endl;

    return 0;
}




Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  int n; cin >> n;
  vector<int> A(n);
  loop(i,0,n) cin >> A[i];
  int min_ = 200000;
  int cnt = 0;
  loop(i,0,n) {
    if (min_ >= A[i]) cnt++;
    min_ = min(min_, A[i]);
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3980
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, K, Q;
	cin >> N >> K >> Q;
	vector<int> A(N);
	for(int i = 0; i < N; i++) cin >> A[i];
	vector<int> val = A;
	sort(begin(val), end(val));
	int ans = OVER9000;
	for(int i = 0; i < N; i++) {
		vector<int> X;
		for(int j = 0; j < N; j++) if(A[j] >= val[i]) if(j == 0 || A[j-1] < val[i]) {
			int k = j;
			vector<int> v;
			while(k < N && A[k] >= val[i]) {
				v.push_back(A[k]);
				k++;
			}
			if((int)v.size() < K) continue;
			sort(begin(v), end(v));
			for(k = 0; k <= (int)v.size()-K; k++) X.push_back(v[k]);
		}
		if((int)X.size() < Q) continue;
		sort(begin(X), end(X));
		ans = min(ans, X[Q-1]-val[i]);
	}
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


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


int main() {
    string S;
    long long K;
    cin >> S >> K;

    for (int i = 0; i < min((long long)S.size(), K); ++i) {
        if (S[i] >= '2') {cout << S[i] << endl; return 0;}
    }
    cout << '1' << endl;
    return 0;
}


Measured memory_bytes: 384
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int n, m, cnt, a, b;
bool gp[50][50], v[50], flag, flag2, v2[50];


ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	ll g = gcd(x, y);
	return x / g * y;
}

int f(int x) {
	if (flag2==false)return 0;
	flag = true;
	lp(n) {
		if (v2[i] == false) {
			flag = false;
			break;
		}
	}
	if (flag) {
		flag2 = false;
		return 0;
	}
	lp(n) {
		if (gp[x][i]==true && v[i] == false) {
			v[i] = true;
			v2[i] = true;
			f(i);
			v[i] = false;
			if (flag2==false)return 0;
		}
	}
	return 0;
}

int main(){
	lp(50) {
		lop(50, j)
			gp[i][j] = false;
	}
	cin >> n >> m;
	lp(m) {
		cin >> a >> b;
		gp[a - 1][b - 1] = true;
		gp[b - 1][a - 1] = true;
	}
	cnt = 0;

	lp(n-1)
		for (int j = i + 1; j < n;j++) {
			if (gp[i][j]) {
				gp[i][j] = false;
				gp[j][i] = false;
				lop(n, k) {
					v[k] = false;
					v2[k] = false;
				}
				v[0] = true;
				v2[0] = true;
				flag2 = true;
				f(0);
//				cout << flag2 << ' ' << i << ' ' << j << ' ' << v2[1] << endl;
				if (flag2) {
					cnt++;
				}
				gp[i][j] = true;
				gp[j][i] = true;
			}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000000 + 7
#define vpi vector<pair<int, int>>
#define ll long long int
#define MAX 1000000
#define minus_inf -1000000000


bool checkPalindrome(string x){
    string y = x;
    reverse(x.begin(), x.end());
    for(int i=0; i<x.length(); ++i){
        if(x[i]!=y[i]) return false;
    }
    return true;
}

int main(){
    string x; cin>>x;
    int n = x.length();
    // cout<<"Left -> "<<x.substr(0, ((n-1)/2))<<endl;
    // cout<<"Right -> "<<x.substr((n+3)/2, n-1)<<endl;
    bool ans = checkPalindrome(x) && checkPalindrome(x.substr(0, ((n-1)/2))) && checkPalindrome(x.substr(((n+3)/2)-1, n-1));
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        //long start = System.currentTimeMillis();
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0;i<n;++i) a[i] = sc.nextLong();
        sc.close();

        long ans = 0;
        long mod = (long) Math.pow(10,9)+7;

        long x = 0;
        for (int i = 0;i<n;++i)
        {
            ans += (a[i]%mod) * x;
            ans %= mod;
            x += (a[i]%mod);
            x %= mod;
        }

        System.out.println(ans);
//        long end = System.currentTimeMillis();
//        System.err.println((end-start)+"ms");
    }
}

Measured memory_bytes: 51244
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;

int main() {
    int N; cin >> N;
    int64_t ans = 1;
    for(int i = 1; i <= N; ++i) {
        ans *= i;
        ans %= MOD;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int N;
void solve() {
    cin >> N;
    vector<P> s(N);
    int last = -1;
    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        s[i] = P(b, a);
    }
    sort(s.begin(), s.end());
    int idx = 0;
    for (P p : s) {
        idx += p.second;
        if (p.first < idx) {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

int main() {
    solve();
    return 0;
}


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

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000

struct Ford{
	struct edge{
		int to;
		int weight;
		int ind;
	};
	vector<vector<edge>> E;
	
	Ford(vector<vector<pair<int,int>>> &e){
		E.resize(e.size(),vector<edge>());
		for(int i=0;i<e.size();i++){
			for(int j=0;j<e[i].size();j++){
				edge t = {e[i][j].first,e[i][j].second,0};
				E[i].push_back(t);
			}
		}
		for(int i=0;i<e.size();i++){
			for(int j=0;j<e[i].size();j++){
				E[i][j].ind = E[E[i][j].to].size();
				edge t = {i,0,j};
				E[E[i][j].to].push_back(t);
			}
		}
	}
	
	int maximum_flow(int s,int t){
		int ret = 0;
		while(true){
			vector<bool> visited(E.size(),false);
			vector<edge> edges;
			dfs(s,t,edges,visited);
			if(edges.size()==0)break;
			
			int mini = 1000000001;
			for(int i=0;i<edges.size();i++){
				mini = min(mini,edges[i].weight);
			}
			ret += mini;
			for(int i=0;i<edges.size();i++){
				edge &t = E[edges[i].to][edges[i].ind];
				t.weight += mini;
				E[t.to][t.ind].weight -= mini;
			}
			
		}
		return ret;
	}
	
	void dfs(int now,int t,vector<edge> &edges,vector<bool> &visited){
		visited[now] = true;
		if(now==t)return;
		
		for(int i=0;i<E[now].size();i++){
			int to = E[now][i].to;
			int weight = E[now][i].weight;
			if(visited[to])continue;
			if(weight<=0)continue;
			edges.push_back(E[now][i]);
			dfs(to,t,edges,visited);
			if(edges.back().to==t)return;
			edges.pop_back();
		}
	}
	
};

int main(){

	int H,W;
	cin>>H>>W;
    
	int sy,sx,ty,tx;
	vector<vector<pair<int,int>>> E(H+W+2,vector<pair<int,int>>());
	
	vector<string> S(H);
	for(int i=0;i<H;i++)cin>>S[i];
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(S[i][j]=='S')sy=i,sx=j;
			if(S[i][j]=='T')ty=i,tx=j;
			if(S[i][j]=='o'){
				E[i].emplace_back(H+j,1);
				E[H+j].emplace_back(i,1);
			}
		}
	}
	
	E[H+W].emplace_back(sy,300);
	E[H+W].emplace_back(H+sx,300);
	E[ty].emplace_back(H+W+1,300);
	E[H+tx].emplace_back(H+W+1,300);
	
	Ford F(E);
	int ans = F.maximum_flow(H+W,H+W+1);
	if(ans>=300)cout<<-1<<endl;
	else cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n,a[200005],sum,sum2;
int main() {
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i],sum=(sum+a[i])%mod,sum2=(sum2+1ll*a[i]*a[i])%mod;
	cout<<(1ll*sum*sum-sum2+mod)%mod*((mod+1)/2)%mod;
	return 0;
}

Measured memory_bytes: 4372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
const ll mod=1e9+7;
int n,k,rt;
bool flag;
int l[N],r[N],a[N];
vector<int> e[N];
void init()
{
	flag=true;
	for(int i=1;i<=n;i++)	
	{
		e[i].clear(),a[i]=-1;
		l[i]=-1e8,r[i]=1e8;
	}
}
void dfs(int u,int fa,int dep)
{
	int x=-1e9,y=1e9;
	if(a[u]!=-1)
	{
		if(dep&&(a[u]%2)!=(a[rt]%2))
			flag=false;
		if(!dep&&(a[u]%2==a[rt]%2))
			flag=false;
	}
	for(int i=0;i<e[u].size();i++)
	{
		int v=e[u][i];
		if(v==fa)
			continue;
		dfs(v,u,1-dep);
		x=max(x,l[v]-1);
		y=min(y,r[v]+1);
	}
	if(a[u]==-1&&x>=l[u]&&y<=r[u])
		l[u]=x,r[u]=y;
	if(a[u]!=-1&&(x>r[u]||y<l[u]))
		flag=false;
}
void dfs2(int u,int fa)
{

	if(a[u]==-1)
	{
		if(a[fa]-1>=l[u]&&a[fa]-1<=r[u])
			a[u]=a[fa]-1;
		else
			a[u]=a[fa]+1;
	}	
	for(int i=0;i<e[u].size();i++)
	{
		int v=e[u][i];
		if(v==fa)	continue;
		dfs2(v,u);
	}
}
int main()
{
	while(cin>>n)
	{
		int u,v,x;
		init();
		for(int i=1;i<=n-1;i++)
		{
			scanf("%d%d",&u,&v);
			e[u].push_back(v),e[v].push_back(u);
		}
		cin>>k;
		for(int i=1;i<=k;i++)
		{
			scanf("%d%d",&u,&x);
			a[u]=x,l[u]=r[u]=x;
			rt=u;
		}
		dfs(rt,-1,1);
		if(flag)
		{
			puts("Yes");
			dfs2(rt,-1);
			for(int i=1;i<=n;i++)
				printf("%d\n",a[i]);
		}
		else
			puts("No");
	}
    return 0;
}

Measured memory_bytes: 19968
N = int(input())
s = ''
i = 0
while N != 0:
    tmp = N % 2
    s += str(tmp)
    N = N - tmp * (-1) ** i
    N = (N // 2)
    i += 1
s = s[::-1]
if s == '':
    print(0)
else:
    print(s)


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long ll;
const int INF = 1e9;

string s;
int a[1 << 17], b, n, i;
main() {
  cin >> s;
  n = s.size();
  for (i = n - 1; i >= 0; i--)
    if (s[i] == 'L')
      b = i;
    else
      a[b - ((b - i) & 1)]++;
  
  for (i = 0; i < n; i++)
    if (s[i] == 'R')
      b = i;
    else
      a[b + ((i - b) & 1)]++;
  
  for (i = 0; i < n; i++) cout << a[i] << " ";
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#include<math.h>
#define loop(i, l, r) for(i=l; i<r; i++)/*Instead of function, (for).*/
#define rep(i,r) for(i=0; i<r; i++)
#define Min(a, b) ((a < b)? a : b)
#define Max(a, b) ((a > b)? a : b)
#define Abs(x) ((x>=0)? x : -x)/*Return the absolute value of x.*/
typedef long long int lli;
/*Return Combination ,(nCr)*/
int combi(int n, int r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
/*Return gcd(a, b)*/
int gcd(int a, int b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}
int main(void)
{
	int x, a;
	scanf("%d%d", &x, &a);
	if(x<a) printf("0");
	if(x>=a)printf("10");
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] m = new int[n];
        int ans = 0;

        for(int i=0;i<n;i++){
            m[i] = sc.nextInt();
        }

        for(int j=0;j<n;j++){
            if(j%2 == 0 && m[j]%2 == 1){
                    ans++;
            }
        }

        System.out.println(ans);
    } 
}

Measured memory_bytes: 35896
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),count=1;
    int[] a=new int[n];
    boolean p=false,m=false;
    for(int i=0;i<n;i++)a[i]=sc.nextInt();
    if(n==1)System.out.println(count);
    else{
    	if(a[0]<a[1])p=true;
    	else if(a[0]>a[1])m=true;
    	for(int i=1;i<n-1;i++) {
    		if(p) {
    			if(a[i]>a[i+1]) {
    				count++;
    				p=false;
    			}
    		}else if(m){
    			if(a[i]<a[i+1]) {
    				count++;
    				m=false;
    			}
    		}else {
    			if(a[i]<a[i+1])p=true;
    	    	else if(a[i]>a[i+1])m=true;
    		}
    	}
    	System.out.println(count);
    }
  }
}


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

int main() {
  int s; cin >> s;
  bool ans=false;
  for(int i=0; i<3; i++) {
    int a=s/10;
    if(s%10 == a%10) ans=true;
    else s/=10;
  }
  if(ans) cout << "Bad" << endl;
  else cout << "Good" << endl;
}

Measured memory_bytes: 3580