akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define ele int
using namespace std;
#define maxn 100010
#define INF 1e18
#define eps 1e-7
struct circle{
	double x,y,r;
};
ele n;
double R;
circle a[maxn];
inline bool cmp1(circle a,circle b){
	return a.x<b.x;
}
inline bool cmp2(circle a,circle b){
	return a.y<b.y;
}
inline double dis(circle a,circle b){
	return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y))-a.r-b.r;
}
double solve(ele l,ele r){
	if (r-l+1<=10){
		double ans=INF;
		for (int i=l; i<=r; ++i)
			for (int j=i+1; j<=r; ++j)
				ans=min(ans,dis(a[i],a[j]));
		return ans;
	}
	ele mid=(l+r)>>1;
	double ans=min(solve(l,mid-1),solve(mid+1,r));
	for (int i=l; i<=r; ++i)
		if (i!=mid) ans=min(ans,dis(a[i],a[mid]));
	static circle p[maxn],q[maxn];
	ele u=0,v=0;
	for (int i=l; i<mid; ++i)
		if (a[mid].x-a[i].x<ans+R*2+eps) p[u++]=a[i];
	for (int i=mid+1; i<=r; ++i)
		if (a[i].x-a[mid].x<ans+R*2+eps) q[v++]=a[i];
	if (!v) return ans;
	sort(p,p+u,cmp2); sort(q,q+v,cmp2);
	ele s=0,t=0;
	for (int i=0; i<u; ++i){
		while (s<v-1 && p[i].y-q[s].y>ans+R*2+eps) ++s;
		while (t<v-1 && q[t+1].y-p[i].y<ans+R*2+eps) ++t;
		for (int j=s; j<=t; ++j) ans=min(ans,dis(p[i],q[j]));
	}
	return ans;
}
int main(){
	while (scanf("%d",&n),n){
		R=0;
		for (int i=0; i<n; ++i){
			scanf("%lf%lf%lf",&a[i].r,&a[i].x,&a[i].y);
			R=max(R,a[i].r);
		}
		sort(a,a+n,cmp1);
		printf("%.10lf\n",solve(0,n-1));
	}
	return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
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=int>inline T get(){
   char c=getchar(); bool neg=(c=='-');
   T res=neg?0:c-'0'; while(isdigit(c=getchar()))res=res*10+(c-'0');
   return neg?-res:res;
}
template<typename T=int>inline void put(T x,char c='\n'){
   if(x<0)putchar('-'),x*=-1; int d[20],i=0;
   do{d[i++]=x%10;}while(x/=10); while(i--)putchar('0'+d[i]);
   putchar(c);
}
//end



int main(){
   int k=get(),a=get(),b=get();
   bool f=0;
   rep(i,0,1100)if(a<=i*k and i*k<=b){
      f=1; break;
   } printf(f?"OK\n":"NG\n");
   return 0;
}

Measured memory_bytes: 3684
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
  
struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};
  
typedef struct node * NodePointer;
  
NodePointer nil;
  
NodePointer listSearch(int key){
  NodePointer a;
    
  a = nil->next;
    
  while(a!= nil && a->key != key)
    {
      a = a->next;
    }
  return a;
    
}
  
void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}
  
void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}
  
void deleteNode(NodePointer t){
  if ( t == nil ) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  
}
  
void deleteFirst(){
  deleteNode(nil->next);
}
  
void deleteLast(){
  deleteNode(nil->prev);
}
  
void delete(int key){
  NodePointer a;
  
  if((a = listSearch(key))!=NULL)
    {     
      deleteNode(a);
    } 
}
  
  
void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
    
}
  
int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
    if ( com[6] == 'F' ) deleteFirst();
    else if ( com[6] == 'L' ) deleteLast();
      } else {
    delete(key); nd++; 
      }
      size--;
    }
  }
  
  printList();
  return 0;
}

Measured memory_bytes: 34976
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

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

    std::pair<int, std::pair<int, int> > dp[3010][3010];

    int n = a.length();
    int m = b.length();
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            if (a[i] == b[j])
            {
                dp[i + 1][j + 1].first = dp[i][j].first + 1;
                dp[i + 1][j + 1].second.first = i;
                dp[i + 1][j + 1].second.second = j;
            }
            else
            {
                if (dp[i + 1][j].first >= dp[i][j + 1].first)
                {
                    dp[i+1][j+1] = dp[i + 1][j];
                    dp[i + 1][j + 1].second.first = i + 1;
                    dp[i + 1][j + 1].second.second = j;
                }
                else
                {
                    dp[i+1][j+1] = dp[i][j+1];
                    dp[i + 1][j + 1].second.first = i;
                    dp[i + 1][j + 1].second.second = j+1;
                }
            }
        }
    }

    std::vector<char> ans;
    int i = n, j = m;
  //  std::cout << i << " " << j << "\n";
    while (i != 0 && j != 0)
    {
        if (dp[i][j].second.first == i - 1 && dp[i][j].second.second == j - 1)
        {
            ans.push_back(a[i - 1]);
        }

  //      std::cout << i << " " << j << " " << dp[i][j].second.first << " " << dp[i][j].second.second << "\n";
        int tempi = dp[i][j].second.first;
        j = dp[i][j].second.second;
        i = tempi;
//        std::cout << i << " " << j << "\n";
    }

   // std::cout << dp[n][m].first;
    for (int i = ans.size() - 1; i >= 0; --i)
        std::cout << ans[i];
}


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

public class Main {

	
	public void read() {
	}
	
	public void prepare() {
		
	}
	
	public long solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();
		
		int[] types = new int[M+1];
		Arrays.fill(types, 0);
		
		for (int i=0; i<N; i++) {
			int K = in.nextInt();
			for (int j=0; j<K; j++) {
				int t = in.nextInt();
				types[t]++;
			}
		}
		
		in.close();

		int count = 0;
		for (int i=0; i<M+1; i++) {
			if (types[i] >= N) {
				count++;
			}
		}
		
		return count;
	}
	
	public static void main(String[] args) {
		Main main = new Main();
		main.read();
		main.prepare();
		System.out.println(main.solve());
	}
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int main(){
//	int t;
//	cin>>t;
//	for(int i=0;i<t;i++){
		int n;
		cin>>n;
		int b[n],dp[n]={0};
		for(int j=0;j<n;j++){
			cin>>b[j];
	    }
	    dp[1]=abs(b[1]-b[0]);
		for(int j=2;j<n;j++){
			dp[j]=min(dp[j-2]+abs(b[j]-b[j-2]),dp[j-1]+abs(b[j]-b[j-1]));
		}
	    cout<<dp[n-1];
		}
//}

Measured memory_bytes: 1024
a = gets.strip.to_i
def judge(a)
  if a == 2
    return true
  end
  if a== 1
    return true
  end
  Array(2..(a-1)).each do |num|
    if a%num == 0
     return false
    end
  end
  return true
end


while true do
  if judge(a)
    break
  end
  a+=1
end
puts a


Measured memory_bytes: 19708
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  int i = 1;
  while(1) {
    if(i * (i + 1) / 2 >= n) {
      ans = i;
      break;
    }
    i++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

#define M 20001

int A[M];

int num2z(int,int);
int m;
int numo;

int main(){
  int n,num;
  int i;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  
  scanf("%d",&m);
  for(i=0;i<m;i++){
  scanf("%d",&num);
  numo=num;
  if(num2z(0,num)) printf("yes\n");
  else printf("no\n");
  }
  
  return 0;
}

int num2z(int i,int num){
  int h;
  if(num==0) return 1;
  if(i>=20) return 0;
  if((h=num2z(i+1,num-A[i]))==1||(h=num2z(i+1,num))==1) return 1;
}





Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    int A,B;
    cin>>A>>B;
    int count=0;
    int tmp,t;
    for(int i=A; i<=B; i++){
        tmp= i;
        t=0;
        while(tmp!=0){
            t=(t*10)+(tmp%10);
            tmp/=10;
        }
        if(A==t){
            count++;
        }
        A++;
    }
    cout<<count<<endl;;
}

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

long long dp[1000][10001];
int main() {
  int h, n;
  cin>>h>>n;
  long long a[n], b[n];
  for (int i=0; i<n; i++) cin>>a[i]>>b[i];
  for (int i=0; i<n; i++) {
    dp[i][0] = 0;
  }
  for (int i=1; i<h+1; i++) {
    dp[0][i] = ((i - 1) / a[0] + 1) * b[0];
  }
  for (int i=1; i<n; i++) {
    for (int j=1; j<h+1; j++) {
      long long t = dp[i][max(j-a[i], 0LL)] + b[i];
      dp[i][j] = min(t, dp[i-1][j]);
    }
  }
  cout<<dp[n-1][h]<<endl;
}

Measured memory_bytes: 78336
// Average Length
#include <iostream>
#include <cmath>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
using namespace std;

int main(){
    int n;
    cin >> n;
    double sum=0;
    double x[n][2];
    for(int i=0; i<n; i++){
        for(int j=0; j<2; j++){            cin >> x[i][j];
        }
    }  
     cout << fixed << setprecision(20);
    for(int i=0; i<(n-1); i++){
        for(int j=(i+1); j<n; j++){
            sum+=sqrt((x[i][0]-x[j][0])*(x[i][0]-x[j][0])+(x[i][1]-x[j][1])*(x[i][1]-x[j][1]));
  //          cout << sqrt((x[i][0]-x[j][0])*(x[i][0]-x[j][0])+(x[i][1]-x[j][1])*(x[i][1]-x[j][1]))  << endl;
        }
    }
 //   cout << sum << endl;
 //   cout << fixed << setprecision(20);
    cout << double(sum*2/n) << endl;
    return 0;
}

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

char S[100] = {0};
bool B[100] = {0};

int main()
{
    scanf("%s",S);
    for(int i = 0; i < strlen(S); i++)
    {
        if(B[S[i] - 'a'])
        {
            printf("no\n");
            return 0;
        }
        B[S[i] - 'a'] = true;
    }
    printf("yes\n");
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	double s=0.0;
	for(int i=0;i<n;i++){
		double t;
		cin>>t;
		s+=1/t;
	}
	cout<<1/s;
}

Measured memory_bytes: 256
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>

int n,a,b,c,d;

int main(){
	cin>>n>>a>>b>>c>>d;
	ll target=b-a;
	d-=c;
	n-=1;
	for(ll add=0;add<=n;add++){
		ll minus=n-add;
		ll cur=target;
		cur-=add*c;
		cur+=minus*c;
		ll low=-d*minus,high=d*add;
		if(cur>=low&&cur<=high){
			cout<<"YES";
			return 0;
		}
	} 
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long 
using namespace std;
const int N = 1e5+10;
const int M = 1e9+7;

int main(){
	FIO;
	int n,k;
	cin >> n >> k;
	long long a[n+2],b[n+2];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		b[i] = INT_MAX; 
	}
	b[0] = 0;
	for (int i = 1; i < n; ++i)
	{
		for (int j = 1; j <= k; ++j)
		{
			if(i-j>=0)
			{
				b[i]=min(b[i],b[i-j]+abs(a[i]-a[i-j]));
			}
		}
	}
	cout << b[n-1] << "\n";
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
struct S
{
    int a, num;
}xx[100005];
bool cmp(S a, S b)
{
    return a.a < b.a;
}
int main()
{
    int n;
    long long k;
    int a, b;
    scanf("%d%lld", &n, &k);
    for(int i = 0; i < n; ++i)
    {
        scanf("%d%d", &a, &b);
        xx[i].a = a;
        xx[i].num = b;
    }
    sort(xx, xx + n, cmp);
    long long sum = 0;
    for(int i = 0; i < n; ++i)
    {
        sum += xx[i].num;
        if(sum >= k)
        {
            cout << xx[i].a << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <bitset>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr int base = 88 * 160;

bitset <base*2> dp[88][88];
int h,w,x,a[88][88];

int main(){

ios::sync_with_stdio(false); cin.tie(0);
cin>>h>>w;

REP(i, h) REP(j, w) cin >> a[i][j];

REP(i, h) REP(j, w) { cin >> x; a[i][j] = abs(x - a[i][j]); }
dp[0][0][base-a[0][0]]=1;
dp[0][0][base+a[0][0]]=1;
for (int i=0; i<(h); i++){
  for (int j=0; j<(w); j++){
    if (i){
      dp[i][j] |= dp[i - 1][j] >> a[i][j];
      dp[i][j] |= dp[i - 1][j] << a[i][j];
    }
    if (j){
      dp[i][j] |= dp[i][j - 1] >> a[i][j];
      dp[i][j] |= dp[i][j - 1] << a[i][j];
    }
  }
}
int ans=base;
for(int i = 0; i < base * 2; ++i) if (dp[h - 1][w - 1][i]) ans = min(ans, abs(base - i));
cout<<ans;
}


Measured memory_bytes: 24704
#include <bits/stdc++.h>
#define N (1<<17)

using namespace std;

int n, h[N][3], d[N][3], ans;

int main(){

	cin >> n;

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

	for(int i=0; i<n; i++){
		for(int j=0; j<3; j++){
			for(int k=0; k<3; k++){
				if(k==j) continue;
				d[i+1][k] = max(d[i+1][k], d[i][j]+h[i][j]);
			}
		}
	}

	for(int i=0; i<3; i++) ans = max(ans, d[n][i]);

	cout << ans << endl;

}


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

#define int long long
using namespace std;


signed  main() {

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] ;
    }
    map<int, int> m;
    int ans = 0;

    for (int i = 0; i < n; i++) {
        m[a[i]]++;
    }
    for (auto c: m) {
       //     cout << c.first << " " << c.second << endl;
        ans += c.second * (c.second - 1) / 2;
    }
    //cout << ans;
    for(int i = 0; i < n; i++) {
        ans -= m[a[i]] * (m[a[i]] - 1) / 2;
        if (m[a[i]] == 0) {
            cout << ans << " ";
        }
        else {
            cout << ans + (m[a[i]] - 1) * (m[a[i]] - 2) / 2 << endl;
        }
        ans += m[a[i]] * (m[a[i]] - 1) / 2;
    }
}


Measured memory_bytes: 11008
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,x,cnt=0;
	cin>>a>>b>>c>>x;
	for(int i=0; i<=a; i++)
		for(int j=0; j<=b; j++)
			for(int k=0; k<=c; k++)
				if( (500*i)+(100*j)+(50*k) == x)
					cnt++;
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = Integer.parseInt(sc.next());
    int X = Integer.parseInt(sc.next());

    int m[] = new int[N];
    int sum = 0;
    int min = 1000;

    for (int i = 0; i < N; i++) {
      m[i] = Integer.parseInt(sc.next());
      sum += m[i];
      if (min > m[i]) {
        min = m[i];
      }
    }

    int rX = X - sum;
    int count = N + rX / min;

    System.out.println(count);

  }

}

Measured memory_bytes: 21716
// In God We Trust


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

# define INF 1 << 31 - 1

signed main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  string ans;
  for (int i = 0; i < s.size(); i++){
    char c ;
    c = s[i];
    c += n;
    if (c > 'Z')
      c -= 26;
    ans += c;
  }
  cout << ans;
  
  
}


Measured memory_bytes: 256
using System;
class ProgramA
    {
        static void Main(string[] args)
        {
            
            string input = Console.ReadLine();
            int a = int.Parse(input);
            

            if(a >= 2)
                Console.WriteLine(Math.Pow(a, 3));
            else
                Console.WriteLine(1);
    
        }
    }

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

const int N = 1e5 + 7;
const ll MX = (ll)(2e18) + 7;;

ll w[N], d[N];

int main()
{
    ios::sync_with_stdio(false);

    ll n, k;
    cin >> n >> k;
    for (int i=0; i<n; i++)
        cin >> w[i] >> d[i];
    ll l = 0, r = MX;
    while (r - l > 1)
    {
        ll mid = (l + r) / 2;
        ll sm = 0;
        for (int i=0; i<n; i++)
            if (mid >= w[i])
                sm += (mid - w[i] + d[i]) / d[i];
        if (sm >= k)
            r = mid;
        else
            l = mid;
    }
    cout << r << "\n";
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
using namespace std;

int main() {
	int x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int x3 = x2 - (y2 - y1);
	int y3 = y2 - (x1 - x2);
	int x4 = x1 - (y2 - y1);
	int y4 = y1 - (x1 - x2);
	cout << x3 <<' '<< y3 << ' ' << x4 << ' ' << y4 << endl;
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	ll n,sum=0;
    cin>>n;
	for(ll i=1;i<=n;++i){
		if(i%3==0||i%5==0)continue;
		else sum+=i;
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
const int mod=1e5+5;
long long a[mod],b[mod];
int main()
{
    long long n,i,sum=0,count=0,k;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        b[i]=a[i]-a[i-1];
        sum+=a[i];
    }
    b[1]=a[1]-a[n];
    if(sum%(n*(n+1)/2))
    {
        cout<<"NO"<<endl;
        return 0;
    }
    k=sum/(n*(n+1)/2);
    for(i=1;i<=n;i++)
    {
        if((k-b[i]<0) || (k-b[i])%n)
        {
            cout<<"NO"<<endl;
            return 0;
        }
        else count+=(k-b[i])/n;
    }
    if(count!=k) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 1792
#define fRead(x)  freopen(x,"r",stdin)
#define fWrite(x) freopen (x,"w",stdout)

#define LL long long
#define ULL unsigned long long
#define ff first
#define ss second
#define pb push_back
#define INF 2e7
#define PI acos(-1.0)

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(a,min(b,min(c,d)))
#define max4(a,b,c,d) max(a,max(b,max(c,d)))
#define SQR(a) ((a)*(a))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,b) for(int i=0;i<b;i++)
#define MEM(a,x) memset(a,x,sizeof(a))

#define scanI(a) scanf("%d",&a)
#define scanI2(a,b) scanI(a) , scanI(b)
#define scanI3(a,b,c) scanI(a), scanI(b), scanI(c)
#define scanI4(a,b,c,d) scanI(a), scanI(b), scanI(c), scanI(d)

#define scanL(a) scanf("%I64d",&a)
#define scanL2(a,b) scanL(a) , scanL(b)
#define scanL3(a,b,c) scanL(a), scanL(b), scanL(c)
#define scanL4(a,b,c,d) scanL(a), scanL(b), scanL(c), scanL(d)

#define SORT(v) sort(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())

#define FastRead ios_base::sync_with_stdio(0);cin.tie(nullptr);

#include<bits/stdc++.h>

using namespace std;
string str;
LL x,n;
LL ara[16][16];
void gen()
{
    LL lim = (1 << (n-1));
    LL pos = 0;
    do
    {
        vector<int>v;
        for(int i=0;i<n-1;i++)
        {
            LL mul = (1 << i);
            if( (pos&mul)==0);
            else v.pb(i);
        }
        int here=0;
        REP(i,v.size())
        {
//            cout << v[i] << " ";
            x+= ara[here][v[i]];
            here=v[i]+1;
//            cout << ara[here][v[i]] << "\n";
        }
//        cout << endl;
        x+= ara[here][n-1];
        pos++;
    }while(pos<lim);
}
int main()
{
    cin >> str;
    n = str.length();
    for(int i=0;i<str.length();i++)
    {
        for(int j=i;j<str.length();j++)
        {
            LL num = 0;
            for(int k=i;k<=j;k++)
            {
                num = num*10+ (LL)(str[k]-'0');
            }
            ara[i][j]=num;
        }
    }
    gen();
    cout << x;
}


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



int main(){
	int l[5];
	int t=5;
	
	int res;
	int cont=0;
	while(t--){
		cont++;
		int x;
		cin>>x;
		if (x==0) res=cont;
		
	}
	cout<<res<<endl;


}





Measured memory_bytes: 3588
# -*- coding: utf-8 -*-

import sys
import os

for s in sys.stdin:
    C1, C2, C3 = map(int, s.split())

    cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    cards.remove(C1)
    cards.remove(C2)
    cards.remove(C3)

    capacity = 20 - C1 - C2
    want_cards = [card for card in cards if card <= capacity]

    if len(want_cards) / len(cards) >= 0.5:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 7568
N = int(input())
kei =[]
for i in range(N):
    s = input()
    kei.append(s)
kei.sort()
t=kei[0]
count=1
for i in range(0,N):
    if(kei[i] != t):
        count+=1
        t = kei[i]
print(count)

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  rep(i, s.size()){
    if((s.at(i)+n) > 90){
      s.at(i) += (n-26);
    }
    else{
      s.at(i) += n;
    }
  }
  cout << s << endl;
  return 0;
}

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

int main() {
	int a,b;
	cin >> a >> b;
	if(a < b) {
		cout << "a < b" << endl;
	}
	else if(a > b) {
		cout << "a > b" << endl;
	}
	else {
		cout << "a == b" << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
(n, k), p, c = [[*map(int, i.split())] for i in open(0)]

def solve(x, t):
    visit = [0] * n
    visit[x] = 1
    loop = [0] * n
    count = 0
    ans = c[p[x] - 1]
    l = True
    sub = 0
    while True:
        x = p[x] - 1
        if l:
            if visit[x]:
                if loop[x]:
                    ln = sum(loop)
                    if t > l:
                        sub += (t//ln -1)*count*(count>0)
                        t %= ln
                        t += ln
                    l = False
                count += c[x]
                loop[x] = 1
            visit[x] = 1
        sub += c[x]
        t -= 1
        ans = max(sub, ans)
        if t < 1:
            return ans


print(max(solve(i, k) for i in range(n)))


Measured memory_bytes: 94764
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int A = Integer.parseInt(sc.next());
        final int B = Integer.parseInt(sc.next());
        int ans = 0;
        
        for (int i = A; i <= B; i++) {
            if ((i / 10000 == i % 10) && (i / 1000 % 10 == i % 100 / 10)) {
                ans++;
            }
        }
        
        out.println(ans);
        
        out.flush();
    }
}

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

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

struct Edge {
  int src, dst;
  Edge(int src, int dst) :
    src(src), dst(dst) { }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void visit(const Graph & g, int v, int u,
           Edges& brdg, vector< vector<int> >& tecomp,
           stack<int>& roots, stack<int>& S, vector<bool>& inS,
           vector<int>& num, int& time) {
    num[v] = ++time;
    S.push(v); inS[v] = true;
    roots.push(v);
    for(auto& e :g[v]) {
        int w = e.dst;
        if (num[w] == 0)
            visit(g, w, v, brdg, tecomp, roots, S, inS, num, time);
        else if (u != w && inS[w])
            while (num[roots.top()] > num[w]) roots.pop();
    }
    if (v == roots.top()) {
        brdg.push_back(Edge(u, v));
        tecomp.push_back(vector<int>());
        while (1) {
            int w = S.top(); S.pop(); inS[w] = false;
            tecomp.back().push_back(w);
            if (v == w) break;
        }
        roots.pop();
    }
}
void bridge(const Graph& g, Edges& brdg, vector< vector<int> >& tecomp) {
    const int n = g.size();
    vector<int> num(n);
    vector<bool> inS(n);
    stack<int> roots, S;
    int time = 0;
    REP(u, 0, n) if (num[u] == 0) {
        visit(g, u, n, brdg, tecomp, roots, S, inS, num, time);
        brdg.pop_back();
    }
}

int main() {
#ifdef LOCAL_TEST
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int n, m;
    cin >> n >> m;
    Graph g(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].pb({a, b});
        g[b].pb({b, a});
    }
    Edges ans;
    vector<vector<int>> tecomp;
    bridge(g, ans, tecomp);
    cout << ans.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;
using ll = long long;

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

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

	cout << (N + 1) / 2 << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/

#include <iostream>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  string a, b, c, r;

  cin >> a >> b >> c;

  r = a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0] ? "YES" : "NO";

  cout << r << "\n";

  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
	n = int(input().strip())
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	s = 0
	for i in range(n):
		if a[i] < b[i]:
			s += a[i]
			if b[i] - a[i] < a[i+1]:
				a[i+1] -= (b[i] - a[i])
				s += b[i] - a[i]
			else:
				s += a[i+1]
				a[i+1] = 0
		else:
			s += b[i]
	print(s)

if __name__ == '__main__':
	main()


Measured memory_bytes: 76416
import qualified Data.ByteString.Char8 as C
import Data.Maybe (isJust, fromJust)
import Control.Monad (replicateM)
import Data.List (sort, drop, length, filter, take)
import qualified Data.Vector.Unboxed as U
import Control.Arrow (first) -- first :: Arrow a => a b c -> a (b, d) (c, d)

cReadLn :: IO Int
cReadLn = fst . fromJust . C.readInt <$> C.getLine

getParms :: IO [Int]
getParms = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [n,c,k] <- getParms -- passengers, maximum num in a bus, and limit time
--  ts <- (U.fromList . sort) <$> replicateM n cReadLn -- i-th passenger's arrival time
  ts <- sort <$> replicateM n cReadLn -- i-th passenger's arrival time
  print $ length $ solve' c k ts

f :: Int -> Int -> U.Vector Int -> Int
f c k ts = solver c k ts 0
  where
    solver :: Int -> Int -> U.Vector Int -> Int -> Int
    solver _ _ ts n 
      | U.null ts = n
    solver c k ts n = solver c k qs (n+1)
      where p  = inABus c k ts
            qs = U.drop p ts

overWrap :: Int -> Int -> Int -> Int
overWrap k t0 t1 = (t0+k - t1)

inABus 
  :: Int -> Int -> U.Vector Int -> Int
inABus c k tt = U.length . U.filter (0<=) . U.map (overWrap k t) . U.take c $ tt
  where
    t = U.head tt

-- https://atcoder.jp/contests/agc011/submissions/3109211

solve :: [Int] -> Int -> Int -> [[Int]]
solve [] _ _ = []
solve xs c k = a : solve b c k
  where
    (a,b) = aux (head xs) xs 1
    aux :: Int -> [Int] -> Int -> ([Int],[Int])
    aux _  []        _  = ([],[])
    aux t0 xx@(x:xs) c0
      | c0 <= c && x <= t0+k = first (x:) (aux t0 xs (c0+1))
      | otherwise            = ([], xx)

-- first (1:) :: ([Int], [Int]) -> ([Int], [Int])

solve' :: Int -> Int -> [Int] -> [[Int]]
solve' _ _ [] = []
solve' c k xs@(x:_) = a : solve' c k ys
  where
    (a,ys) = aux x xs 1
    aux :: Int ->[Int] -> Int -> ([Int], [Int])
    aux _ [] _ = ([],[])
    aux t xx@(x:xs) c0
      | c0<=c && x<= t+k = (\(cs,ds) -> ((x:cs), ds)) (aux t xs (c0+1))
      | otherwise        = ([],xx)

Measured memory_bytes: 30972
# C
H, W = map(int, input().split())
s_list = list()
for _ in range(H):
    s_list.append(list(input()))

res = "Yes"
# check
for i in range(H):
    for j in range(W):
        
        if s_list[i][j] == "#":
            res_temp = "No"
        else:
            res_temp = "Yes"
        # check 1
        if i > 0:
            if s_list[i-1][j] == "#":
                res_temp = "Yes"
        # check 2
        if i+1 < H:
            if s_list[i+1][j] == "#":
                res_temp = "Yes"      
        # check 3
        if j > 0:
            if s_list[i][j-1] == "#":
                res_temp = "Yes"
        # check 4
        if j+1 < W:
            if s_list[i][j+1] == "#":
                res_temp = "Yes"   
        # check
        if res_temp == "No":
            res = "No"
print(res)

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

using namespace std;

#define allof(x) (x).begin(), (x).end()

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

const int MAXN = 1e5 + 5;

int N;
int arr[MAXN];

//the median is at most x if #above < #leq
//#leq - #above > 0
struct {
    int data[MAXN * 2];
    void update(int pos, int val){
        pos += MAXN;
        while(pos < MAXN * 2){
            data[pos] += val;
            pos += pos & -pos;
        }
    }
    
    int query(int pos){
        pos += MAXN;
        int ans = 0;
        while(pos){
            ans += data[pos];
            pos -= pos & -pos;
        }
        return ans;
    }
} ds;

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

    cin >> N;

    for(int a = 1; a <= N; a++){
        cin >> arr[a];
    }

    int lo = 1, hi = 1e9;
    while(lo <= hi){
        ll cnt = 0;
        memset(ds.data, 0, sizeof ds.data);
        ds.update(0, 1);
        int mid = (lo + hi) / 2;
        for(int i = 1, cur = 0; i <= N; i++){
            if(arr[i] <= mid){
                cur++;
            } else {
                cur--;
            }

            cnt += ds.query(cur - 1);
            ds.update(cur, 1);
        }

        if(cnt > (ll)N * (N + 1) / 2 - cnt){
            hi = mid - 1;
        } else {
            lo = mid + 1;
        }
    }
    cout << lo;
}


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

    if (n < m) {
      System.out.println("0");
    } else {
      System.out.println("10");
    }
  }
}


Measured memory_bytes: 21844
using System;
class Program
{
	static void Main()
	{
	int n = int.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
	int a = int.Parse(Console.ReadLine());
	if((n % 500) <= a)
    {
	Console.WriteLine("Yes");//WriteLineをWriteとすると、改行なしで出力。
    }
      else
      {
      Console.WriteLine("No");  
      }
	}
}


Measured memory_bytes: 13140
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

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

using namespace std;
int main() {
	int a, b;
	cin >> a >> b;

	if (a % 500 > b)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn dfs(max: usize, len: usize, val: &mut Vec<usize>, ans: &mut Vec<Vec<usize>>) {
    if val.len() == len {
        ans.push(val.clone());
        return;
    }
    for i in 0..(max + 2) {
        val.push(i);
        dfs(std::cmp::max(i, max), len, val, ans);
        val.pop();
    }
}

fn run() {
    input! {
        n: usize,
    }
    let mut ans = vec![];
    let mut val = vec![0];
    dfs(0, n, &mut val, &mut ans);
    ans.sort();
    let map: Vec<_> = "abcdefghijk".chars().collect();
    for a in ans {
        let mut out = String::new();
        for a in a {
            out.push(map[a]);
        }
        println!("{}", out);
    }
}

fn main() {
    run();
}


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

public class MainApp
{

	static public void Main()
	{
       
            int[] NM = Arrayint();
            int[] A = Arrayint();
            for(int i = 0; i < NM[1]; i++)
            {
                NM[0] -= A[i]; 
            }
            if(NM[0] < 0)
            {
                NM[0] = -1;
            }
             
            Console.WriteLine(NM[0]);
        

	}


	private static string[] Arraystring()
	{
		return Console.ReadLine().Split(' ');
	}

	private static string Onestring()
	{
		return Console.ReadLine();
	}

	private static int Oneint()
	{
		return int.Parse(Console.ReadLine());
	}

	private static int[] Arrayint()
	{
		return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
	}
}


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

using namespace std;

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

int main(void)
{
    int n;
    cin >> n;
    vec<int> a(n), b(n, 1);
    rep(i, n) cin >> a[i];

    sort(a.begin(), a.end());
    rep(i, n) {
        int p = a[n - 1 - i];
        int lower = (int)(lower_bound(a.begin(), a.end(), p / 2) - a.begin()); 

        if (a[lower] == p / 2 || lower == 0) b[n - 1 - i] = a[lower];
        else {
            if (a[lower] + a[lower - 1] >= p) b[n - 1 - i] = a[lower - 1];
            else b[n - 1 - i] = a[lower];
        }
    }

    cout << a[n - 1] << " " << b[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;

int main(void){
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  vector<P> v(m);
  REP(i, n) cin >> a[i];
  REP(i, m){
    int b, c;
    cin >> b >> c;
    v[i] = P(c, b);
  }
  sort(ALL(a));
  sort(ALLr(v));
  ll ans = 0;
  int j = 0;
  REP(i, m){
    int c = v[i].first;
    int b = v[i].second;
    if(a[j] >= c) break;
    while(j < n && a[j] < c && b > 0){
      ans += c;
      j++;
      b--;
    }
    if(j == n) break;
  }
  while(j < n) ans += a[j++];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <cmath>
#include <cstdio>
#include <algorithm>
#define rg register
#define llint long long
using namespace std;
const int N=1008611;

struct ios
{
	template <typename _tp>
	inline ios operator >> (_tp &x)
	{
		x = 0;int f = 1;char c = getchar();
		for(;c<'0'||c>'9';c=getchar()) if(c=='-') f = -1;
		for(;c<='9'&&c>='0';c=getchar()) x = (x<<1)+(x<<3)+(c^48);
		x *= f;
		return *this;
	}
	template <typename _tp>
	inline ios operator << (_tp x)
	{
		char s[66];int dgt = 0;
		if(x==0) putchar('0');
		if(x<0) putchar('-'),x = -x;
		while(x) ++dgt,s[dgt] = x%10+'0',x/=10;
		while(dgt) putchar(s[dgt]),--dgt;
		return *this;
	}
	inline ios operator << (char x)
	{
		putchar(x);
		return *this;
	}
}io;

int n;

int main()
{
	io >> n;
	io << 3*n*n << '\n';
	return 0;
}

Measured memory_bytes: 128
x = int(input())

flag = False
for i in range(1000, -1, -1):
  #print(i)
  for j in range(i, -1001, -1):
    #print(j)
    if i - j != 0:
      if x % (i - j) == 0:
        y = x / (i - j)
        t = i ** 4 + (i ** 3) * j + (i ** 2) * (j ** 2) + i * (j ** 3) + j ** 4
        if y == t:
          lst = [str(i), str(j)]
          print(' '.join(lst))
          flag = True
          break
    else:
      if x == 0:
        print('0 0')
        flag = True
        break
  if flag:
    break


Measured memory_bytes: 9188
package main

import (
	"fmt"
)

func main() {
	var S, h, m, s int
	fmt.Scan(&S)
	h = S / 3600
	m = S % 3600 / 60
	s = S % 3600 % 60

	fmt.Printf("%d:%d:%d\n", h, m, s)
}



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


int main(){
  int N ;
  cin >> N ; 
  vector<int> A(N) , B(N) , C(N-1) ;
  int cnt = 0 ; 
  
  for(int i = 0 ; i < N ; i++){
    cin >> A[i] ; //どの料理を食べたかがA[i]
    A[i]-- ; 
  }
  
  for(int i = 0 ; i < N ; i++){
    cin >> B[i] ; //料理A[i]を食べた時得られる幸福度
  }
  
  for(int i = 0 ; i < N-1 ; i++){
    cin >> C[i] ; //A[i]のあとにA[i+1]を食べたら得られる幸福度

  }  
  
  
  //cnt = B[0] ; 
  
  for(int i = 0 ; i < N ; i++){
     cnt += B[A[i]] ; 
    
        if(  i > 0 && A[i]  == (A[i-1] +1) ){
        cnt +=  C[A[i-1]] ; 
        }

    
  }
  
  cout << cnt << endl ; 
  
  
}

Measured memory_bytes: 3600
import sys
input = sys.stdin.readline

N,T=map(int,input().split())
M=[list(map(int,input().split())) for i in range(N)]

def compare(x,y):
    if x==0:
        return (1<<31)+y
    else:
        return (y+1)/x

M.sort(key=lambda x:compare(x[0],x[1]))

k=N
for i in range(N):
    if M[i][0]==0:
        k=i
        break

#print(k)

DP=[[T+1]*(k+1) for i in range(30)]
for i in range(k+1):
    DP[0][i]=0

def nexttime(x,a,b):
    return x+1+a*(x+1)+b

for i in range(1,30):
    for j in range(1,k+1):
        nt=nexttime(DP[i-1][j-1],M[j-1][0],M[j-1][1])
        DP[i][j]=min(DP[i][j-1],nt)
ANS=0
for i in range(30):
    TIME=min(DP[i])
    if TIME>T:
        break
    SC=i
    for j in range(k,N):
        if TIME+M[j][1]+1<=T:
            TIME+=M[j][1]+1
            SC+=1
    ANS=max(ANS,SC)

print(ANS)

Measured memory_bytes: 120412
#include <iostream>
#include <cstdio>
#define N 60
using namespace std;

typedef long long ll;
ll n, num, s, M = 1e9 + 7;
char a[2][N];
int main()
{
	ll i;
//	freopen ("input.txt", "r", stdin);
	cin >> n;
	cin >> a[0];
	cin >> a[1];
	for (i = 0; i < n; i++) {
		if (a[0][i] == a[1][i]) {
			if (i == 0) s = 3;
			else if (num == 1) s = (s * 2) % M;
			num = 1;
		} else {
			if (i == 0) s = 6;
			else if (num == 1) s = (s * 2) % M;
			else s = (s * 3) % M;
			num = 2;
			i++;
		}
	}
    cout << s;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;


int main(){

int a,b;
cin >> a >> b;

if(a>2*b)cout << a-2*b << endl;
else if(a <= 2*b) cout << 0 <<  endl;
return 0;
}



Measured memory_bytes: 256
s=input()
a=int(s[0]+s[1])
b=int(s[2]+s[3])

if a > 0 and a < 13:
  if b >0 and b < 13:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if b>0 and b < 13:
    print("YYMM")
  else:
    print("NA")

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<queue>
#include<list>
#include<stack>
#include<cstdio>
#include<fstream>
#include<numeric>
#include<functional>
#include<utility>
#include<memory>
#include <cstring>
#include<bits/stdc++.h>
using namespace std; 
  
#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
 
int main() 
{
	int n;
	cin>>n;
	vector<int> a(n);
	for (int i=0;i<n;i++) cin>>a[i];
	int l=0;
	int r=1;
	int x=a[0];
	int s=a[0];
	ll ans=0;
	while (l<r) 
	{
		while (r<n && x==s) 
		{
			x=x^a[r];
			s=s+a[r];
			r++;
		}
		ans+=r-l-1;
		if (x==s) ans++;
		x=x^a[l];
		s=s-a[l];
		l++;
		if (l==r && r<n) r++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println(180*(n-2));


        sc.close();
    }
}

class io {
    public static void br() {
        System.out.println("");
    }

    public static void yesno(boolean f) {
        System.out.println(f ? "yes" : "no");
    }

    public static void YesNo(boolean f) {
        System.out.println(f ? "Yes" : "No");
    }

    public static void YESNO(boolean f) {
        System.out.println(f ? "YES" : "NO");
    }

}

class Algo {
    public static int nibutan(int target, int[] ar) {
        // ar[i] >= target なる最小のiを探す
        int res;
        int high = ar.length;
        int low = 0;
        while (high > low) {
            res = (high + low) / 2;
            if (ar[res] < target) {
                // ↑↓ここを変える
                low = res + 1;
            } else {
                // ↓ここを変える
                high = res;
            }
        }
        return low;
    }

    public static boolean isOdd(int n) {
        return n % 2 == 1;
    }

    public static boolean isEven(int n) {
        return n % 2 == 0;
    }


}



Measured memory_bytes: 20564
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "trace.h"
#else
#define trace(args...)
#endif

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n; cin >> n;
	vector<int> a(n);
	for (int& e : a) cin >> e;
	ll funds = 1000, stocks = 0;
	for (int i = 0; i < n - 1; i++) {
		stocks = funds / a[i];
	  	funds += max(a[i + 1] - a[i], 0) * stocks;
	}
	cout << funds << endl;
}


Measured memory_bytes: 3640
using System;

namespace csharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine();
            var count = 0;
            for(var i=0; i<a.Length; i++){
                if(a[i] == '-'){
                    count--;
                } else {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11092