akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

  bool flg = false;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if (S == "Y") {
      flg = true;
      break;
    }
  }

  if (flg) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}

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

int main()
{
	int y1, y2, m, d, x1, x2, u = 1;
	
	cin >> y1 >> m >> d;
	x1 = m * 100 + d;
	cin >> y2 >> m >> d;
	x2 = m * 100 + d;

	if ((y1 - y2)*(x1 - x2) < 0 || x1 == x2)
		u = 0;

	cout << abs(y1 - y2) + u << endl;

	return 0;
}



Measured memory_bytes: 3276
#include<bits/stdc++.h>
#define ll long long
#define fin(x) scanf("%lld",&x)
#define fout(x) printf("%lld\n",x)
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)
#define cases int t;  scanf("%d",&t);   while(t--)
#define MOD 1000000007
#define MAXN 123456
#define read() freopen("lele.txt","r",stdin)
#define write() freopen("dede.txt","w",stdout)

using namespace std;

int main()
{
    ll n;
    fin(n);
    string s1, s2;
    cin >> s1 >> s2;
    for(ll i = 0; i < n; i++)
        cout << s1[i] << s2[i];
    cout << endl;
    return 0;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

struct UnionFind {
  vector<ll> P;
  UnionFind(ll n) : P(n+1, -1) {}

  ll root(ll n) {
    if (P[n] < 0)
      return n;
    else
      return P[n] = root(P[n]);
  }

  bool same(ll x, ll y) { return root(x) == root(y); }

  bool unite(ll x, ll y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    if (-P[x] > -P[y])
      swap(x, y);
    P[y] += P[x];
    P[x] = y;
    return true;
  }

  ll size(ll n) { return -P[root(n)]; };
};

#define REP(i, n) for(ll i = 0 ; i < n; i++)

#ifdef DEBUG
#define DBG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)
#else
#define DBG(fmt, ...)
#endif

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N, M;
    cin >> N >> M;

    UnionFind u(N);

    REP(i, M){
       ll A, B;
       cin >> A >> B;
       u.unite(A,B);
    }

    ll ans = 0;
    for(int i = 0 ; i < N; i++ ){
        ans  = max(ans, u.size(i+1));
    }

    cout << ans << endl;


}


Measured memory_bytes: 4788
import sys, math
from functools import lru_cache
import numpy as np
from collections import defaultdict
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

# nまでの自然数が素数かどうかを表すリストを返す
def makePrimeChecker(n):
    isPrime = [True] * (n + 1)
    isPrime[0] = False
    isPrime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if isPrime[i]:
            for j in range(i * i, n + 1, i):
                isPrime[j] = False
    return isPrime


def main():
    S = input()
    print(S[:-8])

if __name__ == '__main__':
    main()


Measured memory_bytes: 27132
N = int(input())
s = []
for i in range(N):
    s.append(sorted(input()))
s.sort()

ans = 0
cnt = 1 # for combination

for j in range(N-1):
    if s[j] == s[j+1]:
        cnt += 1
    else:
        ans += cnt * (cnt - 1) // 2
        cnt = 1 # reset
ans += cnt * (cnt -1) // 2
print(ans)


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

int main() {
    int n;cin>>n;
    int mod=1e9+7;
    map<string,int> dp[n+1];
    dp[0]["..."]=1;
    string a="ATGC";
    for (int i=0;i<n;i++)
        for (auto p:dp[i])
            for (int j=0;j<4;j++) {
                string t=p.first+a[j];
                int f=t.find("AGC")==string::npos;
                for (int k=0;k<3;k++) {
                    swap(t[k],t[k+1]);
                    f&=t.find("AGC")==string::npos;
                    swap(t[k],t[k+1]);
                }
                if (f)
                    dp[i+1][t.substr(1)]=(dp[i+1][t.substr(1)]+p.second)%mod;
            }
    int ans=0;
    for (auto p:dp[n])
        ans=(ans+p.second)%mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define ll  long long
  #define ld long double
  #define pb push_back
  #define mp3 make_pair
  #define rep1(i,a,b) for(ll i=a;i<=b;i++)
  #define rep2(i,a,b) for(ll i=a;i<b;i++)
  const ll  mod=998244353;
  const ll INF=1e18;
  template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
  template<typename T> T add(T a,T b,ll m){a+=b;while(a>=0)a-=m;while(a<0)a+=m; return a;}
  template<typename T> T mul(T a,T b,ll m){return (a*1ll*b)%m;}
  int main(){
    IOS;
    ll k;
    cin>>k;
    if(k==1)
    cout<<"0";
    else 
    cout<<"1";
  }

Measured memory_bytes: 3512
from fractions import gcd
N, M = map(int,input().split())
A = list(map(int,input().split()))
hA = list(map(lambda x:x//2,A))
def lcm_of_list(nums):
    lcm = nums[0]
    for i in range(1,len(nums)):
        lcm = (lcm * nums[i])//gcd(lcm,nums[i])
    return lcm


def calc_2dewareru(num):
    temp = 0
    cnt = 0
    while num%2 == 0:
        num /= 2
        cnt += 1
    return cnt
wareru2 = calc_2dewareru(A[0])
for i in range(1,N):
    if calc_2dewareru(A[i]) != wareru2:
        print(0)
        exit()
temp = (M //lcm_of_list(hA))
if temp %2 == 0:
    print(temp//2)
else:
    print(temp//2+1)

# if ans%2 !=0:
#     ans = ans//2+1
# print(ans)
# ans = 0
# cur = lcm_of_list(hA)
# odd = 1
# while True:
#
#     if cur*odd <= M:
#         ans += 1
#     else:break
#     odd += 2
#print(ans)

Measured memory_bytes: 16308
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<String> list = nextCharArray();
		int count = 0;
		int max = 0;
		for(int i = 0; i < list.size(); i++){
			String t = list.get(i);
			if(t.equals("A") || t.equals("C") || t.equals("G") || t.equals("T")){
				count++;
			}else{
				max = Math.max(max, count);
				count = 0;
			}
		}
		max = Math.max(max, count);
		myout(max);
	}
	//Method addition frame start



	//Method addition frame end
}


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

struct StGate
{
  StGate() : 
    m_nPassLow(0), m_nPassHigh(0) { }

  int m_nPassLow;
  int m_nPassHigh;
};

void fnInput(vector<StGate>& rvoGate)
{
  int  nPassSiz, nGateSiz;
  cin >> nPassSiz >> nGateSiz;
  rvoGate.resize(nGateSiz);

  for (StGate& roGate : rvoGate)
    cin >> roGate.m_nPassLow >> roGate.m_nPassHigh;
}

int fnAlmightyPass(const vector<StGate>& cnrvoGate)
{
  int nAlmightyPassLow = 0;
  int nAlmightyPassHigh = 100001;

  for (StGate oGate : cnrvoGate)
  {
    nAlmightyPassLow  = max(nAlmightyPassLow,  oGate.m_nPassLow);
    nAlmightyPassHigh = min(nAlmightyPassHigh, oGate.m_nPassHigh);
  }
  return max(0, nAlmightyPassHigh - nAlmightyPassLow + 1);
}
  
int main()
{
  vector<StGate> voGate;

  fnInput(voGate);
  cout << fnAlmightyPass(voGate) << endl;

  return 0;
}

Measured memory_bytes: 4036
#include <stdio.h>
#include <stdlib.h>

int N, M, X, Y;
int main()
{
	int i, x, y, mi, ma;

	scanf("%d%d%d%d", &N, &M, &X, &Y);

	if (X >= Y) goto No;
	ma = X, mi = Y;
	for (i = 0; i < N; i++) {
		scanf("%d", &x);
		if (x > ma) ma = x;
	}
	for (i = 0; i < M; i++) {
		scanf("%d", &y);
		if (y < mi) mi = y;
	}


	if (ma < mi) puts("No War");
	else {
	No:		puts("War");
	}
	return 0;
}

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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }

template<class T>
class UnionFind
{
private:
	vector<T> parentNo;
	vector<T> parentRank;
	vector<T> parentSize;

public:
	// コンストラクタ
	UnionFind(int n)
	{
		parentNo.resize(n);
		parentRank.resize(n, 0);
		parentSize.resize(n, 1);
		for (int i = 0; i < n; i++) {
			// 始めは全部ROOT
			parentNo[i] = i;
		}
	}

	int root(T x)
	{
		if (parentNo[x] == x) {
			return x;
		} else {
			T rootParentNo = root(parentNo[x]);
			parentNo[x] = rootParentNo;
			return rootParentNo;
		}
	}

	bool same(T x, T y)
	{
		return root(x) == root(y);
	}

	int size(T x)
	{
		return parentSize[root(x)];
	}

	void unite(T xc, T yc)
	{
		T xr = root(xc);
		T yr = root(yc);
		if (xr == yr) {
			return;
		}
		if (parentRank[xr] < parentRank[yr]) {
			parentNo[xr] = yr;
			parentSize[yr] += parentSize[xr];
		} else {
			parentNo[yr] = xr;
			parentSize[xr] += parentSize[yr];
			if (parentRank[xr] == parentRank[yr]) {
				parentRank[xr]++;
			}
		}
	}
};

void Solve()
{
	ll N, M;
	cin >> N >> M;
	VL a(M), b(M);
	REP(i, M) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}

	UnionFind<int> uFindR(N);
	REP(i, M) {
		uFindR.unite(a[i], b[i]);
	}

	map<ll, ll> mp;
	REP(i, N) {
		mp[uFindR.root(i)]++;
	}

	ll ans = 0;
	for (auto ont : mp) {
		ans = max(ans, ont.second);
	}

	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 17832
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<ll> b(n+1, 0);  // 累積和テーブル
    rep(i, n) {
        cin >> a[i];
        b[i+1] = b[i] + a[i];
    }

    ll ans = 0;

    rep(i, n) {
        ll sum = (b[n] - b[i+1]) % mod;
        ans += a[i] * sum;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N,M,oc[MX];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> M;
    F0R(i,M) {
        int a,b; cin >> a >> b;
        oc[a] ^= 1;
        oc[b] ^= 1;
    }
    FOR(i,1,N+1) if (oc[i]) {
        cout << "NO";
        exit(0);
    }
    cout << "YES";
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

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

/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")   */


//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 2e6 + 51, MOD = 1e9 + 7, mod = 998244353, INF = 2e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;



signed main() {
    #ifdef Flash
     freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    double n;
    cin >> n;
    n /= 3.0;
    n = n * n * n;
    cout << setprecision(300) << fixed << n;


}


Measured memory_bytes: 256
from collections import defaultdict

s, t = [s for s in [input(), input()]]


def check(s, t):
    d = defaultdict(set)
    for i in range(len(s)):
        d[s[i]].add(t[i])
    for v in d.values():
        if len(v) > 1:
            return False
    return True

print('Yes' if check(s, t) and check(t, s) else 'No')


Measured memory_bytes: 4144
r=lambda i:('0'*6+str(i))[-6:]
I=lambda:map(int,input().split())
N,M=I()
C=[[i]+list(I())for i in range(M)]
C=sorted(C,key=lambda x:(x[1],x[2]))
q=1;c=1;l=[]
for i,p,_ in C:q,c=(p,1)if p>q else (q,c);l+=[[i,r(p)+r(c)]];c+=1
for _,s in sorted(l,key=lambda x:(x[0])):print(s)

Measured memory_bytes: 42556
tailrec fun sample(x: MutableList<Int>, con: Int): Int {
    for (i in x.indices) {
        if (x[i] % 2 == 0) {
            x[i] = x[i] / 2
        } else {
            return con
        }
    }
    return sample(x, con + 1)
}



fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    var num = readLine()!!.split(" ").map(String::toInt).toMutableList()
    println(sample(num, 0))
}


Measured memory_bytes: 35952
import java.util.*;

class Main{
	
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int candies[][] = new int[2][num];
		for(int m=0;m<2;m++){
			for(int n=0;n<num;n++){
				candies[m][n] = sc.nextInt();
			}
		}

		int max=0;

		for(int m=0;m<num;m++){
			int c=0;
			int y=0;
			for(int n=0;n<num;n++){
				if(m==n){
					c += candies[y][n];
					y++;
				} 
				c += candies[y][n];
			}
			if(max<c) max = c;
		}

		System.out.println(max);
	}
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;
  cin>>n>>k;
  n%=k;
  cout<<min(n,abs(n-k))<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main() {
	string s;
	cin >> s;
	int n = s.size();
	int n1 = (n - 1) / 2;
	int n2 = (n + 3) / 2;
	for (int i = 0; i < n; i++) {
		if (s[i] != s[n - i - 1]) {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int j = 0; j < n1; j++) {
		if (s[j] != s[n1 - j - 1]) {
			cout << "No" << endl;
			return 0;
		}
		
	}
	for (int k = n2 - 1; k < n; k++) {
		if (s[k] != s[n - k - 1]) {
			cout << "No" << endl;
			return 0;
		}
		
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 384
def setHeapDown_max(heap, pos):
    targetkey = heap[pos]
    while pos > 0:
        parentpos = (pos - 1) >> 1
        parent = heap[parentpos]
        if parent < targetkey:
            heap[pos] = parent
            pos = parentpos
            continue
        break
    heap[pos] = targetkey

def setHeapUp_max(heap, pos):
    endpos = len(heap)
    targetkey = heap[pos]
    childpos = 2*pos + 1
    while childpos < endpos:
        rightpos = childpos + 1
        if rightpos < endpos and not heap[rightpos] < heap[childpos]:
            childpos = rightpos
        heap[pos] = heap[childpos]
        pos = childpos
        childpos = 2*pos + 1
    heap[pos] = targetkey
    setHeapDown_max(heap, pos)

def heapPush_max(heap, key):
    heap.append(key)
    setHeapDown_max(heap, len(heap) - 1)

def heapPop_max(heap):
    lastkey = heap.pop()
    if heap:
        returnkey = heap[0]
        heap[0] = lastkey
        setHeapUp_max(heap, 0)
        return returnkey
    return lastkey


import sys

S = []

for x in sys.stdin.readlines():
    if x[0] == 'i':
        k = int(x[7:])
        heapPush_max(S, k)
    elif x[1] == 'x':
        print(heapPop_max(S))
    else:
        pass

Measured memory_bytes: 189344
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;
int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2==0) cout<<(b-a)/2;
    else{
        if(a-1<n-b) cout<<a+(b-a-1)/2;
        else cout<<n-b+1+(n-a-(n-b+1))/2;
    }
}

Measured memory_bytes: 384
n = int(input())
G = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = tuple(map(lambda x: int(x)-1, input().split()))
    G[a].append(b)
    G[b].append(a)

color = [0] * n
color[0] = 1
color[n-1] = -1
from collections import deque
q = deque([])
q.append(0)
q.append(n-1)
while q:
    node = q.popleft()
    c = color[node]
    for to in G[node]:
        if color[to] == 0:
            color[to] = c
            q.append(to)

cb = color.count(1)
cw = color.count(-1)

if cb > cw:
    print('Fennec')
else:
    print('Snuke')


Measured memory_bytes: 26844
n,k= map(int,input().split())
r,s,p = map(int,input().split())
t = str(input())
takahashi = []
Sum = 0
for i in range(k):
    if t[i] == "r":
        takahashi.append("p")
    if t[i] == "p":
        takahashi.append("s")
    if t[i] == "s":
        takahashi.append("r")
for i in range(k,len(t)):
    if t[i] == "r":
        if takahashi[i-k] != "p":
            takahashi.append("p")
        else:
            takahashi.append("0")
    if t[i] == "p":
        if takahashi[i-k] != "s":
            takahashi.append("s")
        else:
            takahashi.append("0")
    if t[i] == "s":
        if takahashi[i-k] != "r":
            takahashi.append("r")
        else:
            takahashi.append("0")
for i in range(len(takahashi)):
    if takahashi[i] == "0":
        Sum += 0
    if takahashi[i] == "r":
        Sum += r
    if takahashi[i] == "p":
        Sum += p
    if takahashi[i] == "s":
        Sum += s
  
print(Sum)

Measured memory_bytes: 49264
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
from operator import itemgetter

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

H, W = na()
N = ni()
a = na()
ans = []
for i in range(N):
    for _ in range(a[i]):
        ans.append(i+1)
for i in range(H):
    if i % 2 == 0:
        print(*ans[i*W:(i+1)*W])
    else:
        print(*ans[i*W:(i+1)*W][::-1])

Measured memory_bytes: 11196
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

void CountingSort(int *,int *,int);
void recordplus(int *,int *,int);
void recordplusunder(int *);

int main(){
  int *A,*B;
  int n,i;

  scanf("%d", &n);

  A = (int *)malloc(sizeof(int)*n+1);
  B = (int *)malloc(sizeof(int)*n+1);

  /* your code */

  for(i = 1;i <= n;i++){
    scanf("%d",&A[i]);
    B[i] = 0;
  }

  CountingSort(A,B,n);

  for(i = 1;i <= n;i++){
    printf("%d",B[i]);
    if(i != n) printf(" ");
  }
  printf("\n");

  free(A);
  free(B);
  return 0;
}

void CountingSort(int *A,int *B,int n){
  int i,C[VMAX+1];
  for(i = 0;i <= VMAX;i++) C[i] = 0;
  recordplus(A,C,n);
  recordplusunder(C);
  for(i = n;i != 0;i--){
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }
  
}

void recordplus(int *A,int *C,int n){
  int i;
  for(i = 1;i <= n;i++){
    C[A[i]]++;
  }
  
}

void recordplusunder(int *C){
  int i;
  for(i = 1;i < VMAX + 1;i++) C[i] = C[i] + C[i - 1];
}



Measured memory_bytes: 17064
def bakt():
    len_s = [0 for _ in range(int(1e+5+1))]
    ans = 0
    N, K = map(int, input().split())
    for _ in range(N):
        a, b = map(int, input().split())
        len_s[a] += b
    len_a = 0

    for i, j in enumerate(len_s):
        len_a += j 
        if len_a >= K and ans == 0:
            ans = i
    print(ans)
if __name__ == '__main__':
    bakt()

Measured memory_bytes: 5924
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int i = 0,
        max = 0;
        for(; i < S.length(); i++){
            if(isACGT(S.substring(i, i+1))){
                int length = 0;
                for(; i < S.length(); i++){
                    if(!isACGT(S.substring(i, i+1))){
                        break;
                    }
                    length++;
                }
                if(max < length){
                    max =length;
                }
            }
        }
        System.out.println(max);
    }

    public static boolean isACGT(String s){
        return s.equals("A") || s.equals("C") || s.equals("G") || s.equals("T");
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<ll> &v) {
    std::for_each(v.begin(), v.end(), [](ll x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main(void) {
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) { cin >> A[i]; }
    REP(i, N) {
        if(A[i] > i) {
            cout << -1 << endl;
            return 0;
        }
    }
    ll ans = 0;
    REP(i, N - 1) {
        if(A[i] + 1 == A[i + 1]) {
            ans++;
        } else if(A[i] == A[i + 1]) {
            if(A[i] > 1) {
                // cout << "p" << endl;
                ans += A[i];
            } else if(A[i] == 1) {
                ans++;
            }
        } else if(A[i] > A[i + 1]) {
            if(A[i + 1] > 0) {
                ans += A[i + 1];
            }
        } else {
            // cout << "hjoge" << endl;
            cout << -1 << endl;
            return 0;
        }
    }
    //狭義増加してるところは一回の更新で行ける
    //増加じゃないところは++
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <utility>
#include <queue>
#include <vector>
#include <cstring>
#include <functional>
using namespace std;
typedef pair<int,int> P;

const int MAX = 100,INF = 1000000;
int edge[MAX][MAX];

bool check(int a[],const int n){
	for(int i = 1;i < n;++i){
		if(a[i - 1] != a[i]) return true;
	}
	return false;
}

int prim(int n){
	priority_queue<P,vector<P>,greater<P> > pq;
	int done[n],cost;
	P tmp;
	memset(done,0,sizeof(done));
	for(int i = 0;i < n;++i){
		if(edge[0][i] != INF) pq.push(make_pair(edge[0][i],i));
	}
	done[0] = 1;
	cost = 0;
	while(check(done,n) && !pq.empty()){
		tmp = pq.top();
		pq.pop();
		if(!done[tmp.second]){
			cost += tmp.first;
			done[tmp.second] = 1;
			for(int i = 0;i < n;++i){
				if(edge[tmp.second][i] != INF) pq.push(make_pair(edge[tmp.second][i],i));
			}
		}
	}
	return cost;
}

int main(){
	int n,m,a,b,cost;
	while(cin >> n >> m,n){
		for(int i = 0;i < MAX;++i){
			for(int j = 0;j < MAX;++j){
				edge[i][j] = MAX;
			}
		}
		for(int i = 0;i < m;++i){
			cin >> a >> b >> cost;
			edge[a][b] = edge[b][a] = cost;
		}
		cout << prim(n) << endl;
	}
	return 0;
}

Measured memory_bytes: 1376
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#define NMAX 40
#define AMAX 10
#define INF (int )1e6

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

int N,M[2],a[NMAX],b[NMAX],c[NMAX],dp[NMAX+1][NMAX*AMAX+1][NMAX*AMAX+1],ans = INF;
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	dp[0][0][0] = 0;
	for (int i = 0; i < N; ++i)
	{
		for (int ca = 0; ca <= NMAX*AMAX; ++ca)
		{
			for (int cb = 0; cb <= NMAX*AMAX; ++cb)
			{
				if(dp[i][ca][cb] == INF){
					continue;
				}
				dp[i+1][ca][cb] = min(dp[i+1][ca][cb],dp[i][ca][cb]);
				dp[i+1][ca+a[i]][cb+b[i]] = min(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i]);
			}
		}
	}
	for (int ca = 1; ca <= NMAX*AMAX; ++ca)
	{
		for (int cb = 1; cb <= NMAX*AMAX; ++cb)
		{
			if(ca*M[1] == cb*M[0]){
				ans = min(ans,dp[N][ca][cb]);
			}
		}
	}
	if(ans == INF)ans = -1;
}

void debug(){

}

void answer(){
	printf("%d\n",ans);
}

int main(){
	ios::sync_with_stdio(false);
	// for(int i = 0; i <= NMAX; ++i){
	// 	for(int ca = 0; ca <= NMAX*AMAX; ++ca){
	// 		for(int cb = 0; cb <= NMAX*AMAX; ++cb){
	// 			dp[i][ca][cb]=INF;
	// 		} 
	// 	}
	// }
	Fill(dp,INF);
	cin >> N >> M[0] >> M[1];
	for (int i = 0; i < N; ++i)
	{
		cin >> a[i] >> b[i] >> c[i];
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 25984
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	//adjMatrix[u][v] = 1 if there is an edge from u to v, otherwise 0
	private int[][] adjMatrix;
	//adjWeight[u][v] -- the weight of the edge from u to v if there is one
	private int[][] adjWeight;
	//if a node is settled (e.g., processed in the Dijkstra's algorithm)
	private Boolean[] ifSettled;
	public Graph() { totalVertex = 0; }
	public int getTotalVertex() { return totalVertex; }
	//load graph from standard input
	public void loadAdjMatrix() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjMatrix = new int[totalVertex][totalVertex];
		adjWeight = new int[totalVertex][totalVertex];
		ifSettled = new Boolean[totalVertex];
		int i, j;
		for(i = 0; i < totalVertex; i ++) {
			ifSettled[i] = false;
			for(j = 0; j < totalVertex; j ++) {
				adjMatrix[i][j] = adjWeight[i][j] = 0;
			}
		}
		int u, v;
		for(i = 0; i < totalVertex; i ++) {
			u = in.nextInt();
			int degree = in.nextInt();
			for(j = 0; j < degree; j ++) {
				v = in.nextInt(); 
				adjMatrix[u][v] = 1;
				adjWeight[u][v] = in.nextInt();
			}	
		}
		in.close();
	}
	//return weight of the edge from u to v if there is one
	public int getWeight(int u, int v) {
		return adjWeight[u][v];
	}
	//return neighbors of u as a LinkedList
	public LinkedList<Integer> getNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if(adjMatrix[u][v] == 1) tmp.add(v);
		}
		return tmp;
	}
	//return unsettled neighbors of u as a LinkedList
	public LinkedList<Integer> getUnsettledNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if((adjMatrix[u][v] == 1) && (ifSettled[v] == false)) tmp.add(v);
		}
		return tmp;
	}
	//return the unsettled node that has the smallest dist
	public int getUnsettledNearest(int[] dist) {
		int md = Integer.MAX_VALUE;
		int mv = -1;
		int v;
		for(v = 0; v < totalVertex; v ++) {
			if((ifSettled[v] == false) && (dist[v] < md)) {
				md = dist[v];
				mv = v;
			}
		}
		return mv;
	}
	//implement the following	
	public int[] Dijkstra(int s) {
		LinkedList<Integer> vertices = new LinkedList<Integer>();
		int dist[] = new int[totalVertex];
		for (int i = 0; i < totalVertex; i++)
			dist[i] = Integer.MAX_VALUE;
		dist[s] = 0;
		while (vertices.size() < totalVertex) {
			int nearest = getUnsettledNearest(dist);
			if(dist[nearest] == Integer.MAX_VALUE) break;
			ifSettled[nearest] = true;
			LinkedList<Integer> neighbors = getUnsettledNeighbors(nearest);
			for (int x = 0; x < neighbors.size(); x++) {
				int u = neighbors.get(x);
				dist[u] = Math.min(dist[nearest] +
								   getWeight(nearest, neighbors.get(x)),
								   dist[u]);
			}
			vertices.add(nearest);
		}
		return dist;
	}
}

public class Main {
	public static void main(String[] argv) {
		Graph g = new Graph();
		g.loadAdjMatrix();
		int[] dist = g.Dijkstra(0);
		for(int i = 0; i < g.getTotalVertex(); i ++) {
			System.out.println(i + " " + dist[i]);
		}
	}
}



Measured memory_bytes: 40180
import sys
n = int(input())
a = list(map(int, sys.stdin.readline().split()))

a.sort(reverse=True)

if a[-1] == 0:
    print(0)
else:
    limit = 10**18
    prod = 1
    for one in a:
        prod *= one
        if prod > limit:
            print(-1)
            break
    else:
        print(prod)

Measured memory_bytes: 82752
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = Console.ReadLine().Split();
            var A = int.Parse(ss[0]);
            var B = int.Parse(ss[1]);

            if (A == 1)
                A += 13;

            if (B == 1)
                B += 13;

            if (A == B)
                Console.WriteLine("Draw");
            else
                Console.WriteLine(A > B ? "Alice" : "Bob");
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define sec second
#define fir first
#define mo  998244353
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)
#define adiii\                               
  ios_base::sync_with_stdio(false);\                                      
  cin.tie(NULL);\
  cout.tie(NULL);									
 
ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}
ll gcd(ll a,ll b) {if (b == 0) return a;return gcd(b, a % b);}

int main(){
	adiii
	ll n;cin>>n;
	using p = pair<ll,ll>;
	vector <p> a;
	rep(i,1,n+1) {ll x;cin>>x;a.pb({x,i});}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	ll dp[n+5][n+5];
	memset(dp,0,sizeof(dp));
	ll ans = 0;
	rep(x,0,n+1){
		rep(y,0,n+1){
			
			if(x+y+1<=n){
				ll nxt_val = a[x+y].first;
				ll nxt_idx = a[x+y].second;
				dp[x+1][y] = max(dp[x+1][y],dp[x][y] + nxt_val*(nxt_idx) - nxt_val*(x+1));
				dp[x][y+1] = max(dp[x][y+1],dp[x][y] - nxt_val*(nxt_idx) + nxt_val*(n - (y)));
				//cout<<x<<" "<<y<<" "<<dp[x+1][y]<<" "<<dp[x][y+1]<<endl;
				ans = max(ans,dp[x+1][y]);
				ans = max(ans,dp[x][y+1]);
				
			} 
			//ans = max(ans,dp[x][y]);
		
		}
	}
	
	
    cout<<ans<<endl;
    
}


Measured memory_bytes: 35152
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  if(a == "SSS") cout << 0 << endl;
  if(a == "SSR") cout << 1 << endl;
  if(a == "SRS") cout << 1 << endl;
  if(a == "RSS") cout << 1 << endl;
  if(a == "SRR") cout << 2 << endl;
  if(a == "RSR") cout << 1 << endl;
  if(a == "RRS") cout << 2 << endl;
  if(a == "RRR") cout << 3 << endl;
return 0;
}

Measured memory_bytes: 3596
// C++ 14
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>

#define ll long long
#define Int ll
#define loop(__x, __start, __end) for(Int __x = __start; __x < __end; __x++)
#define loopdown(__x, __start, __end) for(Int __x = __start; __x > __end; __x--)
#define rep(__n) for(Int __x = 0; __x < __n; __x++)
#define span(__a,__x,__y) __a.begin()+__x,__a.begin()+__y
#define span_all(__a) __a.begin(),__a.end()
#define len(__x) (__x.size())
#define last(__x) (__x[__x.size()-1])

using namespace std;

struct Point {
  Int x, y;
  Point(Int x, Int y): x(x), y(y) {}
  Point(): x(0), y(0) {}

  bool operator< (const Point &p1) {
    return x < p1.x && y < p1.y;
  }
};
ostream & operator << (ostream & out, Point const & v) {
  out << "Point(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Point & v) {
  Int x, y;
  in >> x; in >> y; v.x = x; v.y = y;
  return in;
}

// Geometry

#define EPS 0.0000000001

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (Vector2 v) { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (Vector2 v) { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (double k) { return Vector2(x * k, y * k); }
  Vector2 operator / (double k) { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 v) { return x * v.x + y * v.y; }
  double cross (Vector2 v) { return x * v.y - y * v.x; }
  
  bool operator < (const Vector2 &v) const {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) const {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}

Int N, Q;
vector<Int> A, M;

void input() {
  cin >> N;
  Int x;
  rep(N) {
    cin >> x;
    A.push_back(x);
  }
  cin >> Q;
  rep(Q) {
    cin >> x;
    M.push_back(x);
  }
}

bool dfs(Int n, Int x, Int acc = 0, Int depth=0) {
  if (acc > x) return false;
  if (acc == x) return true;
  if (n == N) return false;
  return dfs(n + 1, x, acc, depth+1) || dfs(n + 1, x, acc + A.at(n), depth+1);
}

void solve() {
  for (auto x: M) {
    if (dfs(0, x)) cout << "yes" << endl;
    else cout << "no" << endl;
  }
}

int main() {
  input();
  solve();
  return 0;
}



Measured memory_bytes: 3164
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

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

int main()
{
	string s, t;
	cin >> s >> t;
	rep(i, s.length())
	{
		string temp = s.substr(i, s.length() - i) + s.substr(0, i);
		if (temp == t)
		{
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 3632
import bisect
s = input()
t = input()

S = list(s)

C = [[]for i in range(26)]
for i in range(len(S)):
    C[ord(S[i])-97].append(i+1)

idx = 0
ans = 0
l = len(s)
for i in range(len(t)):
    now = ord(t[i])-97
    if C[now] == []:
        ans = -1
        break
    up = bisect.bisect_right(C[now], idx)
    if up >= len(C[now]):
        up = bisect.bisect_right(C[now], 0)
        ans += C[now][up] + l-idx
        idx = C[now][up]
    else:
        ans += C[now][up] - idx
        idx = C[now][up]

print(ans)
 

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    constexpr int64_t K = 'z' - 'a' + 1;
    vector<int64_t> a(K, 0L), m(K, 1L << 20), mi(K, 0L);

    for (auto i : irange(0L, static_cast<int64_t>(s.size()))) {
        auto c = s[i];

        if (2 * (a[c - 'a'] + 1) - i > m[c - 'a']) {
            cout << mi[c - 'a'] + 1 << " " << i + 1 << endl;
            return 0;
        }

        for (auto c1 : irange(0L, K)) {
            if (2 * a[c1] - (i - 1) < m[c1]) {
                m[c1] = 2 * a[c1] - (i - 1);
                mi[c1] = i;
            }
        }

        ++a[c - 'a'];
    }

    cout << "-1 -1" << endl;
}

Measured memory_bytes: 512
#include <iostream>
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
using namespace std;

int x, n;
bool p[101];
int main() {
	cin >> x >> n;
	rep(i, 0, n) {
		int tmp; cin >> tmp;
		p[tmp] = true;
	}

	int ans = x, min = 1000;
	rep(i, 0, 102){
		if(p[i]) continue;
		if(min > abs(x-i)){
			min = x-i;
			ans = i;
		}
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3184
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    int a,b;
    cin  >> a;
    cin >> b;
    int d = a/b;
    int r = a % b;
    double  f = double(a) / double(b);
    cout << d;
    cout << " ";
    cout << r;
    cout << " ";
    cout << fixed << setprecision(5) << f;
    cout << endl;
     
}


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

bool check(int e) {
    if (e % 3 == 0 || e % 5 == 0) {
        return true;
    }
    return false;
}

int main() {
    vector<int> a;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int e;
        cin >> e;
        a.push_back(e);
    }

    bool ap = true;
    for (auto e : a) {
        if (e % 2 == 0) {
            ap = check(e);
            if (!ap) break;
        }
    }

    if (ap) {
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
    }
    
    return 0;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        char c[] = br.readLine().toCharArray();
        for(int i=0;i<c.length;i++){
            if(Character.isUpperCase(c[i])){
                c[i] = Character.toLowerCase(c[i]);
            }else{
                c[i] = Character.toUpperCase(c[i]);
            }
        }
        System.out.println(c);
    }
}

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

int main() {
    int N, K, ti, di;
    vector<pii> sushi;

    cin >> N >> K;
    rep(i, N) {
        cin >> ti >> di;
        sushi.push_back(make_pair(di, ti));
    }
    sort(sushi.begin(), sushi.end(), greater<pii>());
    
    priority_queue<pii, vector<pii>, greater<pii>> dup_select; // 美味しさが小さい順
    priority_queue<pii, vector<pii>, less<pii>> not_select; // 美味しさが大きい順
    ll sum = 0, eat_kind_num = 0;
    int eat_num[N+1] = {};

    rep(i, N) {
        pii eat = sushi[i];
        if (i < K) {
            sum += eat.first;
            if (eat_num[eat.second] > 0) {
                dup_select.push(eat);
            } else {
                eat_kind_num++;
            }
            eat_num[eat.second]++;
        } else {
            if (eat_num[eat.second] == 0) {
                not_select.push(eat);
                eat_num[eat.second]++;
            }
        }
    }

    sum += eat_kind_num * eat_kind_num;
    vector<ll> ans_v;
    ans_v.push_back((ll) sum);

    while ((not_select.size() > 0) && (dup_select.size() > 0)) {
        ll next_sum = sum;
        next_sum = next_sum+ not_select.top().first - dup_select.top().first ;
        next_sum += 2 * eat_kind_num + 1;
        sum = next_sum;

        dup_select.pop();
        not_select.pop();
        ans_v.push_back((ll) next_sum);
        eat_kind_num++;
    }

    sort(ans_v.begin(), ans_v.end(), greater<ll>());
    cout << ans_v[0] << endl;

    return 0;
}

 

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<int, pii> piii;
const int INF = 1e9+1;
const int MAXN = 1e5+10;

priority_queue<int> pq;

int A[MAXN];

int main()
{
    int x,y,a,b,c;
    ll n;
    scanf("%d%d%d",&a,&b,&c);

    if(c<=a+b)n = (ll)c+b;
    else n = (ll)a+b+1+b;

    printf("%lld",n);

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
B - K-th Common Divisor
https://atcoder.jp/contests/abc120/tasks/abc120_b

"""
import sys


def solve(A, B, K):
    divisors = []
    for i in range(1, A+1):
        if A % i == 0 and B % i == 0:
            divisors.append(i)
    return divisors[-K]


def main(args):
    A, B, K = map(int, input().split())
    ans = solve(A, B, K)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <set>
#include <vector>
using namespace std;
#define rep(i,n) for(ll i = 0; i < n; ++i)
#define Rep(i,j,n) for(ll i = j; i <= n; ++i)

#define yes "yes"
#define Yes "Yes"
#define no "no"
#define No "No"

namespace mydef
{
  void say(string some){
    cout << some << "\n";
  }
} // namespace mydef
using namespace mydef;
using P = pair<int,int>;
typedef long long ll;
const int INF = 1001001001;
const long double PI=3.14159265358979323846;

//ここから書く

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N){
    cin >> A[i];
  }

  ll sum = 0;
  rep(i, N-1){
    if(A[i] > A[i+1]){
      sum += A[i]-A[i+1];
      A[i+1] = A[i];
      
    }
  }
  cout << sum << "\n";

  return 0;
}




Measured memory_bytes: 4776
N = int(input())
v = list(map(int, input().split()))
v.sort()
u = [0]*N
for i in range(N):
    if i == 0:
        u[0] = (v[0] + v[1]) / 2
    elif i == N-1:
        u[i] = (u[i-1]+v[i])/2
    else:
        u[i] = (u[i-1]+v[i+1])/2
print(u[-2])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,j=0;
	int tmp=0;
	int v[1000];

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int k = 0; k < n; k++) {
		if (k != 0) {
			cout << " ";
		}
		cout << v[k] ;
	}
	cout << endl;

	for (int i = 1; i < n; i++) {
		j = i-1;
		tmp = v[i];
		while (j >= 0 && v[j] > tmp) {
			v[j + 1] = v[j];
			j--;
		}
		v[j+1] = tmp;
		for (int k = 0; k < n; k++) {
			if (k != 0) {
				cout << " ";
			}
			cout << v[k];
		}
		cout << endl;
	}


	//cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3100
import sys
readline = sys.stdin.readline

N,A,B,C = map(int,readline().split())

# 0,0を作ってはいけない
# 基本的には小さいほうに1を足す
# 両方とも1の場合は、次の操作で選ばれるほうに1を足す
# 両方とも次の操作で選ばれるときはどちらに足してもよい

S = [readline().rstrip() for i in range(N)]
ans = []

for i in range(N):
  if S[i] == "AB":
    if A == 0 and B == 0:
      print("No")
      exit(0)
    if A < B:
      ans += ["A"]
      A += 1
      B -= 1
    elif A > B:
      ans += ["B"]
      B += 1
      A -= 1
    else:
      if i + 1 < N and "A" in S[i + 1]:
        ans += ["A"]
        A += 1
        B -= 1
      else:
        ans += ["B"]
        B += 1
        A -= 1
  if S[i] == "AC":
    if A == 0 and C == 0:
      print("No")
      exit(0)
    if A < C:
      ans += ["A"]
      A += 1
      C -= 1
    elif A > C:
      ans += ["C"]
      C += 1
      A -= 1
    else:
      if i + 1 < N and "A" in S[i + 1]:
        ans += ["A"]
        A += 1
        C -= 1
      else:
        ans += ["C"]
        C += 1
        A -= 1
  if S[i] == "BC":
    if B == 0 and C == 0:
      print("No")
      exit(0)
    if B < C:
      ans += ["B"]
      B += 1
      C -= 1
    elif B > C:
      ans += ["C"]
      C += 1
      B -= 1
    else:
      if i + 1 < N and "B" in S[i + 1]:
        ans += ["B"]
        B += 1
        C -= 1
      else:
        ans += ["C"]
        C += 1
        B -= 1
print("Yes")
for a in ans:
  print(a)
      
    
    

  
      

Measured memory_bytes: 16956
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
int main(void){
  int i,b=0;
  ll ans=0;
  string s;
  cin >> s;
  for (i=0;i<s.size();i++){
    if (s[i]=='B') b++;
    else ans+=b;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;
	lint ans = 0;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		ans += tmp;
	}
	cout << ans - N << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.ParseException;

public class Main {

	public static void main(String[] args) throws IOException, ParseException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String readline = br.readLine();
		int date = Integer.parseInt(readline);
		int h = date / 3600;
		int m = (date % 3600) / 60;
		int s = (date % 3600) % 60;
		System.out.println(h + ":" + m + ":" + s);

	}

}

Measured memory_bytes: 24160