akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
    static int count = 0;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] s = new int[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
        }
        
        mergeSort(s, 0, n);
        
        for (int i = 0; i < n - 1; i++) {
            System.out.print(s[i] + " ");
        }
        System.out.println(s[n-1]);
        
        System.out.println(count);
    }
    
    static void mergeSort(int[] a, int left, int right) {
        if (left + 1 < right) {
            int mid = (left + right) / 2;
            
            mergeSort(a, left, mid);
            mergeSort(a, mid, right);
            
            merge(a, left, mid, right);
        }
    }
    
    static void merge(int[] a, int left, int mid, int right) {
//        U.println("l: " + left + ", r: " + right);
//        UArr.printArr(a);
        int n1 = mid - left;
        int n2 = right - mid;
        int[] aL = new int[n1 + 1];
        int[] aR = new int[n2 + 1];
        for (int i = 0; i < n1; i++) {
            aL[i] = a[left + i];
        }
        for (int i = 0; i < n2; i++) {
            aR[i] = a[mid + i];
        }
        
        aL[n1] = Integer.MAX_VALUE;
        aR[n2] = Integer.MAX_VALUE;
        
        int i = 0;
        int j = 0;
        for (int k = left; k < right; k++) {
            count++;
            if (aL[i] <= aR[j]) {
                a[k] = aL[i];
                i++;
            } else {
                a[k] = aR[j];
                j++;
            }
        }
//        UArr.printArr(a);
//        U.println();
    }
}



Measured memory_bytes: 166264
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define  fo(i,a,b) for(ll i=a;i<b;i++)
#define rfo(i,a,b) for(ll i=a;i>=b;i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)

#define err() cout<<"----------"<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define pb push_back
#define deb(x) cout<< #x << " = "<<x<<endl;
#define F first
#define S second
#define MP make_pair
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589
const ll MOD=1e9+7;
ll mod(ll x)
{
   return (x%MOD+MOD)%MOD;
   // works for neg and pos values of x.
}
void solve()
{
    ll n;
    cin>>n;
    ll a[n];
    fo(i,0,n)
    {
        cin>>a[i];
    }
    ll ans=0;
    fo(i,1,n)
    {
        if(a[i]<a[i-1])
        {
            ans+=abs(a[i]-a[i-1]);
            a[i]=a[i-1];
        }
    }
    cout<<ans;
}
int main()
{

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
//  clock_t time_req;
//  time_req = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }

// time_req = clock()-time_req;
//  cout<<"Time taken: "<<(float)time_req/CLOCKS_PER_SEC<<"s"<<endl;

    return 0;
}

Measured memory_bytes: 5212
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	bool west=false,north=false,east=false,south=false;
	bool afuera=true;
	cin >> s;
	for (int i = 0; i < s.size(); ++i){
		if(s[i]=='W')
			west=true;
		if(s[i]=='N')
			north=true;
		if(s[i]=='E')
			east=true;
		if(s[i]=='S')
			south=true;
	}
	if((west && !east)||(east && !west)){
		afuera=false;
	}
	if((north && !south)||(!north && south)){
		afuera=false;
	}
	if(afuera){
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
int ans[5];

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    string s;
    cin >> s;
    if(s[0] == 'M')ans[0]++;
    else if(s[0] == 'A')ans[1]++;
    else if(s[0] == 'R')ans[2]++;
    else if(s[0] == 'C')ans[3]++;
    else if(s[0] == 'H')ans[4]++;
  }
  ll sum = 0;
  ll ssum = 0;
  ll tsum = 0;
  for(int i = 0; i < 5; i++){
    sum += ans[i];
    ssum += (ll)ans[i] * ans[i];
    tsum += (ll)ans[i] * ans[i] * ans[i];
  }
  ll res = (sum * sum * sum + 2 * tsum - 3 * ssum * sum) / 6;
  cout << res << endl;
	return 0;
}


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

const ll mod = 1000000007;

int main() {
  ll n, k;
  cin >> n >> k;
  
  ll res = 0;
  for (ll i = k; i <= n + 1; i++) {
    ll min = (i * (i - 1)) / 2;
    ll max = (i * (2 * n - i + 1)) / 2;
    res += max - min + 1;
  }  
  
  if (res >= mod)
    cout << res % mod << endl;
  else
    cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define yes "Yes\n"
#define no "No\n"
//int m,n;
//int i,j,k,l;
//int a,b,c,d,e,f,g;
//int sum,total;
//long long int ;
//float ;
//double ;
//char a[101],b[101],s[101],t[101],u[101];
char s[10001],alp[53];
int n,i,j,k;
int main(void){
    scanf("%d %s",&n,s);
    alp[0]='A';
    for (size_t i = 0; i < 26; i++)
    {
        alp[i+1]=alp[i]+1;
    }
    alp[26]='A';
    for (size_t i = 26; i < 52; i++)
    {
        alp[i+1]=alp[i]+1;
    }

    for (i = 0; i < strlen(s); i++)
    {
        for (j = 0; j < 26; j++)
        {
            if (s[i]==alp[j])
            {
                printf("%c",alp[j+n]);
                break;
            }            
        }
    }
    printf("\n");
    
    
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

long n, ans;

int main() {
    scanf("%ld", &n);
    ans = 0;

    for ( int i = 1; i <= sqrt(n); i++ ) {
        if ( n % i == 0 and n / i - 1 > i ) {
            ans += n / i - 1;
        }
    }
    
    printf("%ld\n", ans);
}

Measured memory_bytes: 256
# #!/usr/bin/env python3
# # -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = list(map(int, input().split()))

    result = []
    for i, a in enumerate(A, start=1):
        result.append([i, a])
    result = sorted(result, key=lambda x: x[1])

    print(*[i for i, a in result])


if __name__ == "__main__":
    main()


Measured memory_bytes: 23032
#include<bits/stdc++.h>
using namespace std;
int main(){
  int intager[100]={0};
  int num;
  while(cin>>num)
    intager[num-1]++;
  int flag=0;
  for(int i=100;i>0;i--){
    for(int j=0;j<100;j++){
      if(intager[j]==i){
	cout<<j+1<<endl;
	flag=1;
      }
    }
    if(flag==1)
      break;
  }
  return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	cout << (a + b) % 24 << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef bool boool;
typedef long long ll;
#define vl vector<ll>
#define vb vector<boool>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll, ll>>>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define rep1(i, n) for (long long i=0; i<(long long)(n); i++)
#define rep2(i, s, e) for (long long i=(s); i<(long long)(e); i++)
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

long long gcd(long long a, long long b) {
    if (b == 0){
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int main() {
    int n;
    cin >> n;
    vector<bool> vec(1000001, false);
    bool pa = true;
    bool se = true;
    vector<int> v(n);
    rep(i, n){
        int num;
        cin >> num;
        v[i] = num;
        if(num != 1 && vec[num]) pa = false;
        else vec[num] = true;
    }
    rep(i, 2, 1000001){
        bool already = false;
        rep(j, 1, 1000001){
            if(i*j > 1000001) break;
            if(vec[i*j]){
                if(already) pa = false;
                else already = true;
            }
        }
    }
    if(pa) cout << "pairwise coprime" << endl;
    else{
        int num = v[0];
        rep(i, n) num = gcd(num, v[i]);
        if(num == 1) cout << "setwise coprime" << endl;
        else cout << "not coprime" << endl;
    }

    return 0;
}

Measured memory_bytes: 7196
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <stack>
int main(){
    std::string str;
    std::cin >> str;
    long long cnt = 0;
    std::stack<char> stk;
    for(auto it : str){
        if (stk.empty()){
            stk.push(it);
        }else {
            if (stk.top() != it){
                stk.pop();
                cnt += 2;
            }else {
                stk.push(it);
            }
        }
    }
    std::cout << cnt;
}

Measured memory_bytes: 512
#!/usr/bin/env python3
n = int(input())
a = list(map(int,input().split()))
# sum(|a|)がmaxでこれを実現できないケースは負の数が連続で奇数個並んでいる箇所がある時
# その時は両端とその隣の正の数の４つの中で絶対値がminのものを負にするとOK
# 例外は負の数が連続で奇数個並んでいる箇所が１つ間に正を挟んで並んでいる時
# この考えだと簡単に言い換えできない。解説をみるとtotalの負の数が偶数なら全部せいにできる
s = sum([abs(i) for i in a])
if len([i for i in a if i < 0]) % 2 == 0:
  print(s)
else:
  print(s-2*min([abs(i) for i in a]))


Measured memory_bytes: 66644
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());
		long[] dam = new long[N];
		long diff = 0;
		for (int i = 0; i < N; i++) {
			dam[i] = 2 * (Integer.parseInt(sc.next()));

				diff = dam[i] - diff;

		}
		long a = diff / 2;
		long tmp = a;
		System.out.print(a);
		for (int i = 0; i < N-1; i++) {
			tmp = dam[i] - tmp;
			System.out.print(" " + tmp);
		}

		sc.close();

	}
}


Measured memory_bytes: 52660
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
long modding = pow(10, 9) + 7;

ll saisyo(int n){
  if(n==0)
    return 1;
  ll x = saisyo(n / 2);
  x %= modding;
  x *= x;
  x %= modding;
  if(n%2==1) x*=2;
  x %= modding;
  return x;
} 

ll modpow(ll a,ll n){
    ll res = 1;
    while(n > 0){
        if(n&1) res = res * a % modding;
        a = a * a % modding;
        n >>= 1;
    }
    return res;
}

ll modinv(ll x){
    return modpow(x,modding-2);
}
 
long comb(ll   n,ll a){
  ll  x = 1, y = 1;
  rep(i,a){
    x *= (n - i);
    y *= i+1;
    x %= modding;
    y %= modding;
  }

  return x*modinv(y)%modding;
}
int main (){
  long n, a, b;
  cin >> n >> a >> b;
  long ans = saisyo(n);
  ans -= 1;
  ans -= comb(n, a);
  ans -= comb(n, b);
  ans %= modding;
  while(ans<0)
    ans += modding;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.substring(2,3).equals(s.substring(3,4))
                && s.substring(4,5).equals(s.substring(5,6))){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
long long x,r,d;
int main()
{
	scanf("%lld%lld%lld",&r,&d,&x);
	for(int i=1;i<=10;i++)
	{
		x=r*x-d;
		printf("%lld\n",x);
	}
	return 0;
}

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

static const int MAX_N = 1000001;

int main()
{

	int n, a, min = MAX_N, max = -MAX_N;
	long long sum = 0;

	scanf( "%d", &n );
	for( int i = 0; i < n; i++ ) {

		scanf( "%d", &a );
		if( a < min ) min = a;
		if( a > max ) max = a;

		sum += a;

	}

	printf( "%d %d %ld\n", min, max, sum );

	return 0;

}

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

using namespace std;

const int N=1e5+7,MOD=1e9+7;

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

typedef long long ll;

int u,v,p,d,n,tc,q,k,l,r,c,m,b[N],cnt,curr,a[N],ans;

ll calc[N];

bool sum[N],bad[N];

char s[N];
bool ok(int x){
	return (x>=0&&!bad[x]);
}
int main()
{	
	scanf("%d %d",&n,&m);
 	for(int i=0,x;i<m;i++){
 		scanf("%d",&x);
 		bad[x]=1;
 	}
 	calc[0]=1;
 
 	for(int i=1;i<=n;i++){
 		if(ok(i-1)){
 			calc[i]+=calc[i-1];
 			calc[i]%=MOD;
 		}
 		if(ok(i-2)){
 			calc[i]+=calc[i-2];
 			calc[i]%=MOD;
 		}
 	}
 
 	printf("%lld\n",calc[n] );
 
 
}

Measured memory_bytes: 1152
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int N, D[1 << 18], S;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> D[i];
	for (int i = 1; i <= N; i++) {
		for (int j = i + 1; j <= N; j++) S += D[i] * D[j];
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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;
}

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

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

const int MAX = 1010101;

long long fac[MAX], finv[MAX], inv[MAX];

void binom_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long binom(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long perm(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * finv[n - k] % MOD;
}

long long modinv(long long a) {
  long long b = MOD, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= MOD;
  if (u < 0) u += MOD;
  return u;
}

ll N;
vector<ll> Graph[201010];
ll dp[201010];
ll nodes_cnt[201010];

void dfs(ll root, ll par) {
  for (auto e : Graph[root]) {
    if (e == par) continue;

    dfs(e, root);
    nodes_cnt[root] += nodes_cnt[e];
    dp[root] *= dp[e] * binom(nodes_cnt[root], nodes_cnt[e]) % MOD;
    dp[root] %= MOD;
  }

  ++nodes_cnt[root];
}

ll dp2[201010];

void dfs2(ll root, ll from) {
  ll dppar = dp2[from];
  dppar *= modinv(dp[root] * binom(N - 1, nodes_cnt[root]));
  dppar %= MOD;
  dp2[root] = dp[root] * dppar % MOD * binom(N - 1, nodes_cnt[root] - 1) % MOD;
  for (auto e : Graph[root]) {
    if (e == from) continue;

    dfs2(e, root);
  }
}

int main() {
  binom_init();
  cin >> N;
  rep(i, 0, N - 1) {
    ll a, b;
    cin >> a >> b;
    Graph[a].push_back(b);
    Graph[b].push_back(a);
  }

  repe(i, 1, N) { dp[i] = 1; }

  dfs(1, -1);

  dp2[1] = dp[1];
  for (auto e : Graph[1]) {
    dfs2(e, 1);
  }

  repe(i, 1, N) { cout << dp2[i] << endl; }
}


Measured memory_bytes: 44076
#include <iostream>
#include <cstdio>
using namespace std;
#define N 200010

typedef unsigned long long i64;
i64 n, X, x[N], sum[N], Ans = 1LL << 62;

int main(){
    cin >> n >> X;
    for (int i = 1; i <= n; i++){
        i64 tmp;
        cin >> tmp;
        sum[i] = sum[i-1] + tmp;
    }
    for (int k=1; k <= n; k++){
        //throw energy
        i64 energy = (i64)k*(i64)X;
        for (int i=0; i <= n/k; i++){

            int weight = i == 0 ? 5 : 5 + 2*(i - 1);
            int M = n - i*k;
            int m = (M - k) >= 0LL ? M - k : 0;
            energy += (i64)weight * (sum[M]-sum[m]);
            if (energy < 0) break;
            //printf("%d,%d,,M%d,m%d,sum[M]-sum[m]%llu\n",k,weight,M,m, sum[M]-sum[m]);
        }
        energy += n*X;
        if (Ans >= energy){
            Ans = energy;
        }
    }
    cout << Ans << endl;
}

Measured memory_bytes: 1792
n = int(input())
x = [0]*8
y = [0]*8
for i in range(n):

    x[i],y[i] = map(int,input().split())

sum = 0
for i in range(n):
    for j in range(n):
        if i != j:
            sum += pow(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2),0.5)
            
sum = sum / (n * (n - 1)) * (n - 1)
print(sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
long long digits(long long n){
    long long result=0;
    while(n>0){
        result++;
        n/=10;
    }
    return result;
}
int main() {
    ll n;
    cin >> n;
    ll ans=0;
    for(ll i=1;i<=n;i++){
        if(digits(i)&1)ans++;
        else continue;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> vec(101);
  
  int N;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int d;
    cin >> d;
    vec.at(d) = 1;
  }
  
  int x = 0;
  for (int i = 0; i < 101; i++) {
    
    x += vec.at(i);
  }
  
  cout << x << endl;
  
}

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

#define ff                   first
#define ss                   second
#define endl                 '\n'
#define ll                   long long int
#define pii                  pair<int,int>
#define mp                   make_pair<int,int>
#define pb                   push_back
#define rep(i,a,b)           for(int i=a;i<b;i++)
#define t(x)                 int t; cin>>t; while(t--)
#define vi                   vector<int>
#define mii                  map<int,int>
#define min3(a, b, c)        min(min(a, b), c)
#define min4(a, b, c, d)     min(min(a, b), min(c, d))
#define max3(a, b, c)        max(max(a, b), c)
#define max4(a, b, c, d)     max(max(a, b), max(c, d))
#define ps(x,y)              fixed<<setprecision(y)<<x
#define setbits(x)           __builtin_popcountll(x)
#define zrobits(x)           __builtin_ctzll(x)
#define mod                  1000000007
#define all(x)               x.begin(),x.end()
#define FIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                      rng(chrono::steady_clock::now().time_since_epoch().count());


bool isPrime(int n)
{
	if (n <= 1)  return false;
	if (n <= 3)  return true;
	if (n % 2 == 0 || n % 3 == 0) return false;

	for (int i = 5; i * i <= n; i = i + 6)
		if (n % i == 0 || n % (i + 2) == 0)
			return false;

	return true;
}



int main()
{
	FIO;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	double d, t, s;
	cin >> d >> t >> s;
	if (d / s <= t)
		cout << "Yes";
	else
		cout << "No";

}


Measured memory_bytes: 3764
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
	int a,b;
    cin>>a>>b;
    int s1=a+b;
    int s2=a;
    s2+=(a-1);
    int s3=b;
    s3+=(b-1);
    cout<<max(s1,max(s2,s3))<<endl;
}
int32_t main(){
  IOS;
  solve();
  //debug();
 #ifdef LOCAL_DEFINE
 cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
 #endif	
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int m, n;
char flag[1100][1010];
char emblem[3][3];
bool g(int i, int j) {
	if (flag[i][j] == emblem[0][0])
		if (flag[i + 1][j] == emblem[1][0])
			if (flag[i][j + 1] == emblem[0][1])
				if (flag[i + 1][j + 1] == emblem[1][1])
					return true;
	return false;
}
int f() {
	int sum = 0;
	for (int i = 1; i < m; i++) {
		for (int j = 1; j < n; j++) {
			if (g(i, j))sum++;
		}
	}
	return sum;
}
int g1(int i,int j) {
	int cnt = 0;
	if (i > 1) {
		if (j > 1)cnt += g(i - 1, j - 1);
		cnt += g(i - 1, j);
	}
	if (j > 1)cnt += g(i, j - 1);
	cnt += g(i, j);
	return cnt;
}
int main() {
	cin >> m >> n;
	for (int i = 1; i <= m; i++)for (int j = 1; j <= n; j++)cin >> flag[i][j];
	for (int i = 0; i < 2; i++)for (int j = 0; j < 2; j++)cin >> emblem[i][j];
	int ans = f();
	int ans1 = ans;
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			int a = g1(i, j);
			int b = g1(i, j);
			char ch = flag[i][j];
			flag[i][j] = 'J';
			b = max(b, g1(i, j));
			flag[i][j] = 'O';
			b = max(b, g1(i, j));
			flag[i][j] = 'I';
			b = max(b, g1(i, j));
			flag[i][j] = ch;
			if (b > a)ans1 = max(ans1, ans + b - a);
		}
	}
	cout << ans1 << endl;
}


Measured memory_bytes: 4080
from functools import lru_cache
import sys
mod=1000000007

n,k=[int(i) for i in input().split(" ")]

facts=[1 for i in range(n+k+1)]

for i in range(1,n+k+1):
    facts[i]=i*facts[i-1]

@lru_cache()
def combination(i,j):
    return facts[i]//(facts[j]*facts[i-j])

if n>k:
    print(0)
    sys.exit()


print(combination(k,n)%mod)



Measured memory_bytes: 8536
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>
// 多倍長整数型
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */
 
#define INF 1e9
#define LINF 1e18
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
     
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
     
const ll MOD = 1e9 + 7;
const ll ZER = 0;


ll dp[100010][15];
int main(){
  int k;
  cin >> k;
  ll rem = 0;
  rep(i, k){
    rem = (10 * rem + 7) % k;
    if(rem == 0){
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}
 

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

int main(){
	int in,a,b,ans=0,time=0;
	cin >> in;
	for(int loop=0;loop<in;loop++){
		cin >> a >> b;
		if(a==b)time++;
		else time=0;
		if(time>=3){
			ans=1;
			break;
		}
	}
	if(ans){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader s = new FastReader();
        String s1=s.next();
        System.out.println(s1.substring(0,3));
    }

    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

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

int main() {
    int N, ans=0;
    string s;
    cin >> s;
    bool flag=false;

    if(s[0]=='7' || s[1]=='7' || s[2]=='7')
	flag=true;
    

    cout << (flag ? "Yes": "No") << endl;
} 




Measured memory_bytes: 3624
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    
    A.sort()
    B.sort()
    C.sort()
    
    A_cand = [0 for i in range(N)]
    B_cand = [0 for i in range(N)]
    
    skip_loop = 0
    for i in range(N):
        cnt = skip_loop
        for j in range(N-skip_loop):
            if B[N-i-1] < C[N-skip_loop-j-1]:
                cnt += 1
            else:
                break
        B_cand[N-i-1] = cnt
        skip_loop = cnt
    
    skip_loop = 0
    ans = 0
    pre_loop_ans = 0
    for i in range(N):
        cnt = skip_loop
        ans += pre_loop_ans
        for j in range(N-skip_loop):
            if A[N-i-1] < B[N-skip_loop-j-1]:
                ans += B_cand[N-skip_loop-j-1]
                pre_loop_ans += B_cand[N-skip_loop-j-1]
                cnt += 1
            else:
                break
        A_cand[N-i-1] = cnt
        skip_loop = cnt
    print(ans)
    
 
solve()

Measured memory_bytes: 23032
import math


class ConvexHull:
    """凸包に関する各種性質を求める"""
    def __init__(self, ps):
        self.n = len(ps)
        self.ps = sorted(ps)
        self.qs = []

        # 下側凸包の構築
        for p in self.ps:
            while len(self.qs) > 1 and self._ccw(self.qs[-2], self.qs[-1], p) < 0:
               self.qs.pop()
            self.qs.append(p)
        t = len(self.qs)

        # 上側凸包の構築
        for i in range(self.n - 2, -1, -1):
            p = self.ps[i]
            while len(self.qs) > 1 and self._ccw(self.qs[-2], self.qs[-1], p) < 0:
               self.qs.pop()
            self.qs.append(p)

    def _ccw(self, p1, p2, p3):
        """p1 -> p2 -> p3と頂点を移動したときの回転方向を返す。
        反時計回り -> +1、時計回り -> -1、0°もしくは180°回る -> 0
        """
        p2 = [p2[i] - p1[i] for i in range(2)]
        p3 = [p3[i] - p1[i] for i in range(2)]
        if p2[0] * p3[1] == p2[1] * p3[0]:
            return 0
        if p2[0] * p3[1] - p2[1] * p3[0] > 0:
            return +1
        else:
            return -1

    def get_ps(self):
        """凸包の頂点組を反時計回り順で求める（GrahamScan）。"""
        return self.qs


def get_theta(o, a, b):
    a = [a[i] - o[i] for i in range(2)]
    b = [b[i] - o[i] for i in range(2)]
    len_a = (a[0] ** 2 + a[1] ** 2) ** 0.5
    len_b = (b[0] ** 2 + b[1] ** 2) ** 0.5
    ab = a[0] * b[0] + a[1] * b[1]
    return 180 - math.degrees(math.acos(ab / len_a / len_b))


n = int(input())
info = [list(map(int, input().split())) for i in range(n)]

to_ind = {}
for i in range(n):
    to_ind[tuple(info[i])] = i

gs = ConvexHull(info)
ps = gs.get_ps()[:-1]
m = len(ps)

ans = [0.0] * n 
for i in range(m):
    ind = to_ind[tuple(ps[i])]
    ans[ind] = get_theta(ps[i], ps[(i - 1) % m], ps[(i + 1) % m]) / 360

for res in ans:
    print(res)

Measured memory_bytes: 38320
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
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;}

bool comp(pair<ll,ll> l, pair<ll,ll> r){
	return l.first+l.second > r.first+r.second;
}

int main(){
	int n;
	cin >> n;
	vector<pair<ll,ll>> dish(n);
	REP(i,n) cin >> dish[i].first >> dish[i].second;
	sort(dish.begin(), dish.end(), comp);
	
	ll taka=0,ao=0;
	REP(i,n){
		if(i%2==0){
			taka += dish[i].first;
		}else{
			ao += dish[i].second;
		}
	}
	
	cout << taka - ao << endl;
	
	
	return 0;
}

Measured memory_bytes: 4744
import collections
import itertools
import numpy as np
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

A,B,C,D = [i for i in S()]
s = A
l = [B,C,D]
for i in range(1 << len(l)):
	num = int(A)
	data = []
	for j in range(len(l)):
		if ((i >> j) & 1) == 1:
			num += int(l[j])
		else:
			num -= int(l[j])
	if num == 7:
		for j in range(len(l)):
			if ((i >> j) & 1) == 1:
				s += "+"+l[j]
			else:
				s += "-"+l[j]
		else:
			print(s+"=7")
			exit()

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

using namespace std;
typedef long long ll;

int main() {
  ll N; cin >> N;
  ll A; cin >> A;
  ll B; cin >> B;
  ll C; cin >> C;
  ll D; cin >> D;
  string S; cin >> S;
  bool jumpable = false;
  ll cnt = 0;
  for (ll j=B-2; j < D+1; ++j) {
    if (S[j] == '.') {
      cnt += 1;
      if (cnt >= 3) {
        jumpable = true;
        break;
      }
    } else {
      cnt = 0;
    }
  }
  bool sunuke = false, funuke = false;
  ll j;
  for (j=A-1; j < C-1; ++j) {
    if (S[j+1]=='#' && S[j+2]=='#') {
      break;
    }
  }
  if (j == C-1) sunuke = true;
  if (C > D && !jumpable) sunuke = false;
  for (j=B-1; j < D-1; ++j) {
    if (S[j+1]=='#' && S[j+2]=='#') {
      break;
    }
  }
  if (j == D-1) funuke = true;
  cout << (sunuke && funuke ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int l, r, d;
	cin >> l >> r >> d;
	int cnt = 0;
	rep(i, l, r)
	{
		if (i % d == 0)
			cnt++;
	}

	cout << cnt << en;

	return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  LL cnt = 0;
  for (int r = 0; r * R <= N; r++) {
    for (int g = 0; g * G <= N; g++) {
      int b = N - r * R - g * G;
      if (b>=0 && b%B==0){
        ++cnt;
        // DUMP(r, g, b, cnt);
      }
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		Stack<Integer> stack = new Stack<Integer>();
//		int regularAns = 0;
//		boolean flying = false;
//		boolean start = false;
		boolean inOrder = true;
		for(int i = 0; i < n; i++){
			String input = br.readLine();
			if(input.equals("A")){
				stack.push(1);
//				start = true;
			}
//			else if(!start && input.equals("Un")){
//				flying = true;
//				break;
//			}
//			else if(!stack.isEmpty() && input.equals("Un")){
			else{
				if(stack.isEmpty()){
					inOrder = false;
					break;
				}
				stack.pop();
//				regularAns++;
			}
		}
		
		if(stack.isEmpty() && inOrder){
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		}
	}

}

Measured memory_bytes: 24440
//嘘っぽいのに通ってたやつでいこう

#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

char cn[100000], *ci = cn, c;
const char* owa = cn + 100000;
inline char getcha() {
	if (ci == owa) {
		fread(cn, 1, 100000, stdin);
		ci = cn;
	}
	return *ci++;
}

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


	fread(cn, 1, 100000, stdin);
	int N = 0;
	while ((c = getcha()) >= '0') N = N * 10 + c - '0';
	int sL[1001] = {}, sR[1001] = {};
	pair<int, int> RR[500], LL[500];
	int rr = 0, ll = 0;
	int tot = 0;
	rep(i, N) {
		int l = 0, r = 0;
		while ((c = getcha()) >= '(') {
			if (c == '(') r++;
			else {
				if (r > 0) r--;
				else l++;
			}
		}
		tot += r - l;
		if (l < r) {
			if (l <= 1000) sR[l] += r;
			else RR[rr++] = { l,r };
		}
		else {
			if (r <= 1000) sL[r] += l;
			else LL[ll++] = { r,l };
		}
	}

	if (tot != 0) {
		printf("No");
		return 0;
	}

	sort(RR, RR + rr);
	sort(LL, LL + ll);

	int OK = 1;
	int k = 0;
	rep(i, 1001) {
		if (sR[i]) {
			if (k < i) OK = 0;
			k += sR[i];
		}
	}
	rep(i, rr) {
		if (k < RR[i].first) OK = 0;
		k += RR[i].second - RR[i].first;
	}
	k = 0;
	rep(i, 1001) {
		if (sL[i]) {
			if (k < i) OK = 0;
			k += sL[i];
		}
	}
	rep(i, ll) {
		if (k < LL[i].first) {
			OK = 0;
		}
		k += LL[i].second - LL[i].first;
	}

	if (OK) printf("Yes");
	else printf("No");

	Would you please return 0;
}

Measured memory_bytes: 3212
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;
typedef pair<int,int> P;

int main()
{

    int H,W;
    cin >> H >> W;

    string S[2010];
    REP(i,H){
    	cin >> S[i];
    }

    int hol[2010][2010];
    int ver[2010][2010];

    REP(i,H){
    	int count=0;
    	REP(j,W){
    		if(S[i][j]=='#'){
    			if(count!=0){
    				REP(k,count) hol[i][j-k-1] = count;
    			}
    			count = 0;
    		}else{
    			count ++;
    		}

    		if(j==W-1 && count!=0){
				REP(k,count) hol[i][j-k] = count;
			}

    	}
    }

    REP(j,W){
    	int count=0;
    	REP(i,H){
    		if(S[i][j]=='#'){
    			if(count!=0){
    				REP(k,count) ver[i-k-1][j] = count;
    			}
    			count = 0;
    		}else{
    			count ++;
    		}

    		if(i==H-1 && count!=0){
    			REP(k,count) ver[i-k][j] = count;
    		}
    	}
    }

    int ans=0;
    REP(i,H){
    	REP(j,W){
    		if(S[i][j]!='#'){
    			ans = max(ans,hol[i][j]+ver[i][j]-1);
    		}
    	}
    }

    cout << ans << endl;

}


Measured memory_bytes: 35840
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int p=1,i,n,t;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&t);
		if(t%2==0)
		{
			if(t%3!=0&&t%5!=0)
			p=0;
		}
	}
	if(p)
	printf("APPROVED");
	else
	printf("DENIED");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
ll ans=INF;	ll h,w,k;	char ch[12][1010];
bool cut[12];
void cal(){
	vector<ll>sum1(12);
	for(ll i=0;i<12;i++){
		sum1[i]=0;
	}
	ll cut2=0;
	ll cut3=0;
	for(ll i=0;i<h-1;i++){
		if(cut[i]){
			cut3++;
		}
	}
	for(ll i=0;i<w;i++){
		ll cnt=0;
		vector<ll>sum2;
		for(ll j=0;j<h;j++){
			if(ch[j][i]=='1'){
				cnt++;
			}
			if(cut[j]==1||j==h-1){
				sum2.push_back(cnt);
				if(cnt>k){
					return ;
				}
				cnt=0;
			}
//		cout << cnt<<endl;			
		}
		bool ch2=true;
		for(ll j=0;j<sum2.size();j++){
			if(sum2[j]+sum1[j]>k){
				ch2=false;
			}
		}
		if(ch2){
			for(ll j=0;j<sum2.size();j++){
				sum1[j]+=sum2[j];
			}
		}
		else{
			cut2++;
			for(ll j=0;j<sum2.size();j++){
				sum1[j]=sum2[j];
			}
		}
	}
//	cout <<cut2<<" "<<cut3-1<<endl;
	ans=min(cut2+cut3,ans);
}
void dep(ll now){
	if(now==h-1){
		cal();
		return ;
	}
	cut[now]=1;dep(now+1);
	cut[now]=0;dep(now+1);
}
int main() {
	cin>>h>>w>>k;
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			cin>>ch[i][j];
		}
	}
//	cout << ch[0][0]<<endl;
	dep(0);
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x real()
#define y imag()
using namespace std;
typedef complex <double> point;
 
point cal(point a){
  point b=(a*conj(a))/abs(a);
  b.y+=1;
  b=(b*a)/abs(a);
  return b;
}
 
int main(){
  while(1){
    int n;
    cin>>n;
    if(n==-1)break;
    point ans=point(1,0);
    for(int i=1;i<n;i++) ans=cal(ans);
    printf("%lf\n",ans.x);
    printf("%lf\n",ans.y);
  }
  return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int k, a, b;

int main() {
    scanf("%d %d %d", &k, &a, &b);
    for (int i = k; i <= b; i += k) {
        if (i >= a) {
            printf("OK\n");
            return 0;
        }
    }
    printf("NG\n");
    return 0;
}

Measured memory_bytes: 3760
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-10;
const vi emp;

int H,W;
ll ans=0;
vi h,w;

int main(){
	cin>>W>>H;
	w=vi(W);
	h=vi(H);
	for(auto i=w.begin();i!=w.end();i++) cin>>*i;
	for(auto i=h.begin();i!=h.end();i++) cin>>*i;
	sort(w.begin(),w.end());
	sort(h.begin(),h.end());
	for(auto i=w.begin();i!=w.end();i++){
		ans+=(ll)(h.end()-lower_bound(h.begin(),h.end(),*i)+1)**i;
	}
	for(auto i=h.begin();i!=h.end();i++){
		ans+=(ll)(w.end()-upper_bound(w.begin(),w.end(),*i)+1)**i;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long S = sc.nextLong();
		long C = sc.nextLong();
		long scc = 0;
		if (S * 2 <= C) {
			scc += S;
			C -= S * 2;
		} else if (C >= 2) {
			scc += C / 2;
			C = C % 2;
		}
		if (C >= 4) {
			scc += C / 4;
		}
		System.out.println(scc);
	}

}

Measured memory_bytes: 21716
#include <algorithm>
#include <iostream>
#include <cstring>
#include <complex>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <vector>  
#include <string>
#include <cmath>
#include <ctime>
#include <queue>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <ext/pb_ds/assoc_container.hpp>    // PBDS
#include <ext/pb_ds/tree_policy.hpp>      // PBDS

using namespace std;
using namespace __gnu_pbds;                 // PBDS

/* typedef starts */

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> PBDS_INT;               // PBDS for int
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> PBDS_LL;    // PBDS for long long

/* typedef ends */

/* macro starts */

#define PI acos(-1)
#define EPS 1e-9
#define INF ll(1e9 + 7)
#define fastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define sinD(degree) sin((degree * PI) / 180.0)
#define cosD(degree) cos((degree * PI) / 180.0)
#define tanD(degree) tan((degree * PI) / 180.0)
#define cotD(degree) (1.0 / tanD(degree))
#define secD(degree) (1.0 / cosD(degree))
#define cosecD(degree) (1.0 / sinD(degree))
#define asinD(value) (asin(value) * 180.0) / PI
#define acosD(value) (acos(value) * 180.0) / PI
#define atanD(value) (atan(value) * 180.0) / PI
#define forn(i,n) for(int i=0;i<n;i++)
#define value_at_index(x) find_by_order(x)
#define index_of(x) order_of_key(x)
#define pb push_back
#define set0(add) memset(add,0,sizeof(add))
#define max(a,b) a>b ? a : b
#define forr(i,a,b) for(int i=a;i<b;i++)

/* macro ends */

/* function starts */

/// calculates n-th (0-based) Gray Code
template<typename dataType>
dataType nthGrayCode(dataType n)
{
    return (n ^ (n >> 1));
}

/// generates all possible subsets for the given set
//template<typename dataType>
// void generateAllSubset(vector<dataType> &data)
// {
//     int i, j, n;
//     n = data.size();

//     for (i = 0; i < (1 << n); i++) {
//         for (j = 0; j < n; j++) {
//             if (i & (1 << j)) {
//                 cout << data[j] << " ";
//             }
//         }
//         cout << "\n";
//     }
// }


void swap(ll a, ll b){
	ll temp;
	temp=a;
	a=b;
	b=temp;
}


int dp[2005];

int dp_a(int n){
  if(n==0)return 0;
  if(n<3)return -1;
  if(dp[n]!=0)return dp[n];
  ll ans=0;
  forr(i,3,n){
    ll val=(dp_a(n-i))%INF;

    //cout << n << " ";
    if(val!=-1){
      ans=(ans+(val+1)%INF)%INF;
    }
  }
  return dp[n]=ans;
}
  
void solve(){
 ll n;
 cin >> n;
 set0(dp);
 ll v=dp_a(n);
 cout << v+1 << endl;
}






int main()
{
  #ifndef ONLINE_JUDGE
       freopen("in.txt", "r", stdin);
       freopen("out.txt", "w", stdout);
  #endif
  fastIO;
    int t=1;
   // cin >> t;
    while(t--){
     solve();
    }
    return 0;
    }

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  ll n;
  cin >> n;
  string s,t;
  cin >> s >> t;
  string u="";
  for(int i=0;i<n;i++){
    u +=s[i];
    u +=t[i];
  }
  cout << u << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL               long long
#define PB               push_back
using namespace std;
int main(){
    string s; cin>>s;
    int c=0,ans=INT_MAX;
    vector <int>v;
    for (int i=0;i<s.length();i++){
        if (s[i]=='R') c++;
        else {
            v.PB(c);
            c=0;
        }
    }
    
    if (s[s.length()-1]=='R')v.PB(c);
    sort(v.begin(),v.end());
    cout<<v[upper_bound(v.begin(),v.end(),0)-v.begin()]<<'\n';
}


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

int main(){
	string S;
	cin >> S;
	string One = "Sunny";
	string Two = "Cloudy";
	string Three = "Rainy";
	if (S == One) {
		cout << Two;
	}
	else if (S == Two) {
		cout << Three;
	}
	else if (S == Three) {
		cout << One;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)
#define inf 1000000321
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}



int main(){
    int N;
    cin >> N;
    int K;
    cin >> K;
    vector<int> H(N);
    for(int i = 0;i < N;i++){
        cin >> H[i];
    }
    vector<int> dp(N+K+2,inf);
    dp[0] =0;
    for(int i = 0;i < N;i++){
        for(int k = 1;k <= K;k++){

            dp[i+k] = min(dp[i] + abs(H[i] - H[i+k]),dp[i+k]);
        }
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

using ll = long long;
const ll mod = 100000000+7;
const ll MAX_N = 100000;

ll n,ans,x,y,z;
ll a[MAX_N];
string s;
int main(){
  set<int> st;
  cin>>x>>y>>z;
  st.insert(x);
  st.insert(y);
  st.insert(z);

  cout<<st.size()<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
    int n,a=100000;

    scanf("%d",&n);

    for(;n>0;n--){
        a = ((a/100)*105);
        if(a%1000 != 0){
            a=((a/1000)*1000)+1000;
        }
    }
    printf("%d\n",a);
    return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin>>n;
    if(n%2==0) printf("%d\n",n/2);
    else printf("%d\n",n/2+1);
    return 0;
}

Measured memory_bytes: 256