akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
using namespace std;
using namespace __gnu_pbds;
// Policy based data structure 
typedef tree<int, null_type, 
			less_equal<int>, rb_tree_tag, 
			tree_order_statistics_node_update> 
	indexed_set;  
#define ll long long int
#define pii pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define vi vector<ll>
#define vii vector<pii>
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define yes cout<<"YES"<<endl; return;
#define no cout<<"NO"<<endl; return;
#define flus fflush(stdin); fflush(stdout);
#define F first
#define S second
#define np next_permutation
#define inf 1e18
#define mod 1000000007
#define N 200009
#define pi (double)2*acos(0.0)
#define minpq priority_queue <ll, vector<ll>, greater<ll>>
#define maxpq priority_queue<ll> 
void sout(){
	cout<<endl;
}
template <typename T,typename... Types>
void sout(T var1,Types... var2){
	cout<<var1<<" ";
	sout(var2...);
}
/*******************************************************************/



void solve(){
	ll n;
	cin>>n;
	ll a[n];
	rep(i,0,n)
		cin>>a[i];
	ll pre[n];
	pre[0]=a[0];
	rep(i,1,n){
		pre[i]=pre[i-1]+a[i];
		pre[i]%=mod;
	}
	ll ans=0;
	rep(i,1,n){
		ans=(ans+ (pre[i-1]*a[i])%mod)%mod;
	}
	cout<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 6760
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, l[200];
    cin >> n;
    for (int i = 0; i < 2*n; ++i)
        cin >> l[i];
    sort(l, l + 2 * n);
    int sol = 0;
    for (int i = 0; i < n; ++i)
        sol += l[i * 2];
    cout << sol;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define mp make_pair
#define eb emplace_back

const int MAX_N = 1e5+10;

int N;

void solve()
{
	int ans = ((N+999)/1000)*1000-N;
	cout << ans << '\n';
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N;
	solve();
	return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#define MAX 10000
 
struct node{
  int p, q, r;
};
struct node T[MAX];
int n;
 
void preorder(int u){
  if(u == -1) return;
  printf(" %d", u);
  preorder(T[u].q);
  preorder(T[u].r);
}
 
void inorder(int u){
  if(u == -1) return;
  inorder(T[u].q);
  printf(" %d", u);
  inorder(T[u].r);
}
 
void post(int u){
  if(u == -1) return;
  post(T[u].q);
  post(T[u].r);
  printf(" %d", u);
}
 
int main(){
  int i, v, q, r, root;
 
  scanf("%d", &n);
  for(i = 0; i < n; i++) T[i].p = -1;
 
  for(i = 0; i < n; i++){
    scanf("%d %d %d", &v, &q, &r);
    T[v].q = q;
    T[v].r = r;
    if(q != -1) T[q].p = v;
    if(r != -1) T[r].p = v;
  }
 
  for(i = 0; i < n; i++)
    if(T[i].p == -1) root = i;
  printf("Preorder\n");
  preorder(root);
  printf("\n");
  printf("Inorder\n");
  inorder(root);
  printf("\n");
  printf("Postorder\n");
 post(root);
  printf("\n");
 
  return 0;
}

Measured memory_bytes: 620
N=int(input())
S=input()

lb=0
rb=N+1
while rb-lb>1:
    mid = (lb + rb) // 2
    x = 0
    for i, s in enumerate(S[:mid]):
        x += pow(26, i) * (ord(s) - ord('a'))
    m = pow(26, mid - 1)
    a = [x]
    for i, s in enumerate(S[mid:]):
        x -= ord(S[i]) - ord('a')
        x //= 26
        x += m * (ord(s) - ord('a'))
        a += [x]
    f = 0
    se = set([])
    for i, x in enumerate(a):
        if i >= mid:
            se.add(a[i - mid])
        if x in se:
            f = 1
            break
    if f:
        lb=mid
    else:
        rb=mid
print(lb)


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

int main() {
    int D, T, S;
    double time;
    cin >> D >> T >> S;

    time = (double) D / S;
    if (time <= T) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,sum=0,i,p=0;
    cin>>n;
    p=n;
    while(n>0)
    {
        sum=sum+(n%10);
        n=n/10;

    }
    //cout<<sum<<endl;
    if(p%sum==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }



}


Measured memory_bytes: 256
#include <cstdint>
#include <stdexcept>
#include <vector>

using namespace std;

size_t linear_search(uint32_t s[], size_t s_size, uint32_t t[], size_t t_size)
{
  if (s == nullptr) throw runtime_error("s is null");
  if (t == nullptr) throw runtime_error("t is null");

  size_t cnt = 0;

  for (uint32_t i = 0; i < t_size; i++) {
    for (uint32_t j = 0; j < s_size; j++) {
      if (t[i] == s[j]) {
        cnt++;
        break;
      }
    }
  }

  return cnt;
}

#if !defined(TEST)
#include <iostream>
static vector<uint32_t> s, t;

int32_t main()
{
  uint32_t n, m;
  cin >> n;
  for (uint32_t i = 0; i < n; i++) {
    uint32_t val;
    cin >> val;
    s.push_back(val);
  }

  cin >> m;
  for (uint32_t i = 0; i < m; i++) {
    uint32_t val;
    cin >> val;
    t.push_back(val);
  }

  cout << linear_search(&s[0], s.size(), &t[0], t.size()) << endl;

  return 0;
}
#endif

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

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> ans(n+1,-1);
    bool fl = true;
    rep(i,m){
        int s,c;
        cin >> s >> c;
        if(ans[s]==-1) ans[s] = c;
        else{
            if(ans[s] == c) continue;
            else fl = false;
        }
    }
    if(n>=2&&ans[1]==0) fl = false;
    if(n>=2&&ans[1]==-1) ans[1]=1; 
    if(fl){
        REP(i,n){
            if(ans[i]==-1) cout << 0;
            else cout << ans[i];
        }
        cout << endl;
    }else{
        cout << "-1" << endl;
    }
}

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

int binarySearch(vector<int> A,int n,int key){
    int left=0,right=n;
    while(left<right){
        int mid=(left+right)/2;
        if(A.at(mid)==key) return 1;
        else if(key<A.at(mid)) right=mid;
        else left=mid+1;
    }
    return 0;
}

int main(){
    int n;
    cin>>n;
    vector<int> s(n);
    for(int i=0;i<n;i++){
        cin>>s.at(i);
    }
    int q;
    cin>>q;
    vector<int> t(q);
    for(int i=0;i<q;i++){
        cin>>t.at(i);
    }
    int ans=0;
    for(int i=0;i<q;i++){
        if(binarySearch(s,n,t.at(i))) ans++;
    }
    cout<<ans<<endl;    
}


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

int main(void){
  string str;
  cin >> str;
  if(str.length() == 3){
    for(int i = 2;i>=0;i--) cout << str.at(i);
    cout << endl;
  }else{
    cout << str << endl;
  }
  return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
		//出力
		Console.WriteLine(Math.Ceiling(((float)a + b) / 2)) ;
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
int N, K;
cin >> N >> K;
ll sum = 0;
for (int i = K; i <= N + 1; i++)
{
    sum += (ll)i * (N - i + 1) + 1;
    sum %= (1000000000LL + 7);    
}


cout << sum << endl;

}


Measured memory_bytes: 3592
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		int count = 0;
		for (int i = 0; i < 3; i++) {
			if (s[i] == t[i]) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 23636
from sys import stdin, exit
import itertools
#stdin = open("input.txt")

if __name__ == "__main__":
    N, K = [int(item) for item in stdin.readline().split()]
    li = [int(item) for item in stdin.readline().split()]
    
    li.sort()
    
    if sum(li) == K:
        print(N)
    elif sum(li) < K:
        print(N-1)
    else:
        cumsum = itertools.accumulate(li)
        index = [i for i, item in enumerate(cumsum) if item<=K]
        print(len(index))

Measured memory_bytes: 38256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#define llong long long
#define For(i,a,n) for(register int i=a;i<=n;i++)
#define RF(i,a,n) for(register int i=a;i>=n;i--)
#pragma GCC optimize(2)
using namespace std;

const int maxn = 100005;
llong a, b, c;

int main()
{
    ios::sync_with_stdio(false);
    cin>>a>>b>>c;
    llong mx = max(a,max(b,c));
    if(mx%2){
        if(mx==a){
            cout<<b*c<<endl;
        }
        else if(mx==b){
            cout<<a*c<<endl;
        }
        else if(mx==c){
            cout<<b*a<<endl;
        }
    }
    else
        cout<<0<<endl;
    return 0;
}

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

using namespace std;

int a, b, c, d;

int main() {
	cin >> a >> b >> c >> d;

	if ((abs(b - a) <= d && abs(c - b) <= d) || abs(c - a) <= d)
		cout << "Yes\n";
	else
		cout << "No\n";
}

Measured memory_bytes: 256
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


n = inp()
a = inlist()
res = 0
for i in a:
    res += i-1
print(res)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s,t;cin >> s >> t;
  int a,b;cin >> a >> b;
  string u;cin >> u;
  if(s==u)a--;
  else b--;
  cout << a << ' ' << b << endl;
  return 0;
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
    #include<chrono>
     
    using namespace std;
    using namespace std::chrono;
    typedef long long ll;
    typedef vector<int> vi;
    typedef pair<int,int> pi;
    #define F first
    #define S second
    #define PB push_back
    #define EB emplace_back
    #define MP make_pair
    #define REP(i,a,b) for(i=a;i<=b;i++)
    #define RAP(i,a,b) for(i=a;i>=b;i--)

    int main(){
    	ios::sync_with_stdio(0);
    	cin.tie(0);
        cout<<fixed<<setprecision(10);
        int n,i,j;
        cin>>n;
        int x[n],y[n];
        double a[n][n];
        REP(i,0,n-1) cin>>x[i]>>y[i];
        double ans=0;
        REP(i,0,n-1){
            REP(j,0,n-1){
                a[i][j]=sqrt((x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i]));
                ans+=a[i][j];
            }
        }
        cout<<ans/n<<"\n";
        
        return 0;	
    }

Measured memory_bytes: 256
#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 n;
    cin >> n;
    vector<int> a(n), b;
    int pos = 0, neg = 0;
    rep(i,n) {
        cin >> a.at(i);
        if(a.at(i) < 0) {
            b.push_back(a.at(i));
            a.at(i) = -a.at(i);
        }
    }
    sort(a.begin(), a.end());
    ll ans = 0;
    rep(i,n) {
            ans += a.at(i);
    }
    if(b.size()%2 != 0) {
        ans -= 2 * a.at(0);
    }
    cout << ans << endl;
    return 0;
}

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

public class Main
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);
		
		boolean a[] = new boolean[10000001];
		Arrays.fill(a, true);
		a[0]=a[1]=false;
		for(int i=2; i*i<=10000000; i++)
		{
			if(!a[i])
				continue;
			for(int j=i+i; j<=10000000; j+=i)
				a[j] = false;
		}
		
		while(sc.hasNext())
		{
			int n = sc.nextInt();
			if(n==0)
				return;
			for(int i =n; n>0; i--)
			{
				if(a[i]&&a[i-2]&&a[i-6]&&a[i-8])
				{
				System.out.println(i);
				break;
				}
			}
		}
	}

}

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

namespace AtCoder.Abc
{
    class A_160_Coffee
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            // 文字列の入力
            string s = Console.ReadLine();
            string a;

            if(s.Substring(2,1) == s.Substring(3,1) && s.Substring(4,1) == s.Substring(5, 1))
            {
                a = "Yes";
            }
            else
            {
                a = "No";
            }

            string result = a;

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 25764
from itertools import combinations

n = int(input())
set_m = set()
set_a = set()
set_r = set()
set_c = set()
set_h = set()
for i in range(n):
    s = input()
    start = s[0]
    if start == 'M':
        set_m.add(s)
    elif start == 'A':
        set_a.add(s)
    elif start == 'R':
        set_r.add(s)
    elif start == 'C':
        set_c.add(s)
    elif start == 'H':
        set_h.add(s)
sets = [set_m, set_a, set_r, set_c, set_h]
numbers = []
for se in sets:
    if len(se) > 0:
        numbers.append(len(se))
num_group = len(numbers)
if num_group < 3:
    ans = 0
else:
    ans = 0
    ind_ls = list(range(num_group))
    c = combinations(ind_ls, 3)
    for ind1, ind2, ind3 in c:
        ans += numbers[ind1] * numbers[ind2]* numbers[ind3]
print(ans)

Measured memory_bytes: 14316
#include<stdio.h>
int main()
{
	int n;
	char s[100],t[100];
	int i;
	scanf("%d %s %s",&n,s,t);
	for(i=0;i<n;i++){
		printf("%c%c",s[i],t[i]);
	}
	return 0;
}

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

int fanc(int a){
    int ret=0;
    while(a!=0){
        ret+=a%10;
        a/=10;
    }
    return ret;
}

int main(){

    int n;
    cin >> n;
    int ans=1e+9;
    for(int i=1;i<=(n+1)/2;i++){
        ans=min(ans,fanc(i)+fanc(n-i));
    }

    cout << ans << endl;

    return 0;
}

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

int grid[1000][1000];
int dp[1001][1001];
int dx[] = {1, 0};
int dy[] = {0, 1};

int main()
{
	int h, w, n;
	while (scanf("%d %d %d", &h, &w, &n), h){
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				scanf("%d", &grid[i][j]);
			}
		}
		
		memset(dp, 0, sizeof(dp));
		dp[0][0] = n - 1;
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				dp[i][j + 1] += dp[i][j] / 2;
				dp[i + 1][j] += dp[i][j] / 2;
				if (dp[i][j] & 1){
					if (grid[i][j] == 0) dp[i + 1][j]++;
					else dp[i][j + 1]++;
				}
			}
		}
		
		int nx = 0;
		int ny = 0;
		while (nx < h && ny < w){
			int dir = (grid[nx][ny] + dp[nx][ny]) & 1;
			nx += dx[dir];
			ny += dy[dir];
		}
		
		printf("%d %d\n", nx + 1, ny + 1);
	}
	
	return 0;
}

Measured memory_bytes: 9016
using System;
using System.Linq;

namespace Cells {
    class Program {
        static void Main(string[] args) {
            var input1 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var input2 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var h = input1[0] - input2[0];
            var w = input1[1] - input2[1];
            
            Console.WriteLine(h * w);
        }
    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<numeric>
#define all(x) (x).begin(),(x).end()
typedef long long ll;

using namespace std;

int main()
{
    ll N;   cin >> N;
    ll ans = 0;
    ll p = min(N,1000000LL);
    for(ll i=1; i<p; i++){
        if((N-i)%i == 0){
            if((N-i)/i > i) ans += (N-i)/i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    int tmp = 1;
    int ans = 0;

    for (int i = 1; i < n; ++i) {
        if (a[i-1] != a[i]) {
            if (tmp % 2) ++ans;
            tmp = 1;
        } else {
            ++tmp;
        }
    }

    if (tmp % 2) ++ ans;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int area = x * y;
        int length = (x + y) * 2;
        
        System.out.println(area + " " + length);
        
        sc.close();     
    }
}


Measured memory_bytes: 26176
#include<stdio.h>
#include<cstdlib>
#include<iostream>
#include<string>

using namespace std;

int main(){
    int a;
    cin >> a;
    string s;
    cin >> s;
    if( a<3200 ){
        cout<<"red"<<endl;
    }
    else{
        cout<<s<<endl;
    }
}

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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;


int main(){
    int n,q;
    string s;
    cin>>n>>q>>s;

    vector<int>l(q),r(q);
    rep(i,q)cin>>l[i]>>r[i];

        
    vector<int>L(n),R(n);

    rep2(i,1,n-1){
        if(s[i-1]=='A'&&s[i]=='C')L[i]=L[i-1]+1;
        else L[i]=L[i-1];
    }

    repr(i,n-2,0){
        if(s[i]=='A'&&s[i+1]=='C')R[i]=R[i+1]+1;
        else R[i]=R[i+1];
    }

    rep(i,q){
        int ans=R[0];
        cout<<ans-L[l[i]-1]-R[r[i]-1]<<endl;
    }
}


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

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(R);
    if (R < 1200){
        puts("ABC");
    }else if (R < 2800){
        puts("ARC");
    }else{
        puts("AGC");
    }
}


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

#define ll long long
#define ld long double
#define ii pair<int ,int >
#define S second
#define F first
#define PI 3.1415926535897932384626
#define SPEED std::ios_base::sync_with_stdio(false);

int n,m,sum=0;

int main(){
    SPEED
    cin>>n>>m;
    int a[n];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    sort(a+1,a+n+1);
    for(int i = n ; i>=n-m+1 ; i--){
        if(a[i]*1.0 < ((sum*1.0) / (4*m*1.0))){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}

void NG(){
    cout << "No" << endstr;
}

void OK(){
    cout << "Yes" << endstr;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    vl A(N); ll mx = 0, mn = LINF;
    rep(i, N){
        cin >> A[i];
        chmax(mx, A[i]); chmin(mn, A[i]);
    }
    if(mx-mn > 1){
        NG(); return 0;
    }
    if(mx == mn){
        if(mx != N-1 && mx*2 > N) NG();
        else OK();
        return 0;
    }
    
    ll single_cnt = 0;;
    rep(i, N) if(A[i] == mn) single_cnt++;
    
    if(single_cnt >= mx) NG();
    else if(single_cnt + 2*(mx-single_cnt) > N) NG();
    else OK();
    return 0;
}


Measured memory_bytes: 1024
n=int(input())
a=[int(i) for i in input().split()]
num=[False for i in range(8)]

ans=0
over=0
for rate in a:
	if rate<3200:
		num[int(rate/400)]=True
	else:
		over+=1
for flag in num:
	if flag:
		ans+=1

print(max(ans,1),end="")
print(" ",end="")
print(ans+over)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#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 drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
const int mod = 1000000007;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
ll cost[1<<16];
ll dp[1<<16];
ll a[20][20];
int main(){
    int n;cin >> n;
    rep(i,n){
        rep(j,n){
            cin >> a[i][j];
        }
    }
    for(int s=0;s<(1<<n);s++){
        for(int i=0;i<n;i++){
            if((s>>i)%2==0) continue;
            for(int j=i+1;j<n;j++){
                if((s>>j)%2==0) continue;
                cost[s]+=a[i][j];
            }
        }
    }
    dp[0]=0;
    for(int s=1;s<(1<<n);s++){
        for(int t=s;t>0;t=(t-1)&s){
            dp[s]=max(dp[s],dp[s-t]+cost[t]);
        }
    }
    cout << dp[(1<<n)-1] << endl;
    return 0;
}

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

int main(){
  using lint = long long;
  /*
  gcd1 A-1
  A,B = 4,6  A-1
  A,B = 6,4  A-2
  A/B=1.5 A-2
  A/B=1 A-1
  A/B=1.00001  A-2 
  A- ( (A+B-1)/B ) (Nでかくて>=Bのとき)
  N<Bなら？
  A*(N/B)の底
  */
  lint A,B,N;
  cin >> A >> B >> N;
  lint ans = 0;
  
  if(N>=B) ans = A - (A+B-1)/B;
  else ans = A*N/B;
  
  cout << ans << endl;
}
  
  
  

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var ST = ReadLine().Split(' ');
        var (S, T) = (ST[0], ST[1]);

        var ans = S.Zip(T, (s, t) => new { s, t }).Aggregate("", (s, e) => s + e.s + e.t);

        WriteLine(ans);
    }
}


Measured memory_bytes: 27932
a = int(input(""))
list = []
if(a == 0):
    list.append(0)
while(a):
    if(a%(-2)==0):
        list.append(0)
        a//=-2
    elif(a%(-2)==-1):
        list.append(1)
        a -= 1
        a//=-2

list.reverse()
for i in list:print(i,end='')
print()

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
long long a[305],d[303][303];
int main(){
	long long n,m,ans=2e17;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	if(m==n){
		cout<<0<<endl;
		return 0;
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			d[i][j]=2e17;
		}
	}
	for(int i=1;i<=n;i++){
		d[i][1]=a[i];
	}
	d[0][0]=0;
	for(int i=2;i<=n;i++){
		for(int j=1;j<i;j++){
			for(int k=1;k<=i;k++){
				d[i][k]=min(d[i][k],d[j][k-1]+max((long long)0,a[i]-a[j]));
			}
		}
	}
	for(int i=1;i<=n;i++){
		ans=min(d[i][n-m],ans);
	}
	cout<<ans<<endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}


const int INF=1001001001;

int N;
int A[55],B[55],C[55],D[55];

vector<vint>G,H;

void mk(){
    G=vector<vint>(N);
    H=vector<vint>(N);
    rep(i,N-1){
        G[A[i]].pb(B[i]);G[B[i]].pb(A[i]);
        H[C[i]].pb(D[i]);H[D[i]].pb(C[i]);
    }
}

void dfs(int v,int p,vector<vint>&G,vector<int>&parG){
    parG[v]=p;
    for(auto u:G[v])if(u!=p){
        dfs(u,v,G,parG);
    }
}

int calc(int r){
    vint parG(N),parH(N);
    dfs(r,-1,G,parG);
    dfs(r,-1,H,parH);

    vector<int>used(N);
    used[r]=true;
    queue<int>que;
    que.push(r);
    while(que.size()){
        int v=que.front();
        que.pop();
        for(auto u:G[v]){
            if(used[u])continue;
            if(parH[u]==v){
                used[u]=true;
                que.push(u);
            }
        }
    }

    int ret=0;
    vector<vint>F(N);
    vint deg(N);
    rep(i,N){
        if(used[i])continue;
        ret++;
        if(!used[parG[i]]){
           F[i].pb(parG[i]);deg[parG[i]]++;
        }
        if(!used[parH[i]]){
            F[parH[i]].pb(i);deg[i]++;
        }
    }

    rep(i,N)if(deg[i]==0)que.push(i);
    while(que.size()){
        int v=que.front();
        que.pop();
        for(auto u:F[v]){
            if(--deg[u]==0)que.push(u);
        }
    }
    if(count(all(deg),0)!=N)return INF;
    return ret;
}

void solve(){
    cin>>N;
    rep(i,N-1)cin>>A[i]>>B[i],A[i]--,B[i]--;
    rep(i,N-1)cin>>C[i]>>D[i],C[i]--,D[i]--;

    int ans=INF;


    mk();

    rep(i,N)chmin(ans,calc(i));

    vint deg(N);
    rep(i,N-1)deg[A[i]]++,deg[B[i]]++;
    rep(i,N-1){
        rep(j,2){
            if(deg[A[i]]==1){
                for(int k=0;k<N;k++)if(k!=A[i]){
                    int tmp=B[i];
                    B[i]=k;

                    mk();chmin(ans,calc(A[i])+1);

                    B[i]=tmp;
                }
            }
            swap(A[i],B[i]);
        }
    }

    if(ans==INF)cout<<-1<<endl;
    else cout<<ans<<endl;
}

signed main(){
    int T;cin>>T;
    while(T--)solve();
    return 0;
}


Measured memory_bytes: 256
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<58; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
const int MX = 1e5+7;
ll s[MX];
ll t[MX];
int A,B,Q;

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    cin >> A >> B >> Q;
    s[0] = -LINF;
    s[A+1] = LINF;
    t[0] = -LINF;
    t[B+1] = LINF;
    FOR(i,1,A) {
        cin >> s[i];
    }
    FOR(i,1,B) {
        cin >> t[i];
    }
    A += 2;
    B += 2;
    while(Q--) {
        ll x; cin >> x;
        ll su, sd, tu, td;
        ll ans = LINF;
        su = *lower_bound(s, s+A, x)-x;
        sd = x - *(upper_bound(s, s+A, x)-1);
        tu = *lower_bound(t, t+B, x)-x; 
        td = x - *(upper_bound(t, t+B, x)-1);
        chmin(ans, max(su, tu));
        chmin(ans, max(sd, td));
        chmin(ans, min(su,td)+su+td);
        chmin(ans, min(sd, tu)+sd+tu);
        cout << ans  << endl;
    }
    return 0;
}


Measured memory_bytes: 5148
#include <iostream>
using namespace std;
int dp[50];
int fib(int n){
        if(n<2)
                return 1;
        if(dp[n]!=-1)return dp[n];
        return dp[n]=fib(n-1)+fib(n-2);
}
int main(){
        int N;
        for(int i=0 ; i<50 ; i++ )
                dp[i]=-1;
        cin >> N;
        cout << fib(N) << endl;
        return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define debug printf("bug!!!\n");
typedef long long ll;
const int MAXN=1e4+10;
const ll MOD=1e9+7;
map<string,int>mp;
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;



    return 0;
}



Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <utility>
#include <algorithm>

#define MAX_N (100000)
#define MAX_M (100000)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  int N, M, as[MAX_M], bs[MAX_M];
  scanf("%d %d", &N, &M);
  for (int i = 0; i < M; i++) {
    scanf("%d %d", &as[i], &bs[i]);
    as[i]--;  // NOTE : modified input
    bs[i]--;  // NOTE : modified input
  }

  // sort by bs
  vector<pair<int, int>> cs;
  for (int i = 0; i < M; i++) {
    cs.push_back(pair<int, int>(bs[i], as[i]));    
  }
  sort(cs.begin(), cs.end());

  // solve greedy
  int num_destroyed = 1, last_destroyed = cs[0].first - 1;
  for (int i = 1; i < M; i++) {
    const int a = cs[i].second, b = cs[i].first;
    if (b - 1 > last_destroyed && a > last_destroyed) {
      last_destroyed = b - 1;
      num_destroyed++;
    }
  }
  printf("%d\n", num_destroyed);
  
  return 0;
}


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}


void solve() {
    int N;
    cin >> N;
    vector<ll> A(N);

    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    ll g = A[0];
    for (int i = 1; i < N; i++) {
        g = std::gcd(g, A[i]);
    }

    vector<vector<ll>> Ds(1000001, vector<ll>());
    for(int i = 2; i < 1000001; i++) {
        if (Ds[i].size() == 0) {
            Ds[i].push_back(i);
        } else {
            continue;
        }
        for(int j = i + i; j < 1000001; j += i) {
            Ds[j].push_back(i);
        }
    }

    vector<int> flag(1000001, 0);
    bool ok = true;
    for (int i = 0; i < N; i++) {
        if (A[i] == 1) continue;
        vector<ll> &D = Ds[A[i]];
        for (int j = 0; j < D.size(); j++) {
            if (flag[D[j]]) {
                ok = false;
            }
            flag[D[j]] = 1;
        }
    }

    if (ok) {
        cout << "pairwise coprime" << endl;
    } else if (!ok && g == 1) {
        cout << "setwise coprime" << endl;
    } else {
        cout << "not coprime" << endl;
    }
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

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

#define LLINF (1LL<<60)
typedef long long ll;

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

//C++14 (GCC 5.4.1)
int main() {
    int N;
    cin >>N;

    vector<int> p(N);
    rep(i,N) cin >> p[i];
    
    //-----------------------------------
    int ans=0;
    repd(i,1,N-1){
        if((p[i-1]<p[i]&&p[i]<=p[i+1])
        || (p[i+1]<p[i]&&p[i]<=p[i-1])) ans++;
    }


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

Measured memory_bytes: 256
#include<iostream>
static const int MAX = 100;
using namespace std;

void trace(int A[], int N)
{
	int i;
	for(i=0; i<N; i++){
		if(i>0){
			cout << " ";
		}
		cout << A[i];
	}
	cout << endl;
}

void selectionSort(int A[], int N)
{
	int i, j, k, tmp, minj, count;
	int _A[N];
	
	count = 0;
	
	for(i=0; i<N; i++){
		minj = i;
		for(j=i; j<N; j++){
			if(A[j] < A[minj]){
				minj = j;
			}
		}
		
		for(k=0; k<N; k++){
			_A[k] = A[k];
		}
		
		tmp = A[i];
		A[i] = A[minj];
		A[minj] = tmp;
		
		for(k=0; k<N; k++){
			if(_A[k] != A[k]){
				count++;
				break;
			}
		}
	}
	
	trace(A, N);
	
	cout << count << endl;
}

int main()
{
	int N, i;
	int A[MAX];
	
	cin >> N;
	for(i=0; i<N; i++)cin >> A[i];
	
	selectionSort(A, N);
	
	return 0;
}

Measured memory_bytes: 3020
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

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

  int w, h, x, y, r; cin >> w >> h >> x >> y >> r;
  if (x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }

  return 0;
}


Measured memory_bytes: 3208
#include <iostream>

int main() {
	int N; 
	std::cin >> N;
	int sum = 0;
	for (int temp = N; temp > 0; temp /= 10) {
		sum += temp % 10;
	}
	std::cout << (N % sum == 0 ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 256
import numpy as np
H,W,K=map(int,input().split())
s=[]
for i in range(H):
    a=list(input())
    a=[0 if moji=="." else 1 for moji in a]
    s.append(a)
s=np.array(s)
count=0
for i in range(2**H):
    l1=[]
    ss = s.copy()
    for j in range(H):
        if i>>j&1:l1.append(j)
    for height in l1:
        ss[height, :] = 0
    for k in range(2**W):
        l2=[]
        ss2=ss.copy()
        for m in range(W):
            if k>>m&1:l2.append(m)
        for width in l2:
            ss2[:,width]=0
        if np.sum(ss2)==K:
            count+=1

print(count)


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

int main()
{
    long long i;
    string s;

    cin >> i >> s;

    long long dn = (s[0]-'0')*100 + (s[2]-'0')*10 + (s[3]-'0');

    cout << (long long) (i*dn)/100;

    return 0;
}


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

typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
ll n,ans,sum;
ll a[100];
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i]; sum += a[i];
	}
	rep(i, n)ans += pow(a[i] - round(sum / double(n)), 2);
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
#define PB push_back
#define MP make_pair
const int maxn = 200009;
const int MOD = 1e9 + 7;
int main(){
#ifdef LOCAL
  freopen("a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int T;cin>>T;
  while(T--){
    int n;
    int64_t res=0;
    cin>>n;
    vector<pair<int,int>> A,B;
    for(int i=1;i<=n;++i){
      int k,l,r;
      cin>>k>>l>>r;
      if(l<r)B.emplace_back(n-k,r-l);
      else A.emplace_back(k,l-r);
      res+=min(l,r);
    }
    auto cal=[&](vector<pair<int,int>> &C){
      sort(C.rbegin(),C.rend());
      priority_queue<int> Q;
      for(int i=n,j=0;i>=1;--i){
        while(j<SZ(C)&&C[j].first==i)Q.push(C[j++].second);
        if(SZ(Q)){
          res+=Q.top();
          Q.pop();
        }
      }
    };
    cal(A);
    cal(B);
    cout<<res<<'\n';
  }
  
  return 0;
}
//2020.07.13 13:06:12


Measured memory_bytes: 5092
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
using namespace std;
using u8t = std::uint64_t;
using i8t = std::int64_t;
#define F(I,N) for(i8t I=0,I##_N=N;I<I##_N;I++)
#define FR(I,N) for(i8t I=N;I--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;
int main() {
  RL(line);
  P(line[0]=='7'||line[1]=='7'||line[2]=='7'?"Yes":"No");
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535897932;
const ll MOD = 1000000007;

int main()
{
    int a, b;
    cin >> a >> b;
    int ans = a - 2 * b;
    ans = max(0, ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define ll long long int
#include<bits/stdc++.h>
#include<cmath>
#define MOD 1000000009
using namespace std;
int main()
{
ll n;
cin>>n;
ll arr[n];
ll pos[100005];
ll sum=0;
for(ll i=0;i<100005;i++)
pos[i]=0;
for(ll i=0;i<n;i++)
{
	cin>>arr[i];
	sum+=arr[i];pos[arr[i]]++;
}
ll k;
cin>>k;
for(ll i=0;i<k;i++)
{
	ll b=0;ll c=0;
	cin>>b>>c;
	sum=sum-(pos[b]*b)+(pos[b]*c);
	pos[c]+=pos[b];
	pos[b]=0;
	cout<<sum<<endl;
}
return 0;
}

Measured memory_bytes: 5060
#include <cstdio>
#include <cmath>

bool isPrime(int x){
    for(int i=2;i<=sqrt(x);i++){
        if(x%i==0)return false;
    }
    return true;
}

int main(){
    int i,n,x;
    int c=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&x);
        if(isPrime(x))c++;
    }
    printf("%d\n",c);
    return 0;
}



Measured memory_bytes: 2604
#include<stdio.h>
int main()
{
	int a,b,n,i,r,d;
	while(~scanf("%d %d", &a, &b))
	{
		int count =0;
		for(i=a; i<=b; i++)
		{
			n=i;
			d=0;
			while(n!=0)
			{
				r=n%10;
				d = d*10 + r;
				n/=10;
			}
			if(d==i)
				count++;
		}
		printf("%d\n", count);
	}		
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const string MINUSINF = "-";

typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

ll N, K, M;
ll A[100010];
int X[100010];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);

    cin >> N >> M;
    for (int i = 0; i < M; ++i)
        cin >> X[i];

    vector<int> v;

    sort(X, X + M);
    for (int i = 0; i < M - 1; ++i)
    {
        v.push_back(X[i + 1] - X[i]);
    }

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

    int ans = 0;
    for (int i = 0; i < M - N; ++i)
    {
        ans += v[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1276
import numpy as np
H, W = map(int, input().split())
lines = np.array([[i for i in input()] for _ in range(H)])
lines = lines[np.any(lines=="#", axis=1)]
lines = lines[:, np.any(lines=="#", axis=0)]

ans = ""
for i in lines:
  ans += "".join(i) + "\n"
ans = ans[:-1]
print(ans)

Measured memory_bytes: 12520
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	ll a,b;
	cin>>a>>b;
	if(a==b) cout<<"0";
	else if( (a+b)%2==0 ){
		cout<<(a+b)/2;
	}
	else cout<<"IMPOSSIBLE";
}

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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline ll toLL(string s) {
  ll v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VLL a(n);
  rep(i, n) cin >> a[i];
  map<ll, ll> mp;
  rep(i, n) mp[a[i]]++;
  ll ans = 0;
  for(auto x : mp) {
    if(x.second >= 2)
      ans += x.second * (x.second - 1) / 2ll;
  }
  rep(i, n) {
    ll x = mp[a[i]];
    ll tmp = ans - (x * (x - 1) / 2ll);
    if(x >= 3)
      tmp += ((x - 2) * (x - 1) / 2ll);
    cout << tmp << endl;
  }
  return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
const int N = 2e5 + 5, MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin>>n;
    int ans = n/2;
    if(n%2 == 0)    ans--;
    cout<<ans;




    return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<stdlib.h>
#include<string.h>
using namespace std;

int main(){
  char a[1000][1000],b[1000][1000];
  string c;
  int i,j;
  
  getline(cin,c);
  
  for(j=0;j<c.length();j++){
    if(c[j] >= 97 && c[j] <=122){
      c[j]=c[j]-32;
    }
  }

  cout << c << endl;
  

}

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

int k(int a,int b){
	if(a%b==0){
		return b;
	}
	return k(b,a%b);
}


int main(){
	int n,s;
	cin>>n;
	int ans=0;
	for(int i=1; i<=n; i++){
		for(int j=i; j<=n; j++){
			for(int t=i+1; t<=n; t++){
				s=k(j,i);
				ans+=(k(t,s))*3;
				//cout<<i<<" "<<j<<" "<<t<<endl;
			}
		}
	}
	//cout<<ans<<endl;
	for(int i=1;i<=n;i++){
		ans+=i;
	}
	cout<<ans<<endl;
}
				

Measured memory_bytes: 3596
#include <stdio.h>

int main(void){
    int h,w;
    int flag = 0;

    scanf("%d %d",&h,&w);
    char S[h+2][w+2];
    char s[h][w];
    for(int i = 0; i < h+2; i++){
        for(int j = 0; j < w+2; j++){
            S[i][j] = '.';
        }
    }


    for(int i = 0; i < h; i++){
        scanf("%s",s[i]);
        for(int j = 0; j < w; j++){
            S[i+1][j+1] = s[i][j];
        }
    }
    for(int i = 1; i < h+1; i++){
        for(int j = 1; j < w+1; j++){
                if((S[i][j]=='#') && (S[i-1][j]=='.') && (S[i][j-1]=='.') && (S[i+1][j]=='.') && (S[i][j+1]=='.')) flag = 1;
        }
    }

    if(flag == 1){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    return 0;
}

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

int ans,n,x,maxi;

int main(){
	scanf("%d",&n);
	for(int i =0;i<n;i++){
		scanf("%d",&x);
		maxi = max(maxi,x);
		if(maxi<=x) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256