akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define be(v) v.begin(), v.end()
typedef long long ll;
typedef vector<int> vint;
#define scout cout << fixed << setprecision(5) 
ll INF = 1e9;
ll mod = 1e9+7;

int main() {
	int n; cin >> n;
	vint k(n);
	rep(i,n) cin >> k[i];
	int ans=INF;
	int l=k[0]; int r=k[0];
	rep(i,n) {
		l=min(l,k[i]);
		r=max(r,k[i]);
	}
	for(int i=l;i<=r;i++) {
		int cost=0;
		rep(j,n) cost+=(k[j]-i)*(k[j]-i);
		ans = min(ans,cost);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[16];
int main()
{
	int n;
	scanf("%s",a);
	for(int i=0;i<strlen(a);i++)
	{
		if(a[i]=='x')
			n++;
	}
	if(n>=8)
		printf("NO");
	else
		printf("YES");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
inline vector<ll> divisor(ll M){ //約数の全列挙
    vector<ll> dd;
    for(ll i = 1; i*i <= M; i++){
        if(M % i == 0){
            dd.push_back(i);
            if(i * i != M){
                dd.push_back(M/i);
            }
        }
    }
    sort(dd.begin(), dd.end());
    return dd;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll A[100010];
    cin >> N;
    rep(i,0,N) cin >> A[i];
    vector<ll> v = divisor(A[0]);
    vector<ll> v1 = divisor(A[1]);
    v.insert(v.end(), v1.begin(), v1.end());
    sort(v.begin(), v.end(), greater<ll>());
    v.erase(unique(v.begin(), v.end()), v.end());
    ll M = v.size();
    rep(m,0,M){
        ll cnt = 0;
        rep(i,0,N){
            if(A[i] % v[m] != 0) cnt++;
        }
        if(cnt <= 1){
            print(v[m]);
            return 0;
        }
    }




    
    
}


Measured memory_bytes: 1024
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main() {
	vector<int> time1(5), time2(5);
	for (int i = 0; i < 5; ++i) {
		cin >> time1[i];
	}
	for (int i = 0; i < 5; ++i) {
		time2[i] = ((time1[i] + 10 - 1) / 10) * 10;
	}

	int answer = 10000;
	for (int i = 0; i < 5; ++i) {
		int tmp =
		    accumulate(time2.begin(), time2.end(), 0) - time2[i] + time1[i];
		if (tmp < answer) {
			answer = tmp;
		}
	}

	cout << answer << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll r;
	cin>>r;
	cout<<r*r<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ABS(a) abs(a)
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a==b)
    {
        cout<<"Draw\n";
    }
    else if(a==1)
    {
        cout<<"Alice\n";
    }
    else if(b==1)
    {
        cout<<"Bob\n";
    }
    else if(a>b)
    {
        cout<<"Alice\n";
    }
    else
    {
        cout<<"Bob\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int ssChecker(string &S) {
    int cnt = 0;
    while (true) {
        S.pop_back();
        if (len(S) % 2 != 0) continue;

        string st = S.substr(0, len(S) / 2);
        string str = S.substr(len(S) / 2);
        if (st == str) {
            return len(st) + len(str);
        }
    }
}

int main() {
    string S; cin >> S;
    cout << ssChecker(S) << endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int> vi;

struct fenwickTree
{
    int n;
    vi t;
    fenwickTree(int n)
    {
        this->n = n;
        t = vi(n+1);
    }
    void add(int k, int x)
    {
        while (k <= n)
        {
            t[k] += x;
            k += k & (-k);
        }
    }
    int sum(int k)
    {
        int ans = 0;
        while (k > 0)
        {
            ans += t[k];
            k -= k & (-k);
        }
        return ans;
    }
    int sum(int l, int r)
    {
        return sum(r) - sum(l-1);
    }
};

signed main()
{
    int n, q;
    cin >> n >> q;
    vi arr(n+1);
    for (int i = 1; i <= n; i++)
        cin >> arr[i];
    vector<vi> ql(n+1), qid(n+1);
    for (int i = 0; i < q; i++)
    {
        int l, r;
        cin >> l >> r;
        ql[r].push_back(l);
        qid[r].push_back(i);
    }
    fenwickTree ft(n);
    vi ans(q);
    vi c(n+1, 0);
    for (int i = 1; i <= n; i++)
    {
        if (c[arr[i]] > 0) ft.add(c[arr[i]], -1);
        c[arr[i]] = i;
        ft.add(i, 1);
        for (int j = 0; j < ql[i].size(); j++)
            ans[qid[i][j]] = ft.sum(ql[i][j], i);
    }
    for (auto it:ans) cout << it << "\n";
}

Measured memory_bytes: 62724
#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 mod = 998244353;
const int N = 1000005;
const int K = 25;
int ans[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n, x;
    cin >> n >> x;
    if (x == n + n - 1 || x == 1){
        cout << "No";
        return 0;
    }
    if (n == 2){
        cout << "Yes" << endl;
        cout << "1 2 3";
        return 0;
    }
    set < int > s;
    for (int i = 1; i <= n + n - 1; i++) s.insert(i);
    ans[n] = x;
    s.erase(x);
    ans[n + 1] = x + 1;
    s.erase(x + 1);
    ans[n - 1] = x - 1;
    s.erase(x - 1);
    if (x == n + n - 2){
        ans[n + 2] = x - 2;
        s.erase(x - 2);
    }
    else{
        ans[n - 2] = x + 2;
        s.erase(x + 2);
    }
    for (int i = 1; i <= n + n - 1; i++){
        if (ans[i] == 0){
            ans[i] = *s.begin();
            s.erase(s.begin());
        }
    }
    cout << "Yes" << endl;
    for (int i = 1; i <= n + n - 1; i++) cout << ans[i] << " ";
}


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

/*
   AtCoder contest code
   coder : yoichidon
 */

class Counter<T> extends HashMap<T,Integer>{
    public Counter(){
        super();
    }
    public Integer get(Object elm){
        return getOrDefault(elm,0);
    }
    public void add(T elm, int amount){
        if(!this.containsKey(elm)) put(elm, amount);
        else replace(elm, get(elm)+amount);
    }
    public void addOne(T elm){
        add(elm, 1);
    }
    public void remove(T elm, int amount){
        replace(elm, Math.max(get(elm)-amount, 0));
    }
    public void removeOne(T elm){
        remove(elm, 1);
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Counter<Long> ball = new Counter<>();
        for(int n=0; n<N; n++) ball.addOne(sc.nextLong());

        long[] power = new long[32];
        power[31]=2;
        for(int i=30; i>=0; i--) power[i] = 2 * power[i+1];

        long ans = 0;

        for(long p:power){
            for(Long b:ball.keySet()){
                int r = (p!=b*2) ? Math.min(ball.get(b), ball.get(p-b)) : ball.get(b)/2;
                ball.remove(b,r);
                ball.remove(new Long(p-b), r);
                ans += r;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 178516
#include <stdio.h>
int main(){
	int a[50],b[50];
	int n,r;
	while (scanf("%d%d",&n,&r)!=EOF) {
		if (n==0&&r==0) {
			break;
		}
		for (int i=n;i>=1;i--) {
			a[i]=n-i+1;
		}
		while (r--) {
			int p,c;
			scanf("%d%d",&p,&c);
			int k=1;
			for(int i=0;i<c;i++){
				b[k++]=a[p+i];
			}
			for (int i=1;i<=p-1;i++) {
				b[k++]=a[i];
			}
			for(int i=p+c;i<=n;i++){
				b[k++]=a[i];
			}
			b[k]='\n';
			for(int i=1;i<=n;i++)
			    a[i]=b[i];
		}
		printf("%d\n",a[1]);
	}
	return 0;


}



Measured memory_bytes: 1964
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int K = sc.nextInt();
        int X = sc.nextInt();

        if (500 * K >= X) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        HashSet<Integer> res = new HashSet<>();
        res.add(sc.nextInt());
        res.add(sc.nextInt());
        res.add(sc.nextInt());
        System.out.println(res.size());
    }
}


Measured memory_bytes: 21204
#include <stdio.h>
int main(void)
{
	int n, m, i, j;
	
	scanf("%d %d\n",&n, &m);
	int A[n][m]; int b[m]; int c[n];
	
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&A[i][j]);
		}
	}
	
	for(j=0;j<m;j++){
		scanf("%d",&b[j]);
	}
	
	//積の計算
	for(i=0;i<n;i++){
		c[i] = 0;
		for(j=0;j<m;j++){
			c[i] += A[i][j] * b[j];
		}
		printf("%d\n",c[i]);
	}
	
	return 0;
}


Measured memory_bytes: 2104
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;

#define For(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define rall(a)		(a).rbegin(), (a).rend()
#define sz(a)		(sizeof(a))
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

bool cheak(int x, int y, int xMax, int yMax){ return x >= 0 && y >= 0 && xMax > x && yMax > y; }
const int dx[4] = { -1, 0, 1, 0 }, dy[4] = { 0, 1, 0, -1 };
const int mod = 5;
const ll INF = 1e17;

const int M = 10005;
ll x[M], y[M], d[M], c[M];
ll p[22];
ll q[22][55];
ll r[22][55];
ll cD[22][105][105];
ll D[105][105];
ll cost[22][1010 * 201];
int main(){

	int n, m, C, S, G;
	while (cin >> n >> m >> C >> S >> G){
		//??\???????????????????????????
		if (!n && !m && !C && !S && !G)return 0;

		//??????????????????
		For(k, 1, C + 1)For(i, 1, n + 1)For(j, 1, n + 1){
			cD[k][i][j] = cD[k][j][i] = (i == j ? 0 : INF);
		}
		For(i, 1, n + 1)For(j, 1, n + 1){
			D[i][j] = D[j][i] = (i == j ? 0 : INF);
		}

		//???????????¨??????????????????????????§??????
		rep(i, m){
			cin >> x[i] >> y[i] >> d[i] >> c[i];
			cD[c[i]][x[i]][y[i]] = cD[c[i]][y[i]][x[i]] = min(cD[c[i]][y[i]][x[i]], d[i]);
		}

		//???????????¨??????????????±???????????????
		For(i,1, C+1)cin >> p[i];
		For(i,1, C+1){
			For(j,1, p[i]){ cin >> q[i][j]; q[i][j + 1] = -1; }
			For(j,1, p[i]+1)cin >> r[i][j];
		}

		//?§?????????¢??????????????????????¨????????????????
		for (int i = 1; i <= C; i++){
			For(j,1, p[i]+1){
				For(k,q[i][j-1]+1, q[i][j]+1){
					cost[i][k] = cost[i][k-1] + r[i][j];
				}
			}
			For(k, q[i][p[i]-1] + 1, 1010 * 201)
				cost[i][k] = cost[i][k - 1] + r[i][p[i]];
		}

		//???????????¨??????????????£?????????????????????
		For(l, 1, C + 1){
			For(k, 1, n + 1)For(i, 1, n + 1)For(j, 1, n + 1){
				cD[l][j][i] = cD[l][i][j] = min(cD[l][i][j], cD[l][i][k] + cD[l][k][j]);
			}
		}
		For(i, 1, n + 1)For(j, 1, n + 1)For(k, 1, C + 1){
			if (cD[k][i][j] != INF){
				D[i][j] = D[j][i] = min(D[i][j], cost[k][cD[k][i][j]]);
			}
		}
		For(k, 1, n + 1)For(i, 1, n + 1)For(j, 1, n + 1){
			D[j][i] = D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
		}
		if (D[S][G] == INF)D[S][G] = -1;
		cout << D[S][G] << endl;
	}
	return 0;
}

Measured memory_bytes: 36780
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define pr pair<int,int>
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt", "w", stdout);
    // #endif
    int n; cin>>n;
    int flag=0;
    while(n){
      if(n%10==7)
        flag=1;
      n/=10;
    }
    if(flag)
      cout<<"Yes\n";
    else
      cout<<"No\n";
    return 0;
}

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

int main(){
 int n,m;
 int t[100];
 int sum=0;
 int p[100];
 int x[100];
 int i;

 cin>>n;
 for(i=0;i<n;i++){
     cin>>t[i];
   	 sum+=t[i];
 }
 

 cin>>m;
 for(i=0;i<m;i++){
     cin>>p[i]>>x[i];
 }

  
for(int j=0;j<m;j++){
  int temp=sum;
  	temp=temp-(t[p[j]-1]-x[j]);
    cout<<temp<<endl;
  
}
  
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

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

int main()
{
	int n;
	int k;
	scanf("%d %d", &n, &k);
	int a[100000];
	int ans=0;
	vector<int> v[100000];
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
		a[i]--;
		if(i>0){
			v[a[i]].push_back(i);
		}else{
			if(a[0]!=0){
				ans++;
				a[0]=0;
			}
		}
	}
	int d[100000];
	d[0]=0;
	queue<int> que;
	que.push(0);
	while(!que.empty()){
		int x=que.front();
		que.pop();
		for(int i=0; i<v[x].size(); i++){
			d[v[x][i]]=d[x]+1;
			que.push(v[x][i]);
		}
	}
	vector<P> dist;
	for(int i=0; i<n; i++){
		dist.push_back(P(d[i], i));
	}
	bool ok[100000]={};
	sort(dist.begin(), dist.end(), greater<P>());
	for(int i=0; i<n; i++){
		int x=dist[i].second;
		if(d[x]<=k) continue;
		if(ok[x]==1) continue;
		bool e=0;
		for(int j=0; j<k; j++){
			if(ok[x]==1){
				e=1;
				break;
			}
			ok[x]=1;
			x=a[x];
		}
		if(e==0) ans++;
	}
	printf("%d\n", ans);
	return 0;
}

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

int main() {
	
	ll n; string s; cin >> n >> s;
	ll Nr = 0;
	ll Ng = 0;
	ll Nb = 0;
	for (ll i = 0; i < n; i++) {
		if (s[i] == 'R') Nr++;
		if (s[i] == 'G') Ng++;
		if (s[i] == 'B') Nb++;	
	}
	if (Nr == 0 || Ng == 0 || Nb == 0) {
		cout << 0 << endl;
		return 0;
	}
	ll sum = Nr * Ng * Nb;
	ll tmp = 0;
	for (ll i = 0; i < n - 2; i++) {
		for (ll j = i + 1; j < n - 1; j++) {
			ll k = 2 * j - i;
			if (n - 1 < k) continue;
			if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) {
				tmp++;
			}			
		}
	}
	cout << max(0LL, sum - tmp) << endl;
	return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
	ll L, R;
	cin >> L >> R;
	if (L/2019 < R/2019) {
		cout << 0 << endl;
	}
	else {
		L %= 2019;
		R %= 2019;
		if (R <= L) {
			R += 2019;
		}
		int ans = 2019;
		for (int i = L; i <= R - 1; ++i) {
			for (int j = i + 1; j <= R; ++j) {
				ans = min(ans, (i*j) % 2019);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
    ll N;
    cin >> N;
    string S;
    cin >> S;
    vector<char> c(N);
    ll Red = 0;
    for (ll i=0; i<N; i++) {
        c[i] = S[i];
        if (c[i] == 'R') {
            Red++;
        }
    }
    ll White = N-Red;
    ll Red_right = 0, White_left = 0;
    for (ll i=0; i<Red; i++) {
        if (c[i] == 'W') {
            White_left++;
        }
    }
    for (ll i=Red; i<N; i++) {
        if (c[i] == 'R') {
            Red_right++;
        }
    }
    ll ans = max(Red_right,White_left);
    cout << ans << endl;
}

Measured memory_bytes: 3924
n = gets.to_i
as = gets.split.map(&:to_i).sort!
bs = gets.split.map(&:to_i)
cs = gets.split.map(&:to_i).sort!

ans = 0
bs.each do |b|
  x = as.bsearch_index { |a| a >= b } || n
  y = n - (cs.bsearch_index { |c| b < c } || n)
  ans += x * y
end
puts ans


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

using namespace std;

int main(){
int n;
cin >> n;
vector<int> a(n);

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


int ans = 0;
int tmp = 0;
for(int i = 0;i < n-1;i++){
	if(a[i] >= a[i+1]){
		tmp++;
		ans = max(ans,tmp);
	}
	else{
		tmp = 0;
	}
}


cout << ans <<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ull uint64_t
#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mx5 100005
#define mx6 1000005
#define mod 1000000007
#define nfs ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

ll ans[1000] = {};

int main() {
    nfs
    int i, j, h, w;
    char ch;
    ans[0] = 1;
    cin >> h >> w;
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            cin >> ch;
            if (ch == '#')
                ans[j] = 0;
            else
                ans[j] = (ans[j] + (j > 0 ? ans[j-1] : 0))%mod;
            
        }
    }
    cout << ans[w-1];
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] p = new int[N];
    int sumK = 0;
    int max = -1, midx = -1;
    for (int i = 0; i < N; i++) {
      p[i] = sc.nextInt();
      sumK += p[i];
      if (i >= K) {
        sumK -= p[i - K];
      }
      if (i >= K - 1 && sumK > max) {
        max = sumK;
        midx = i;
      }
    }
    double ans = 0;
    double[] cache = build();
    for (int i = midx; i > midx - K; i--) {
      ans += cache[p[i]];
    }
    System.out.println(ans);
  }

  private static double[] build() {
    double[] c = new double[1001];
    double sum = 0;
    for (int i = 1; i <= 1000; i++) {
      sum += i;
      c[i] = sum / i;
    }
    return c;
  }
}


Measured memory_bytes: 82920
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,d;
  cin >> n >> d;
  int ans = 0;
  // vector<vector<int>> points(n,vector<int>(2));
  for(int i = 0; i < n; i++) {
    // cin >> points.at(i).at(0);
    // cin >> points.at(i).at(1);
    double x,y;
     cin >> x >> y;
    // cout << x * x << endl;
    // cout << y * y << endl;
    // cout << sqrt(x * x + y * y) << endl;
    // cout << sqrt((x * x) + (y * y)) << endl;
    if(sqrt(x*x + y*y) <= d) {
      ans += 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3792
#include <iostream>
#include <vector>

using namespace std;
int main(){
  int n;cin>>n;
  vector<int> A(n);
  for(int i = 0; n > i; i++){
    cin>>A[i];
  }
  int ans = 0;
  for(int i = 0; n > i; i++){
    for(int j = i; n > j; j++){
      if(i==j)continue;
      ans += A[i]*A[j];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int countDigit(int n)
{
  int digit = 1;
  while((n /= 10) != 0)
    digit++;
  return digit;
}

int main()
{
  int sx,sy,tx,ty; cin >> sx >> sy >> tx >> ty;
  string r;
  rep(i,ty-sy) r += "U";
  rep(i,tx-sx) r += "R";
  rep(i,ty-sy) r += "D";
  rep(i,tx-sx) r += "L";
  r += "L";
  rep(i,ty-sy+1) r += "U";
  rep(i,tx-sx+1) r += "R";
  r += "DR";
  rep(i,ty-sy+1) r += "D";
  rep(i,tx-sx+1) r += "L";
  r += "U";
  cout << r;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")
 
 
def main():
    N = int(input())
    K = int(input())
    ans = INF
    for a in range(N + 1):
        b = N - a
        ans = min(ans, 2 ** a + b * K)
    print(ans)
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include<stdio.h>
 
int main(){
	int N, AC=0,WA=0,TLE=0,RE=0;
	scanf("%d", &N);
	for(int i=0;i<N;i++){
		char S[100];
		scanf("%s", &S);
		if (S[0]=='A'){
			AC+=1;
			continue;
		}
		else if (S[0]=='W'){
			WA++;
			continue;
		}
		else if (S[0]=='T'){
			TLE++;
			continue;
		}
		else if (S[0]=='R'){
			RE++;
			continue;
		}	
	}
	printf("\nAC x %d\nWA x %d\nTLE x %d\nRE x %d\n", AC,WA,TLE,RE);
	return 0;
}

Measured memory_bytes: 2172
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

long long vis[444][444];
long long cnt0, cnt1;
long long dy[4] = {1, -1, 0, 0};
long long dx[4] = {0, 0, 1, -1};
long long H, W;
vector<string> S;

void dfs(long long y, long long x){
    if(vis[y][x] != 0) return;
    if(S[y][x] == '.'){
        vis[y][x] = 1;
        cnt0++;
    }else{
        vis[y][x] = -1;
        cnt1++;
    }

    for(long long i=0; i<4; i++){
        long long y2 = y+dy[i];
        long long x2 = x+dx[i];
        if(y2 < 0 || H <= y2 || x2 < 0 || W <= x2) continue;
        if(S[y][x] == S[y2][x2]) continue;
        dfs(y2, x2);
    }
}

int main(){
    cin >> H >> W;
    S.resize(H);

    for(long long i=0; i<H; i++)
        cin >> S[i];

    vector<pair<long long, long long>> v;
    for(long long i=0; i<H; i++){
        for(long long j=0; j<W; j++){
            cnt0 = 0;
            cnt1 = 0;
            if(vis[i][j] != 0) continue;
            dfs(i, j);
            v.push_back(make_pair(cnt0, cnt1));
        }
    }
    long long ans = 0;
    for(auto x : v){
        long long a = x.first;
        long long b = x.second;
        ans += a*b;
    }

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

Measured memory_bytes: 14336
import numpy as np
N=int(input())

arr=np.array([0 for _ in range((N+1)//2)])
num=np.array([2*i+1 for i in range((N+1)//2)])
for i in range(1,N+1):
    arr[num%i==0]+=1
print(len(arr[arr==8]))

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

int main() {
  int x, y;
  cin >> x >> y;

  for (int i = 0; i <= x; i++) {
    if (y - (i * 2) == (x - i) * 4) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 100
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

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 mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x)
{ //bit計算
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num)
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
signed main()
{
    int N;
    cin >> N;
    vector<int> AB;
    int B = 0;
    int ans = 0;
    rep(i, N)
    {
        int a, b;
        cin >> a >> b;
        B += b;
        AB.push_back(a + b);
    }
    ans -= B;
    sort(AB.begin(), AB.end(), greater<int>());
    for (int i = 0; i < N; i++)
    {
        if (i % 2 == 0)
            ans += AB[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	int a[]=new int[1000],i,j,n,sum,k,m;
    Scanner b =new Scanner(System.in);
    n= b.nextInt();
    for(i=0;i<n-1;i++)
    {
    	a[i]=b.nextInt();
    }
    sum=a[0];
    for(i=0;i<n-2;i++)
    {
    	if(a[i]>=a[i+1])
    	{
    		sum=sum+a[i+1];
    	}
    	else if(a[i+1]>a[i])
    	{
    		sum=sum+a[i];
    	}
    }
    sum=sum+a[n-2];
    System.out.println(""+sum);
	}

}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int a,b; cin >> a >> b;
    if(a == 1 && b == 2) cout << 3 << endl;
    if(a == 2 && b == 1) cout << 3 << endl;
    if(a == 1 && b == 3) cout << 2 << endl;
    if(a == 3 && b == 1) cout << 2 << endl;
    if(a == 3 && b == 2) cout << 1 << endl;
    if(a == 2 && b == 3) cout << 1 << endl;
}

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

int gcd(int &a, int &b,int &c) {
  int g;
  for(int i=1; i<=a; i++ ){
    if(a%i==0 && b%i==0 && c%i==0)g=i;
  }
  return g;
} 

int main() {
  int k;
  cin>>k;
  int sum=0;
  
  for(int a=1; a<=k; a++){
    for(int b=1; b<a; b++){
      for(int c=1; c<b; c++){
         sum+= 6*gcd(a, b, c);
      }
    }
  }
  for(int a=1; a<=k; a++){
    sum+= a;}
  for(int a=1; a<=k; a++){
    for(int b=1; b<a; b++){
      sum+=  6*gcd(a, a, b);
    }
  }
  cout<<sum<<endl;
}






Measured memory_bytes: 3612
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        a: usize,
        b: usize,
    }

    let ans = if a >= 13 {
        b
    } else if a >= 6 {
        b / 2
    } else {
        0
    };
    println!("{}", ans);
}


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

using namespace std;

const int N = 2345;

int n;
bitset<N> beat[N], ll[N], rr[N];
bool dp_l[N][N], dp_r[N][N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 2; i <= n; ++i) {
    string s;
    cin >> s;
    for (int j = 1; j < i; ++j) {
      if (s[j - 1] == '1') {
        beat[i][j] = true;
      } else {
        beat[j][i] = true;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    dp_l[i][i] = dp_r[i][i] = ll[i][i] = rr[i][i] = true;
  }
  for (int i = 2; i <= n; ++i) {
    bitset<N> seg;
    for (int j = 0; j < i; ++j) {
      seg[j] = true;
    }
    for (int j = 1; j + i - 1 <= n; ++j) {
      int x = j, y = j + i - 1;
      seg[x - 1] = false;
      seg[y] = true;
      bitset<N> result = beat[x] & rr[x + 1] & ll[y] & seg;
      if (result.count()) {
        dp_l[x][y] = ll[y][x] = true;
      }
      result = beat[y] & ll[y - 1] & rr[x] & seg;
      if (result.count()) {
        dp_r[x][y] = rr[x][y] = true;
      }
    }
  }
  int answer = 0;
  for (int i = 1; i <= n; ++i) {
    if (dp_r[1][i] && dp_l[i][n]) {
      ++answer;
    }
  }
  cout << answer << '\n';
  return 0;
}

Measured memory_bytes: 12928
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
 

int main(){
    int n;
    ll h;
    cin>>n>>h;
    vector<ll> a(n),b(n);
    rep(i,n) cin>>a[i]>>b[i];

    sort(all(b));
    sort(all(a));
    reverse(all(b));
    ll ans=0;
    rep(i,n){
        if(b[i]>a[n-1]){
            h-=b[i];
            ans++;
            if(h<=0){
                cout<<ans<<endl;
                return 0;
            }
        }
    }

    ans+=(h+a[n-1]-1)/a[n-1];
    cout<<ans<<endl;
}


Measured memory_bytes: 4740
#include<stdio.h>

int main(){
	int cnt;
	int i;
	int x[10000];
	while(1){
		scanf("%d",&x[cnt]);
		if(x[cnt]==0)break;
		cnt++;
	}
	
	for(i=0;i<cnt;i++){
		printf("Case %d: %d\n",i+1,x[i]);
	}
	return 0;
}

Measured memory_bytes: 2656
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>//cout << fixed からの cout << setprecision(n) << 小数　によって小数を整数部分含めてn桁表示できるようにする
#include <cctype>
#include <unordered_map>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int n,w;
  cin >> n >> w;
  vector<vector<int> > w_v(n,vector<int>(2));
  /*
  dp[i][w_zantei] = v
  i:何番目の商品まで使うか
  w_zantei : この重さ以下になる
  v :価値
  */
  vector<vector<ll> > dp(n,vector<ll>(w+1));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 2; j++){
     cin >> w_v[i][j];
   }
  }

  for(int i = 0;i < n;i++){
    for(int w_zantei = 0; w_zantei < w+1; w_zantei++){
      if (i != 0){
        if(w_zantei >= w_v[i][0]) dp[i][w_zantei] = max(dp[i-1][w_zantei],dp[i-1][w_zantei - w_v[i][0]]+w_v[i][1]);
        else dp[i][w_zantei] = dp[i-1][w_zantei];
      }else if(w_zantei >= w_v[i][0]) dp[i][w_zantei] = w_v[i][1];
      }
    }

  cout << dp[n-1][w] << endl;
  return 0;
}


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

int main(){
  string S;
  cin >>S;
  int len = S.size();
  int len2 = (len + 0.5)/2;
  int ans = 0;
  for(int i=0;i<len2;i++){
    if(S[i] != S[len-i-1]) ans ++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =  long long;
int main() {
  ll n=0,def=0,sum=0;
  cin >> n;

  int A[n];
  for(int i=0;i<n;i++){
    cin >> A[i];
    if(i != 0){
      if(A[i - 1] <= A[i]) continue;
      else{
        def  = A[i - 1] - A[i];
        A[i] = def + A[i];
        sum += def;
      }
    }
  }

  cout << sum << endl;
 /* for(int i=0;i<n;i++){
    cout << A[i] << endl;
  }
  */
  return 0;
}

Measured memory_bytes: 4376
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
  int n,s[100],dp[10010]={},maxa=0;
  scanf("%d",&n);
  dp[0]=1;
  for(int i=0;i<n;i++){
    scanf("%d",&s[i]);
    for(int j=10000;j>=0;j--)
      if(dp[j])
        dp[j+s[i]]=1;
  }
  for(int i=0;i<=10000;i++)
    if(i%10!=0&&dp[i]&&maxa<i)
      maxa=i;
  printf("%d\n",maxa);
}

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

using namespace std;

int main()
{
	int n;
	long long f[52][6] = {}, x = 0;
	string a, b;
	cin >> n >> a >> b;
	
	if (n == 1)
	{
		cout << 3;
		return 0;
	}
	
	for (int i = 0; i < (a[0] == a[1] ? 6 : 3); i++)
		f[0][i] = 1;
			
	for (int i = 1; i < n; i++)
	{
		if (a[i] == a[i-1])
			for (int j = 0; j < 6; j++)
				f[i][j] = f[i-1][j];
		else if (a[i] == b[i])
		{
			if (a[i-1] == b[i-1])
			{
				f[i][0] = (f[i-1][1]+f[i-1][2])%1000000007;
				f[i][1] = (f[i-1][0]+f[i-1][2])%1000000007;
				f[i][2] = (f[i-1][0]+f[i-1][1])%1000000007;
			}
			else
			{
				f[i][0] = (f[i-1][3]+f[i-1][5])%1000000007;
				f[i][1] = (f[i-1][1]+f[i-1][4])%1000000007;
				f[i][2] = (f[i-1][0]+f[i-1][2])%1000000007;
			}
		}
		else
		{
			if (a[i-1] == b[i-1])
			{
				f[i][0] = f[i][2] = f[i-1][2];
				f[i][1] = f[i][4] = f[i-1][1];
				f[i][3] = f[i][5] = f[i-1][0];
			}
			else
			{
				f[i][0] = ((f[i-1][2] + f[i-1][3])%1000000007 + f[i-1][4])%1000000007;
				f[i][1] = ((f[i-1][2] + f[i-1][4])%1000000007 + f[i-1][5])%1000000007;
				f[i][2] = ((f[i-1][0] + f[i-1][1])%1000000007 + f[i-1][5])%1000000007;
				f[i][3] = ((f[i-1][0] + f[i-1][4])%1000000007 + f[i-1][5])%1000000007;
				f[i][4] = ((f[i-1][0] + f[i-1][1])%1000000007 + f[i-1][3])%1000000007;
				f[i][5] = ((f[i-1][1] + f[i-1][2])%1000000007 + f[i-1][3])%1000000007;
			}
		}
	}
	
	for (int i = 0; i < 6; i++)
		x = (x+f[n-1][i])%1000000007;
		
	cout << x;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

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

    LL ans = 0;
    REP(a,K){
        REP(b,K){
            REP(c,K){
                LL tmp = gcd(a+1,b+1);
                tmp = gcd(tmp,c+1);
                ans += tmp;
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

signed main(void)
{
  while(true) {
    int n;
    cin >> n;
    if(!n) break;
    int ret = INF;
    for(int i=0; i*i*i<=n; ++i) {
      for(int j=0; j*j<=n; ++j) {
        int tmp = n - i*i*i - j*j;
        if(tmp >= 0) {
          ret = min(ret, i+j+tmp);
        }
      }
    }
    cout << ret << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[100005];
ll B[100005];

int main() {
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }

    ll ans = 1;
    memset(B, 0, sizeof(B));
    B[0] = 3;
    REP(i, N) {
        ans = (ans * B[A[i]]) % MOD;
        B[A[i]]--;
        B[A[i] + 1]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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;}
void YES(bool ok){
    cout << (ok ? "Yes" : "No") << endl;
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s, t;cin >> s >> t;
    sort(all(s));
    sort(all(t), greater<char>());
    YES(s < t);
}

Measured memory_bytes: 3616
# -*- coding: utf-8 -*-
"""
B - Strings with the Same Length
https://atcoder.jp/contests/abc148/tasks/abc148_b

"""
import sys


def solve(S, T):
    return ''.join(s+t for s, t in zip(S, T))


def main(args):
    _ = input()
    S, T = input().split()
    ans = solve(S, T)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
import java.io.ByteArrayInputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	
	String INPUT = "";
	
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes()));
		PrintWriter out = new PrintWriter(System.out);
		
		solve(sc, out);
		out.flush();
	}
	
	void solve(Scanner sc, PrintWriter out) {
		int a,b;
		String op;
		
		a = sc.nextInt();
		op = sc.next();
		b = sc.nextInt();
		
		while (!"?".equals(op)) {
			int ans = 0;
			if ("+".equals(op)) ans=a+b;
			if ("-".equals(op)) ans=a-b;
			if ("*".equals(op)) ans=a*b;
			if ("/".equals(op)) ans=a/b;
			System.out.println(ans);
			
			a = sc.nextInt();
			op = sc.next();
			b = sc.nextInt();
		}
	}
}



Measured memory_bytes: 26296
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arr(p,n);

  vec a(n);
  rep(i,n){
    a[i]=i+1;
  }

  int mismatch=0;
  rep(i,n){
    if(a[i]!=p[i]){
      mismatch++;
    }
  }

  if(mismatch==0 || mismatch==2){
    prt("YES");
  } else {
    prt("NO");
  }

}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
using namespace std;

int main()
{
	int h, w;
	cin >> h >> w;
	vector<string> c(h);
	for (int i = 0; i < h; i++) {
		cin >> c[i];
	}
	for (int i = 0; i < h; i++) {
		cout << c[i] << endl;
		cout << c[i] << endl;
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

#define MAX_N 14
ll dp[1<<MAX_N][MAX_N];
void init(){
    fill(*dp,*dp + (1<<MAX_N)*MAX_N,LINF);
}

void comp(vector<string>& S){
    ll N = S.size();
    vector<int> f(N,0);
    for(int i = 0; i < N;i++){
        for(int j = 0; j < N;j++){
            if(i == j) continue;
            if(S[j].find(S[i]) != string::npos){
                f[i] = true;
            }
        }
    }
    
    for(ll i = N-1; i >= 0;i--){
        if(f[i]){
            S.erase(S.begin()+i);
        }
    }
}
ll solve(ll N){
    ll res = LINF;
    vector<string> S(N);
    for(auto& in:S) cin >> in;
    comp(S);
    N = S.size();
    vector<vector<ll>> minCost(N,vector<ll>(N,LINF));
    for(int i = 0; i < N;i++){
        for(int j = 0; j < N;j++){
            if(i==j) continue;
            string& s1 = S[i];
            string& s2 = S[j];
            minCost[i][j] = s2.length();
            for(int k = 0; k <s1.length();k++){
                if(s1.substr(k) == s2.substr(0,s1.length()-k)){
                    minCost[i][j] = min(minCost[i][j],(ll)(s2.length() - (s1.length()-k)));
                }
            }
        }
    }
    
    for(int i = 0; i < N;i++){
        dp[1<<i][i] = S[i].length();
    }
    
    //cout << minCost << endl;
    
    for(int i = 0; i < (1<<N);i++){
        for(int j = 0; j < N;j++){
            if(dp[i][j] == LINF) continue;
            for(int k = 0; k < N;k++){
                if((i>>k)&1) continue;
                dp[i|(1<<k)][k] = min(dp[i|(1<<k)][k],dp[i][j]+minCost[j][k]);
                
                //cout << bitset<5>(i) << ' ' << j << ' ' << k << ' ' << minCost[j][k] << endl;
            }
        }
    }
    for(int i = 0; i < N;i++){
        res = min(res,dp[(1<<N)-1][i]);
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll N;
    while(cin>>N,N){
        init();
        cout << solve(N) << endl;
    }
    return 0;
}



Measured memory_bytes: 4816
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, N) for (int i = 0; i < (N); ++i)
#define rep2(i, a, b) for (ll i = a; i <= b; ++i)
#define rep3(i, a, b) for (ll i = a; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) begin(c), end(c)
#define ok() puts(ok ? "Yes" : "No");
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll, ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
// clang++ -std=c++11 -stdlib=libc++

int N;
int main() {
  cin >> N;
  ll ans = 0;
  rep2(a, 1, N) {
    rep2(b, 1, N) {
      if (a * b < N)
        ans++;
      else
        break;
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 3756
#include <iostream>
#include <sstream>
#include <bitset>
using namespace std;

int main(){
  string a, b;
  cin >> a >> b;
  int x = a[0] - b[0];

  if (x > 0)
    cout
        << ">" << endl;
  else if(x==0)
    cout << "=" << endl;
  else
    cout << "<" << endl;
  //cout << x;
}

Measured memory_bytes: 256
n=int(input())
s=input()
ans=0

for i in range(1000):
    v = str(i).zfill(3)
    start=0
    f=0

    for j in range(3):
        idx=s.find(v[j],start)
        if idx > -1:
            start =idx+1
            f+=1
        else:
            break
    if f==3:
        ans+=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int main() {
    string a, b;  cin >> a >> b;

    double c = stoi(a+b);
    double sq = (int)sqrt(c);

    if (c / sq == sq) yes;
    else no;
    
}




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

const int N = 200005;

int n, m, u, v, cnt[N][2];
bool chk[N];
char s[N];
vector<int> ve, adj[N];

int main()
{
    scanf("%d %d\n%s\n", &n, &m, s + 1);
    for (int i = 1; i <= n; i++)
        s[i] -= 'A';
    for (int i = 1; i <= m; i++)
    {
        scanf("%d %d\n", &u, &v);
        adj[u].push_back(v);
        adj[v].push_back(u);
        cnt[u][s[v]]++;
        cnt[v][s[u]]++;
    }
    for (int i = 1; i <= n; i++)
        if (cnt[i][0] == 0 || cnt[i][1] == 0)
        {
            ve.push_back(i);
            chk[i] = true;
        }
    for (unsigned int i = 0; i < ve.size(); i++)
    {
        int u = ve[i];
        for (int &v : adj[u])
            if (!chk[v] && (--cnt[v][s[u]]) == 0)
            {
                ve.push_back(v);
                chk[v] = true;
            }
    }
    printf("%s\n", ve.size() == n ? "No" : "Yes");
}

Measured memory_bytes: 13308
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int y = sc.nextInt();
		int absX = Math.abs(x);
		int absY = Math.abs(y);

		int result = 0;
		if(y > 0){
			if(absX <= absY){
				result = absY - absX;
				if(x < 0){
					result++;
				}
			}
			else {
				result = absX - absY + 1;
				if(x > 0){
					result++;
				}
			}
		}
		else if(y == 0){
			result = absX - absY;
			if(x > 0){
				result++;
			}
		}
		else {
			if(absX <= absY){
				result = absY - absX + 1;
				if(x < 0){
					result++;
				}
			}
			else {
				result = absX - absY;
				if(x > 0){
					result++;
				}
			}
		}

		System.out.println(result);
	}
}


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

int main(){
  int n,i,count=1;
  cin>>n;
  vector<int> vec(n);
  for(i=0;i<n;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  for(i=1;i<n;i++){
    if(vec.at(i)!=vec.at(i-1))
      count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;

int main(){

ll A,B;
cin >> A >> B;

cout << A*B << endl;
  
return 0;

}   


Measured memory_bytes: 3648