akhauriyash/Code-Regression huggingface dataset:
import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
  public static void main(String[] args) throws Exception {
    solve(System.in, System.out);
  }

  static final int MOD = (int)Math.pow(10,9)+7;

  static void solve(InputStream is, PrintStream os) {
    // Your code here!
    Scanner scan = new Scanner(is);
    int N = scan.nextInt();
    long all = 1;
    for(int i = 0; i < N; i++) {
      all *= 10;
      all %= MOD;
    }

    long not0 = 1;
    for(int i = 0; i < N; i++) {
      not0 *= 9;
      not0 %= MOD;
    }

    long not9 = 1;
    for(int i = 0; i < N; i++) {
      not9 *= 9;
      not9 %= MOD;
    }

    long not09 = 1;
    for(int i = 0; i < N; i++) {
      not09 *= 8;
      not09 %= MOD;
    }

    long ans = all-not0;
    ans %= MOD;
    if(ans < 0)
      ans += MOD;
    ans -= not9;
    ans %= MOD;
    if(ans < 0)
      ans += MOD;
    ans += not09;
    ans %= MOD;

    os.println(ans);
  }
}


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

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int K = sc.nextInt();
            int[] p = new int[N];
            for (int i = 0; i < N; i++) {
                p[i] = sc.nextInt();
            }
            Arrays.sort(p);
            int sum = 0;
            for (int k = 0; k < K; k++) {
                sum += p[k];
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 30140
#include<iostream>
#include<cmath>

using namespace std;

int number_of_digits(int x){
	int ans = 0;
	while(x){
		++ans;
		x /= 10;
	}
	return ans;
}

int main(){
	int n, ans = 0;
	scanf("%d", &n);
	while(n){
		ans += (number_of_digits(n--) & 1);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>


using namespace std;


class A {
	int N;

public:
	void solve()
	{
		cin >> N;

		cout << "ABC" << N << endl;
	}
};


class B {
	int N;

public:
	void solve()
	{
		cin >> N;

		int ans{ 1 };

		for (; ans <= N; ans <<= 1);

		cout << ans / 2 << endl;
	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#define past 5000000000000000;
using namespace std;
char a[102];
long long k;
int main()
{
	scanf("%s%lld",a+1,&k);
	int n=strlen(a+1);
	for(int i=1;i<=n;++i) {
		if(a[i]=='1') --k;
		else {printf("%c\n",a[i]);return 0;}
		if(!k) {printf("1\n");return 0;}
	}
	return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**6)

def dfs(v, p):
    for nv in G[v]:
        if nv == p:
            continue
        point[nv] += point[v]
        dfs(nv, v)

n, q = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(n-1):
    x, y =  map(int, input().split())
    x, y = x-1, y-1
    G[x].append(y)
    G[y].append(x)

point = [0 for _ in range(n)]
for _ in range(q):
    p, x = map(int, input().split())
    point[p-1] += x

dfs(0, -1)
print(*point)

Measured memory_bytes: 232792
#include<bits/stdc++.h>
using namespace std;
#define N 1111116

int n,xmx,xmn,ymx,ymn,tmx,tmn;

struct ball{int x,y;}a[N];
bool operator <(ball a,ball b){
	return a.x<b.x;
}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();
	xmx=ymx=-1e9;xmn=ymn=1e9;
	for (int i=1;i<=n;i++){
		a[i].x=read();a[i].y=read();
		if (a[i].x>a[i].y) swap(a[i].x,a[i].y);
		xmx=max(xmx,a[i].x);
		xmn=min(xmn,a[i].x);
		ymx=max(ymx,a[i].y);
		ymn=min(ymn,a[i].y);
	}
	long long ans=1ll*(xmx-xmn)*(ymx-ymn);
	sort(a+1,a+n+1);tmn=1e9;tmx=xmx;
	for (int i=1;i<=n;i++){
		ans=min(ans,1ll*(ymx-xmn)*(tmx-min(a[i].x,tmn)));
		tmn=min(tmn,a[i].y);tmx=max(tmx,a[i].y);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int mis1 = 0;
  int mis2 = 0;
  for(int i=0;i<S.size();){
    if(S[i] != '1'){
      mis1++;
    }
    i++;
    if(i == S.size()) break;
    if(S[i] != '0'){
      mis1++;
    }
    i++;
  }
  for(int i=0;i<S.size();){
    if(S[i] != '0'){
      mis2++;
    }
    i++;
    if(i == S.size()) break;
    if(S[i] != '1'){
      mis2++;
    }
    i++;
  }
  cout << min(mis1, mis2) << endl;
}


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

#pragma warning(disable : 4996)

#define mod 100000

using namespace std;

int H, W, dp[2][1 << 19][2][2], bits[10946];

string M[20];

int main()
{
	scanf("%d", &H);
	scanf("%d", &W);

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

	if (M[0][0] == 'J' || M[0][0] == '?') dp[0][0][0][0] += 1;
	if (M[0][0] == 'O' || M[0][0] == '?') dp[0][0][1][0] += 1;
	if (M[0][0] == 'I' || M[0][0] == '?') dp[0][0][1][0] += 1;

	int maxbits = 0;

	for (int i = 0; i < (1 << (W - 1)); i++)
	{
		bool ok = true;

		for (int j = 0; j < W - 2; j++)
		{
			if ((i & (1 << j)) && (i & (1 << (j + 1))))
			{
				ok = false; break;
			}
		}

		if (ok) bits[maxbits++] = i;
	}

	for (int i = 0; i < H * W - 1; i++)
	{
		for (int j = 0; j < maxbits; j++)
		{
			dp[(i ^ 1) & 1][bits[j]][0][0] = 0;
			dp[(i ^ 1) & 1][bits[j]][0][1] = 0;
			dp[(i ^ 1) & 1][bits[j]][1][0] = 0;
			dp[(i ^ 1) & 1][bits[j]][1][1] = 0;
		}

		for (int j = 0; j < maxbits; j++)
		{
			char c = M[(i + 1) / W][(i + 1) % W];

			int nxt = (bits[j] << 1) % (1 << (W - 1));

			int sum0 = (dp[i & 1][bits[j]][0][0] + dp[i & 1][bits[j]][1][0]) % mod;
			int sum1 = (dp[i & 1][bits[j]][0][1] + dp[i & 1][bits[j]][1][1]) % mod;

			if (c == 'J' || c == '?')
			{
				dp[(i ^ 1) & 1][nxt][0][0] += sum0;
				dp[(i ^ 1) & 1][nxt][0][1] += sum1;
			}

			if (c == 'O' || c == '?')
			{
				if ((M[i / W][i % W] == 'J' || M[i / W][i % W] == '?') && i % W != W - 1)
				{
					dp[(i ^ 1) & 1][nxt + 1][1][0] += dp[i & 1][bits[j]][0][0];
					dp[(i ^ 1) & 1][nxt + 1][1][1] += dp[i & 1][bits[j]][0][1];

					dp[(i ^ 1) & 1][nxt + 1][1][0] %= mod;
					dp[(i ^ 1) & 1][nxt + 1][1][1] %= mod;

					dp[(i ^ 1) & 1][nxt][1][0] += (sum0 - dp[i & 1][bits[j]][0][0] + mod);
					dp[(i ^ 1) & 1][nxt][1][1] += (sum1 - dp[i & 1][bits[j]][0][1] + mod);
				}
				else
				{
					dp[(i ^ 1) & 1][nxt][1][0] += sum0;
					dp[(i ^ 1) & 1][nxt][1][1] += sum1;
				}
			}

			if (c == 'I' || c == '?')
			{
				if (bits[j] & (1 << (W - 2)))
				{
					dp[(i ^ 1) & 1][nxt][1][1] += sum0;
				}
				else
				{
					dp[(i ^ 1) & 1][nxt][1][0] += sum0;
				}

				dp[(i ^ 1) & 1][nxt][1][1] += sum1;
			}

			dp[(i ^ 1) & 1][nxt][1][0] %= mod;
			dp[(i ^ 1) & 1][nxt][1][1] %= mod;
		}
	}

	int ret = 0;

	for (int i = 0; i < maxbits; i++)
	{
		ret += dp[(H * W - 1) % 2][bits[i]][0][1];
		ret += dp[(H * W - 1) % 2][bits[i]][1][1];

		ret %= mod;
	}

	printf("%d\n", ret);

	return 0;
}

Measured memory_bytes: 5948
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define INF 1000000000000000000

int main(){
  string S;
  ll K;
  cin>>S>>K;
  ll N=S.size();
  if(N==1){
    cout<<K/2<<endl;
  }else if(N==2){
    if(S.at(0)==S.at(1)){
      cout<<K<<endl;
    }else{
      cout<<0<<endl;
    }
  }else{
    ll counter=0;
    bool flag=false;
    bool sub=true;
    int sub_counter=1;
    set<char> s;
    for(int i=0;i<N;i++){
      s.insert(S.at(i));
    }
    if(s.size()==1){
      cout<<K*N/2<<endl;
      return 0;
    }
    for(int i=1;i<N;i++){
      if(S.at(i-1)==S.at(i)&&sub){
        sub_counter++;
      }else{
        sub=false;
      }
      if(S.at(i-1)==S.at(i)&&!flag){
        counter++;
        flag=true;
      }else{
        flag=false;
      }
    }
    if(S.at(N-1)==S.at(0)&&!flag&&sub_counter%2==1){
      cout<<counter*K+(K-1)<<endl;
    }else{
      cout<<counter*K<<endl;
    }
  }
}


Measured memory_bytes: 256
import sys

with sys.stdin as f:
    s_input = f.read()

    s_args = s_input.splitlines()
    n = int(s_args[0])
    sa = s_args[1].split()
    a = [0] + [int(elm) for elm in sa]

    D = 0
    dist = []
    sd = []
    for i in range(n):
        dist.append(abs(a[i+1] - a[i]))
        D += dist[i]
        if i == 0:
            sd.append(0)
        else:
            sd.append(abs(a[i+1] - a[i-1]))

    D += abs(a[n])
            
    for i in range(1,n+1):
        if i != n:
            print(D - (dist[i-1] + dist[i]) + sd[i])
        else:
            print(D - (dist[n-1] + abs(a[n])) + abs(a[n-1]))
            
sys.exit(0)


Measured memory_bytes: 24412
#include<iostream>
#include<cmath>
using namespace std;
int a,b;
string s;
main(){
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0')a++;
        else b++;
    }
    cout<<s.size()-abs(a-b)<<endl;
}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = int.Parse(Console.ReadLine());
            var tmp = (X % 500);
            tmp = (tmp / 5)*5;
            var ans = (X / 500)*1000 + tmp;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>

int main(void){

  
  int N , M;
  scanf("%d %d",&N , &M);
  
  int K;
  int A[30] ={0};            //好きだと答えたカウント
  for(int i = 0 ; i < N ; i++){
    scanf("%d", &K);

    for(int j = 0 ; j < K ; j++){
      int num;
      scanf("%d",&num); //一時的な数の保管場所
      num--;
      A[num]++;
    }
  }

  int ans = 0;          //カウントが人数と同じだったら全員が好きと答えている
  for(int i = 0 ; i < M ; i++){
    if(A[i] == N)     ans++;
  }

  printf("%d", ans );

  
  return 0;
}

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

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

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

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

    return a.first < b.first;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int x[51];
int y[51];
ll dp[55][5010];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    //cout << fixed << setprecision(15);

    int N, A;
    cin >> N >> A;
    int maxV = 0;
    REP(i, N)
    {
        cin >> x[i];
        y[i] = x[i] - A;
        maxV = max(maxV, x[i]);
    }

    //i番目, 何個取ったか, その時の値 = 個数

    //i番目までを見た時の値j
    //ただし0=2NXで正規化している事に注意
    dp[0][N * maxV] = 1;
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j <= 2 * N * maxV; ++j)
        {

            if (j - y[i] >= 0 && j - y[i] < 2 * N * maxV)
                dp[i + 1][j] = dp[i][j] + dp[i][j - y[i]];
            else
            {
                dp[i + 1][j] = dp[i][j];
            }
        }
    }
    cout << dp[N][N * maxV] - 1 << endl;
    return 0;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    int h,w;cin>>h>>w;

    vector<string>a(h);
    rep(i,h){
            cin>>a[i];
    }

    vector<bool>H(h,false),W(w,false);

    rep(i,h){
        rep(j,w){
            if(a[i][j]=='#'){
                H[i]=true;
                W[j]=true;
            }
        }
    }

    rep(i,h){
        if(H[i]){
            rep(j,w){
                if(W[j]){
                    cout<<a[i][j];
                }
            }
            cout<<endl;
        }
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int x, n;
        cin >> x >> n;
        map<int, int> Vis;
        for(int i = 0; i < n; i++){
            int a;
            cin >> a;
            Vis[a] = 1;
        }
        int k = 0, ans = 0;
        while(1){
            if(!Vis[x - k]){
                ans = x - k;
                break;
            }
            if(!Vis[x + k]){
                ans = x + k;
                break;
            }
            k++;
        }
        cout << ans << '\n';
    }
}

Measured memory_bytes: 34608
N,X = list(map(int,input().split()))
L = list(map(int,input().split()))
D = [0]*(N+1)
cnt = 0
for i in range(N):
  D[i+1] += D[i] + L[i]
  cnt += 1 if D[i+1]<=X else 0
print(cnt+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define reps(i,a,b) for(long long int i=a;i<b;i++)
#define rep(i,a) for(long long int i=0;i<a;i++)
typedef long long int ll;
using namespace std;
ll MOD = 1000000007;

const int MAX = 510000;

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int main(){
    string S;
    cin>>S;
    int ans=0;
    rep(i,S.size()){
        if(S[i]=='o'){
            ans++;
        }
    }


    if(ans+(15-S.size())>=8){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX = 2e5+1, XMX = 1e5+1;
int par[MX], xcnt[MX], ycnt[MX];
int f(int i) {return par[i] == i ? i : par[i] = f(par[i]);}
void join(int i, int j) {
	i = f(i), j = f(j);
	if(i != j) {
		par[j] = i;
		xcnt[i] += xcnt[j];
		ycnt[i] += ycnt[j];
	}
}
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	for(int i=1; i<XMX; i++) {
		xcnt[i] = 1;
		par[i] = i;
	}
	for(int i=XMX; i<MX; i++) {
		ycnt[i] = 1;
		par[i] = i;
	}
	for(int i=0; i<n; i++) {
		int x, y;
		cin >> x >> y;
		join(x, y+100000);
	}
	ll tot = 0;
	for(int i=0; i<MX; i++) {
		if(par[i] != i) continue;
		tot += (ll)xcnt[i]*ycnt[i];
	}
	cout << (tot - n);
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main()
{
  int n; cin >> n;
  int x = 0;
  int res = 0;
  for (int i = 0; i < n; i++) {
    char s; cin >> s;
    if (s == 'I') x += 1;
    else          x -= 1;
    res = max(x, res);
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 632
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

const int N = 2e5 + 5;

int n;
int a[N], b[N];

int main()
{
  cin >> n;
  bool same = true;
  int mnb = 1e9 + 5;
  long long sum = 0;
  for(int i = 0 ; i < n ; i++) {
    cin >> a[i] >> b[i];
    same &= a[i] == b[i];
    if(a[i] > b[i]) mnb = min(mnb, b[i]);
    sum += a[i];
  }
  if(same) return cout << 0 << endl, 0;
  cout << sum - mnb << endl;
  return 0;
}


Measured memory_bytes: 384
N = int(input())
ans = ''
for i in range(1, 10000):
#     print(N)
#     print("-> ",26 ** i)
    if N <= 26 ** i: 
#         print("ok")
        N += -1
        for j in range(i):
#             print("N:", N)
#             print("N % 26:", N % 26)
            ans += chr(ord('a') + N % 26)
            N = N // 26  # 26で割った商
        break
    else:
        N -= 26 ** i

print(ans[::-1])

Measured memory_bytes: 9040
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N;
  long long ans =0;
 
  cin >> N;

  vector<long long> a(N);
  vector<long long> c(N, 0);
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  for(int i = 0; i < N; i++){
    long long tmp = a[i];
    while(tmp%2 == 0){
      tmp = tmp/2;
      c[i]++;
    }
  }
  for(int i = 0; i < N; i++){
    ans += c[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long k=sc.nextInt();
        long a=sc.nextInt();
        long b=sc.nextInt();
        if(k<a){
            System.out.println(1+k);
            return;
        }
        k=k-a+1;
        if(k%2==0){
            if(b-a>2){
                System.out.println(a+(b-a)*k/2);
            }else{
                System.out.println(a+k);
            }
        }else{
            if(b-a>2){
                System.out.println(a+(b-a)*(k-1)/2+1);
            }else{
                System.out.println(a+k);
            }
        }
        

    }

}

Measured memory_bytes: 24916
a = int(input())#整数
x = list(map(int, input().split()))#配列Int型

ans = 0

for i in range(a):
    for j in range(1, a):
        for k in range(2, a):
            if x[i] == x[j] or x[i] == x[k] or x[j] == x[k]:
                continue
            if i > j or i > k or j > k:
                continue
            res = x[i] - x[j]
            res *= -1 if res < 0 else 1
            if res < x[k] and x[k] < (x[i] + x[j]):
                ans += 1
print(ans)

Measured memory_bytes: 9220
#include<cstdio>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vc=vector<char>;
using vvc=vector<vc>;


int main(void)
{
	int n;
	while(scanf("%d", &n)==1)
	{
		vvc s(n);
		map<vc,int> m;

		for(auto&ms:s) ms.resize(10+2);

		for(int i=0;i<n;i++)
		{
			scanf("%10s", &s[i][0]);
			m[s[i]]++;
		}

		printf("%u\n", m.size());
	}
	return 0;
}


Measured memory_bytes: 35520
import sys
from sys import stdin

N = int(input())
A = list(map(int,stdin.readline().split()))

count = 0

while True:
    for i,value in enumerate(A):
        if value % 2 == 0:
            A[i] /= 2
        else:
            print(count)
            sys.exit()
    count += 1

print(count)


Measured memory_bytes: 3060
import java.util.*;
import java.lang.*;



public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        int b[] = new int[n];
        int c[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
        }
        Arrays.sort(a);
        Arrays.sort(b);
        Arrays.sort(c);

        int d[] = new int[n];
        int e[] = new int[n];

        for (int i = 0; i < n; i++) {
            int ok = n;
            int ng = -1;
            //[ok,ng)の中に、b[i]以上のaの中で最小のものがある
            while (Math.abs(ng-ok) > 1) {
                int mid = (ng + ok) / 2;
                if (a[mid] >= b[i]) {
                    ok = mid;
                } else {
                    ng = mid;
                }
            }
            d[i] = ok;
        }
        for (int i = 0; i < n; i++) {
            int ok = n;
            int ng = -1;
            while (Math.abs(ng - ok) > 1) {
                int mid = (ok + ng) / 2;
                if (c[mid] <= b[i]) {
                    ng = mid;
                } else {
                    ok = mid;
                }
            }
            e[i] = ok;
        }
        long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += (long)d[i] * (long)(n - e[i]);
        }

        System.out.println(sum);

    }
}

Measured memory_bytes: 95996
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end


N=get_nsp
puts yn_judge(N.include?("7"))

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;


ll dp[3005][3005];


int main() {

	int n;
	cin >> n;
	VLL a(n);
	REP(i, n)cin >> a[i];


	FOR(i, 1, n + 1) {
		REP(j, n - i + 1) {
			int k = i + j;

			if ((n - i) % 2 == 0)
				dp[j][k] = max(dp[j + 1][k] + a[j], dp[j][k - 1] + a[k - 1]);
			else
				dp[j][k] = min(dp[j + 1][k] - a[j], dp[j][k - 1] - a[k - 1]);
		}
	}

	cout << dp[0][n] << endl;


}




Measured memory_bytes: 70016
# -*- coding: utf-8 -*-
N=int(input())
S=input()

ref=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
x=[]

for s in S:
    for i in range(26):
        if s==ref[i]:
            x.append(ref[(i+N)%26])
for i in range(len(x)):
    print(x[i],end="")

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = "";

        while ((line = br.readLine()) != null && !line.isEmpty()) {
            char[] str = line.toCharArray();
            int u = str.length - 1;
            char c;
            for (int i = 0; i < str.length / 2; i++) {
                c = str[i];
                str[i] = str[u - i];
                str[u - i] = c;
            }
            System.out.println(str);
        }
    }
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#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(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#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 IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                vector<int>tmp;

                if(v[i]==v[j] or v[i]==v[k] or v[j]==v[k])continue;
                tmp.pb(v[i]);
                tmp.pb(v[j]);
                tmp.pb(v[k]);
                sort(all(tmp));
                if(tmp[0]+tmp[1]>tmp[2]){
//                    cout<<i<<" "<<j<<" "<<k<<endl;
                    cnt++;
                }

            }
        }
    }
    cout<<cnt;

}


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

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int n = ni();

        int t = (int) Math.sqrt(n * 2);

        while (t * (t + 1) / 2 < n) t++;

        for (int i = t; i >= 1; i--) {
            if (n >= i) {
                out.println(i);
                n -= i;
            }
        }
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 8912
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include <set>
#include <queue>
#include <iomanip>
#include <sstream>
typedef long long ll;

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

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 long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[510][510];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}
/*
ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}*/
int main() {
	cin >> n >> m;
	ll res = (1900 * m + 100 * (n - m));
	rep(i, m) {
		res *= 2;
	}
	cout << res << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
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 main() {
	int a, b;
	cin >> a >> b;
	int res = a * b;
	if (res % 2 == 0)puts("No");
	else puts("Yes");
	return 0;
}

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

int main()
{
	string str, ord;
	string ans, p;
	int q, i, a, b, n;

	cin >> str;
	cin >> q;

	i = 0;
	while (i < q) {
		cin >> ord >> a >> b;

		if (ord == "print") {
				cout << str.substr(a, b - a + 1) << endl;
		}
		else if (ord == "reverse") {
			reverse(str.begin() + a, str.begin() + b + 1);
			}
		else if (ord == "replace") {
			cin >> p;
			str = str.substr(0, a) + p + str.substr(b + 1, str.size() - a - 1);
		}
		i++;
	}
    return 0;
}




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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


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

    vector<int> Damage(N);
    vector<int> MP(N);
    rep(i,N) cin >> Damage[i] >> MP[i];

    std::vector<int>::iterator iter = std::max_element(all(Damage));
    size_t index = std::distance(Damage.begin(), iter);

    vector<vector<ll> > dp(N+1, vector<ll>(H+Damage[index]+1,INF_LL));
    dp[0][0] = 0;

    rep(i,N)
    {
        rep(j,dp[i].size())
        {
            chmin(dp[i+1][j], dp[i][j]);
            if( j >= Damage[i] )
            {
                chmin(dp[i+1][j], dp[i][j-Damage[i]] + MP[i]);
                chmin(dp[i+1][j], dp[i+1][j-Damage[i]] + MP[i]);
            }
        }
    }
    ll ans = INF_LL;
    /*
    rep(i,dp.size())
    {
        rep(j,11) cout << dp[i][j] << " ";
        cout << endl;
    }
    */
    REP(i, H, dp[N].size())
    {
        chmin(ans, dp[N][i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 87936
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std; 
using namespace __gnu_pbds;
 
#define ll long long int
#define pb push_back
#define endl "\n"
#define F first
#define S second

#define pq priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>
#define MAX  *max_element
#define MIN  *min_element
#define des_sort(v) sort(v.begin(),v.end(),greater<int>())
 
#define c_ones(number) __builtin_popcountll(number)
#define flip_bits(number) static_cast<unsigned>(~number)
 
#define all(X) X.begin(),X.end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(itr,n) for(itr=n.begin();itr!=n.end();itr++)
 
#define FLUSH fflush(stdout)
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb_ds tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define mod 1000000007
#define INF 1e18
 
const double PI = acos(-1);
 
bool compare(pair<int,int>a , pair<int,int>b){
	return a.first==b.first ? a.second<b.second : a.first < b.first;
}
 
struct hash_pair{ 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};


int main(){
	int n,m;
	cin>>n>>m;
	char a[n][m];
	rep(i,n){
		rep(j,m)cin>>a[i][j];
	}
	ll dp[n][m];
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	rep(i,n){
		rep(j,m){
			if(a[i][j]=='#')dp[i][j]=0;
			else{
				if(i-1>=0){
					dp[i][j]+=dp[i-1][j]%mod;
				}
				if(j-1>=0){
					dp[i][j]+=dp[i][j-1]%mod;
				}
			}
//			cout<<dp[i][j]<<" ";
		}
//		cout<<endl;
	}
	cout<<dp[n-1][m-1]%mod<<endl;
}

Measured memory_bytes: 12224
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        ((a)*((b)/gcd((a),(b))))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n,k;
    cin>>n>>k;

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

        if(v[i]>1e9)
        {
            for(;;)
                cout<<"lolol\n";
        }
    }

    vi w;
    for(int i=0;i<n;++i)
    {
        int x=0;
        for(int j=i;j<n;++j)
        {
            x+=v[j];
            w.pb(x);
        }
    }

    vi tmp;
    int ans=0;
    for(int i=60;i>=0;--i)
    {
        int val=1ll<<i,cnt=0;
        for(auto c:w)
        {
            if(c&val)
                ++cnt;
        }

        if(cnt<k)
            continue;

        ans^=val;
        for(auto c:w)
        {
            if(c&val)
                tmp.pb(c);
        }

        w=tmp;
        tmp.clear();
    }

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 6512
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

def solve():
    ordA = ord('a')

    N = int(input())
    Ass = []
    for _ in range(N):
        Ss = input().rstrip()
        As = [ord(S)-ordA for S in Ss[::-1]]
        Ass.append(As)

    Ass.sort(key=lambda x: len(x))

    fsss = []
    for As in Ass:
        fss = []
        fs = [0] * 26
        for i in reversed(range(len(As))):
            fs[As[i]] = 1
            fss.append(fs[:])
        fsss.append(fss[::-1])

    ans = 0
    nodes = []
    nodes.append([-1]*26)
    nums = []
    nums.append([0]*26)
    numNode = 1
    for As, fss in zip(Ass, fsss):
        lenA = len(As)
        iNode = 0
        for j in range(lenA):
            A = As[j]
            fs = fss[j]
            for c in range(26):
                if fs[c]:
                    ans += nums[iNode][c]

            if nodes[iNode][A] == -1:
                nodes.append([-1]*26)
                nums.append([0]*26)
                nodes[iNode][A] = numNode
                numNode += 1
            else:
                pass

            if j == lenA-1:
                nums[iNode][As[-1]] += 1

            iNode = nodes[iNode][A]

    print(ans)


solve()


Measured memory_bytes: 989556
#include <iostream>
#include <vector>
#include <limits.h>
using namespace std;
int main()
{
    int n, t;
    while(cin>>n>>t){
        vector<int> tmp(n);
        for(int i=0;i<n;i++){
            cin>>tmp[i];
        }
        int max_val=INT_MIN;
        int max_num=tmp[n-1];
        int cnt=0;
        for(int i=n-2;i>=0;i--){
            int ans=max_num-tmp[i];
            if(ans>0){
                if(max_val==ans){
                    cnt++;
                }
                else if(max_val<ans){
                    max_val=ans;
                    cnt=1;
                }
            }
            else{
                max_num=tmp[i];
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}


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

int s[1010];
int p[200010];

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

    int n,k;cin>>n>>k;
    for(int i=0;i<n;i++)cin>>p[i];

    for(int i=1;i<=1000;i++)s[i]=i+s[i-1];

    int sum=0;
    for(int i=0;i<k;i++)sum+=p[i];

    int m=sum;
    int mpos=0;

    for(int i=1;i<n-k+1;i++)
    {
        sum=sum-p[i-1]+p[i+k-1];
        if(sum>m){m=sum;mpos=i;}
    }

    double ans=0.0;

    for(int i=0;i<k;i++)
    {
        double q=s[p[i+mpos]];
        double qq=p[i+mpos];
        ans+=q/qq;
    }

    printf("%.10lf",ans);

    return 0;
}


Measured memory_bytes: 4536
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reg(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=(b);i>=(a);i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX

int uni[100005];
int find(int a){
  if(uni[a]==a)return a;
  return (uni[a]=find(uni[a]));
}
bool same(int a,int b){
  return find(a)==find(b);
}
void merge(int a,int b){
  uni[find(a)]=find(b);
}

lli h[100005];
vector<mp> vs[100005];
int gone[100005];
void dfs(int no,lli d){
    //printf("%d %lld\n",no,d);
    h[no] = d;
    gone[no]=1;
    rep(i,vs[no].size()){
        int to=vs[no][i].fir;
        if(gone[to])continue;
        dfs(to,d+vs[no][i].sec);
    }
}

int main(void){
    for(;;){
        int m,n;
        scanf("%d%d",&n,&m);
        if(n==0 && m==0)break;
        typedef pair<mp,mp> mmp;
        vector<mmp> dat;
        memset(gone,0,sizeof(gone));
        memset(h,0,sizeof(h));
        rep(i,n+1)uni[i]=i;
        rep(i,n+1)vs[i].clear();
        rep(iii,m){
            char cc[2];
            scanf("%s ",cc);
            int a,b,c;
            scanf("%d%d",&a,&b); a--; b--;
            if(cc[0]=='!')scanf("%d",&c);
            else c=-1;
            //printf("\n%c %d %d %d . \n",cc,a,b,c);
            dat.push_back(mmp(mp(cc[0]=='!'?1:0,a),mp(b,c)));
            if(cc[0]=='!'){
            vs[a].push_back(mp(b,c));
            vs[b].push_back(mp(a,-c));
            }
        }
        rep(i,n+1)if(!gone[i])dfs(i,0);
        //puts("df");
        rep(iii,m){
            mmp pa=dat[iii];
           int a=pa.fir.sec,          
               b=pa.sec.fir,
               c=pa.sec.sec;
           //printf("abc :: %d %d %d %d\n",pa.fir.fir,a,b,c); 
           if(pa.fir.fir==0){
                if(same(a,b))printf("%lld\n",h[b]-h[a]);
                else puts("UNKNOWN");
            }
            else{
                merge(a,b);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 15680
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
using namespace std;
double r;
int main(){
	cin>>r;
	printf("%.12f\n",r*2*3.1415926);
	return 0;
}

Measured memory_bytes: 3784
#include <string>
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, c;
    cin >> n >> m >> c;
    int b[m];
    int a[m];
    int d;
    int ans = 0;
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }

    for (int j = 0; j < n; j++) {
        d = 0;
        for (int i = 0; i < m; i++) {
            cin >> a[i];
            d += a[i] * b[i];
        }
        if (d + c > 0)
            ans++;
    }
    cout << ans;
}


Measured memory_bytes: 256
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<double, null_type, less_equal<double>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define int long long
typedef long long ll;
typedef double dd;
typedef long double ldd;
typedef pair <int, int> pii;
typedef pair <pii , int> ppii;
#define pb push_back	
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define f first
#define s second
#define sz(x) (int)x.size()
#define smin(x , y) x = min(x , y)
#define smax(x , y) x = max(x , y)
#define mp make_pair
#define all(x) x.begin() , x.end()
#define debug(x) cerr<< #x << " = " << x << endl
#define ddebug(x, y) cerr<< #x << " = " << x  << ", " << #y << " = " << y << endl
#define uop(x, y) pii(min(x, y), max(x, y))
#define mem(a, b) memset(a, b, sizeof a)
#define sq(x) (x) * (x)
#define out return cout << "-1" << '\n', 0
const int mx = 3e3 + 10;
vector < int > ad[mx];
int a[mx];
bool dfs(int v, int p){
	bool ans = 0;
	for(int u : ad[v])
		if(u != p)
			ans |= (!dfs(u , v) && a[u] < a[v]);
	return ans;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, u, v;
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < n - 1; i++){
		cin >> u >> v;
		u--, v--;
		ad[u].pb(v);
		ad[v].pb(u);
	}
	for(int i = 0; i < n; i++)
		if(dfs(i , -1))
			cout << i + 1 << " ";
	cout << endl;
	return 0;
}


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

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    int ans=1;
    int count=1;
    if(b==1){
        printf("%d\n",0);
        return 0;
    }
    while(1){
        count+=a-1;
        if(count>=b) break;
        ans++;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<iomanip>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) // <a> must be sorted in advance

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}


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

    char X, Y;
    cin >> X >> Y;

    if(X == Y) cout << "=";
    else if(X > Y) cout << ">";
    else cout << "<";
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N; cin >> N;
    for (int i = N; i <= 999; i++) {
        int num = i;
        int a = num / 100;
        num = num % 100;
        int b = num / 10;
        num = num % 10;
        if (a == b && b == num) {
            printf("%d\n", i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3580
#include<stdio.h>
#include<string.h>
#include<math.h>
int sub (double x1,double y1,double x2,double y2,double x3,double y3){
	double a;
	a=x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2);
	if(a>=0)return 1;else return 0;
}
int main(){
	int a,b,c,d,e,f,g,h;
	double x1,x2,x3,xx,y1,y2,y3,yy;
	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf ",&x1,&y1,&x2,&y2,&x3,&y3,&xx,&yy)!=EOF){
		a=sub(xx,yy,x2,y2,x3,y3);
		b=sub(xx,yy,x1,y1,x2,y2);
		c=sub(xx,yy,x3,y3,x1,y1);
		if(a==b&&b==c){printf("YES\n");}	
		else {printf("NO\n");}
	}
	return 0;
}

Measured memory_bytes: 616
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int n,k;
    cin>>n>>k;
    int ans=0;
    for(int i=0;i<n+1;i++){
        for(int j=0;j<n+1;j++){
            if(k-i-j>=0&&k-i-j<=n){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256