akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string str_Day = Console.ReadLine();
    int int_Day = int.Parse(str_Day);
    string[] str2 = Console.ReadLine().Split(' ');

    int[] int_C_i = new int[26];
    int[] last_d_i = new int[26];

    int SatisfactionLevel_last = 0;

    for(int i=0;i<26;i++){
        int_C_i[i] = int.Parse(str2[i]);
        last_d_i[i] = 0;
    }
    
    for(int i=1;i<=int_Day;i++){

        string[] str_S_d_i = Console.ReadLine().Split(' ');
        int[] int_S_d_i = new int[26];
        int[] SatisfactionLevel_list = new int[26];

        for(int l=0;l<str_S_d_i.Length;l++){
            int_S_d_i[l] = int.Parse(str_S_d_i[l]);
        }

        for(int j=0;j<26;j++){
        
            int SatisfactionLevel = SatisfactionLevel_last + int_S_d_i[j];
        
            for(int k=0;k<26;k++){
                if(j!=k){
                    SatisfactionLevel = SatisfactionLevel - int_C_i[k]*(i - last_d_i[k]);
                }
            }
            
            SatisfactionLevel_list[j] = SatisfactionLevel;
            
        }

        int index = 0;

        for(int j=0;j<26;j++){
        
            if(SatisfactionLevel_list[j] == SatisfactionLevel_list.Max() ){
                index = j;
            }
            
        }

        last_d_i[index] = i;

        SatisfactionLevel_last = SatisfactionLevel_list[index];

        Console.WriteLine(index + 1);

    }


   }
   
  }

}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  double sum=1.0;
  rep(i,n) {
    cin >> a[i]; sum*=a[i];
  }
  double b=0.0;
  rep(i,n) {
    b+=sum/a[i];
  }
  double ans=sum/b;
  printf("%.10f", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


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

    ll a,b; cin >> a >> b;
    
    if(a == 1 or b == 1){
        cout << 1 << endl;
        return 0;
    }
    ll ans = a * b;
    if(ans % 2 == 1) ans ++;
    ans /= 2;
    cout << ans << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int A[20+5], n;
int M[200+5], q;

int solve(int, int);

int main()
{
    int i;
    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &A[i]);
    scanf("%d", &q);
    for (i = 0; i < q; i++) scanf("%d", &M[i]);
    
    for (i = 0; i < q; i++){
        (solve(0, M[i]))? printf("yes\n") : printf("no\n");
    }
    
    return 0;
}

int solve(int p, int t){
    if (p > n) return 0;
    if (t == A[p]) return 1;
    return ((solve(p+1, t-A[p])) ? solve(p+1, t-A[p]) : solve(p+1, t));
}



Measured memory_bytes: 2104
#include <map>
#include <string>
#include <iostream>
#include<vector>
#include <set>
#include<algorithm>

using namespace std;

int main()
{
	int n;
	
	while (cin >> n)
	{
		int count=0;
		
		for (int a=0; a<=9; a++)
		{
			for (int b=0; b<=9; b++)
			{
				for (int c=0; c<=9; c++)
				{
					for (int d=0; d<=9; d++)
					{
						if (a+b+c+d == n) count++;
					}
				}
			}
		}
		
		cout << count << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
const int N = 1e5 + 10;
 
int n, kol;
string a[N], s;
 
void f(int x, int m, int e)
{
    
    if (x == m + 1)
    {
        kol += 1;
        if (kol == n){cout << s << endl;
        exit(0);
        }
    } else
    {
        if (e == -1)
        {
            for (int i = 1; i <= 9; i++)
            {
                s += char('0' + i);
                f(x + 1, m, i);
                s.pop_back();
            }
        } else
        {
            for (int i = max(0, e - 1); i <= min(9, e + 1); i ++)
            {
                s += char('0' + i);
                f(x + 1, m, i);
                s.pop_back();
            }
        }
    }
}
 
int main ()
{
    cin >>n;
    f(1, 1, -1);
    f(1, 2, -1);
    f(1, 3, -1);
    f(1, 4, -1);
    f(1, 5, -1);
    f(1, 6, -1);
    f(1, 7, -1);
    f(1, 8, -1);
    f(1, 9, -1);
    f(1, 10, -1);
    cout <<a[n];
    return 0;
}

Measured memory_bytes: 1024
s = input()
t = input()
sdic = {}
tdic = {}
S = [0] * len(s)
T = [0] * len(t)
for i, char in enumerate(s):
  if char not in sdic.keys():
    sdic[char] = len(sdic.keys())
  S[i] = sdic[char]
for i, char in enumerate(t):
  if char not in tdic.keys():
    tdic[char] = len(tdic.keys())
  T[i] = tdic[char]
if S == T:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 46388
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define UP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define UU(a,b,c) for(ll (a)=(b);(a)<=(c);(a)++)
#define DN(a,b,c) for(ll (a)=(b);(a)>(c);(a)--)
#define DU(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)

ll r,c,k,grid[3005][3005] = {0}, DP[3005][3005][4];

void reset()
{
	UU(i,0,c + 1)
	{
		UU(j,0,r + 1)
		{
			DP[i][j][0] = -1;
			DP[i][j][1] = -1;
			DP[i][j][2] = -1;
			DP[i][j][3] = -1;
		}
	}
}

void input()
{
	cin>>r>>c>>k;
	UU(i,1,k)
	{
		int x,y;
		ll v;
		cin>>y>>x>>v;
		grid[y][x] = v;
	}
}

ll dp(int x, int y, int life)
{
	if(x == c && y == r)
	{
		return 0;
	}
	else if(DP[x][y][life] != -1)
	{
		return DP[x][y][life];
	}
	else
	{
		ll best = LLONG_MIN;
		if(x < c)
		{
			if(life > 0)
			{
				best = max(best, grid[y][x + 1] + dp(x + 1, y, life - 1));
			}
			best = max(best, dp(x + 1, y, life));
		}
		if(y < r)
		{
			best = max(best, grid[y + 1][x] + dp(x, y + 1, 2));
			best = max(best, dp(x, y + 1, 3));
		}
		return DP[x][y][life] = best;
	}
}

void solve()
{
	ll best = dp(1, 1, 3);
	best = max(best, dp(1,1,2) + grid[1][1]);
	cout<<best<<endl;
}

void LetsRock()
{
	solve();	
}

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

	input();
	reset();
	LetsRock();
	
	return 0;
}


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

int main(){
    int N,ans;
    std::cin >> N;
    ans=0;
    // std::vector<int> a(N);
    int a[N];
    
    for (int i=0;i<N;i++){
        std::cin >> a[i];
    }
    for (int i=0;i<N;i++){
        if (a[i]%2==1){
            ans++;
        }
        i++;
    }
    std::cout << ans << std::endl;
    return 0;

}


Measured memory_bytes: 3632
#include <stdio.h>
 
int main(void){
      
      double r,l,s,pie = 3.141592653589;
       scanf("%lf",&r);
        l = 2*pie*r;
        s = pie*r*r;
       printf("%lf %lf\n",s,l);
       
        return 0;
 }


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

#define rep(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fill(x,v) memset(x,v,sizeof(x))
#define all(x) (x).begin(), (x).end()
#define trace(x) cerr << #x <<": " << x << endl
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef long double C;

const ll MAX = 1e5+10;

vi arr;
vii cant0, cant1;

int main(){
    fastio;
    ll n;
    cin >> n;
    arr.resize(n);
    cant0.assign(MAX, mp(0,-1));
    cant1.assign(MAX, mp(0,-1));
    rep(i,0,n){
        cin >> arr[i];
    }
    ll total0 = 0, total1 = 0;
    for(int i = 0; i < n; i+=2){
        total0++;
        cant0[arr[i]].ff++;
        cant0[arr[i]].ss = arr[i];
    }
    for(int i = 1; i < n; i+=2){
        total1++;
        cant1[arr[i]].ff++;
        cant1[arr[i]].ss = arr[i];
    }

    sort(cant0.rbegin(), cant0.rend());
    sort(cant1.rbegin(), cant1.rend());
    ll rpta = 0;
    if(cant0[0].ss != cant1[0].ss){
        rpta +=(total0 - cant0[0].ff);
        rpta +=(total1 - cant1[0].ff);
    }
    else{
        ll aux1, aux2;
        aux1 = (total0 - cant0[0].ff);
        aux1 +=(total1 - cant1[1].ff);

        aux2 = (total0 - cant0[1].ff);
        aux2 +=(total1 - cant1[0].ff);

        rpta = min(aux2,aux1);
    }

    cout << rpta << endl;

    return 0;
}

Measured memory_bytes: 7172
n,p=map(int,raw_input().split())
a=map(int,raw_input().split())
od=sum(k%2 for k in a)
ev=sum(1-k%2 for k in a)
if p==0:
	if od==0: print 2**n
	else: print 2**(n-1)
else:
	if od==0: print 0
	else: print 2**(n-1)


Measured memory_bytes: 28012
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout << endl
#define sp(x) cout << setprecision(x);
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vd vector<double> 
#define vvd vector<vector<double>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; }
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, w; cin >> n >> w;
	vl w_(n), v(n), x(n);
	rep(i, n)cin >> w_[i] >> v[i];
	rep(i, n)x[i] = w_[i] - w_[0];
	ll dp[110][110][350] = {};
	rep(i, n)rep(j, i + 2)rep(k, 3 * n + 1)
	{
		if (j > 0 && k >= x[i])
		{
			chmax(dp[i + 1][j][k], dp[i][j][k]);
			chmax(dp[i + 1][j][k], dp[i][j - 1][k - x[i]] + v[i]);
		}
		else
		{
			chmax(dp[i + 1][j][k], dp[i][j][k]);
		}
	}
	ll ans = 0;
	rep(j, n + 1)rep(k, 3 * n + 1)
	{
		if (j * w_[0] + k <= w)chmax(ans, dp[n][j][k]);
	}

	co(ans);
	return 0;
}


Measured memory_bytes: 33408
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
char s[1000050];
int main()
{
	scanf("%s",s);
	int jb=strlen(s);
	printf("%c%d%c",s[0],jb-2,s[jb-1]);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    string s;
    ll a=0,b;
    cin>>b;
    s = to_string(b);
    for(ll i = 0;i < s.size();i++)
    {
        a += s[i]-'0';
    }

    if(b%a==0)
    {
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }

}



Measured memory_bytes: 256
#include<iostream>
#include<complex>//abs()で、絶対値
#include<algorithm>
#include<utility>
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using namespace std;

int main()
{
    ll x, k, d;
    cin >> x >> k >> d;
    if(d < abs(x)){
        if(abs(x) / d >= k){
            cout << abs(x) - (d * k) << endl;
            return 0; 
        }else{
            if((k - (abs(x) / d)) % 2 == 0){
                cout << abs(x) - (d * (abs(x) / d)) << endl;
                return 0;
            }else{
                cout << abs((abs(x) - (d * (abs(x) / d))) - d) << endl;
                return 0; 
            }
        }
    }else{
        if(k % 2 == 0){
            cout << abs(x) << endl;
            return 0;
        }else{
            cout << abs(abs(x) - d) << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, sum = 1;
  cin >> N >> K;
  for (; N > 0; N--) {
    if ( sum * 2 <= sum + K) {
      sum *= 2;
      continue;
    }
      sum += K;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
fun main(args:Array<String>?): Unit {
    val (a, b, n) = readLine()!!.trim().split(' ').map(String::toLong)
    println(
            (1 .. n).mapNotNull{d ->
                if (b % d == 0L || d % b == 0L){
                    (1 .. n).map{num -> Math.abs(num * b / d - a)}.min()
                }else null
            }.min()!!
    )
}


Measured memory_bytes: 33148
#include<iostream>
#include<string>
#include<math.h>
#include<stdio.h>

using namespace std;

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

    while (n != 0)
    {
        double a=0;
        double m = 0;
        int s[1000] = {0};

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

        for(int i=0;i<n;i++)
        {
            a = a + pow((s[i]-m),2);
        }
        a = a/n;

        printf("%.5f\n",pow(a,0.5));

        cin>>n;
    }

    return 0;
}



Measured memory_bytes: 3352
import numpy as np

def main():
  H,W = map(int,input().split())
  maze = np.array([[0 if x == "#" else float('INF') for x in input()]for _ in range(H)])
  for i in range(1,H):
    maze[i,:]=np.minimum(maze[i,:],maze[i-1,:]+1)
  for i in range(H-2,-1,-1):
    maze[i,:]=np.minimum(maze[i,:],maze[i+1,:]+1)
  for i in range(1,W):
    maze[:,i]=np.minimum(maze[:,i],maze[:,i-1]+1)
  for i in range(W-2,-1,-1):
    maze[:,i]=np.minimum(maze[:,i],maze[:,i+1]+1)
  print(int(np.max(maze)))

main()



Measured memory_bytes: 52500
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
const ll mod = 1000000007;

typedef tree<pair<ll, int>, null_type, less<pair<ll, int>>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//Ordered set
//pbds s1
 
void testCase() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    ans = min (a, k);
    a -= ans;
    k -= ans;
    if (k == 0) {
        cout << ans << endl;
        return;
    }
    ll mn = min (b, k);
    k -= mn;
    if (k == 0) {
        cout << ans << endl;
        return;
    }
    mn = min (c, k);
    ans -= mn;
    cout << ans << endl;
}
 
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String t = sc.nextLine();
    String z = solve(s, t);
    System.out.println(z);
  }

  private static String solve(String s, String t) {
    int[][] dp = new int[s.length()][t.length()];
    dp[0][0] = s.charAt(0) == t.charAt(0) ? 1 : 0;
    for (int i = 1; i < t.length(); i++) {
      if (s.charAt(0) == t.charAt(i)) {
        dp[0][i] = 1;
      } else {
        dp[0][i] = dp[0][i - 1];
      }
    }

    for (int i = 1; i < s.length(); i++) {
      if (s.charAt(i) == t.charAt(0)) {
        dp[i][0] = 1;
      } else {
        dp[i][0] = dp[i - 1][0];
      }
    }

    for (int i = 1; i < s.length(); i++) {
      for (int j = 1; j < t.length(); j++) {
        if (s.charAt(i) == t.charAt(j)) {
          dp[i][j] = dp[i - 1][j - 1] + 1;
        } else {
          dp[i][j] = Math.max(Math.max(dp[i - 1][j], dp[i][j - 1]), dp[i - 1][j - 1]);
        }
      }
    }

    StringBuilder ans = new StringBuilder();
    int i = s.length() - 1;
    int j = t.length() - 1;
    for (; j >= 1 && i >= 1; ) {
      if (dp[i][j] == dp[i - 1][j]) {
        i--;
      } else if (dp[i][j] == dp[i][j - 1]) {
        j--;
      } else {
        ans.insert(0, t.charAt(j));
        i--;
        j--;
      }
    }

    while (i > 0) {
      if (dp[i][j] == dp[i - 1][j]) {
        i--;
      } else {
        ans.insert(0, s.charAt(i));
        break;
      }
    }
    while (j > 0) {
      if (dp[i][j] == dp[i][j - 1]) {
        j--;
      } else {
        ans.insert(0, t.charAt(j));
        break;
      }
    }
    if(s.charAt(0)==t.charAt(0)){
      ans.insert(0, t.charAt(0));
    }
    return ans.toString();
  }
}


Measured memory_bytes: 81212
//
// 全頂点対間最短路を求める、Floyd-Warshall のアルゴリズム
//
// cf.
//
//
// verified:
//   AOJ Course GRL_1_C Shortest Path - All Pairs Shortest Path
//     http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_C&lang=jp
//


/*
    dp[a][b] := a から　b への距離
 
 として初期化しておいて、アルゴリズム終了後には
 
    dp[a][b] := a から　b への最短距離
 
 が格納される。注意点として、初期化時に dp[a][a] = 0 となるようにする必要がある。
 なお負閉路判定に用いることもできて、
 
 - 負閉路がなければ、任意の頂点 a に対して dp[a][a] = 0
 - 負閉路があったら、ある頂点 a に対して dp[a][a] < 0
 
 */


#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1LL<<60;

int main() {
    int V, E; cin >> V >> E;
    
    // initialization of Floyd-Warshall
    vector<vector<long long> > dp(V, vector<long long>(V, INF));
    for (int i = 0; i < V; ++i) dp[i][i] = 0;  // necessary
    
    // input
    for (int e = 0; e < E; ++e) {
        int a, b, w; cin >> a >> b >> w;
        dp[a][b] = w;
    }
    
    // Floyd-Warshall
    for (int k = 0; k < V; ++k)
        for (int i = 0; i < V; ++i)
            for (int j = 0; j < V; ++j)
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
    
    // output
    bool isnegative = false;
    for (int v = 0; v < V; ++v) if (dp[v][v] < 0) isnegative = true;
    if (isnegative) puts("NEGATIVE CYCLE");
    else {
        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < V; ++j) {
                if (dp[i][j] < INF/2) cout << dp[i][j];
                else cout << "INF";
                if (j != V-1) cout << " ";
            }
            cout << endl;
        }
    }
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define loop for(;;)
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;
#define inf (1e9)
#define eps (1e-9)

template<class S, class T> inline
ostream& operator<<(ostream&os, pair<S,T> p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template<class S, class T, class U> inline
ostream& operator<<(ostream&os, tuple<S,T,U> t) {
  return os << '('
    << get<0>(t) << ", "
    << get<1>(t) << ", "
    << get<2>(t) << ')';
}

template<class T> inline
ostream& operator<<(ostream&os, vector<T> v) {
  if (v.size() == 0) { return os << "(empty)"; }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

template<class T> inline
istream& operator>>(istream&is, vector<T>&v) {
  rep (i, v.size()) is >> v[i];
  return is;
}

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

typedef vector<int> vi;
typedef vector<vi> vvi;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout.setf(ios::fixed);
  cout.precision(10);
  random_device dev;
  mt19937 rand(dev());

  int m; cin >> m;
  rep (_, m) {
    int n; cin >> n;
    vi xs(n); cin >> xs;
    int mn = 0;
    int mx = 0;
    rep (i, n-1) {
      int d = xs[i+1]-xs[i];
      mn = min(mn, d);
      mx = max(mx, d);
    }
      cout <<
        mx
        << ' '
        << (-mn)
        << endl;
  }

  return 0;
}

Measured memory_bytes: 1244
#include <iostream>

using namespace std;

int main() {
    int n,m;
    cin>>n>>m;
    int a[n][m],aa[n+1][m+1];
    
    char c;
    
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>c;
            if(c=='.'){
                a[i][j]=0;
                
            }
            else
            {
                a[i][j]=1;
                
            }
        }
        
    }
    for( int i=0;i<n;i++)
{
    for(int j=0;j<m;j++){
        if(i+j==0){
            aa[i][j]=a[i][j];
            
        }
        else{
        aa[i][j]=1e9;
        if(i)
        aa[i][j]=min(aa[i][j],aa[i-1][j]+((a[i][j]!=a[i-1][j])&a[i][j]));
        if(j)
        aa[i][j]=min(aa[i][j],aa[i][j-1]+((a[i][j]!=a[i][j-1])&a[i][j]));
        
        }
        //cout<<i<<" "<<j<<" "<<aa[i][j]<<endl;
    }
}

cout<<aa[n-1][m-1]<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int h,m,s;
	while(cin>>h>>m>>s){
		if(h==-1&&m==-1&&s==-1) break;
		int time=120*60 - h*60*60 - m*60 - s;
		printf("%02d:%02d:%02d\n",time/60/60,(time/60)%60,time%60%60);
		time*=3;
		printf("%02d:%02d:%02d\n",time/60/60,(time/60)%60,time%60%60);
	}
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
deque<char> Q;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K>>s;
	FORR(c,s) Q.push_back(c);
	
	bool rev=false;
	FOR(i,min(K,2*N+(K%2))) {
		if((Q[0]=='A')^rev) {
			Q[0]='A'+'B'-Q[0];
		}
		else {
			Q.pop_front();
			rev ^= 1;
			Q.push_back('A'+rev);
		}
	}
	
	FORR(r,Q) _P("%c",rev?('A'+'B'-r):r);
	_P("\n");
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

using ll = long long;

constexpr int INF = 1e9;

vector<int> bfs(vector<vector<int>> const& g, int s) {
    int const n = g.size();
    vector<int> d(n, INF);
    d[s] = 0;
    queue<int> que;
    que.push(s);
    while(!que.empty()) {
        int v = que.front();
        que.pop();
        for(auto to : g[v]) {
            if(d[to] != INF) {
                continue;
            }
            d[to] = d[v] + 1;
            que.push(to);
        }
    }
    return d;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<vector<int>> g(N);
    for(int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<vector<int>> vs(N);
    vector<int> sz(N);
    for(int i = 0; i < N; ++i) {
        auto d = bfs(g, i);
        for(int j = 0; j < N; ++j) {
            if(d[j] > K) {
                vs[i].push_back(j);
                sz[i]++;
            }
        }
    }

    int res = 0;
    while(true) {
        auto it = max_element(sz.begin(), sz.end());
        if(*it == 0) {
            break;
        }
        int v = it - sz.begin();
        sz[v] = 0;
        for(auto w : vs[v]) {
            sz[w]--;
        }
        vs[v].clear();
        res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 16512
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

int MOD_BIG = 1000000007;
int MOD_BIG2 = 998244353;
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

//////////////////////////////////////

//////////////////////////////////////

int main() {
    
    int N;
    cin >> N;
    
    vector<std::pair<ll, ll>> P(N), R(N);
    ll lbx = 0, lby = 0, rtx = MOD_BIG, rty = MOD_BIG;
    REP(i, N) {
        ll x, y;
        cin >> x >> y;
        P[i] = std::make_pair(x, y);
        R[i] = std::make_pair(y, x);
        lbx = std::min(lbx, x);
        lby = std::min(lby, y);
        rtx = std::max(rtx, x);
        rty = std::max(rty, y);
    }
    vector<ll> cnt(N), cnt2(N), cnt3(N), cnt4(N);
    REP(i, N) {
        cnt[i] = P[i].first - lbx + P[i].second - lby;
        cnt2[i] = rtx + rty - P[i].first - P[i].second;
        cnt3[i] = -lbx + rty + P[i].first - P[i].second;
        cnt4[i] = rtx - lby - P[i].first + P[i].second;
    }
    std::sort(cnt.begin(), cnt.end());
    std::sort(cnt2.begin(), cnt2.end());
    std::sort(cnt3.begin(), cnt3.end());
    std::sort(cnt4.begin(), cnt4.end());
    
    ll ans = rtx + rty - lbx - lby;
    cout << std::max(ans - cnt[0] - cnt2[0], ans - cnt3[0] - cnt4[0]) << endl;
    
    
    return 0;
}


Measured memory_bytes: 15652
a, b, c, x = map(int, [input() for _ in range(4)])
n = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                n += 1
print(n)

Measured memory_bytes: 2940
A, B, C = map(int, input().split())
K = int(input())

count = 0
for i in range(K):
    if A >= B:
        B *= 2
        count += 1
    else:
        break

if A >= B:
    print('No')
    sys.exit()

for i in range(K-count):
    if B >= C:
        C *= 2
    else:
        break

if B >= C:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin>>N;
int cnt=0,sum=0;
for(int i=1;i<=N;i++){
    if(i%2!=0){
        for(int j=1;j<=i;j++){
            if(i%j==0)cnt++;
        }
    if(cnt==8)sum++;
    cnt=0;
    }
}
cout<<sum;
return 0;
}


Measured memory_bytes: 256
n = int(input())
a = str(input())
b = str(input())
c = str(input())
ans = 0
for i in range(n):
  if a[i] == b[i] and b[i] == c[i]:
    ans += 0
  elif a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
    ans += 1
  else:
    ans += 2
print(ans)

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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(c<=a){
		if (d <= a)cout << 0 << endl;
		else if (a < d&&d < b)cout << d - a << endl;
		else cout << b - a << endl;
	}
	else if(a<c&&c<b){
		if (d <= b)cout << d - c << endl;
		else cout << b - c << endl;
	}
	else cout << 0 << endl;
}

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

using namespace std;

typedef long long ll;

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

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappop, heappush, heapify, heappushpop
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()

if N%2 == 0:
	print(N)
else:
	print(N*2)


Measured memory_bytes: 3892
import sys
import numpy as np

n = int(sys.stdin.readline().rstrip())
xy = [[] for _ in range(n)]
for i in range(n):
    a = int(sys.stdin.readline().rstrip())
    for _ in range(a):
        x, y = map(int, sys.stdin.readline().split())
        xy[i].append((x - 1, y))

def main():
    comb = (np.arange(2 ** n).reshape(-1, 1) >> np.arange(n) & 1).astype(np.bool)
    for i in range(n):
        for x, y in xy[i]:
            bl = ~comb[:, i] | (comb[:, x] == np.bool(y))
            comb = comb[bl] # ありえる組み合わせだけを残す
    '''
    ~comb[:, i]:= (i番目がUnkindと仮定したとき、)i番目をUnkind(False)としている組み合わせを残す
    (comb[:, x] == np.bool(y)):= (i番目がHonestと仮定したとき、)i番目の証言が矛盾しない組み合わせを残す
    '''
    
    ans = np.amax(np.sum(comb, axis=1))
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 29688
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while(s.hasNext()){
			double in = s.nextDouble();
			for(int i=2 ; ; i++){
				if(Math.sqrt(19.6*5*(i-1))>in){
					System.out.println(i);
					break;
				}
			}
		}
    }
}

Measured memory_bytes: 12000
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int []a = new int[n];
		int []b = new int[n];
		int high = 0;

		for(int i = 0; i < n; i++) {
			a[i] = stdIn.nextInt();
			b[i] = a[i];
			high = Math.max(high, a[i]);
		}
		Arrays.sort(b);

		for(int i = 0; i < n; i++) {
			if(a[i]!= high) {
				System.out.println(high);
			}else {
				System.out.println(b[n-2]);
			}
		}













	/*	for(int i = 0; i < max.length; i++) {
			max[i] = Integer.MIN_VALUE;
		}

		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				if(j==i) {
					continue;
				}else {
					max[i] = Math.max(max[i], a[j]);
				}
			}
		}
		for(int i = 0; i < n; i++) {
			System.out.println(max[i]);
		}*/

	}

}


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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

signed main(){
    io();
    string s; cin >> s;
    int n = s.size();
    n;
    int ans = 0;
    int ff = (n-1)/2;
    int ss = n/2;

    for(int i = ff, j = ss; i >= 0; --i, ++j){
        if(s[i] != s[j]){
            ++ans;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3596
//ALLAH bachiye naw plz,amr 1400+ rating tulai daw plzz
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int dd,nn,x,p[120]={},n[120]={};
  cin>>x>>nn;
  for(int i=1;i<=nn;i++) {
    int q;
    cin>>q;
    if(q-x==0) { p[0]=1; n[0]=1; }
    else if(q-x>0) { p[q-x]=1; }
    else { n[x-q]=1; }
  }
  for(int i=0;i<101;i++) {
    if(p[i]*n[i]==0) {
      if(!n[i]) { cout<<x-i; break; }
      else { cout<<x+i; break; }
    }
  }
  return 0;
} 

Measured memory_bytes: 3616
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 M1, D1, M2, D2;
  std::cin >> M1 >> D1 >> M2 >> D2;
  std::cout << (M1 != M2) << std::endl;
  return 0;
}

Measured memory_bytes: 256
/*
  AOJ 0535
  Title:crossing black ice
  @kankichi573
*/
#include <stdio.h>

#define check_inner(y,x,n,m) (((y)>=0) && ((x)>=0) && ((y)<(n)) && ((x)<(m)))

int m,n,ice[90][90];
int dirx[4]={1,0,-1,0};
int diry[4]={0,1,0,-1};
//
//depth first
//
int max(int a,int b)
{
  return (a>b)?a:b;
}
int solve(int y,int x,int dep)
{
  int i,ret,ty,tx;

  //printf("%d %d [%d]\n",y,x,dep);

  ret= dep;
  for(i=0;i<4;i++)
    {
      ty = y+diry[i],tx = x+dirx[i];
      if(check_inner(ty,tx,n,m) && ice[ty][tx])
	{
	  ice[ty][tx] = 0;
	  ret = max(ret,solve(ty,tx,dep+1));
	  ice[ty][tx] = 1;
	}
    }
  return (ret);
}

main()
{
  int i,j,ret;
  
  while(scanf("%d %d",&m,&n) && (m||n))
    {
      for(i=0;i<n;i++)
	for(j=0;j<m;j++)
	  scanf("%d",&ice[i][j]);

      ret=0;
      for(i=0;i<n;i++)
	for(j=0;j<m;j++)
	  if(ice[i][j]>0)
	    {
	      ice[i][j]=0;
	      ret = max(ret,solve(i,j,1));
	      ice[i][j]=1;
	    }

      printf("%d\n",ret);
    }
  return(0);
}

Measured memory_bytes: 632
// buy a lot of 0s
// or simply return 0 ?
// nope, it's buy one 0
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

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

  int n;
  cin >> n;
  for(int i = 1000; i <= 10000; i += 1000) {
    if(i >= n) {
      cout << i - n << '\n';
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3608
//
//  main.cpp
//  test3
//
//  Created by 黒田浩揮 on 2019/04/21.
//  Copyright © 2019 黒田浩揮. All rights reserved.
//

#include <iostream>
using namespace std;
int main() {
    // insert code here...
    int a,b,c,d;
    d=0;
    
    cin>>a>>b;
    int number[a+1][b+1];
    int number2[a+1];
    int number3[b];
    for (int u=0; u<a; u++) {
        number2[u]=0;
    }
    for (int u=0; u<b; u++) {
        number3[u]=0;
    }
    for(int v=0;v<a;v++){
        for(int l=0;l<b;l++){
            cin>>c;
            
            number[v][l]=c;
            number2[v]+=c;
            number3[l]+=c;
            
            
        }
    }
    for(int n=0;n<a;n++){
        number[n][b]=number2[n];
    }
    for(int y=0;y<b;y++){
        number[a][y]=number3[y];
    }
    for(int y=0;y<b;y++){
        d+=number3[y];
    }
    number[a][b]=d;
    for(int v=0;v<a+1;v++){
        for(int l=0;l<b+1;l++){
            if(l==0){
                cout<<number[v][l];
            }else{
                cout<<" "<<number[v][l];
            }
            if(l==b){
                cout<<endl;
            }
        }
    }
}



Measured memory_bytes: 3088
import heapq
N,K = map(int,input().split())
hist = [0] * 26

def ctoi(c):
    return ord(c) - ord('A')

for i in range(N):
    c = input()[0]
    hist[ctoi(c)] -= 1

if K == 1:
    print(N)
    exit()
if K == 26:
    print(min(hist))
    exit()

heapq.heapify(hist)
ans = 0
while True:
    used = []
    for i in range(K):
        a = heapq.heappop(hist)
        if a == 0:
            print(ans)
            exit()
        used.append(a+1)
    ans += 1
    for u in used:
        heapq.heappush(hist, u)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define pb emplace_back
#define mp make_pair
#define int long long

using namespace std;

int hig(int a)
{
	return (1ll << (32 - __builtin_clz((int32_t)a)));
}

int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10);
	std::map<int, int> m;
	int n; cin >> n;
	vector<int> a(n); for (int o = 0; o < n; o++) { cin >> a[o]; }
	sort(a.rbegin(), a.rend());
	int cnt = 0;
	for (int i = 0; i < n; ++i)
	{
		if ((a[i] & (a[i] - 1)) == 0 && m[a[i]] != 0)
		{
			m[a[i]]--;
			cnt++;
		}
		else if ((m[a[i]] != 0))
		{
			m[a[i]]--;
			cnt++;
		}
		else
		{
			m[(hig(a[i]) - a[i])]++;
		}
	}
	cout << cnt;
}

Measured memory_bytes: 26880
from heapq import heappush, heappop

R_next = tuple((x, y) for x in range(-3, 0) for y in range(-2, 3) if abs(x) + abs(y) <= 3)
L_next = tuple((x, y) for x in range(1, 4) for y in range(-2, 3) if abs(x) + abs(y) <= 3)
c_num = tuple(str(i) for i in range(10))
L, R = 0, 1
INF = 10 ** 20

def conv(c):
  if c in c_num:
    return int(c)
  if c in ("T", "S"):
    return 0
  return -1

while True:
  w, h = map(int, input().split())
  if w == 0:
    break
  mp = [[-1] * 3 + input().split() + [-1] * 3 for _ in range(h)]
  for i in range(h):
    mp[i] = list(map(conv, mp[i]))
  mp.insert(0, [-1] * (w + 6))
  mp.insert(0, [-1] * (w + 6))
  mp.append([-1] * (w + 6))
  mp.append([-1] * (w + 6))
  start = []
  goal = []
  for x in range(3, w + 3):
    if mp[h + 1][x] == 0:
      start.append((x, h + 1))
    if mp[2][x] == 0:
      goal.append((x, 2))

  que = []
  dic = {}
  for x, y, in start:
    heappush(que, (0, x, y, L))
    heappush(que, (0, x, y, R))
    dic[(x, y, L)] = 0
    dic[(x, y, R)] = 0

  while que:
    total, x, y, foot = heappop(que)
    if foot == R:
      direct = R_next
      next_foot = L
    else:
      direct = L_next
      next_foot = R

    for dx, dy in direct:
      nx, ny = x + dx, y + dy
      cost = mp[ny][nx]
      if cost == -1:
        continue
      if not (nx, ny, next_foot) in dic or dic[(nx, ny, next_foot)] > total + cost:
        dic[(nx, ny, next_foot)] = total + cost
        heappush(que, (total + cost, nx, ny, next_foot))
  
  ans = INF
  for x, y in goal:
    if (x, y, L) in dic: ans = min(ans, dic[(x, y, L)])
    if (x, y, R) in dic: ans = min(ans, dic[(x, y, R)])
  if ans == INF:
    print(-1)
  else:
    print(ans)


Measured memory_bytes: 6208
n,m = map(int,input().split())
graph = {i+1:[] for i in range(n)}
for _ in range(m):
  a,b = map(int,input().split())
  graph[a].append(b)
  graph[b].append(a)

def func(path,p,count):
  if len(path) == n:
    return count + 1
  for i in graph[p]:
    if i in path:
      continue
    count = func(path+[i],i,count)
  return count
print(func([1],1,0))




Measured memory_bytes: 3064
pub struct Scanner {
    line: Vec<String>,
    idx: usize,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        return Scanner {
            line: vec![],
            idx: 0,
        };
    }
    fn next<T: std::str::FromStr>(&mut self) -> T {
        if self.idx == self.line.len() {
            let mut buffer = String::new();
            std::io::stdin().read_line(&mut buffer).ok();
            let a: Vec<&str> = buffer.trim().split(' ').collect();
            self.line = a.iter().map(|&s| String::from(s)).collect();
            self.idx = 0;
        }
        let ret: T = self.line[self.idx].parse::<T>().ok().expect("Parse error.");
        self.idx += 1;
        ret
    }
    fn next_string(&mut self) -> Vec<char> {
        let s: String = self.next();
        return s.chars().collect::<Vec<char>>();
    }
    fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        let mut v: Vec<T> = Vec::with_capacity(n);
        for _i in 0..n {
            v.push(self.next());
        }
        v
    }
}

fn main(){
    let mut scan = Scanner::new();
    let n:i32 = scan.next();
    let mut s :i64 = 0;

    for i in 1..n+1{
        if i%3 != 0 && i%5 != 0{
            s += i as i64;
        }
    }
    println!("{}", s);
}


Measured memory_bytes: 2104
int a[100001],b[100001];
main(n,k,m,i){
  for(;scanf("%d%d",&n,&k),n;printf("%d\n",m)){
    for(i=1;i<=k;i++)
      scanf("%d",a+i),b[i]=b[i-1]+a[i];
    for(m=b[i];i<=n;i++){
      scanf("%d",a+i),b[i]=b[i-1]+a[i]-a[i-k];
      if(m<b[i])m=b[i];
    }
  }
  return 0;
}

Measured memory_bytes: 1380
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    int n;
    cin >> n;
    int a[] = {n/1000, n%1000/100, n%100/10, n%10};
    int s[] = {1, -1};
    int ans = 0;
    string pm = "+-";

    rep(i, 8){
        if(a[0] + a[1] * s[(i>>2)&1] + a[2] * s[(i>>1)&1] + a[3] * s[i&1] == 7){
            ans = i;
            break;
        }
    }

    printf("%d%c%d%c%d%c%d=7\n", 
            a[0],
            pm[(ans>>2)&1],
            a[1],
            pm[(ans>>1)&1],
            a[2],
            pm[ans&1],
            a[3]
          );
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n, ans;
		while(sc.hasNext()){
			n = sc.nextInt();
			ans = 100000;
			for(int i = 0; i < n; i++){
				ans += ans / 20;
				if(ans != (ans = ans / 1000 * 1000)){
					ans += 1000;
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 100010
vector<pii> v[M];
ll ans[M];
void dfs(ll u,ll p){
	for(auto j:v[u]){
		if(j.fi==p)continue;
		if(j.se%2==1)ans[j.fi]=!ans[u];
		else ans[j.fi]=ans[u];
		dfs(j.fi,u);
	}
}
int main(){
	IOS;
	ll n;cin>>n;
	rep(i,0,n-1){
		ll a,b,w;cin>>a>>b>>w;a--,b--;
		v[a].pb({b,w});v[b].pb({a,w});
	}
	ans[0]=0;
	dfs(0,-1);
	rep(i,0,n)cout<<ans[i]<<"\n";
	return 0;
}



Measured memory_bytes: 10240
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
ll fact(int x){
	if(x==0)
		return 0;
	return (x*(x-1))/2;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE    
		freopen("input.txt", "r", stdin);     
		freopen("output.txt", "w", stdout);
	#endif

//----------------------------------------------------//
 int n,m;
 cin>>n>>m;
 ll x = fact(n);
 ll y = fact(m);
 cout<<x+y;





 






	#ifndef ONLINE_JUDGE
   		cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif

return 0;
}



Measured memory_bytes: 3584
#include <stdio.h>

int min(int a,int b){
  if(a < b){
    return a;
  }
  return b;
}

int main(void){
  int N;
  scanf("%d", &N);

  int D;
  int time[24], flag = 0;
  for (int i = 0; i < 24; i++) {
    time[i] = 0;
  }

  time[0] = 1;
  for (int i = 0; i < N; i++) {
    scanf("%d", &D);
    if(D > 12) D -= 12;
    time[D]++;
  }

  if(time[0] != 1 || time[12] >= 2){
    printf("0\n");
    return 0;
  }

  for (int i = 1; i < 12; i++) {
    if(time[i] > 2){
      printf("0\n");
      return 0;
    }else if(time[i] == 2){
      time[i] = 1;
      time[24-i] = 1;
    }else if(time[i] == 1){
      if(flag){
        flag = 0;
      }else{
        time[i] = 0;
        time[24-i] = 1;
        flag = 1;
      }
    }
  }

  int ans = 50;
  int past = 0;
  for (int i = 1; i < 24; i++) {
    if(time[i] == 1){
      ans = min(ans, i-past);
      past = i;
    }
  }
  ans = min(ans, 24-past);

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

  return 0;
}

Measured memory_bytes: 128
N,X,M=map(int,input().split())
Q=0
for i in range(min(100,N)):
  Q+=X
  X=X*X%M
N-=min(N,100)
S=set([X])
P=X
A=X
R=0
for i in range(M):
  A=A*A%M
  if A in S:
    R=i+1
    break
  S.add(A)
  P+=A
P*=(N//R)
N%=R
for i in range(N):
  P+=X
  X=X*X%M
print(P+Q)


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

int main(void) {
  long long k, x;
  cin >> k;
  
  x = 7 % k;
  
  for (int i = 1; i <= k; i++) {
  	if (x == 0) {
      cout << i;
      return 0;
    }
    x = (x * 10 + 7) % k;
  }

  cout << "-1";
  
  return 0;
}

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

int main () {
  std::vector<int> x;
  while (1)
  {
    int a;
    std::cin >> a;
    if (a == 0)
      break;
    x.push_back(a);
  }
  for (int i = 0; i < x.size(); i++)
  {
    std::cout << "Case " << i + 1 << ": " << x[i] << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3192
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int sum = 0;
    int _max = 0;
    for (int i=0; i<n; i++) {
        int l;
        cin >> l;
        _max = max(_max, l);
        sum += l;
    }

    if (sum > 2*_max) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

using namespace std;
vector<int> lista[100001];
int memo[100001];
int dist(int node){
    if(lista[node].size()==0)
        return 0;
    if(memo[node])
        return memo[node];
    int maxi=0;
    for(auto x:lista[node])
        maxi=max(maxi, dist(x)+1);
    memo[node]=maxi;
    return maxi;
}
int main(){
    int n, m;
    cin>>n>>m;
    for(int i=0; i<m; i++){
        int x, y;
        cin>>x>>y;
        lista[x].push_back(y);
    }
    int ans=0;
    for(int i=1; i<=n; i++){
        if(!memo[i])
            dist(i);
        ans=max(memo[i], ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8192
#include<cstdio>
#include<set>
using namespace std;
int main(void){
	set<int>a;
	int n, x;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &x);
		if(a.erase(x)==0)a.insert(x);
	}
	printf("%d\n", a.size());
	return 0;
}

Measured memory_bytes: 4864
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1)(r(2).readFileSync("/dev/stdin","UTF-8"))},function(e,t){e.exports=function(e){for(var t=e.split("\n"),r=Number(t[0]),n=0,o=0,u=r,i=.1;u>0;)o+=1,i*=10,u=Math.floor(u/10);n+=[0,9,9,909,909,90909][o-1],o%2==1&&(n+=r-i+1),console.log(n)}},function(e,t){e.exports=require("fs")}]);

Measured memory_bytes: 21064