akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define INF 9223372036854775807 / 2
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair


using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

struct uf_tree {
	std::vector<int> parent;
	int __size;
	uf_tree(int size_) : parent(size_, -1), __size(size_) {}
	void unite(int x, int y) {
		if ((x = find(x)) != (y = find(y))) {
			if (parent[y] < parent[x]) std::swap(x, y);
			parent[x] += parent[y];
			parent[y] = x;
			__size--;
		}
	}
	bool is_same(int x, int y) { return find(x) == find(y); }
	int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
	int size(int x) { return -parent[find(x)]; }
	int size() { return __size; }
};

//!!!問題をちゃんと読む!!!
//!!!問題をちゃんと読め!!!
//!!!問題は読みましたか？!!!
int wwa[2000000], bwa[2000000];

signed main() {
	int N;
	string S;
	cin >> N >> S;
	int w = 0, b = 0;
	rep(i,N) {
		if (S[i] == '.') {
			w++;
		}
		else {
			b++;
		}
		wwa[i + 1] = w;
		bwa[i + 1] = b;
	}
	//どこで切り替えるかを全探索
	int lb, rw ,ans = LL_HALFMAX;
	rep(i, N+1) {

		lb = bwa[i];
		rw = wwa[N] - wwa[i];
		ans = min(ans, lb + rw);
	}
	cout << ans<<"\n";



	return 0;
}

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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int X; cin >> X;
  string ans;
  if(X >= 30){
    ans = "Yes";
  } else {
    ans = "No";
  }
  cout << ans << endl;
}


Measured memory_bytes: 3612
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        String[] a = new String[h];
        for (int i = 0; i < h; i++) {
            a[i] = sc.next();
        }
        for (int i = 0; i < w + 2; i++) {
            System.out.print("#");
        }
        System.out.println();
        for (int i = 0; i < h; i++) {
            System.out.print("#");
            System.out.print(a[i]);
            System.out.println("#");
        }
        for (int i = 0; i < w + 2; i++) {
            System.out.print("#");
        }
        System.out.println();
    }
}


Measured memory_bytes: 23380
import sys
input = sys.stdin.readline
n=int(input())
Edges=[]
for i in range(n-1):
  a,b=map(int,input().split())
  Edges.append([a,b,1])
def BFS(K,edges,N):
  roots=[ [] for i in range(N)]
  for a,b,c in edges:
    roots[a-1]+=[(b-1,c)]
    roots[b-1]+=[(a-1,c)]
  dist=[-1]*N
  stack=[]
  stack.append(K)
  dist[K]=0
  while stack:
    label=stack.pop(-1)
    for i,c in roots[label]:
      if dist[i]==-1:
        dist[i]=dist[label]+c
        stack+=[i]
  return dist
F,S=BFS(0,Edges,n),BFS(n-1,Edges,n)
count=0
for i in range(1,n-1):
  if F[i]<=S[i]:
    count+=1
  else:
    count-=1
print("Fennec" if count>0 and n!=2 else "Snuke")

Measured memory_bytes: 58340
#include <algorithm>
#include <iostream>

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

    int ans = 0, count = 0;
    for(int i = 0; i < s.size(); ++i){
        char ch = s.at(i);
        if('A' == ch || 'C' == ch || 'G' == ch || 'T' == ch){
            ++count;
        }else{
            ans = std::max(ans, count);
            count = 0;
        }
    }

    ans = std::max(ans, count);
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
//Variables End


void solve(){
	int n,m;cin>>n>>m;
	int a=1;
		int st1,st2;
		if(m&1)st1=m,st2=m-1;
		else st1=m-1,st2=m;
		a=n;
		for(;st1>0;st1-=2){
			cout<<a<<" "<<a-st1<<"\n";
			a--;
		}
		a=1;
		for(;st2>0;st2-=2){
			cout<<a<<" "<<a+st2<<"\n";
			a++;
		}
	
}
int main()
{
    ios
    int ti=1;
    //cin>>ti;
    for(int i=1;i<=ti;i++)
    {
		solve();        
    }
    return 0;
        
}


Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int n, m;
char S[200000];
char T[200000];

llong gcd(llong x, llong y) {
    if (x < y) swap(x, y);
    if (y == 0) return x;
    return gcd(y, x % y);
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m >> S >> T;
	llong g = gcd(n, m);
	
	llong sn = m / g;
	llong sm = n / g;
	for (int i = 0; i < n; ++i) {
        llong p = sn * i;
        if (p % sm == 0 && S[i] != T[p / sm]) {
            printf("-1\n");
            return 0;
        }
	}
	printf("%lld\n", sn * sm * g);
	return 0;
}


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

using namespace std;

int main(){
  int N;
  string S;
  string S_c;
  cin >> N;
  cin >> S;
  // S_c += S[0];
  
  for(int i=0;i<N;i++){
    if(S[i] != S[i+1]){
      S_c += S[i];
    }
    
  }
  
  cout << (int)(S_c.length()) << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	int l,r,d;
	cin>>l>>r>>d;
	int ans = 0;
	for(int i = l; i <=r; i++) {
		if(i % d == 0)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
 
using namespace std;
int main()
{
    int r,d,D[10],x;
    cin>>r>>d>>x;
    D[0]=r*x-d;
    for(int i=0;i<10;i++){
        D[i+1]=r*D[i]-d;
    }
    for(int i=0;i<10;i++){
        cout<<D[i]<<endl;
    }
    return 0;
}

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

using namespace std;


int main (void) 
{

  int N; // 団体数
  cin >> N;

  int i, j;
  vector<int> l(N); // left_end
  vector<int> r(N); // right_end

  int sit; // output


  for(i=0; i<N; i++)
  {

    cin >> l.at(i);
    cin >> r.at(i);

  }
  sit = 0;


  for(i=0; i<N; i++)
  {
    sit += r.at(i) - l.at(i) +1;
  }


  cout << sit << endl;


  return 0;

}


Measured memory_bytes: 256
using System;
using System.Linq;
namespace Myatcoder
{
    public class Program
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());

            if (n == 1) {
                Console.WriteLine("Hello World"); 
            } else {
                int a = int.Parse(Console.ReadLine());
                int b = int.Parse(Console.ReadLine());
                Console.WriteLine(a + b);
            }

        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int extended_euclid(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  int gcd = extended_euclid(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - (a / b) * y;
  return gcd;
}

int main() {
  int a, b;
  cin >> a >> b;
  int x, y;
  extended_euclid(a, b, x, y);
  cout << x << " " << y << endl;
  return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int m1,d1,m2,d2;
	cin>>m1>>d1>>m2>>d2;
	ote(m1!=m2);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define INIT() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define Rep(i,n) for (int i = 0; i < (n); ++i)
#define For(i,s,t) for (int i = (s); i <= (t); ++i)
#define rFor(i,t,s) for (int i = (t); i >= (s); --i)
#define ForLL(i, s, t) for (LL i = LL(s); i <= LL(t); ++i)
#define rForLL(i, t, s) for (LL i = LL(t); i >= LL(s); --i)
#define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define rforeach(i,c) for (__typeof(c.rbegin()) i = c.rbegin(); i != c.rend(); ++i)
 
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
 
#define LOWBIT(x) ((x)&(-x))
 
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
 
#define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,inf,sizeof(a))
#define msM(a) memset(a,-1,sizeof(a))

#define MP make_pair
#define PB push_back
#define ft first
#define sd second
 
template<typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &p) {
    in >> p.first >> p.second;
    return in;
}
 
template<typename T>
istream &operator>>(istream &in, vector<T> &v) {
    for (auto &x: v)
        in >> x;
    return in;
}
 
template<typename T1, typename T2>
ostream &operator<<(ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]" << "\n";
    return out;
}

inline int gc(){
    static const int BUF = 1e7;
    static char buf[BUF], *bg = buf + BUF, *ed = bg;
    
    if(bg == ed) fread(bg = buf, 1, BUF, stdin);
    return *bg++;
} 

inline int ri(){
    int x = 0, f = 1, c = gc();
    for(; c<48||c>57; f = c=='-'?-1:f, c=gc());
    for(; c>47&&c<58; x = x*10 + c - 48, c=gc());
    return x*f;
}
 
typedef long long LL;
typedef unsigned long long uLL;
typedef pair< double, double > PDD;
typedef pair< int, int > PII;
typedef pair< string, int > PSI;
typedef set< int > SI;
typedef vector< int > VI;
typedef map< int, int > MII;
typedef pair< LL, LL > PLL;
typedef vector< LL > VL;
typedef vector< VL > VVL;
const double EPS = 1e-10;
const LL inf = 0x7fffffff;
const LL infLL = 0x7fffffffffffffffLL;
const LL mod = 1e9 + 7;
const int maxN = 3e5 + 7;
const LL ONE = 1;
const LL evenBits = 0xaaaaaaaaaaaaaaaa;
const LL oddBits = 0x5555555555555555;

LL N, M, K;

int main(){
    INIT(); 
    cin >> M >> K;
    N = (1 << M) - 1;

    if(K > N) cout << -1 << endl;
    else if(M == 1) {
        if(K == 1) cout << -1 << endl;
        else cout << "0 0 1 1" << endl;
    }
    else {
        For(i, 0, N) if(i != K) cout << i << " ";
        cout << K << " ";
        rFor(i, N, 0) if(i != K) cout << i << " ";
        cout << K << " ";
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int k = sc.nextInt();

		int i = 0;
		while(i<s.length()){
			int j = 26 - (s.charAt(i) - 'a');
			if(i==s.length()-1){
				int t = ((s.charAt(i)-'a') + k)%26;
				System.out.println((char)(t+'a'));
			}else if(k>=j && j!=26){
				System.out.print('a');
				k -= j;
			}else{
				System.out.print(s.charAt(i));
			}
			i++;
		}
	}
}

Measured memory_bytes: 23348
a = input().rstrip().split()
count5=0
count7=0
for i in range(len(a)):
 
    if int(a[i]) == 5:
        count5+=1
    elif int(a[i])== 7:
        count7+=1
 
if count5==2 and count7==1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>

using ll = long long;

using namespace std;

#define MAX 1000010

template <typename T>
T gcd(T a, T b) {
    if (a > b) {
        T buf = a;
        a = b;
        b = buf;
    }
    return a == 0 ? b : gcd(a, b%a);
}

int spf[MAX];

int main() {
    int n;
    cin >> n;
    vector spf(MAX, -1);
    spf[0] = 0; spf[1] = 1;
    for (int i=2; i<MAX; i++) {
        if (spf[i] < 0) {
            for (int j=i; j<MAX; j+=i) {
                spf[j] = i;
            }
        }
    }
    set<int> st;
    int all_gcd = 0;
    bool pairwise = true;
    for (int i=0, ai; i<n; i++) {
        cin >> ai;
        all_gcd = gcd(all_gcd, ai);
        while (ai > 1) {
            if (st.count(spf[ai])) {
                pairwise = false;
                break;
            } else {
                int prime = spf[ai];
                while (ai % prime == 0) ai /= prime;
                st.insert(prime);
            }
        }
    }
    if (pairwise) {
        cout << "pairwise coprime" << '\n';
    } else if (all_gcd == 1) {
        cout << "setwise coprime" << '\n';
    } else {
        cout << "not coprime" << '\n';
    }
    return 0;
}

Measured memory_bytes: 10916
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class E { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		long A = GetLong();
		long B = GetLong();
		if(N < A + B - 1 || N > A * B)
		{
			WriteLine(-1);
			return;
		}

		var list = new List<long>();
		long free = N - (A + B - 1);
		for(long i = 1; i <= A; i++)
			list.Add(A * (B - 1) + i);

		for(long i = B - 2; i >= 0; i--)
		{
			list.Add(A * i + 1);
			if(free > 0)
			{
				for(long j = 2; j <= A; j++)
				{
					list.Add(A * i + j);
					free--;
					if(free == 0)
						break;
				}
			}
		}

		var tmp = new List<long>(list);
		tmp.Sort();
		var dict = tmp.Select((x, i) => (x, i)).ToDictionary(x => x.Item1, x => x.Item2);
		WriteLine(string.Join(" ", list.Select(x => dict[x] + 1)));
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 69312
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;

int		main(void)
{
	int n;
	cin >> n;
	vector<Vec> num_table(10, Vec(10, 0));
	for (int i = 1; i <= n; i++)
	{
		string si = to_string(i);
		num_table[si[0]-'0'][si[si.size()-1]-'0']++;
	}
	int c = 0;
	for (int i = 1; i <= 9; i++)
	{
		for (int j = 1; j <= 9; j++)
			c += num_table[i][j] * num_table[j][i];
	}
	cout << c << endl;
}

/*
bool	check(int a, int b)
{
	string sa, sb;
	sa = to_string(a);
	sb = to_string(b);
	if (sa[0] == sb[sb.size() - 1] && sb[0] == sa[sa.size() - 1])
		return (true);
	return (false);
}

int		main(void)
{
	int n;
	cin >> n;
	int c = 0;
	for (int i = 1; i < n; i++)
	{
		for (int j = 1; j < n; j++)
		{
			if (check(i, j))
				c++;
		}
	}
	cout << c << endl;
}
*/


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
priority_queue<ll> pque;
ll n,k,a,ans;
int main(void){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a;
        pque.push(a);
    }
    for(int i=0;i<k;i++){
        ll q=pque.top();
        pque.pop();
        q/=2;
        pque.push(q);
    }
    while(!pque.empty()){
        ll q=pque.top();
        pque.pop();
        ans+=q;
    }
    cout<<ans<<endl;
}


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

int main(void){
	int n;
	std::cin >> n;
	std::string s;
	std::cin >> s;
	int count = 0;

	for(int i = 0; i < n - 2; i++){
		if(s[i] == 'A'){
			if(s[i + 1] == 'B'){
				if(s[i + 2] == 'C'){
					count++;
				}
			}
		}
	}

	std::cout << count << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>

using namespace std;
using  ull = unsigned long long int;

#define rep(i,n,m) for(long long int i=n;i<(long long int)(m);i++)


int main() {

	int n, m;
	cin >> n >> m;
	int sum = 0;
	vector<int>num(n);
	rep(i, 0, n)cin >> num[i];

	sort(num.begin(), num.end(), greater<int>());
	rep(i, 0, m)sum += num[i];

	cout << sum << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
string G[405];
bool seen[405][405];
ll H, W, cnt_w, cnt_b;
 
void dfs(int h, int w) {
    seen[h][w] = true;
    if (G[h][w] == '.') cnt_w++;
    else cnt_b++;
 
    for (int dir = 0; dir < 4; ++dir) {
        int nh = h + dx[dir];
        int nw = w + dy[dir];
 
        if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
        if (G[nh][nw] == G[h][w]) continue;
 
        if (seen[nh][nw]) continue;
 
        dfs(nh, nw);
    }
 
    return;
}
 
int main() {
    ll ans = 0;
    cin >> H >> W;
    for (int h = 0; h < H; h++) cin >> G[h];
 
    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            if (!seen[h][w]) {
                cnt_b = 0;
                cnt_w = 0;
                dfs(h, w);
                ans += cnt_b * cnt_w;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 20608
#include <stdio.h>
#define MAX 100001
 
 
typedef struct{
  int parent;
  int left;
  int right;
  int id;
}Node;
 
Node T[MAX];
 
int main(){
  int l,k,n,i,j,count=0;
  int flag=0;
  
  int id;
 
 
  for(i=0;i<MAX;i++){
    T[i].parent=-1;
    T[i].left=MAX;
    T[i].right=MAX;
    T[i].id=0;
  }
 
  scanf("%d",&n);
  
 
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d",&k);
    T[id].id=id;
    if(k!=0){
      scanf("%d",&T[id].left);
      l=T[id].left;
      T[l].parent=id;
      for(j=0;j<k-1;j++){
    scanf("%d",&T[l].right);
    l=T[l].right;
    T[l].parent=id;
 
      } 
    }
  }
 
 
 
  for(i=0;i<n;i++){
    printf("node %d:",T[i].id);
    printf(" parent = %d,",T[i].parent);
 
    j=i;
    while(T[j].parent!=-1){
      j=T[j].parent;
      count++;
    }
    printf(" depth = %d,",count);
    count=0;
 
    if(T[i].parent==-1)printf(" root,");
    else if(T[i].left!=MAX)printf(" internal node,");
    else printf(" leaf,");
 
 
    j=T[i].left;
    printf(" [");
 
 
    while(j!=MAX){
      if(flag==0)printf("%d",j);
      if(flag==1)printf("% d",j);
      j=T[j].right;
      if(j!=MAX)printf(",");
      flag=1;
    }
    printf("]");
 
 
 
    printf("\n");
      flag=0;
  }
 
 
   
 
 
  return 0;
}

Measured memory_bytes: 4284
package main

import (
	"fmt"
)

const Mod = 1e9 + 7

var dp[][]int64
var mod10memo int

func main() {
	var S string
	fmt.Scanf("%s", &S)

	slen := len(S)
	dp = make([][]int64, slen + 1)
	dp[0] = make([]int64, 13)
	dp[0][0] = 1

	mod10memo = 1

	for i := 0; i < slen; i++ {
		dp[i+1] = make([]int64, 13)
		if S[slen-i-1] == '?' {
			addAll(i)
		} else {
			addOne(int(S[slen-i-1] - '0'), i)
		}

		mod10memo = mod10memo * 10 % 13
	}

	fmt.Println(dp[slen][5] % Mod)
}


func addAll(i int) {
	for j := 0; j < 10; j++ {
		mod := j * mod10memo % 13
		for k := 0; k < 13; k++ {
			dp[i+1][(mod+k)%13] += dp[i][k]
			dp[i+1][(mod+k)%13] %= Mod
		}
	}
}

func addOne(n int, i int) {
	mod := n * mod10memo % 13
	for k := 0; k < 13; k++ {
		dp[i+1][(mod+k)%13] += dp[i][k]
		dp[i+1][(mod+k)%13] %= Mod
	}
}

Measured memory_bytes: 14592
import heapq


def dijkstra(start: int, graph: list) -> list:
    """dijkstra法: 始点startから各頂点への最短距離を求める
    重み付きグラフgraphは隣接リストで与えられる
    計算量: O(|E|log|V|)
    """
    INF = float("inf")
    n = len(graph)
    distance = [INF] * n
    distance[start] = 0
    q = [(0, start)]  #q = [(startからの距離, 現在地)]
    while q:
        dist, pos = heapq.heappop(q)
        if distance[pos] < dist:
            continue
        for next_pos, cost in graph[pos]:
            if distance[pos] + cost < distance[next_pos]:
                distance[next_pos] = distance[pos] + cost
                heapq.heappush(q, (distance[next_pos], next_pos))
    return distance
  

k = int(input())
MOD = k
INF = 10**9

graph = [[] for i in range(k)]
for i in range(k):
    graph[i].append((i*10%MOD, 0))
    graph[i].append(((i+1)%MOD, 1))
    
dp = dijkstra(1, graph)
print(dp[0] + 1)

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

int main() {
  int x,y;cin>>x>>y;
  for(int i=0;i<=x;i++){
    int a=x-i;
    if(2*i+4*a==y){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;
#define int long long
#define ld double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define sz(x) ((long long)x.size())
#define all(x) (x).begin(), (x).end()
#define popcount(x) __builtin_popcountll(x)
const int MOD =1e9+7;

mt19937_64 rng(high_resolution_clock::now().time_since_epoch().count());
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> istream& operator >> (istream &in,vector<T> &A){ for(auto &x:A) in>>x; return in; };
template<typename T> ostream& operator << (ostream &out,vector<T> &A){ for(auto &x:A) out<<x<<" "; return out; };
template<typename T,typename W> istream& operator >> (istream &in,pair<T,W> &A){ in>>A.fi>>A.se; return in; };
const int N = 2*1e5+3;

void solve()
{
	int x;
	cin>>x;
	if(x>=30)
	{
		cout<<"Yes\n";
	}	
	else cout<<"No\n";
}

int32_t main(){
	cin.tie(0)->sync_with_stdio(0);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	#endif

	int t=1;
	// cin>>t;
	for(int _t=1;_t<=t;_t++){
		// cout<<"Case #"<<_t<<": ";
		solve();
	}
} 


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

int main(){
    int n;
    scanf("%d",&n);
    pair<pair<string,int>, int> p[n];
    for(int i=0;i<n;i++){
        char in[120];
        int t;scanf("%s%d",in,&t);
        p[i]=make_pair(make_pair(in,-t),i);
    }
    sort(p,p+n);
    for(int i=0;i<n;i++) printf("%d\n",p[i].second+1);
    
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
    S = int(input())
    dp = [0]*(S+1)
    dp[0] = 1
    M = 10**9 + 7
    for i in range(1, S+1):
        for j in range(0,i-2):
            dp[i] += dp[j]
            dp[i] %= M
    print(dp[S])

if __name__ == '__main__':
    main()

Measured memory_bytes: 9068
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

#define FOR(i,n) for(int i=0;i<n;i++)
 
int main(){

	int a[3],s=0,t=0;
	
	FOR(i,3){
		cin>>a[i];
		if(a[i]!=5&&a[i]!=7)s=1;
		t=t+a[i];
	}

	if(s==0&&t==17)cout<<"YES"<<"\n";
	else cout<<"NO"<<"\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define ALLR(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EMP emplace
#define EMPB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

int N, M;
pii ps[100010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  REP(i, M) {
    int a, b;
    cin >> a >> b;
    ps[i] = MP(b, a);
  }
  sort(ps, ps+M);
  int ans = 1, last = 0;
  REP(i, M) {
    if (ps[i].second >= ps[last].first) {
      ans++;
      last = i;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
use proconio::input;
use std::collections::HashMap;
fn main() {
    input! {
        n: usize
    }
    let mut map: HashMap<usize, usize> = HashMap::new();
    for _ in 0..n {
        input! {
            a: usize
        }
        let count = map.entry(a).or_insert(1);
        *count += 1;
    }
    let res = map.iter().filter(|&a| a.1 % 2 == 0).count();
    println!("{}", res);
}


Measured memory_bytes: 6424
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<string>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

// dp[i][j]: i番目までの子供たちにj個の飴を配る場合の数
int dp[105][110000];

int main () {
  int N, K;
  cin >> N >> K;
  vi a(N);
  rep(i,N) cin >> a[i];

  /*dp[0][0] = 1;
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j <= K; ++j) {
      // dp[i][j] = ∑(k=max(0,j-a[i-1]), j)dp[i-1][k]と同じ
      for (int k = 0; k <= a[i-1]; ++k) {
        if (j-k >= 0) dp[i][j] = (dp[i][j] + dp[i-1][j-k])%mod;
      }
    }
  }*/
  
  dp[0][0] = 1;
  for (int i = 1; i <= N; ++i) {
    // csum[j] = dp[i-1][0] + dp[i-1][1] + ... + dp[i-1][j-1]
    vector<int> csum(K+2);
    for (int j = 0; j <= K; ++j) csum[j+1] = (csum[j] + dp[i-1][j])%mod;
    for (int j = 0; j <= K; ++j) dp[i][j] = (csum[j+1] - csum[max(0,j-a[i-1])] + mod)%mod;
  }

  cout << dp[N][K] << endl;
  return 0;
}

Measured memory_bytes: 45180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, m;
    cin >> n >> m;
    vll x(n), y(n), z(n);
    rep(i, n){
        cin >> x[i] >> y[i] >> z[i];
    }
    vvll val(8, vll(n, 0));
    rep(i, 8){
        rep(j, n){
            if(i & 1) val[i][j] += x[j];
            else val[i][j] -= x[j];
            if(i & 2) val[i][j] += y[j];
            else val[i][j] -= y[j];
            if(i & 4) val[i][j] += z[j];
            else val[i][j] -= z[j];
        }
        sort(ALL(val[i]), greater<ll>());
    }
    ll ans = 0;
    rep(i, 8){
        chmax(ans, accumulate(val[i].begin(), val[i].begin()+m, 0ll));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int S_MAX = 10002;

ll n;

int ans[S_MAX];

int p[S_MAX];

vector <bool> aux;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    n++;
    while(n)
    {
        if(n & 1)
            aux.push_back(1);
        n >>= 1;
        aux.push_back(0);
    }
    aux.pop_back();
    aux.pop_back();
    int r = aux.size(), l = 1;
    int k = aux.size();
    for(bool i : aux)
    {
        if(i == 1)
            p[l++] = k--;
        else
            p[r--] = k--;
    }
    cout << aux.size() * 2 << "\n";
    for(int i = 1; i <= aux.size(); i++)
        cout << p[i] << " ";
    for(int i = 1; i <= aux.size(); i++)
        cout << i << " ";
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3604
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))

s = [0] * (n-k+1)
for i in range(0, k):
    s[0] += p[i]

ans = 0
max_s = s[0]
max_i = 0
for i in range(k, n):
    s[i-k+1] = s[i-k] + p[i] - p[i-k]
    if s[i-k+1] > max_s:
        max_s = s[i-k+1]
        max_i = i-k+1

ans = 0
for i in range(max_i, max_i+k):
    ans += p[i] * (p[i]+1) / 2 / p[i]

print("%.8f" % ans)


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

int main()
{
    int N ; 
    cin >> N ;
    
    vector<vector<int>> a(N, vector<int>(3)) ;
    for(vector<int> &r : a)
        cin >> r[0] >> r[1] >> r[2] ;

    vector<vector<int>> dp(N, vector<int>(3, 0)) ;
    dp[0] = a[0] ;

    for(int i = 1 ; i < N ; ++i)
    {
        for(int j : {0, 1, 2})
        {
            for(int k : {0, 1, 2})
            {
                if(j == k) continue ;
                dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i][j]);
            }
        }
    }

    cout << *max_element(dp[N-1].begin(), dp[N-1].end()) << endl ;

    return 0 ;
}


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

using namespace std;

typedef pair<int, int> pii;

const int MAXK = 100005;
const int oo = (int)1e9 + 7;

int k, dist[MAXK];

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

    set<pii> s;
    fill(dist, dist + k, oo);
    for(int d = 1; d <= 9; ++d) {
        int v = d % k;
        if (dist[v] > d) {
            s.erase({dist[v], v});
            dist[v] = d;
            s.insert({dist[v], v});
        }
    }

    while (!s.empty()) {
        int u = s.begin()->second; s.erase(s.begin());
        for(int d = 0; d <= 9; ++d) {
            int v = (u * 10 + d) % k;
            if (dist[v] > dist[u] + d) {
                s.erase({dist[v], v});
                dist[v] = dist[u] + d;
                s.insert({dist[v], v});
            }
        }
    }

    printf("%d\n", dist[0]);

    return 0;
}


Measured memory_bytes: 4352
public class Main {
  public static void main(String[] args) {
    String S = new java.util.Scanner(System.in).nextLine();
    switch (S) {
      case "ABC":
       System.out.println("ARC");
       break;
      case "ARC":
       System.out.println("ABC");
       break;
    }
  }
}


Measured memory_bytes: 35464
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);


int d;
int s[365][26];
int c[26];

int calc(vector<int> &v) {
	int sum = 0;
	int las[26]; rep(i, 26)las[i] = -1;
	

	int dec = 0;

	int aldec = 0;

	rep(i, d) {
		if (las[v[i]] >= 0) {
			aldec -= c[v[i]] * (i - las[v[i]]);
		}
		else {
			dec += c[v[i]];
		}

		sum += s[i][v[i]];
		las[v[i]] = i;




		sum -= aldec;
		aldec += dec;
	}
	return max(sum, 0);
}

void query(vector<int> v) {
	rep(i, d) {
		cout << v[i] + 1 << "\n";
	}
}
void solve() {
	cin >> d;
	rep(i, 26)cin >> c[i];
	rep(i, d)rep(j, 26)cin >> s[i][j];

	//init_answer
	vector<int> v;
	int las[26]; rep(j, 26)las[j] = -1;
	int sum = 0;

	rep(i, d) {
		int ma = -mod;
		int chk = -1;
		rep(j, 26) {
			int ad = s[i][j];
			if (las[j] >= 0) {
				ad += c[j] * (i - las[j]);
			}
			if (ma < ad) {
				ma = ad;
				chk = j;
			}
		}
		v.push_back(chk);
		las[chk] = i;

		sum += s[i][chk];
		rep(j, 26)if (las[j] >= 0) {
			sum -= c[j] * (i - las[j]);
		}
	}

	random_device rnd;
	mt19937 mt(rnd());
	uniform_int_distribution<> ud(0, d - 1);
	vector<int> alt = v;


	int cur=sum;
	rep(i, 30000) {
		int id = ud(mt);
		rep(j, 26) {
			if (j == v[id])continue;
			alt[id] = j;
			int val = calc(alt);
			if (cur < val) {
				v=alt;
				cur = val;
				break;
			}
		}
	}

	query(v);
}


signed main() {
	solve();
		return 0;
}


Measured memory_bytes: 3684
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,k = inpm()
    r,s,p = inpm()
    t = list(input())
    past = [0 for _ in range(k)]
    ans = 0
    for i in range(n):
        if t[i] == 'r' and past[i%k] != 1:
            ans += p
            past[i%k] = 1
        elif t[i] == 's' and past[i%k] != 2:
            ans += r
            past[i%k] = 2
        elif t[i] == 'p' and past[i%k] != 3:
            ans += s
            past[i%k] = 3
        else:
            past[i%k] = 0
    print(ans)        

if __name__ == "__main__":
    main()

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

template<typename T> bool chmin(T &a,const T b){if(a>b){a=b; return true;}return false;}
template<typename T> bool chmax(T &a,const T b){if(a<b){a=b; return true;}return false;}



int main(){
    string s; cin >> s;
    string s1=s.substr(0, 2), s2=s.substr(2, 2);
    int n=stoi(s1), m=stoi(s2);
    if(m >= 1 && m <= 12){
        if(n == 0 || n > 12) cout << "YYMM" << endl;
        else cout << "AMBIGUOUS" << endl;
    }
    else if(n >= 1 && n <= 12){
        if(m == 0 || m > 12) cout << "MMYY" << endl;
        else cout << "NA" << endl;
    }
    else cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i=0; i<N; i++) {
        cin >> S[i];
    }
    for(int j=0; j<26; j++) {
        int m = numeric_limits<int>::max();
        for(int i=0; i<N; i++) {
            m = min(m, (int)count(S[i].begin(), S[i].end(), (char)('a'+j)));
        }
        cout << string(m, 'a'+j);
    }
    return 0;
}


Measured memory_bytes: 256
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Fri Jan  4 15:34:19 2019
//
package main

import (
	"fmt"
	"sort"
	"strings"
)

func new(s string) []string {
	ss := make([]string, 0)
	for i := range s {
		ss = append(ss, string(s[i]))
	}
	return ss
}

func reverse(s []string) {
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		s[i], s[j] = s[j], s[i]
	}
}

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	ss, tt := new(s), new(t)
	sort.Strings(ss)
	sort.Strings(tt)
	reverse(tt)

	if strings.Compare(strings.Join(ss, ""), strings.Join(tt, "")) < 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define INF 1000000

int main()
{
  int v,e;cin>>v>>e;
  vector<int> s(e);
  vector<int> t(e);
  vector<int> d(e);
  int i,j,k;
  rep(i,e)cin>>s[i]>>t[i]>>d[i];
  vector<vector<int>> g(v,vector<int>(v,INF));
  rep(i,e)
  {
    g[s[i]][t[i]]=d[i];
  }
  int ans=INF;
  bool exist=false;
  vector<vector<int>> dp(1<<v,vector<int>(v,INF));
  dp[0][0]=0;
  rep(i,1<<v)
  {
    rep(j,v)
    {
      rep(k,v)
      {
        if(g[j][k]==INF)continue;
        if(i&(1<<k))continue;
        int to=(i|(1<<k));
        dp[to][k]=min(dp[to][k],dp[i][j]+g[j][k]);
      }
    }
  }
  if(dp[(1<<v)-1][0]==INF)cout<<-1<<endl;
  else cout<<dp[(1<<v)-1][0]<<endl;
}



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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const intll INF = 200000000000000000;
const int MOD = 1e9 + 7;

int main() {
  int n ; 
  cin >> n ; 
  int ans = 0 ;
  int now = 1 ;
  while(ans == 0){
    if((now*n) % 360 == 0 ) ans = now ;
    now ++ ;
  }
  
  cout << ans ;
}


Measured memory_bytes: 3620
import java.io.BufferedReader

fun main(args: Array<String>) {
    /** comment in when you submit **/
    System.`in`.bufferedReader().use { println(getOutputString(it)) }

    /** delete below after your test **/
    // executeTest()
}

private fun getOutputString(reader: BufferedReader): String {
    val counts = reader.readLine().split(" ").map { it.toInt() }

    val a = mutableListOf<String>()
    val b = mutableListOf<String>()

    for (i in 0 until counts[0]) {
        a.add(reader.readLine())
    }
    for (i in 0 until counts[1]) {
        b.add(reader.readLine())
    }

    // 候補を探す
    for (xOffset in 0 until b[0].length) {
        val startCandidates = mutableListOf<Pair<Int, Int>>()
        for (i in 0..a.size - b.size) {
            startCandidates.add(a[i].indexOf(b[0], xOffset) to i)
        }

        startCandidates.forEach {
            var ok = true
            for (i in 0 until b.size) {
                ok = ok && a[i + it.second].startsWith(b[i], it.first + xOffset)
            }

            if (ok) return "Yes"
        }
    }

    return "No"
}


Measured memory_bytes: 26072
import math
n = int(input())
a = math.sqrt(n)
if int(a)<a:
  a=int(a)+1
else:
  a=int(a)
ans = 0
for i in range(1,a):
  if (n-i)%i==0 and n%((n-i)//i)==i:
    ans+=(n-i)//i
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
	int a,b,i,j,x[7];
	for(i=0;i<7;i++){
		scanf("%d %d",&a,&b);
		x[i]=a-b;
	}
	for(j=0;j<7;j++){
		printf("%d\n",x[j]);
	}
	return 0;
}

Measured memory_bytes: 1028
using System;

namespace B___Christmas_Eve_Eve
{
    class Program
    {
        static void Main(string[] args)
        {
            

            //入力
            var N = int.Parse(Console.ReadLine());

            //配列生成
            int[] input;
            input = new int[N];

            
            for(int i = 1; i<=N; i++)
            {
              
                input[i-1] = int.Parse(Console.ReadLine());
            }
            

            Array.Sort(input, (a, b) => b - a);      //降順の並び替え

            int sum = input[0] / 2;

            for(int i =1; i<input.Length; i++)
            {
                sum += input[i];
            }

            //出力
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  string s;cin>>s;
  string s2=s.substr(0,1)+s.substr(0,1)+s.substr(0,1);
  if(s>s2){
    cout<<char(s[0]+1)<<char(s[0]+1)<<char(s[0]+1)<<endl;
  }else{
    cout<<s2<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
*a, = map(int, input().split())
b = [0]*(n//2) + a[n//2:]
for i in reversed(range(n//2)):
    b[i] = sum(b[(i+1)*(j+1)-1] for j in range(n//(i+1)))&1 ^ a[i]
print(sum(b))
print(*[i+1 for i in range(n) if b[i]==1])


Measured memory_bytes: 17888
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF 999999999999999999
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
       string s;
       cin>>s;
       if(s=="ARC")
        cout<<"ABC";
       else
        cout<<"ARC"; 
   }
}

Measured memory_bytes: 3612