akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
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; }
typedef long long ll;
#define pint pair<int,int>
#define pll pair<ll,ll>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int bin[3][3];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    rep(i,3) rep(j,3) cin >> bin[i][j];
    int n; cin >> n;
    rep(i,n) {
        int b; cin >> b;
        rep(j,3)rep(k,3){
            if(bin[j][k]==b) bin[j][k] = INF;
        }
    }
    bool flag = false;
    if(bin[0][0]==bin[0][1] && bin[0][1]==bin[0][2] && bin[0][2]==bin[0][0]) flag = true;
    if(bin[1][0]==bin[1][1] && bin[1][1]==bin[1][2] && bin[1][2]==bin[1][0]) flag = true;
    if(bin[2][0]==bin[2][1] && bin[2][1]==bin[2][2] && bin[2][2]==bin[2][0]) flag = true;
    if(bin[0][0]==bin[1][0] && bin[1][0]==bin[2][0] && bin[2][0]==bin[0][0]) flag = true;
    if(bin[0][1]==bin[1][1] && bin[1][1]==bin[2][1] && bin[2][1]==bin[0][1]) flag = true;
    if(bin[0][2]==bin[1][2] && bin[1][2]==bin[2][2] && bin[2][2]==bin[0][2]) flag = true;
    if(bin[0][0]==bin[1][1] && bin[1][1]==bin[2][2] && bin[2][2]==bin[0][0]) flag = true;
    if(bin[0][2]==bin[1][1] && bin[1][1]==bin[2][0] && bin[2][0]==bin[0][2]) flag = true;
    if(flag) 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 < (ll)(n); i++)
typedef long long ll;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<long long>> vvll;
typedef long double ld;
typedef std::vector<long double> vld;
typedef std::vector<std::vector<long double>> vvld;
using namespace std;
void yesno(bool state);

void Main(){
    ll N;
    cin >> N;
    vll A(N+1,0);
    rep(x,99)
        rep(y,99)
            rep(z,99){
                ll memo = (x+1)*(x+1) + (y+1)*(y+1) + (z+1)*(z+1) + (x+1)*(y+1) + (y+1)*(z+1) + (z+1)*(x+1);
                if(memo <= N)
                    A[memo]++;
            }
    rep(i,N) cout << A[i+1] << endl;
}

int main(int argc, char const *argv[])
{
    Main();
    return 0;
}

void yesno(bool state){
    if(state)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
	ll n;
	cin>>n;
	ll ans = 0;
	vector<ll> a;
	for(int i=1;i<=n;i++) {
		ll temp;
		cin>>temp;
		a.push_back(temp);
	}
	vector<ll> b = a;
	sort(a.begin(), a.end());
	for(int i=0;i<n;i++) {
		if(i&1) {
			ll ind = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
			if(ind%2 == 0) {
				ans ++;
			}
		}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(){
   long long n,d;
   cin>>n>>d;
   long long ans=0;
   rep(i,n){
       long long x,y;
       cin>>x>>y;
       if(x*x+y*y<=d*d) ans++;
   }
   cout<<ans;
}

Measured memory_bytes: 3624
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val nums = listOfInt()
    val sum = nums[0] + nums[1]

    if (sum % 2 == 1) {
        println("IMPOSSIBLE")
    } else {
        println(sum/2)
    }
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 36272
n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[0] == 0:
    print(0)
else:
    ans = 1
    for v in a:
        if v > 10 ** 18 // ans:
            print(-1)
            exit()
        ans *= v
    print(ans)


Measured memory_bytes: 88300
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE

signed main()
{   



      
      senky_bansal
      IIIT_ALLAHABAD
      
      // pre();
      ll t;
      // cin>>t;
      t=1;
      while(t--)
      { 
         
           ll n,m;
           cin>>n>>m;
           ll ans = (n*(n-1))/2;
           ans+=(m*(m-1))/2;
           cout<<ans<<endl;      

      }
      






}



























Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	int x = sc.nextInt();
      
      	if(x >= a && a+b >= x){
        	System.out.println("YES");
        }else{
        	System.out.println("NO");
        }
    }
}

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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;


ll N;
ll a[100010];
map<ll, ll> mp;
int main(){
	cin >> N;

	ll g = 0;
	ll zero = 0;
	REP(i,0,N){
		cin >> a[i];
		g ^= a[i];
		mp[a[i]]++;
		if(a[i] ==0) {
			zero=1;
		}
	}

	if(mp.size() == 3 && g==0){
		ll tmp = -1;
		for(auto m: mp){
			if(tmp==-1){
				tmp = m.second;
			}
			else if(m.second != tmp) {
				tmp = -2;
			}
		}
		if(tmp==-2) p("No");
		else p("Yes");
	}else if(zero && mp.size() == 2 && g==0){
		ll a, b;
		for(auto m: mp){
			if(m.first==0){
				a = m.second;
			}
			else {
				b = m.second;
			}
		}
		if(b != a*2) p("No");
		else p("Yes");
	}else if(zero && mp.size()==1){
		p("Yes");
	}else{
		p("No");
	}

	return 0;
}

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

using namespace std;

void print_num(vector<int> num, int len)
{
    for (int i = 0; i < len; i++)
    {
        if (i > 0)
        {
            cout << " ";
        }
        cout << num[i];
    }
    
    cout << endl;
}

void insert_sort(vector<int> &num, int len)
{
    print_num(num, len);
    
    for (int i = 1; i < len; i++)
    {
        int j = i - 1;
        int val = num[i];
        while ((j >= 0) && (num[j] > val))
        {
            num[j + 1] = num[j];
            j--;
        }
        num[j + 1] = val;
        print_num(num, len);
    }
}

int main()
{
    int cnt = 0;
    int tmp = 0;
    vector<int> num;
    
    cin >> cnt;
    for (int i = 0; i < cnt; i++)
    {
        cin >> tmp;
        num.push_back(tmp);
    }
    
    insert_sort(num, cnt);
    
    return 0;
}



Measured memory_bytes: 3108
#include <cstdio>
#include <utility>
#include <array>


using uint = unsigned int;
constexpr uint N = 1e6;
constexpr uint mod = 1e9 + 7;

// a^nを返す関数
constexpr uint power(uint a, uint n)noexcept{
    unsigned long long res = 1, waiting = a;
    while(n){ 
        if(n & 1) { res *= waiting; res %= mod; }
        waiting *= waiting; waiting %= mod; 
        n >>= 1;
    }
    return res;
}


template <unsigned int N> struct shuumai{
    unsigned int minPrime[N + 1];
    unsigned int Next[N + 1];
    unsigned int Primes[N + 1];
    unsigned int size_;
    unsigned int Power[N + 1];
    unsigned int powInverse[N + 1];
    unsigned int inverse[N + 1];

    constexpr shuumai(void): minPrime(), Primes(), Next(), Power(), powInverse(), inverse(), size_(0U){
        minPrime[0] = 1; minPrime[1] = 1;
        for(int even = 2, odd = 3; odd <= N; even += 2, odd += 2){
            minPrime[even] = 2;
            minPrime[odd] = odd;
        }
        if(!(N & 1)) minPrime[N] = 2;
        Primes[size_++] = 2;
        
        for(unsigned int x = 3; x <= N; x += 2){
            if(minPrime[x] == x) Primes[size_++] = x;
            for(int y = 0; y < size_ and Primes[y] <= minPrime[x] and x * Primes[y] <= N; ++y)
                    minPrime[x * Primes[y]] = Primes[y];
        }
        for(unsigned  int x = N; x >= 2; --x) Next[x] = x / minPrime[x];
        
        Power[0] = 1; Power[1] = 1;
        for(unsigned long long int x = 2; x <= N; ++x) Power[x] = Power[x - 1] * x % mod;
        powInverse[N] = power(Power[N], mod - 2);
        for(unsigned long long int x = N; x >= 2; --x){
            powInverse[x - 1] = x * powInverse[x] % mod;
            inverse[x] = (unsigned long long int)(Power[x-1]) * powInverse[x] % mod;
        }
        inverse[1] = 1;
    }
    // 範囲for文用の begin() と end()
    const unsigned int *begin(void) const noexcept{ return Primes; }
    const unsigned int *end(void) const noexcept{ return Primes + size_;}
    const unsigned int size(void) const {return this.size_;}
};


uint fastRead(void) {
    char c;
    while(true){
        c = getchar();
        if('0' <= c) break;
    }
    uint res = c - '0';
	while(true){
        c = getchar();
        if(c < '0') break;
        res = 10 * res + (c - '0');
    }
    return res;
}


constexpr shuumai<N> P;
std::array<uint, N + 1> Count;

int main(void){
    uint n = fastRead();
    uint inv_sum = 0;
    for(uint _ = 0; _ < n; ++_){
        uint a = fastRead();
        inv_sum += P.inverse[a]; if(inv_sum >= mod) inv_sum -= mod;
        while(a - 1U){
            uint fac = P.minPrime[a];
            uint cnt = 1; a = P.Next[a];
            while(fac == P.minPrime[a]) a = P.Next[a], cnt++;
            if(Count[fac] < cnt) Count[fac] = cnt; 
        }
    }

    unsigned long long int lcm = 1;
    for(unsigned int x : P) if(Count[x]) (lcm *= power(x, Count[x])) %= mod;
    unsigned int res = lcm * inv_sum % mod;
    
    printf("%u\n", res);
    return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
using namespace std;

int memo[2000][2000],p=pow(10,9)+7;
int func(int i,int j){
    if(i<j)return 0;
    if(j==0||i==j)return 1;
    if(memo[i][j]!=-1)return memo[i][j];

    return memo[i][j]=(func(i-1,j-1)%p+func(i-1,j)%p)%p;
}
int main(){
    for(int i=0;i<2000;++i){
        for(int j=0;j<2000;++j)
            memo[i][j]=-1;
    }
    int N,K,a,b;
    cin>>N>>K;
    a=N-K+1;
    b=K-1;

    long long x;
    for(int i=1;i<=K;++i){
        x=(long long)func(a,i)*func(b,i-1);
        cout<<x%p<<endl;
    }   
    return 0;
}

Measured memory_bytes: 16000
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0 ; i < k ; i++) {
            int d = sc.nextInt();
            for (int j = 0 ; j < d ; j++) {
                int g = sc.nextInt();
                a[g - 1]++;
            }
        }
        int c = 0;
        for (int i = 0 ; i < n ; i++) {
            if (a[i] == 0) c++;
        }
        System.out.println(c);
    }

}

Measured memory_bytes: 46312
n, k = map(int,input().split())
s = 0
ans = 0
x = []
for _ in range(n):
    a,b = map(int,input().split())
    x.append([a,b])
x.sort()
for i in range(n):
    s += x[i][1]
    if s >= k:
        ans = x[i][0]
        break
print(ans)


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

int main() {
	int N;
	cin >> N;
	int total = 0;
	for (int i = 1; i < N + 1; i++) {
		if (i * i <= N) {
			total = i * i;
		}
		else {
			break;
		}
	}
	cout << total << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n, a, d, m, K, x[200000], y[200000], z[200000];

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	cin >> n >> a >> d >> m;
	rep(i, m){
		cin >> x[i] >> y[i] >> z[i];
		y[i]--;
	}
	cin >> K; K--;
	
	for(int i = m - 1; i >= 0; i--) if(x[i] == 0){
		if(y[i] <= K && K < z[i]) K = z[i] - 1 - K + y[i];
	}
	int cur = a + K * d;
	rep(i, m){
		if(x[i] == 0 && y[i] <= K && K < z[i]) K = z[i] - 1 - K + y[i];
		if(x[i] == 1 && y[i] <= K && K < z[i]) cur++;
		if(x[i] == 2 && y[i] <= K && K < z[i]) cur /= 2;
	}
	cout << cur << endl;
	
	return 0;
}

Measured memory_bytes: 5260
#include<bits/stdc++.h>
#define MAXN 1e5

using namespace std;

float l,a,b,c;

int main(){
    cin>>l;
    int q=l;
    a=l/3;
    b=l/3;
    c=l/3;
    if (q%3==1){
        c+=0.000001;
    }
    else if (q%3==2){
        a-=0.000001;
    }
    cout<<fixed<<setprecision(6)<<a*b*c<<endl;
}


Measured memory_bytes: 3768
import java.util.*;
import java.io.*;

class Main {

	void solve() {
		
		String s = instr().substring(0, 1) + instr().substring(0, 1) + instr().substring(0, 1);
		out.println(s.toUpperCase());

	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}

	public String instr() {
		return in.next();
	}

	public char inchar() {
		return in.next().charAt(0);
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()

int main()
{
    int n;
    cin >> n;
    vector<tuple<string, int, int>> a;
    for (int i = 1; i <= n; i++)
    {
        string s;
        int p;
        cin >> s >> p;
        p = -p;
        a.push_back(tie(s, p, i));
    }
    sort(all(a));
    for (int i = 0; i < n; i++)
    {
        cout << get<2>(a[i]) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
s = input()
k = int(input())
cnt = 0
if len(set(list(s))) == 1:
	cnt = k * len(s) // 2
	print(cnt)
	exit()

x, y = 0, 0
t = s + s
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		x += 1
		s = s[:i+1] + '#' + s[i+2:]

for i in range(len(t) - 1):
	if t[i] == t[i + 1]:
		y += 1
		t = t[:i+1] + '#' + t[i+2:]

cnt = x + (k - 1) * (y - x)
print(cnt)

Measured memory_bytes: 38256
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
// int main(){

//   int A , B,K;

//   cin >> A >> B >> K;

//   return 0;
// }

int main()
{

  int A, B, C;

  cin >> A >> B >> C;

  if (A > B)
  {
    cout << 0 << endl;
  }
  else
  {
    if (B / A >= C)
    {
      cout << C << endl;
    }
    else
    {
      cout << B/A << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<cstring>

using namespace std;

const long long MOD = 1000000007;

int main()
{
    long long ans, n, k;
    while(cin >> n >> k) {
        ans = 0;
        for(long long i = k; i <= n+1; i++) {
            ans += n*i-i*i+i+1;
            ans %= MOD;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const ll MOD=1e9+7;
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  cout << (a==b ? a*2 : max(a,b)*2-1) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    ll ans;
    if (A == B) {
        ans = A * 2;
    } else {
        ans = max(A, B) * 2 - 1;
    }
    cout << ans << endl;
}


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

int main(){
  int N;
  long fac;
  
  cin >> N;
  
  fac = 1;
  for(int i=1; i<N+1; ++i)
    fac = i * fac % 1000000007;
  
  cout << fac << endl;
  
  return 0;
}

Measured memory_bytes: 256
from sys import maxsize
N = int(input())
arms = []
for i in range(N):
    x, l = map(int, input().split())
    arms.append((x-l, x+l))

arms.sort(key=lambda x: x[1])

end = -maxsize

res = 0

for arm in arms:
    if end <= arm[0]:
        res += 1
        end = arm[1]
print(res)


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

const int N = 100050;
int cnt[N];

int main() {
  int n, a;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    cnt[a]++;
    cnt[a+1]++;
    cnt[a+2]++;
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans = max( ans, cnt[i]);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll layer[64];
ll patty[64];
void calclayer(){
    layer[0]=1;
    patty[0]=1;
    for(int i=0;i<55;i++){
        layer[i+1]=layer[i]*2+3;
        patty[i+1]=patty[i]*2+1;
    }
}
ll calc(ll n,ll x){
    if(x==0) return 0;
    if(x>0&&x<(layer[n]+1)/2) return calc(n-1,x-1);
    if(x==(layer[n]+1)/2) return patty[n-1]+1;
    if(x>(layer[n]+1)/2&&x<layer[n]) return patty[n-1]+1+calc(n-1,x-(layer[n-1]+2));
    if(x==layer[n]) return patty[n];
    return 0;
}
int main(){
    ll n,x;cin>>n>>x;
    calclayer();
    ll ans=calc(n,x);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
//Robs Code
#include<bits/stdc++.h>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define all(x) x.begin(),x.end()
#define ed cout<<"\n";
#define pb push_back
#define pii pair<ll,ll>
#define _1 first
#define _2 second
#define maxi 100000007
/**********************************************************/
using namespace std;
ll i,j,k,n,m,q,t,a,b,c,cnt,sum,tot;
ll part[100001],sz[100001],cur,connect;
void init(ll n){
    for(i=1;i<=n;i++){
        part[i]=i;
        sz[i]=1;
    }
}
 ll findParent(ll k){
     return part[k]==k?k:part[k]=findParent(part[k]);
 }
void unite(ll x,ll y){
    x=findParent(x),y=findParent(y);
    if(x==y) return ;
    cur -= (sz[x]*sz[y]);
    sz[x]+=sz[y];
    sz[y]=0;
    part[y]=x;
}
int main() 
{
    speed;
    cin>>n>>m;
    init(n);
    vector<pii> v(m);
    fri(0,m-1) cin>>v[i]._1>>v[i]._2;
    vector<ll> ans;
    cur=n*(n-1)/2;
    for(i=m-1;i>=0;i--){
        ans.pb(cur);
         unite(v[i]._1,v[i]._2);
    }
    for(i=ans.size()-1;i>=0;i--)
        cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 5364
a = input()
b = input()
if len(a)>len(b):
    print('GREATER')
elif len(b)>len(a):
    print('LESS')
else:
    if int(a)>int(b):
        print('GREATER')
    elif int(b)>int(a):
        print('LESS')
    else:
        print('EQUAL')

Measured memory_bytes: 3060
def main():
    h, w = map(int, input().split())
    ans_i, ans_j = 0, 0
    for i in range(h):
        s = list(map(str, input().split()))
        for j in range(w):
            if s[j] == "snuke":
                ans_i = i
                ans_j = j
    print(chr(ord("A")+ans_j)+str(ans_i+1))

if __name__ == "__main__":
    main()


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

int main() {
  int m, f, r;
  while(true) {
    cin >> m >> f >> r;
    if(m == -1 && f == -1 && r == -1) {
      break;
    }

    if(m == -1 || f == -1 || m + f < 30) {
      cout << "F" << endl;
    } else if (m + f >= 80) {
      cout << "A" << endl;
    } else if (m + f >= 65 && m + f < 80) {
      cout << "B" << endl;
    } else if (m + f >= 50 && m + f < 65 || m + f >= 30 && m + f < 50 && r >= 50) {
      cout << "C" << endl;
    } else {
      cout << "D" << endl;
    }
  }
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define maxn 620
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define inf 0x3f3f3f3f
typedef long long ll;
typedef pair<int,int> pr;

const ll mod = 1e9 + 7;
ll f[maxn][maxn],g[maxn * 2];
int tag[maxn],n,k,cnt[maxn][maxn];

int main(){
	scanf("%d %d",&n,&k);
	rep(i,1,n * 2) tag[i] = -1;
	rep(i,1,k){
		int x,y;
	   	scanf("%d %d",&x,&y);
		tag[x] = y;
		tag[y] = x;
	}
	n *= 2 , k *= 2;
	g[0] = 1;
	rep(i,2,n) if ( !(i & 1) ) g[i] = g[i - 2] * (i - 1) % mod;
	ll ans = 0;
	rep(i,1,n){
		rep(j,i,n){
			cnt[i][j] = cnt[i][j - 1] + (tag[j] == -1);
		}
	}
	rep(i,1,n){
		int mn = n + 1 , mx = 0;
		if ( ~tag[i] ) mn = mx = tag[i];
		rep(j,i + 1,n){
			if ( ~tag[j] ) mn = min(mn,tag[j]) , mx = max(mx,tag[j]);
			if ( mn < i ) break;
			if ( mx > j || (cnt[i][j] & 1) ) continue;
			f[i][j] = g[cnt[i][j]];
			rep(k,i + 1,j - 1) f[i][j] = (f[i][j] - f[i][k] * g[cnt[i][j] - cnt[i][k]] % mod + mod) % mod;
			ans = (ans + f[i][j] * g[n - k - cnt[i][j]]) % mod;
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 4608
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n, k = map(int, input().split())
p_array = np.array(list(map(int, input().split())))
expc = lambda x: (x+1.0)/2.0
p_array = expc(p_array)

p_cum = np.cumsum(p_array)
p_cum_diff = p_cum[k:] - p_cum[0:n-k]
if len(p_cum_diff) > 0:
    print(max(p_cum_diff))
else:
    print(p_cum[-1])

Measured memory_bytes: 35180
#include <bits/stdc++.h>
#define M 55555
using namespace std;
vector<int> getPrimes(int n) {
  vector<bool> prime(n + 1, true);
  prime[0] = prime[1] = false;
  vector<int> primes;
  for (long long i = 2; i * i <= n; i++)
    if (prime[i]) {
      for (long long j = i * i; j <= n; j += i)
        prime[j] = false;
    }
  for (int i = 0; i <= n; i++) {
    if (prime[i]) primes.push_back(i);
  }
  return primes;
}
int main() {
  int n = 0, N;
  cin >> N;
  for (int x : getPrimes(M)) {
    if (x%5 == 1) cout << x << ' ';
    n += x%5 == 1;
    if (n == N) return 0;
  }
}

Measured memory_bytes: 3696
program main
	read *, i, j ,k
	if (i<j) then
		if (j<k)then
			print *, i+j
			stop
		else 
			print *, i+k
			stop
		end if
	else
		if (i<k) then
			print *, i+j
			stop
		else
			print *, j+k
			stop
		end if
	end if
	end

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

using ll = long long int;
using P = pair<int, int>;
using P3 = pair<ll,P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9) + 7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-8;

bool solve(){
    int n, q = 1000;
    cin >> n;
    vector<string> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    vector<int> cnt(n, 0);
    vector<int> pre;
    for(int i=0;i<n;i++){
        pre.push_back(i+1);
    }
    for(int t=0;t<q;t++){
        int hnd = 1, maxi = -INF;
        for(auto x : pre){
            cnt[x]++;
        }
        for(int i=0;i<n;i++){
            int scr = 0;
            for(int j=0;j<n;j++){
                if(a[i][j] == 'o') scr += 2*cnt[j];
                else if(a[i][j]== '-') scr += cnt[j];
                // else  scr--;
                // if(a[i][j] == 'x') scr-=cnt[j];
            }
            if(scr > maxi){
                maxi = scr;
                hnd = i+1;
            }
        }
        cout << hnd << endl;
        int ai;
        cin >> ai;
        pre.push_back(ai-1);
        if(pre.size() > 50) pre.erase(pre.begin());
    }
    return false;
}

int main(){
    solve();
    // while(!solve());
    // int t; cin >> t; for(;t>0;t--) solve();
    return 0;
}


Measured memory_bytes: 3392
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, int> pii;
const int N = 1e5 + 5, P = 1e9 + 7;
struct edge {
	int nxt, to, w;
} e[N << 2];
int n, m, cnt = 1, s, t;
ll ans;
int h[N], vis[N];
ll ds[N], dt[N], ways[N], wayt[N];
void dj(int s, ll *d, ll *way) {
	for(int i = 1; i <= n; ++i) {
		d[i] = 1e18;
		vis[i] = 0;
	}
	d[s] = 0;
	way[s] = 1;
	priority_queue<pii, vector<pii>, greater<pii> > q;
	q.push(make_pair(0, s));
	while(!q.empty()) {
		pii o = q.top();
		q.pop();
		int u = o.second;
		if(vis[u]) {
			continue;
		}
		vis[u] = 1;
		for(int i = h[u]; i; i = e[i].nxt) {
			ll tmp = d[u] + e[i].w;
			if(tmp < d[e[i].to]) {
				d[e[i].to] = tmp;
				way[e[i].to] = 0;
				q.push(make_pair(d[e[i].to], e[i].to));
			}
			if(tmp == d[e[i].to]) {
				way[e[i].to] = (way[u] + way[e[i].to]) % P;
			}
		}
	}
}
void link(int u, int v, int w) {
	e[++cnt].nxt = h[u];
	h[u] = cnt;
	e[cnt].to = v;
	e[cnt].w = w;
}
int main() {
	scanf("%d%d%d%d", &n, &m, &s, &t);
	for(int i = 1; i <= m; ++i) {
		int u, v, w;
		scanf("%d%d%d", &u, &v, &w);
		link(u, v, w);
		link(v, u, w);
	}
	dj(s, ds, ways);
	dj(t, dt, wayt);
	ans = ways[t] * ways[t] % P;
	for(int i = 1; i <= n; ++i) {
		if(ds[i] * 2 == ds[t] && ds[i] + dt[i] == ds[t]) {
			ans = ((ans - ways[i] * ways[i] % P * wayt[i] % P * wayt[i] % P) % P + P) % P;
		}
	}  
	for(int i = 1; i <= n; ++i) {
		for(int j = h[i]; j; j = e[j].nxt) {
			if(ds[i] + dt[e[j].to] + e[j].w == ds[t]) {
				if(ds[i] * 2 < ds[t] && dt[e[j].to] * 2 < ds[t]) {
					ans = ((ans - ways[i] * ways[i] % P * wayt[e[j].to] % P * wayt[e[j].to] % P) % P + P) % P;
				}
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 12500
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll Nagaemon1;
void swap(ll i,ll j){
  Nagaemon1=i;
  i=j;
  j=Nagaemon1;
}
ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main(void){
  ll n;
  cin >> n;
  ll a[n];
  rep(i,n){
    cin >> a[i];
  }
  sort(a,a+n);
  ll ans=-a[n-1];
  rep(i,n){
    ans+=a[n-1-i/2];
  }
  cout << ans << endl;
}

Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  bool is_ok = false;
  if (A <= C && C <= B)
    is_ok = true;
  printYesNo(is_ok);
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        Integer[] a = new Integer[n];

        for (int i = 0; i < n; i++) {
            a[i] = scan.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 != 0) {
                bob += a[i];
            } else {
                alice += a[i];
            }
        }

        System.out.print(alice - bob);
    }
}

Measured memory_bytes: 22996
#include <cstdio>
#include <iostream>
#include <string>
#include <complex>
using namespace std;

#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
typedef double D;
typedef complex<D>P;

const int MAX_X = 10;
const int MAX_Y = 10;
int m[MAX_Y+1][MAX_X+1];

int main(){
    string s;
    while(getline(cin, s)){
        int x, y, sz;
        sscanf(s.c_str(), "%d,%d,%d", &x, &y, &sz);
        P p1(x,y);
        double r = (sz + 1.0) / 2; r = r*r;
        REPEAT(ny, -2, 3){
            int y2 = y + ny; if(y2 < 0 || y2 >= MAX_Y) continue;
            REPEAT(nx, -2, 3){
                int x2 = x + nx; if(x2 < 0 || x2 >= MAX_X) continue;
                P p2(x2, y2);
                if(norm(p1-p2) <= r) m[y2][x2]++;
            }
        }
    }
    int zeronum = 0, max = -1;
    REP(y,MAX_Y) REP(x,MAX_X){
        if(m[y][x] == 0) zeronum++;
        max = MAX(max, m[y][x]);
    }
    cout << zeronum << endl << max << endl;
    return 0;
}

Measured memory_bytes: 1252
def d():
	from bisect import bisect_left
	N = int(input())
	S = input()
	chars_at = {}
	for i in range(N):
		try:
			chars_at[S[i]].append(i)
		except KeyError:
			chars_at[S[i]] = [i]
	ans = 0
	for i in range(1000):
		s = str(i).zfill(3)
		cur = -1
		for j in range(3):
			try:
				p = bisect_left(chars_at[s[j]],cur)
			except KeyError:
				break

			if p < len(chars_at[s[j]]):
				cur = chars_at[s[j]][p] + 1
			else:
				break
		else:
			ans += 1
	print(ans)
d()

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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mp(v1, v2)       make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arrll(a,n);

  int odd=0, div4=0, div2=0;
  rep(i,n){
    if(a[i]%4==0) div4++;
    else if(a[i]%2==0 && a[i]%4!=0) div2++;
    else odd++;
  }
  prtok(div4-odd>=0 || (div4-odd==-1 && div2==0));

}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scn = new Scanner(System.in)) {
			int N = scn.nextInt();
			int M = scn.nextInt();
			int[] H = new int[N];
			int[] good_tenbodai = new int[N];
			int[][] AB = new int[M][2];

			for(int i = 0; i < N; i++) {
				H[i] = scn.nextInt();
			}

			for(int i = 0; i < M; i++) {
				AB[i][0] = scn.nextInt();
				AB[i][1] = scn.nextInt();
			}

			for(int i = 0; i < M; i++) {
				if(H[AB[i][0]-1] <= H[AB[i][1]-1]) {
					good_tenbodai[AB[i][0]-1] = 1;
				}
				if(H[AB[i][0]-1] >= H[AB[i][1]-1]) {
					good_tenbodai[AB[i][1]-1] = 1;
				}
			}

			int cnt = 0;
			for(int i = 0; i < N; i++) {
				if(good_tenbodai[i] == 0) cnt++;
			}

			System.out.println(cnt);
		}
	}
}

Measured memory_bytes: 53496
#include "bits/stdc++.h"
using namespace std;

int main()
{
    unsigned long long n, a, b;
    cin >> n >> a >> b;
    auto length = a + b;
    auto cycle = n / length;
    // cout << cycle << endl;
    auto rest = n - length * cycle;
    // cout << rest << endl;
    auto last_cycle_blue = rest != 0 ? min(rest, a) : 0;
    // cout << last_cycle_blue << endl;

    cout << a * cycle + last_cycle_blue << endl;
}


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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

constexpr ll P = 27;

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

    int N;
    cin >> N;

    vs S(N);
    for (int i=0;i<N;i++) cin >> S[i];

    // unordered_map<ll, int> right;
    // unordered_map<ll, int> zleft;
    // unordered_map<ll, int> zright;

    unordered_set<ll> left;
    for (const string& s : S) {
        ll cur = 0;
        int n = s.length();
        for (int i=0;i<n;i++) {
            cur *= P;
            cur += (s[n-1-i]-'a') + 1;
        }
        left.insert(cur);
    }

    ll ans = 0;
    for (const string& s : S) {
        vi freqs(26, 0);
        int n = s.length();
        for (int i=0;i<n;i++) freqs[s[i]-'a']++;

        // suffixes
        ll cur = 0;
        for (int i=0;i<=n-1;i++) {
            if (i < n-1) {
                for (int j=0;j<26;j++) {
                    if (freqs[j] > 0) {
                        ll nxt = cur*P + (j+1);
                        if (left.find(nxt) != left.end()) ans++;
                    }
                }
            }

            cur *= P;
            cur += (s[n-1-i]-'a')+1;
            freqs[s[n-1-i]-'a']--;
        }

    }

    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 17624
def main():
    N, K = (int(i) for i in input().split())
    F = [True]*N
    for _ in range(K):
        d = int(input())
        A = [int(i) for i in input().split()]
        for a in A:
            F[a-1] = False
            # いたずらうけない
    ans = 0
    for f in F:
        if f:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 67592
import sys
import codecs
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    S=list(input())
    ans=''
    for a in S:
        ans+=chr(ord(a)+N) if ord(a)+N<=90 else chr(ord(a)+N-26)
    print(ans)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 41580
#include <bits//stdc++.h>
using namespace std;
#define int long long
#define rep(i,k) for(int i=0;i<k;i++)
signed main(void){
    int m,n,a,b,c;
    map<string,int> moji;
    cin>>n;
    int ans=0;
    rep(i,n){
        string s;
        cin>>s;
        vector<char> temp;
        rep(j,10) temp.push_back(s[j]);
        sort(temp.begin(),temp.end());
        rep(j,10)
        s[j]=temp[j];
        if(moji.find(s)==moji.end())
        moji[s]=1;
        else{
            ans+=moji[s];
            moji[s]++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
int a[55],b[55];
int ab(int x)
{
    if(x<0)x=-x;
    return x;
}
int main()
{
    int n;
    cin>>n;
    int t=0,ti=1;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(t<ab(a[i]))
        {
            t=ab(a[i]);
            ti=i;
        }
    }
    printf("%d\n",2*(n-1));
    for(int i=1;i<=n;i++)
    {
        if(i!=ti)
        {
            a[i]+=a[ti];
            printf("%d %d\n",ti,i);
        }
    }
    if(a[1]<0)
    {
        for(int i=n-1;i>0;i--)
            printf("%d %d\n",i+1,i);
    }
    else
    {
        for(int i=1;i<n;i++)
        printf("%d %d\n",i,i+1);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int x,y;
    cin>>x>>y;
    int group1[7]={1,3,5,7,8,10,12};
    int group2[4]={4,6,9,11};
    int group3[1]={2};
    
    for(int i=0;i<7;i++){
        if(x==group1[i]){
            for(int j=i+1;j<7;j++){
                if(y==group1[j]){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    for(int i=0;i<4;i++){
        if(x==group2[i]){
            for(int j=i+1;j<4;j++){
                if(y==group2[j]){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    for(int i=0;i<1;i++){
        if(x==group3[i]){
            for(int j=i+1;j<1;j++){
                if(y==group3[j]){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

int main(){
  int a,b,c,d;
  int m,s;

  cin >> a >> b >> c >> d;
  m = a*b;
  s = c*d;
  if(m > s)
    {
      cout << m << endl;
    }
  else
    {
      cout << s << endl;
    }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
using P = pair<int,int>;

int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<char>> A(H,vector<char>(W));
    vector<vector<int>> dp(H,vector<int>(W,0));
    vector<vector<bool>> visited(H,vector<bool>(W,false));
    const char wall = '#';
    const int dx[4] = {0,1};
    const int dy[4] = {1,0};

    for(int h=0;h<H;h++){
        for(int w=0;w<W;w++){
            cin >> A[h][w];
        }
    }

    queue<P> que;
    que.push({0,0});
    dp[0][0] = 1;
    while(!que.empty()){
        P now = que.front(); que.pop();
        int y = now.first;
        int x = now.second;
        if(visited[y][x]) continue;
        visited[y][x] = true;

        for(int i=0;i<2;i++){
            int ny = y + dy[i];
            int nx = x + dx[i];

            if(ny < 0 || ny >= H || nx < 0 || nx >= W || A[ny][nx] == wall) continue;

            (dp[ny][nx] += dp[y][x]) %= MOD;
            que.push({ny,nx});
        }
    }

    cout << dp[H-1][W-1] << endl;

}

Measured memory_bytes: 5376
z = input()
a = ["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"]
for b in range(26):
    if a[b]==z:
        c=b+1
print(a[c])

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

int main() {
    int H, W, i, j;
    while (1) {
        cin >> H >> W;
        if (H == 0 && W == 0) {return 0;}
        for (i = 0; i < H; ++i) {
            for (j = 0; j < W; ++j) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}

Measured memory_bytes: 3088
N, M = map(int, input().split())

K = []
A = []
ans = 0

for i in range(N):
    line = list(map(int, input().split()))
    K.append(line[0])
    A.append(line[1:])

for i in range(1, M+1):
    c = 0
    for a in A:
        if i in a:
            c += 1

    if c == N:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define N 998244353
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll r;
    cin>>r;
    cout<<r*r;
    return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int n, k, S, T;
// S: AND
// T: OR

bool compat(int x) {
    if ((x|T) != T) return false;
    if ((x&S) != S) return false;

    return true;
}


bool ok(ll mask) {
    // check S
    for (int i=0; i<18; i++) {
	if (!(S>>i&1)) {
	    if (mask>>i&1) {
		if (!((mask>>(i+18))&1)) {
		    return false;
		}
	    }
	}
    }

    // check T
    for (int i=0; i<18; i++) {
	if (T>>i&1) {
	    if (!(mask>>i&1)) {
		return false;
	    }
	} else {
	    if (mask>>i&1) {
		return false;
	    }
	}
    }



    return true;
}


ll make(ll x, ll mask) {
    mask |= x;
    x = (~x)&((1<<18)-1);
    mask |= (x<<18);

    return mask;
}

unordered_map<ll, ll> dp[55]; // dp[size][have]

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

    cin>>n>>k>>S>>T;
    if ((S&T) != S) out(0);

    vector<int> a;
    while (n--) {
	int x;
	cin>>x;
	if (compat(x)) {
	    a.push_back(x);
	}
    }

    dp[0][0] = 1;


    for (int x: a) {
	for (int sz=k-1; sz>=0; sz--) {
	    for (auto p: dp[sz]) {
		ll nmask = make(x, p.first);
		dp[sz+1][nmask] += p.second;
	    }
	}
    }

    ll res = 0;
    for (int i=1; i<=k; i++) {
	for (auto p: dp[i]) {
	    if (ok(p.first)) {
		res += p.second;
	    }
	}
    }

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


Measured memory_bytes: 107488
import numpy as np

U = 10**5
is_prime = np.full(U+1,True)
is_prime[:2] = False
for p in range(2,U+1):
  if p*p > U:
    break
  if is_prime[p]:
    is_prime[p*p::p] = False

sophy = np.zeros(U+1,dtype = np.int32)
for p in range(1,U+1):
  if 2*p > U:
    break
  if is_prime[p] and is_prime[2*p-1]:
    sophy[2*p-1] = 1

sophy_cnt = sophy.cumsum()

# 入力に対応ここから
Q = int(input())
for i in range(Q):
  l,r = map(int,input().split())
  ans = sophy_cnt[r] - sophy_cnt[l-1]
  print(ans)
  

Measured memory_bytes: 16448
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<string>
#include<list>
using namespace std;

typedef long long ll;

int main(){
	int n; cin>>n;
	vector<ll>a(n);
	list<ll> b;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++){
		if((n-1)%2==i%2){
			b.push_front(a[i]);
		}else{
			b.push_back(a[i]);
		}
	}
	for(auto itr=b.begin();itr!=b.end();itr++){
		cout<<*itr<<" ";
	}
	cout<<endl;
	return 0;
}


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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int count=0;
  for(int i=100;i>0;i--){
    if(a%i==0&&b%i==0)
      count++;
    if(count==c){
      cout<<i<<endl;
      break;
    }
  }
}

Measured memory_bytes: 256