akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll k;
    cin >> k;
    ll sum = 0;
    for(ll a = 1; a <= k; a ++) {
    for(ll b = 1; b <= k; b ++) {
    for(ll c = 1; c <= k; c ++) {
        sum += __gcd(a, __gcd(b, c));
    }
    }
    }
    cout << sum << endl;
    return 0;
}




Measured memory_bytes: 3660
using System;
using System.Linq;

class D
{
	static void Main()
	{
		Console.ReadLine();
		var d = Console.ReadLine().Select((c, i) => new { c, i }).GroupBy(_ => _.c).Select(g => g.Select(_ => _.i).ToArray()).ToArray();

		int r = 0, j;
		foreach (var i1 in d.Select(x => x[0]))
			foreach (var i3 in d.Select(x => x.Last()).Where(i3 => i3 - i1 >= 2))
				foreach (var a in d)
				{
					if ((j = Array.BinarySearch(a, i1 + 1)) < 0) j = ~j;
					if (j < a.Length && a[j] < i3) r++;
				}
		Console.WriteLine(r);
	}
}


Measured memory_bytes: 15072
#include<iostream>
#include<vector>
#include<unordered_map>
int main(){
    int N;
    unsigned long long K;
    std::cin>>N>>K;
    std::vector<int>A(N);
    for(int i=0;i<N;++i){
        std::cin>>A[i];
        A[i]-=1;
    }
    std::vector<int> path;
    std::unordered_map<int,int>map;
    unsigned int nowTown=0;
    unsigned long long cnt=0;
    long long loopStart=-1;
    bool isFindLoop=0;
    path.push_back(nowTown);
    while(cnt<K){
        cnt++;
        nowTown=A[nowTown];
        path.push_back(nowTown);
        if(map[nowTown]==1){
            isFindLoop=1;
            break;
        }
        map[nowTown]=1;
    }
    if(isFindLoop){
        for(int i=path.size()-2;i>=0;--i){
            if(nowTown==path[i]){
                loopStart=i;
                break;
            }
        }
        cnt=(K-cnt)%(path.size()-loopStart-1);
        for(int i=0;i<cnt;++i){
            nowTown=A[nowTown];
        }
    }
    std::cout<<nowTown+1<<std::endl;
}

Measured memory_bytes: 11456
import sys
def s():
 e=sys.stdin.readline
 n,m=map(int,e().split())
 P=[[]for _ in[0]*n]
 C=[0]*n
 k=0
 for _ in[0]*m:
  s,t=map(int,e().split());P[s]+=[t];P[t]+=[s]
 for i in range(n):
  k+=1
  if C[i]<1:
   s=[i];C[i]=k
   while s:
    u=s.pop()
    for v in P[u]:
     if C[v]<1:C[v]=k;s+=[v]
 for _ in[0]*int(e()):
  a,b=map(int,e().split())
  print(['no','yes'][C[a]==C[b]])
if'__main__'==__name__:s()


Measured memory_bytes: 24088
#include <bits/stdc++.h>
#define itn int
#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;
typedef long long ll;


int main(){
    int n;
    cin >> n;
    int a[n];
    int ans=0;
    rep(i,n){
        cin >> a[i];
        ans+=a[i];
    }
    cout << ans-n << endl;
}


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

ll solve() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    // sort(A.begin(), A.end());
    vector<vector<bool>> sl(N+1, vector<bool>(K+1,false)), sr(N+1, vector<bool>(K+1,false));
    sl[0][0] = true;
    for ( int i = 0; i < N ; i++ ) {
        for ( int k = 0; k <= K ; k++ ) {
            sl[i+1][k] = sl[i][k];
        }
        for ( int k = 0; k <= K ; k++ ) {
            if ( k + A[i] <= K ) {
                sl[i+1][k + A[i]] = sl[i+1][k + A[i]] || sl[i][k + A[i]] || sl[i][k];
            }
        }
    }
    sr[N][0] = true;
    for ( int i = N-1; i >= 0 ; i-- ) {
        for ( int k = 0; k <= K ; k++ ) {
            sr[i][k] = sr[i+1][k];
        }
        for ( int k = 0; k <= K ; k++ ) {
            if ( k + A[i] <= K ) {
                sr[i][k + A[i]] = sr[i][k + A[i]] || sr[i+1][k + A[i]] || sr[i+1][k];
            }
        }
    }
    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        ll k_max = 0;
        vector<ll> nl, nr;
        for ( int k = 0; k < K; k++ ) {
            if ( sl[i][k] ) nl.push_back(k);
            if ( sr[i+1][k] ) nr.push_back(k);
        }
        ll il = nl.size()-1, ir = 0;
        while ( true ) {
            while ( il >= 0 && nl[il] + nr[ir] >= K ) {
                il--;
            }
            if ( il < 0 ) break;
            while ( ir < nr.size() && nl[il] + nr[ir] < K )  {
                if ( k_max < nl[il] + nr[ir] ) k_max = nl[il] + nr[ir];
                ir++;
            }
            if ( ir >= nr.size() ) break;
        }
        if ( k_max + A[i] < K ) ans++;
    }
    
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 7160
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

const int maxn = 301;
int dp[maxn][maxn][maxn];

int f(string &s, int i, int j, int k) {
  if (i > j or i >= s.size() or j < 0) return 0;

  if (dp[i][j][k] == -1) {
    int ret = 0;
    if (s[i] == s[j]) {
      int cnt = 1 + (i != j) + f(s, i + 1, j - 1, k);
      ret = max(ret, cnt);
    } else {
      int cnt = f(s, i + 1, j, k);
      ret = max(ret, cnt);

      cnt = f(s, i, j - 1, k);
      ret = max(ret, cnt);

      if (k) {
        cnt = 2 + f(s, i + 1, j - 1, k - 1);
        ret = max(ret, cnt);
      }
    }

    dp[i][j][k] = ret;
  }

  return dp[i][j][k];
}

int main() { IO;
  string s;
  cin >> s;

  int k;
  cin >> k;

  memset(dp, -1, sizeof dp);
  int ans = f(s, 0, s.size() - 1, k);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 106752
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
using namespace std;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {

  int a, b; cin >> a >> b;
  cout << (a-1) * (b-1) << endl;

  return 0;
}




//


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

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

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        String stations = scan.next();
        if(stations.charAt(0) == 'A' && stations.charAt(1) == 'A' && stations.charAt(2) == 'A') {
            os.println("No");
        } else if(stations.charAt(0) == 'B' && stations.charAt(1) == 'B' && stations.charAt(2) == 'B') {
            os.println("No");
        } else {
            os.println("Yes");
        }
    }
}

Measured memory_bytes: 23124
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

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


int main(){
  string s; cin >> s; ll sum = 0;
  
  rep(i,4){
    if(s[i] == '+') sum++;
    else sum--;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
def dfs(i, now,  count):
    if count == len(s):
        if i == 7:
            print(str(s[0]),end="")
            for j in range(len(s)-1):
                print(now[j+1] + str(s[j+1]), end="")
            print('=7')
            exit()
    else:
        dfs(i + s[count], now + '+', count + 1)
        dfs(i - s[count], now + '-', count + 1)


s = list(map(int, input().strip()))

dfs(0, '', 0)


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


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


	int N;
	scanf("%d", &N);
	int A[16][16];
	rep(i, N) rep(j, N) scanf("%d", A[i] + j);

	ll dp[1 << 16] = {};
	int n = 1 << N;
	rep1(i, N - 1) {
		int M = 1 << i;
		rep(j, M) {
			ll kari = dp[j];
			rep(k, i) if (j >> k & 1) kari += A[i][k];
			dp[M + j] = kari;
		}
	}

	rep1(i, n - 1) {
		int k = 1 << 31 - __builtin_clz(i);
		for (int j = i - 1 & i; j >= k; j = j - 1 & i) {
			dp[i] = max(dp[i], dp[j] + dp[i ^ j]);
		}
	}

	printf("%lld", dp[n - 1]);

	Would you please return 0;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(4100000)

N = int(input())
INF = 10 ** 14
edges = [[] for _ in range(N)]
for _ in range(N-1):
    a, b, c = map(int,input().split())
    edges[a-1].append((b-1, c))
    edges[b-1].append((a-1, c))

Q, K = map(int,input().split())
d = [INF] * N
d[K-1] = 0

def dfs(x):
    for u, cost in edges[x]:
        if d[u] == INF:
            d[u] = d[x] + cost
            dfs(u)

dfs(K-1)

for _ in range(Q):
    x, y = map(int,input().split())
    ans = d[x-1] + d[y-1]
    print(ans)

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<string> isu(N);

	ll L = 0;
	ll R = N;
	std::cout << L << std::endl;
	cin >> isu[L];
	if (isu[L] == "Vacant") return 0;

	while (abs(R-L) > -1)
	{
		ll mid = (R+L)/2;
		std::cout << mid << std::endl;
		cin >> isu[mid];
		if (isu[mid] == "Vacant") return 0;

		if ((mid - L) & 1)
		{
			if (isu[mid] == isu[L])
			{
				R = mid;
			}
			else
			{
				L = mid;
			}
		}
		else
		{
			if (isu[mid] == isu[L])
			{
				L = mid;
			}
			else
			{
				R = mid;
			}
		}
		
	}
	std::cout << L << std::endl;

	return 0;
}


Measured memory_bytes: 6408
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 105
#define P 998244353
#define G 3
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
#define fuck printf("FUCK!!\n");
using namespace std;

int n, ans[MAXN], a[MAXN], vis[MAXN];

int main()
{
    scanf("%d", &n);
    for(rint i=1; i<=n; ++i) scanf("%d", &a[i]);
    for(rint i=1; i<=n; ++i)
    {
        int num=0, pos=0;
        for(rint j=1; j<=n; ++j)
        {
            if(vis[j]) continue;
            num++;
            if(num==a[j]) pos=j;
        }
        if(!pos) {printf("-1\n"); return 0;}
        vis[pos]=1, ans[i]=a[pos], vis[pos]=1;
    }
    for(rint i=n; i>=1; --i) printf("%d\n", ans[i]);
    return 0;
}

Measured memory_bytes: 128
H,W=map(int,input().split())
c=[list(map(int,input().split())) for _ in range(10)]

for k in range(10):
	for i in range(10):
		for j in range(10):
			c[i][j] = min(c[i][j], c[i][k] + c[k][j])

ans = 0
for _ in range(H):
	for x in input().split():
		x = int(x)
		if x != -1:
			ans += c[x][1]
print(ans)


Measured memory_bytes: 3064
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer N = sc.nextInt();
        int p[] = new int[N+1];
        for(int i=1; i<=N; i++) {
            p[i] = sc.nextInt();
        }
        int cnt=0;
        for(int i=2; i<=N-1; i++) {
            if(p[i-1] < p[i] && p[i] < p[i+1]) {
                cnt++;
            } else if(p[i-1] > p[i] && p[i] > p[i+1]) {
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <stdlib.h>
#include <time.h>
#include <map>
#include <queue>
#include <math.h>
using namespace std;
long long n, k, ans;
int a[1000005], b[1000005];
inline int check(long long x) {
	long long res= 0, y;
	for(int i= 1; i <= n; i++) {
		y= x / b[n - i + 1];
		if(a[i] > y) res+= a[i] - y;
	}
	return res <= k;
}
int main() {
	cin >> n >> k;
	for(int i= 1; i <= n; i++) cin >> a[i];
	for(int i= 1; i <= n; i++) cin >> b[i];
	sort(a + 1, a + n + 1), sort(b + 1, b + n + 1);
	long long l= 0, r= 1e15, mid;
	while(l <= r) {
		mid= (l + r) >> 1;
		if(check(mid))
			r= mid - 1, ans= mid;
		else
			l= mid + 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5120
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        String str = sc.nextLine();
        
        
        
        for(int i=0;i<str.length();i++){
            char c = str.charAt(i);
            if (Character.isUpperCase(c)){
                System.out.print(Character.toLowerCase(c));
            }else if (Character.isLowerCase(c)){
                System.out.print(Character.toUpperCase(c));
            }else{
                System.out.print(c);
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 26976
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int nx[4] = {1,0,-1,0};
int ny[4] = {0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    int ans = 0;
    rep(i,2,(int)sqrt(x)+1){
        int b = i;
        while(b*i <= x){
            b *= i;
        }
        chmax(ans,b);
    }
    if (x == 1) PRINT(1);
    else PRINT(ans);
}

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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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 dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

char alpha[26] = {'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'};

int main(){
    string s; cin >> s;
    string t = "";
    REP(i, 0, s.size()){
        if(s[i] == '0'){
            t = t + "0";
        }else if(s[i] == '1'){
            t = t + "1";
        }else{
            if(t.size() != 0){
                t.erase(t.size()-1);
            }
        }
    }
    cout << t << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    string s;
    cin>>s;
    int a=(s[0]-48)*10+s[1]-48;
    int b=(s[2]-48)*10+s[3]-48;
    bool con1=0<a&a<13;
    bool con2=0<b&b<13;
    string ret;
    if(con1&con2){
        ret="AMBIGUOUS";
    }else if(con1){
        ret="MMYY";
    }else if(con2){
        ret="YYMM";
    }else{
        ret="NA";
    }
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
//const ll mod = 1000000007;
ll N, M;
ll A[1005];
ll Asum;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        Asum += A[i];
    }
    int num = 0;
    for(int i = 0; i < N; i++) {
        if(A[i] * 4 * M >= Asum) num++;
    }
    if(num >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int countOdd(vector<int> array) {
    int count = 0;
    for (int j = 0; j < array.size(); j++) {
        while(array[j] % 2 == 0) {
            array[j] /= 2;
            count++;
        }
    }
    return count;
}

int main(void){
    int N; cin >> N;
    int i=0;

    vector<int> a(N);

    while(N > i){
        cin >> a[i];
        i++;
    }
    cout << to_string(countOdd(a)) << endl;
}




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

int main(){
    int N,M;cin>>N>>M;
    ll ans = 0;
    ans += N*(N-1)/2;
    ans += M*(M-1)/2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
mod = 10**9+7
dp = [[0] * (K+1) for i in range(K+1)]  # the number of ways to split j into i parts
dp[0][0] = 1
for i in range(1, K+1):
    for j in range(1, K+1):
        dp[i][j] = dp[i][j-1] + dp[i-1][j-1]

combination = 1
for i in range(1, K+1):
    combination = (combination * (N-K-i+2) * pow(i, mod-2, mod)) % mod
    print((dp[i][K] * combination) % mod)


Measured memory_bytes: 356084
#include<stdio.h>
int main(void){
    int a,b,rem,fg,i,tem;
    fg=0;
    scanf("%d %d %d",&a,&b,&rem);
    for(i=1;i<=b;i++){
        tem=a*i;
        if(rem==tem%b){
            fg=1;
            break;
        }
    }
    if(fg==1){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
    return 0;
}



Measured memory_bytes: 128
((input) => {
  const data = input.split('\n');
  const line1 = data[0].split(' ');
  const L = +line1[0];
  const R = +line1[1];
 
  if (R - L === 1) {
    console.log((L % 2019) * (R % 2019) % 2019);
    return;
  }

  if (R - L >= 2019 || L - L % 2019 + 2019 <= R) {
    console.log(0);
    return;
  }
 
  var min = Infinity;
  for (var i = L; i <= R - 1; i += 1) {
    for (var k = L + 1; k <= R; k += 1) {
      min = Math.min(min, (i % 2019) * (k % 2019) % 2019);
    }
  }
  console.log(min);
})(
  require("fs").readFileSync("/dev/stdin", "utf8")
);

Measured memory_bytes: 7484
import java.util.*;

class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] L = new int[N];
        for (int i = 0; i < N; i++) {L[i] = Integer.parseInt(sc.next());}
        int[][] A = nCombination3(L);

        int counter = 0;
        int a, b, c;
        for (int i = 0; i < N*(N-1)*(N-2)/6; i++) {
            a = A[i][0];
            b = A[i][1];
            c = A[i][2];
            
            if (a == b) {continue;}
            else if (b == c) {continue;}
            else if (c == a) {continue;}

            if ((Math.max(a-b, b-a) < c) && (c < a + b)) {counter++;}
            
        }


        System.out.println(counter);
    }

    private static int[][] nCombination3(int[] list) {
        int count = list.length;
        int num = 0;
        int[][] A = new int[count*(count-1)*(count-2)/6][3];

        for (int i = 0; i < count - 2; i++) {
            for (int j = i + 1; j < count - 1; j++) {
                for (int k = j + 1; k < count; k++) {
                    A[num][0] = list[i];
                    A[num][1] = list[j];
                    A[num][2] = list[k];
                    num++;
                }
            }
        }
        return A;
    }
}

Measured memory_bytes: 42464
#include <stdio.h>

int main() {
    int vec[5], a = 0;
    
    for(int i = 0; i < 5; ++i){
        scanf("%d", &vec[i]);
        if (vec[i] == 0)
            a = i+1;
    }
    printf("%d\n", a);
    return 0;
}


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

int main(void){
    int n, l;
    cin >> n >> l;
    string str[110];
    for(int i=0;i<n;++i){
        cin >> str[i];
    }
    sort(str, str+n);
    for(int i=0;i<n;++i){
        cout << str[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <ctime>

#define inf 0x3f3f3f3f
#define Inf 0x3FFFFFFFFFFFFFFFLL
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, n) for (int i = 1; i <= (n); ++i)
#define clr(x, a) memset(x, (a), sizeof x)
using namespace std;
typedef long long ll;
bool mk[111];
int a[3][3];

int main() {
  rep(i, 3) rep(j, 3) cin >> a[i][j];  
  int n; cin >> n;
  rep(i, n) {
    int x; cin >> x; mk[x] = 1;
  }
  rep(i, 3) {
    int t = 0;
    rep(j, 3) t += mk[a[i][j]];
    if (t == 3) {
      cout << "Yes" << endl;
      return 0;
    }
    t = 0;
    rep(j, 3) t += mk[a[j][i]];
    if (t == 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  if (mk[a[0][0]] && mk[a[1][1]] && mk[a[2][2]]) {
    cout << "Yes" << endl;
    return 0;
  }
  if (mk[a[0][2]] && mk[a[1][1]] && mk[a[2][0]]) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int main() {
    int n,x;
    cin>>n>>x;
    ll a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    int l=0;
    ll s=0;
    for(int i=0;i<n;i++){
        s+=a[i];
        if(s<=x)
        l++;
    }
    if(l==n){
        if(s==x)
        cout<<l;
        else cout<<l-1;
        return 0;
    }
    cout<<l;
}


Measured memory_bytes: 256
import math as mt

value = input().split(' ')
short = int(value[0])
long = int(value[1])
hour = int(value[2])
minute = int(value[3])

anglong = 6 * minute
angshort = 30 * (hour + minute/60)


radialang = anglong - angshort
if(radialang >= 180):
  radialang = -1 * radialang
  
rad = radialang * mt.pi / 180

ans = mt.sqrt(long**2 + short**2 - 2*long*short*mt.cos(rad))

print(ans)

Measured memory_bytes: 9580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fo(i,n) for(ll i=0;i<n;i++)
#define fok(i,k,n) for(ll i=k;i<n;i++)
#define ci(x) cin>>x
#define ci2(x,y) cin>>x>>y
#define co(x) cout<<x<<"\n"
#define co2(x,y) cout<<x<<" "<<y<<"\n"
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define deb1(x) cout<<#x<<" "<<x<<endl
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n"
#define deb3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n"
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;	


int main(){
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t; t=1;
	//ci(t);
	while(t--){
		ll x;
		ci(x);
		int ans=0;
		ll p=100;
		while(p<x){
			p+=(p/100);
			ans++;
		}
		co(ans);
	}
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int n;
int dp[200000]; // dp[i] := i円引き出すのに必要な最小の操作回数

void input(){
    cin >> n;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    for(int i=0;i<200000;i++) dp[i] = INF;
    dp[0] = 0; //0円引き出すのには0回でよい
    for(int i=0;i<n;i++){
        for(int pow6=1;i+pow6<=n;pow6*=6){
            chmin(dp[i+pow6], dp[i]+1);
        }
        for(int pow9=1;i+pow9<=n;pow9*=9){
            chmin(dp[i+pow9], dp[i]+1);
        }
    }
    cout << dp[n] << endl;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    string s; cin >> s;
    ll res = 700;
    rep(i,s.size()) if(s[i]=='o')res+=100;
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++)
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
using namespace std;
string s;
vector<ll> v;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(110, vector<ll>(110, INF));
vector<tuple<ll, ll, ll>> vt;
set<ll> st;
map<char, ll> mp;

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	string s, ans;
	cin >> s;
	if(s.size()==2)
	{
		cout << (s[0] == s[1] ? "1 2" : "-1 -1") << endl;
		return 0;
	}
	FOR(i, 1, s.size() - 1)
	{
		if (s[i - 1] == s[i] || s[i - 1] == s[i + 1] || s[i] == s[i + 1])
		{
			cout << i << " " << i + 2;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fr first
#define sc scanf
#define pf printf
#define se second
#define sq(x) x * x
#define ll long long
#define pb push_back
#define mk make_pair
#define ld long double
#define pr pair<int,int>
#define sz(s) int(s.size())
#define piip pair< pair<ll,ll>,ll >
#define fin(s) freopen( s, "r", stdin )
#define fout(s) freopen( s, "w", stdout )
#define TIME ios_base::sync_with_stdio(0)
using namespace std;

const ll INF = 1e9;
const ll N = 2e2+7;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;
ll a, b, n , cnt ,mx,ans,c;
ll used[ N ];
string s;
int main()
{
        TIME;
        cin >> n;
        if( n == 1 )
            return cout <<"Hello World",0;
            cin >> a >> b;
        cout << a + b;
}


/* MADE BY
//________________________________________________________
//________________________________________________________ //
                                                           //
// ██╗   ██╗     ██████╗     ███████╗    ██╗    ███╗   ██╗ //
// ╚██╗ ██╔╝    ██╔═══██╗    ██╔════╝    ██║    ████╗  ██║ //
//  ╚████╔╝     ██║   ██║    ███████╗    ██║    ██╔██╗ ██║ //
//   ╚██╔╝      ██║   ██║    ╚════██║    ██║    ██║╚██╗██║ //
//    ██║       ╚██████╔╝    ███████║    ██║    ██║ ╚████║ //
//    ╚═╝        ╚═════╝     ╚══════╝    ╚═╝    ╚═╝  ╚═══╝ //
//________________________________________________________ //
//________________________________________________________ */


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
        LinkedList<Integer> list = new LinkedList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        Collections.sort(list);
		// Alice,Bob got poit.
		int a = 0;
        int b = 0;
        Integer val = list.pollLast();
        while (val != null) {
            a += val;
            val = list.pollLast();
            if (val != null) {
                b += val;
                val = list.pollLast();
            }
        }
		// 出力
		System.out.println(a-b);
	}
}


Measured memory_bytes: 21460
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		
		int a = Integer.parseInt(scan.next());
		int b = Integer.parseInt(scan.next());
		int c = Integer.parseInt(scan.next());
		
		int tmp = 0;
		Boolean flag = false;
		do {
			flag = false;
			
			if (a > b) {
				tmp = a;
				a = b;
				b = tmp;
				flag = true;
			}
			if (b > c) {
				tmp = b;
				b = c;
				c = tmp;
				flag = true;
			}
		} while (flag);
		
		System.out.println(a + " " + b + " " + c);
	}
	
}

Measured memory_bytes: 26128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

typedef long long int ll;
using namespace std;
using namespace __gnu_pbds;
#define fastio ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);

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

const ll mod = 998244353;
const ll MAXN = 1e5+5;
const ll inf = 1e18;

int main()
{
    fastio;
    ll n;
    cin >> n;
    vector < ll > x(n + 1);
    for(int i = 1; i <= n; i++) cin >> x[i];
    ll ans = inf;
    for(int p = 1; p <= 100; p++){
        ll sum = 0;
        for(int i = 1; i <= n; i++) sum += (x[i] - p) * (x[i] - p);
        ans = min(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let (k, s) = read_touple::<i64>();
    let mut ans = 0;
    for x in 0..k+1 {
      for y in 0..k+1 {
        let z = s - x - y;
        if 0 <= z && z <= k {
          //println!("x = {}, y = {}, z = {}", x, y, z);
          ans += 1;
        }
      }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            int cnt = 0;
            for(int i = 0; i < S.Length; i++) {
                if(S[i] != T[i]) cnt++;
            }

            Console.WriteLine(cnt);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 27528
#include <iostream>
using namespace std;
int main (){
	int a,b;
	cin >>a>>b;
	int count= 0;
	for (int i=0;i<2;i++){
		if(a > b){
			count += a;
			a -=1;
		}else {
			count += b;
			b -= 1;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 888
/*input

*/


// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}

int solve()
{
	ll s,w;cin>>s>>w;
	cout<<(w>=s?"unsafe":"safe");
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

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

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

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

    int N,M;
    cin>>N>>M;

    int cmax=50;
    vector<int> a(cmax),b(cmax),c(cmax),d(cmax);

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

    for(int i=0;i<M;i++){
        cin>>c[i]>>d[i];
    }

    for(int i=0;i<N;i++){
        int m=abs(a[i]-c[0])+abs(b[i]-d[0]), cp=1;

        for(int j=1;j<M;j++){
            int dist=abs(a[i]-c[j])+abs(b[i]-d[j]);

            if(m>dist){
                m=dist;
                cp=j+1;
            }
        }
        cout<<cp<<endl;
    }
}


Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) tsort(v); reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

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

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() {
	cin.tie(0);
	ios::sync_with_stdio(0);

	lint n, k, in, ans = 0;
	cin >> n >> k;
	rep(i, n) {
		cin >> in;
		ans += 2 * min(in, abs(in - k));
	}
	co(ans);
	gc();
}

Measured memory_bytes: 256
n = gets.to_i
A = gets.split.map(&:to_i)
A.insert(0, 0)
A.insert(-1, 0)
distance = 0
B = []
0.upto(n) do |i|
    B << (A[i] - A[i+1]).abs
    distance += B[i]
end
1.upto(n) do |i|
    ans = distance
    ans -= B[i-1]
    ans -= B[i]
    ans += (A[i-1] - A[i+1]).abs
    puts ans
end

Measured memory_bytes: 12420
import scala.io.StdIn

object Main {

  case class Query(l: Int, r: Int)
  case class Memo(cnt: Int, pre: Char)

  def main(args: Array[String]): Unit = {

    val Array(n, q) = StdIn.readLine().split(' ').map(_.toInt)
    val s = StdIn.readLine().toIndexedSeq
    val lrs = (1 to q).map{_ =>
      val Array(l, r) = StdIn.readLine().split(' ').map(_.toInt)
      Query(l, r)
    }.toList
    val memos = s.foldLeft(Vector(Memo(0, 'Z'))){(acc, c) =>
      val memo = acc.last
      if (memo.pre == 'A' && c == 'C') {
        acc :+ Memo(memo.cnt + 1, c)
      } else {
        acc :+ Memo(memo.cnt, c)
      }
    }
    val ans = lrs.map{q =>
      memos(q.r).cnt - memos(q.l).cnt
    }
    ans.map(println)
  }

}


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

int main()
{
	double a,b,x;
	double PI = 3.141592653;
	cin >> a >> b >> x;
	double xx = 0;
	double tot = a * a * b;
	if(tot == x * 2){
		x = atan(b / a) * 180 / PI;
	}else if(tot > x * 2){
		x = atan(b / (2 * x / a / b)) * 180 / PI;
	}else{
		x = atan((b - (2 * (x - tot / 2) / a / a)) / a) * 180 / PI;
	}
	printf("%.8lf",x);
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#define lmid l,m,rt<<1
#define rmid m+1,r,rt<<1|1
#define LL long long
#define rl r-l+1
using namespace std;
int s[305][305];
long long dis[305][305];
long long sum = 0;
int vis[305][305];
int n;
int main() {
     scanf("%d", &n);
     for (int i = 1; i <= n; i++)
          for (int j = 1; j <= n; j++) {
               scanf("%d", &s[i][j]);
               dis[i][j] = s[i][j];
          }
     for (int k = 1; k <= n; k++)
          for (int i = 1; i <= n; i++)
               for (int j = 1; j <= n; j++) {
                    if(dis[i][j]>=dis[i][k]+dis[k][j])
                    {
                         dis[i][j] = dis[i][k] + dis[k][j];
                         if(i!=j&&i!=k&&k!=j)
                         {vis[i][j]=1;
                         vis[j][i]=1;}
                    }
               }
     bool flag = false;
     for (int i = 1; i <= n; i++)
          for (int j = 1; j <= n; j++)
               if (dis[i][j] != s[i][j]) {
                    flag = true;
                    break;
               }
     if (flag) {
          cout << -1 << endl;
          return 0;
     }
     for(int i=1;i<=n;i++)
          for(int j=i+1;j<=n;j++)
          {
               if(!vis[i][j])
                    sum+=dis[i][j];
          }
     cout<<sum<<endl;
}


Measured memory_bytes: 1664
// 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    string S;
    cin >> S;
    if (S.back() == 's')
    {
        S.append("es");
    }
    else
    {
        S.push_back('s');
    }
    cout << S << endl;
    
    return 0;
}


Measured memory_bytes: 3628
from collections import deque

n = int(input())
l = list(map(int, input().split()))
d = deque()

for i in range(n):
  if (i % 2 == 0):
    d.appendleft(l[i])
  else:
    d.append(l[i])

if (n % 2 == 0):
  d = reversed(d)

print(" ".join(map(str, d)))


Measured memory_bytes: 29252
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
//#define debug
//#define TRACE(x)

using namespace std;

typedef long long llint;

const int MAXN = 110;

int n;
string a, b;

int main(void) {
  scanf("%d",&n);
  cin >> a >> b;
  int sol = 2 * n;
  REP(i, n)
    if (a.substr(i, n - i) == b.substr(0, n - i))
      sol = min(sol, 2 * n - (n - i));
  printf("%d\n",sol);
  
  return 0;
}


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

int main() {
  
  
  int d, t, s;
  cin >> d >> t >> s;
  
  int x;
  x = t * s;
  
  if(d <= x){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  
  
 
  
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
using namespace std;
#define MAX 101

string mj;

void set(){
    for(int i = 0 ; i < 26 ; i++) mj += 'a'+i;
    for(char i = 26 ; i < 52 ; i++) mj += 'A'+i-26;
}

char change(int t,char ch){
    int i;
    for(i = 0 ; i < 52 ; i++){
        if(mj[i] == ch) break;
    }
    i -= t;
    if(i < 0) i+= 52;
    
    return mj[i];
}


int main(){
    int n,a[MAX];
    
    set();
    
    while(cin >> n,n){
        for(int i = 0 ; i < n ; i++) cin >> a[i];
        string str ,tmp = "";
        int k = 0;
        cin >> str;
        for(int i = 0 ; i < str.size() ; i++){
            tmp += change(a[k++],str[i]);
            if(k >= n) k = 0;
        }
        cout << tmp << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
	int n,k;
	cin>>n>>k;
	int mp[n+1];
	memset(mp, 0, sizeof(mp));
	while(k--) {
		int d, x;
		cin>>d;
		for(int i = 0; i < d; i++) {
			cin>>x;
			mp[x]++;
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) 
		if(mp[i] == 0) ans++;
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 3604
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a = Array.ConvertAll(line, int.Parse);
            if (a.Sum() == 0) break;
            var x = getTimes(a[0], a[1]);
            var y = getTimes(a[2], a[3]);
            var z = getTimes(a[4], a[5]);
            Console.WriteLine(Lcm(Lcm(x, y), z));
        }
    }
    public static int getTimes (int a, int m)
    {
        var rtime = 0;
        var x = 1;
        while (true)
        {
            x = (a * x) % m;
            rtime++;
            if (x == 1) return rtime;
        }
    }
    public static long Lcm (long a , long b)
    {
        if (a < b)  return Lcm(b, a);
        var ab = a * b;
        while (b != 0)
        {
            var wk = a % b;
            a = b;
            b = wk;
        }
        return ab / a;
    }
}

Measured memory_bytes: 9544
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,c=0,i,j,k,q;
  string s;
  while(cin>>n,n){
    c=0;
  cin>>m>>s;
  for(i=0;i<m-n*2;i++){
    if(s[i]=='I'){
      k=0;
      for(j=i,q=0;q<n;j+=2,q++){
	if(s[j+1]=='O'&&s[j+2]=='I')k++;
      }
      if(k==n)c++;
    }
  }
  cout<<c<<endl;
  }
}

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

using namespace std;

typedef long long LL;

#define mod 1000000007
#define INF_LL 1145141919810364

#define MAX_N 200005
#define MAX_Q 200005

int N, Q;
LL A[MAX_Q], B[MAX_Q], C[MAX_Q];

void input()
{
  cin >> N >> Q;
  for (size_t i = 0; i < Q; i++) {
    scanf("%lld %lld %lld", &A[i], &B[i], &C[i]);
  }
}

class UnionFind{
public:
  UnionFind(int _n)
  {
    init(_n);
  }

  void init(int _n)
  {
    par.clear();
    par.resize(_n);
    for (size_t i = 0; i < par.size(); i++) {
      par[i] = i;
    }
  }

  int find(int _x)
  {
    if(_x == par[_x]){
      return _x;
    }
    else{
      return par[_x] = find(par[_x]);
    }
  }

  void unite(int _x, int _y)
  {
    _x = find(_x);
    _y = find(_y);
    if(_x == _y){
      return;
    }
    par[_x] = _y;
  }

  bool same(int _x, int _y)
  {
    return find(_x) == find(_y);
  }

private:
  vector<int> par;
};

LL dp[MAX_N][2];
LL Cost[MAX_N];

vector<pair<LL, pair<int, int>>> EdgeList;
LL solve()
{
  for (size_t i = 0; i < N; i++) {
    Cost[i] = INF_LL;
  }

  for (size_t i = 0; i < Q; i++) {
    Cost[A[i]] = min(Cost[A[i]], C[i]+1);
    Cost[B[i]] = min(Cost[B[i]], C[i]+2);
  }

  for (size_t d = 0; d < 2; d++) {
    for (size_t i = 0; i < N; i++) {
      Cost[(i+1)%N] = min(Cost[(i+1)%N], Cost[i]+2);
    }
  }

  UnionFind uf(N);
  for (size_t i = 0; i < Q; i++) {
    EdgeList.push_back(make_pair(C[i], make_pair(A[i], B[i])));
  }
  for (size_t i = 0; i < N; i++) {
    EdgeList.push_back(make_pair(Cost[i], make_pair(i, (i+1)%N)));
  }

  sort(EdgeList.begin(), EdgeList.end());

  LL ret = 0;
  for (size_t i = 0; i < EdgeList.size(); i++) {
    auto edge = EdgeList[i];
    if(!uf.same(edge.second.first, edge.second.second)){
      uf.unite(edge.second.first, edge.second.second);
      ret += edge.first;
    }
  }

  return ret;
}

int main()
{
  input();

  cout << solve() << endl;

  return 0;
}


Measured memory_bytes: 15596
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 2 - 170;

int main() {
    int n, p = 0, q = INF<int>;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a, b;
        scanf("%d%d", &a, &b);
        p = max(p, a);
        q = min(q, b);
    }
    cout << p+q << "\n";
    return 0;
}


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

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

    string s;
    cin >> s;
    int win_num = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'o')
        {
            win_num++;
        }
    }

    if (win_num + 15 - s.size() >= 8)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n, w;
		cin >> n >> w;
		if (!n)break;
		vi v(100/ w+1,0);
		REP(i, n) {
			int a;
			cin >> a;
			v[a / w]++;
		}
		int p = -1, cmax = -1;
		cmax = *max_element(ALL(v));
		REP(i, v.size()) {
			if (v[i] > 0)p = i;
		}
		double ans = 0;
		REP(i, p+1) {
			ans += double(v[i]) / cmax*(1 - double(i) / p);
		}
		cout << fixed << setprecision(10) <<ans+0.01<< endl;
	}
	return 0;
}

Measured memory_bytes: 3224