akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.IO.Pipes;
using System.Linq;
using System.Net;
using System.Numerics;
using System.Text.RegularExpressions;
using System.Threading;

namespace Atcoder
{
	class Program
	{
		//string s = Console.ReadLine();
		//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		//int H = intArray[0];
		//int W = intArray[1];
		//int N = int.Parse(Console.ReadLine());
		//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
		//Boolean ok = false;

		//Console.WriteLine(ans);
		//Console.WriteLine("Yes");
		//Console.WriteLine("No");
		//Console.ReadKey();
		//Console.WriteLine(cnt);

		//string[] strArray = Console.ReadLine().Split(' ').ToArray();
		//string S = strArray[0];
		//string T = strArray[1];
		static void Main(string[] args)
		{

			int[] NM = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
			int N = NM[0];
			int M = NM[1];
			int[] H = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
			int mm = M * 2;

			int[,] AB = new int[mm, 2];
			
			for (int i = 0;i < M; i++)
            {
				int[] tmp = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
				AB[i, 0] = tmp[0];
				AB[i, 1] = tmp[1];
				AB[mm - 1 - i, 0] = tmp[1];
				AB[mm - 1 - i, 1] = tmp[0];
			}

			bool[] ans = new bool[N];
			for (int i = 0; i < N; i++)
			{
				ans[i] = true;
			}

			for (int i = 0; i < mm; i++)
			{
				if (H[AB[i, 0] - 1] <= H[AB[i, 1] - 1])
				{
					ans[AB[i, 0] - 1] = false;
				}
			}

			int cnt = ans.Count(x => x == true);
			Console.WriteLine(cnt);
		}

		/// <summary>
		/// 回文
		/// </summary>
		/// <param name="Target"></param>
		/// <param name="len"></param>
		/// <returns></returns>
		static bool Palindrome(string Target , int len)
        {
			bool yes = true;

			for(int i = 0;i < len; i++)
            {
				if(Target[i] != Target[len - 1 - i])
                {
					yes = false;
					break;
                }
            }
			return yes;
        }

		/// <summary>
		/// アナグラム
		/// </summary>
		/// <param name="word1"></param>
		/// <param name="word2"></param>
		/// <returns></returns>
		static bool IsAnagramOf(string word1, string word2)
		{
			return word1.OrderBy(x => x).SequenceEqual(word2.OrderBy(x => x));
		}
		/// <summary>
		/// 最小公倍数
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static BigInteger Lcm(BigInteger a, BigInteger b)
		{
			return a * b / Gcd(a, b);
		}

		/// <summary>
		/// 最大公約数
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static BigInteger Gcd(BigInteger a, BigInteger b)
		{
			if (a < b)
				// 引数を入替えて自分を呼び出す
				return Gcd(b, a);
			while (b != 0)
			{
				var remainder = a % b;
				a = b;
				b = remainder;
			}
			return a;
		}
	}
}

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

int main(void)
{
    int A, B, result;
    cin >> A;
    cin >> B;

    result = A + B;
    if(result < (A - B))
    {
        result = A-B;
    }
    if(result < (A*B))
    {
        result = A*B;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

void Back(string &str, vector<bool> &used)
{
    if (str.size() == used.size()) {
        cout << str << "\n";
        return;
    }

    for (size_t i = 0; i < used.size(); i += 1) {
        if (i == 0 || used[i - 1]) {
            bool init = used[i];
            used[i] = true;

            str.push_back('a' + i);
            Back(str, used);
            str.pop_back();

            used[i] = init;
        } else {
            break;
        }
    }
}

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

    vector<bool> used(n, false);
    string str = "";
    Back(str, used);

    return 0;
}


Measured memory_bytes: 1536
#include <cstdio>
#include <iostream>
#define Iakioi 0
using namespace std;
int main(){
	int n,m,a,b;
	scanf("%d %d %d %d",&n,&m,&a,&b);
	int i = 19260817;
	for(i=1;i<=max(n-b,b);i++){
		int j = 19260817;
		for(j=1;j<=max(m-a,a);j++)putchar('1');
		for(;j<=m;j++)putchar('0');
		putchar('\n');
	}
	for(;i<=n;i++){
		int j = 19260817;
		for(j=1;j<=max(m-a,a);j++)putchar('0');
		for(;j<=m;j++)putchar('1');
		putchar('\n');
	}
	return Iakioi;
}

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

int main() {
  int n; cin>>n;
  vector<int> a(n);
  int sum=0;
  rep(i, n) {
    cin>>a[i];
    sum+=a[i];
  }

  vector<int> p(n);
  p[0]=sum;
  rep(i, n) if (i%2==1) p[0]-=2*a[i];
  rep(i, n-1) p[i+1]=2*a[i]-p[i];
  rep(i, n) printf("%d ", p[i]);
  printf("\n");
  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  string S;
  cin >> N >> S;
  string ans=S;
  int l=0,r=0;
  for(int i=0;i<N;i++){
    if(S[i]=='('){
      l++;
    }else{
      if(l>0){
        l--;
        continue;
      }else{
        ans= '('+ans;
      }
    }
  }
  if(l>0){
    while(l!=0){
      l--;
      ans=ans+')';
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int a,b,c;
  while(scanf("%d%d%d",&a,&b,&c),a+b+c){
    vector<int> ans(a+b+c, 2);
    int n;
    scanf("%d",&n);
    vector<int> aa(n), bb(n), cc(n), dd(n);
    REP(i,n) scanf("%d%d%d%d",&aa[i],&bb[i],&cc[i],&dd[i]);
    REP(i,n) {aa[i]--; bb[i]--; cc[i]--;}

    REP(i,n) if(dd[i] == 1){
      ans[aa[i]] = ans[bb[i]] = ans[cc[i]] = 1;
    }

    REP(i,n) if(dd[i] == 0){
      if(ans[aa[i]] == 1 && ans[bb[i]] == 1)
	ans[cc[i]] = 0;
      if(ans[aa[i]] == 1 && ans[cc[i]] == 1)
	ans[bb[i]] = 0;
      if(ans[cc[i]] == 1 && ans[bb[i]] == 1)
	ans[aa[i]] = 0;
    }
    FOR(it,ans) printf("%d\n",*it);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define MAXN 410
using namespace std;
const int mod=1e9+7;
int n,c,a[MAXN],b[MAXN];
long long dp[MAXN][MAXN],g[MAXN][MAXN],h[MAXN][MAXN];

void init()
{
	int i,j,k;
	for(i=1;i<=400;i++){
		g[i][0]=1;
		for(j=1;j<=400;j++)
			g[i][j]=(g[i][j-1]*i)%mod;
	}
	for(i=1;i<=n;i++){
		for(j=a[i];j<=b[i];j++){
			for(k=0;k<=c;k++){
				h[i][k]=(h[i][k]+g[j][k])%mod;
			}
		}
	}
}

int main()
{
	int i,j,k;
	scanf("%d%d",&n,&c);
	for(i=1;i<=n;i++) scanf("%d",&a[i]);
	for(i=1;i<=n;i++) scanf("%d",&b[i]);
	init();
	dp[0][0]=1;
	for(i=1;i<=n;i++)
		for(j=0;j<=c;j++){
			for(k=0;k<=j;k++){
				dp[i][j]+=dp[i-1][j-k]*h[i][k]%mod;
				dp[i][j]%=mod;
			}
		}
	cout<<dp[n][c]<<endl;
 return 0;
}


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

using namespace std;

int main()
{
	int N;
	string S;

	long long alphabet[26];
	long long ans = 1;

	for(int i=0;i<26;i++)
	{
		alphabet[i] = 0;
	}

	cin >> N >> S;

	for(int i=0;i<S.size();i++)
	{
		alphabet[S[i]-'a']++;
	}

	for(int i=0;i<26;i++)
	{
		if(alphabet[i] > 0)
		{
			ans = ans*(alphabet[i]+1);
			ans %= 1000000007;
		}
	}

	cout << ans-1 << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*
10^5全部みれる？
グループの中で1つとか
*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N, M; cin>>N >> M;
  vector<ll> H(N+1, 0);
  for(ll i=1; i<=N; i++) cin>>H[i];
  vector<vector<ll>> G(N+1, vector<ll>(0,0));
  for(ll i=1; i<=M; i++){
    ll a,b; cin>>a>>b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  ll ans = 0;
  for(ll i=1; i<=N; i++){
    ll tmp = H[i];
    ll gsz = G[i].size();
    if (gsz == 0)
      ans++;
    for(ll j=0; j<gsz; j++){
      if (H[G[i][j]] >= tmp)
        break;
      if (j == gsz - 1)
        ans++;
    }
  }
  cout<<ans<<endl;
}


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

int N,M;
int S[11];
vector<int> L[10];
bool check(){
  for(int i=0;i<M;i++){
    int cnt=0;
    for(auto s:L[i]) cnt+=S[s];
    if(cnt%2) return false;
  }
  return true;
}

int main(void){
  cin>>N>>M;
  for(int i=0;i<10;i++) S[i]=0;
  S[10]=1;
  for(int i=0;i<M;i++){
    int k; cin>>k;
    for(int j=0;j<k;j++){
      int s; cin>>s;
      L[i].push_back(s-1);
    }
  }
  for(int i=0;i<M;i++){
    int p; cin>>p;
    if(p) L[i].push_back(10);
  }
  int ans=0;
  while(S[N-1]<2){
    S[0]++;
    for(int i=0;i<N-1;i++){
      S[i+1]+=S[i]/2;
      S[i]%=2;
    }
    if(check()) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
long long n,a,b;
int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	if(n==1 && a!=b)printf("0");else printf("%lld",max(0LL,(n-1)*b+a-(n-1)*a-b+1));
	return 0;
} 

Measured memory_bytes: 256
using System;

namespace ABC070
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			string N = Console.ReadLine();
			for (int i = 0; 2*i < N.Length; i++) {
				if (N[i] != N[N.Length - 1 - i]) {
					Console.WriteLine("No");
					return;
				}
			}

			Console.WriteLine("Yes");
		}
	}
}


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

int main() {
	int N;
	cin >> N;
	string S, T;
	cin >> S >> T;

	for (int i = 0; i < N; i++) {
		cout << S.at(i) << T.at(i);
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>

int main(){
  long long int N;
  long long int A;
  double ans = 0.0;
  
  scanf("%lld", &N);
  
  for(int i = 0; i < N; i++){
    scanf("%lld", &A);
    ans += 1.0/A;
  }
  
  printf("%.7lf\n", 1.0/ans);
  
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  int a = n % 10;
  if ((n - a) % 9 == 0) {
    cout << "Yes" << endl;
  } else if (a == 9) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef pair<int,int> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr> PQ;
const int SIZE=2*5+1e5;
const int INF=10+1e9;
const LL p =7+1e9;
int A[SIZE];
int num[SIZE];
int main(){
	int N;
	cin >> N;
	REP(i,N){
		cin >> A[i];
		num[A[i]]++;
	}
	int ans=0;
	REP(i,SIZE){
		if(num[i]) ans++;
	}
	cout << ans+ans%2-1 << endl;
	return 0;
}

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

int main() {
    int n,ans = 0;
    string a,b,c;
    cin >> n >> a >> b >> c;
    rep(i,n){
        if (a.at(i) == b.at(i) and b.at(i) == c.at(i)){
            continue;
        }
        else if (a.at(i) == b.at(i) or b.at(i) == c.at(i) or a.at(i) == c.at(i)){
            ans ++;
        }
        else {
            ans += 2;
        }
    }
    cout << ans << endl;
}

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

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

    std::vector<int> L(n);

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

    std::sort(L.begin(), L.end());
    int ans = 0;
    for ( int b = 0; b < n; ++b ) {
        for ( int a = 0; a < b; ++a ) {
            int ab = L[a]+L[b];
            int r = lower_bound(L.begin(), L.end(), ab) - L.begin();
            int l = b + 1;

            ans += max(0, r-l);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#B - Two Colors Card Game
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
s_set = list(set(s))

maxim = 0
for i in s_set:
    count = 0
    for j in s:
        if i == j:
            count += 1
    for k in t:
        if i == k:
            count -= 1
    if maxim<count:
        maxim = count
print(maxim)

Measured memory_bytes: 9160
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	int a[5];
	scanf("%d%d%d%d%d",a+0,a+1,a+2,a+3,a+4);
	sort(a,a+5,greater<int>());
	printf("%d %d %d %d %d\n",a[0],a[1],a[2],a[3],a[4]);
	return 0;
}

Measured memory_bytes: 0
pli = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
soli = []
it = []
for i in range(100):
    k = i+1
    so = [0]*(len(pli))
    for m in range(len(pli)):
        for j in range(8):
            if (k%pli[m])==0:
                so[m]+=1
                k//=pli[m]
            else:
                break
    soli.append(so)
N=int(input())
ssum = [ sum([ soli[i][m] for i in range(N) ]) for m in  range(len(pli))]

#4izyo: 9
#2-3 : 6
# 4izyo * 4izyo * 4izyo -> 9 * 8 * 7
# 4izyo * 4izyo * 2-3 -> 9 * 8 * 6
# 9*8*7/(3*2*1)+(9*8)/(2*1)*6

def getAB(a,b):
    return sum(map( lambda x:x>=a and b>=x ,ssum ))
def getC(a,r):
    if (a<=0):
        return 0
    if (r==1):
        return a
    else:
        return a * getC(a-1,r-1)
s = 0
s += max(getC(getAB(4,1000),3)//2,0)
s += max(getC(getAB(4,1000),2)//2*getAB(2,3),0)
s += max(getC(getAB(24,1000),2),0)
s += max(getAB(24,1000)*getAB(2,23),0)
s += max(getC(getAB(14,1000),2),0)
s += max(getAB(14,1000)*getAB(4,13),0)
s += max(getAB(74,1000),0)
print (s)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  int N ;
  cin >> N ;
  if( N== 3 || N== 5 || N== 7 ) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	bool ok = true;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		if (x % 2 == 0 and x % 3 and x % 5)
			ok = false;
	}
	cout << (ok ? "APPROVED" : "DENIED");
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static long fact(int n){
		if(n == 1 || n == 0)return 1;
		return n * fact(n - 1);
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int p[] = new int[n];
		int q[] = new int[n];
		List<Integer> listp = new ArrayList<Integer>();
		List<Integer> listq = new ArrayList<Integer>();
		for (int i = 0; i < n; ++i){
			p[i] = sc.nextInt();
			listp.add(i + 1);
		}
		for (int i = 0; i < n; ++i){
			q[i] = sc.nextInt();
			listq.add(i + 1);
		}
		sc.close();
		long ans = 0;
		long fact = fact(n);
		long nump = 1, numq = 1;
		for(int i = 0; i < n - 1; ++i){
			fact /= (n - i);
			int tmp = listp.indexOf(p[i]);
			listp.remove(tmp);
			long tmp2 = fact * (tmp + 1);
			nump += tmp2;
			tmp = listq.indexOf(q[i]);
			listq.remove(tmp);
			tmp2 = fact * (tmp + 1);
			numq += tmp2;
		}
		long num = nump - numq;
		ans = Math.abs(num);
		System.out.println(ans);
	}
}


Measured memory_bytes: 22868
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		while(true){
			int x=sc.nextInt();
			int y=sc.nextInt();
			if(x==0&&y==0){
				break;
			}else if(x>y){
	        	sb.append(y+" "+x+"\n");
	        }else{
	        	sb.append(x+" "+y+"\n");
	        }
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 27752
import numpy as np
n, t = map(int, input().split())
lst = np.full((t), -float("inf"))
lst[0] = 0
ans = 0
ab = [list(map(int, input().split())) for i in range(n)]
ab.sort()
for a, b in ab:
    ans = max(ans, max(lst) + b)
    if a < t:
        lst[a:] = np.maximum(lst[a:], lst[:-a] + b)
ans = int(ans)
print(ans)

Measured memory_bytes: 14832
/*
AizuOnline A0085
Title
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int m,n;
char flag[1000];
//
main()
{
  int i,ptr,nokori;

  while(EOF!=scanf("%d %d",&n,&m) && (n || m))
    {
      memset(flag,0,sizeof(flag));
      nokori=n;ptr=0;

      while(nokori)
	{
	  i=0;

	  while(i < m)
	    {
	      ptr++;
	      if(ptr>n)
		ptr=1;
	      if(flag[ptr]==0)
		i++;
	    }
	  flag[ptr]=1;
	  nokori--;
	}
      printf("%d\n",ptr);
    }

return(0);
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>
#include <cmath>
#include <stdio.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

struct Line{

    ll start;
    ll end;

};

int main(){

    string s;
    cin >> s;

    /*
    for(int i = 0; i < s.size(); i++ ){
        if(s[i] == 'L'){
            Lpos.push_back(i);
        }
        else{
            Rpos.push_back(i);
        }
    }
    */

    vector< int > change;
    for(int i = 0; i < s.size() - 1; i++ ){
        if(s[i] == 'R' && s[i + 1] == 'L'){
            change.push_back(i);
        }
    }

    vector <int> pos(s.size());
    for(int i = 0; i < s.size(); i++) pos[i] = 0;
    for(int i = 0; i < s.size(); i++){
        auto it = lower_bound(all(change), i);
        int d;
        int dist;
        if(s[i] == 'R'){
            d =  *it ;
        }  
        else{
            d =  *(it - 1);
        } 
        dist = abs(d - i);
        if(dist % 2 == 0){
            pos[d] ++; 
        }
        else{
            pos[d+1] ++;
        }
    }

    cout << pos[0];
    for(int i = 1; i < s.size(); i++){
        cout << " " << pos[i];
    }
    cout << endl;


}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false),cin. tie(0);
using namespace std;
typedef long long ll;
ll a,b,k,n,m;
const ll maxn=100005;
const ll mod=1e9+7;
ll num[maxn];
bool broken[maxn];
int main()
{
while(cin>>n>>m)
{
  //IOS
  memset(broken,0,sizeof(broken));
  rep(i,m)
  {
    cin>>a;
    broken[a]=1;
  }
  num[0]=1;
  num[1]=1;
  if(broken[1]) num[1]=0;
  for(int i=2;i<=n;i++)
  {
    if(broken[i]) num[i]=0;
    else
    {
      num[i]=(num[i-1]+num[i-2])%mod;

    }
    //cout<<i<<" "<<num[i]<<"\n";
  }
  cout<<num[n]<<"\n";

}

}


Measured memory_bytes: 1152
def eval(A, B, C):
    rest = C
    count = 0
    
    while True:
        for i in range(7):
            rest -= A
            if i == 6:
                rest -= B
                
            count += 1
            if rest <= 0:
                return count


A, B, C = tuple(map(int, input().split()))
print(eval(A, B, C))


Measured memory_bytes: 5600
import scala.io.StdIn._
object Main extends App {
  val mod = 1000000007L
  val Array(n, k) = readLine.trim.split(' ').map(_.toInt)
  if (n > k) println(0)
  else {
    val factorial = Array.fill(k + 1){1L}
    val inverse = Array.fill(k + 1){1L}
    val inverseFactorial = Array.fill(k + 1){1L}
    for (i ← 2 to k) {
      factorial(i) = i * factorial(i - 1) % mod
      inverse(i) = (mod - mod / i) * inverse((mod % i).toInt) % mod
      inverseFactorial(i) = inverse(i) * inverseFactorial(i - 1) % mod
    }
    println(factorial(k) * inverseFactorial(k - n) % mod)
  }
}



Measured memory_bytes: 44124
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin()) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
    for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
    cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/



int main()
{
    FASTIO
    /*
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //scanf("%d", &T);
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        ll n, a, b;
        cin >> n >> a >> b;
        ll ans = 0;
        ll t = 0;
        for (int i = 0; i < n; i++) {
            ll x;
            cin >> x;
            if (i) {
                ans += min(a * (x - t), b);
            }
            t = x;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<numeric>
#include<algorithm>
#include<tuple>
#include<cmath>
#include <iomanip>

typedef unsigned long long ull;
typedef long long ll;

ll DENOM = 1000000000LL + 7LL;

using namespace std;

ll n, m, k;
ll h, w;

int main(){
    ll ctr = 0;
    cin >> n;
    string ret = "No";
    for (int i=0; i<n; ++i){
        ll a,b;
        cin >> a >> b; 
        if (a==b){
            ctr++;
        }else{
            ctr = 0;
        }
        if (ctr >= 3){
            ret = "Yes";
        }
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef long int li;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
#define PI 3.14159265358979
#define MOD 998244353
const int MAX = 510000;

int main() {
  double A,B,H,M;
  cin>>A>>B>>H>>M;
  double P=H+(M/(double)60);
  double si=((double)11*PI*P)/(double)6;
  double ans=sqrt((A*A+B*B)-2*A*B*cos(si));
  cout<<setprecision(13)<<ans;
}

Measured memory_bytes: 4232
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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;}

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

    string s;
    cin >> s;
    int s_len = s.length();
    map<int, int> m;
    rep(i, 0, s_len) {
        int tmp = s[i] - '0';
        m[tmp]++;
    }

    int rsl = 2 * min(m[0], m[1]);
    cout << rsl << endl;
}


Measured memory_bytes: 512
#include<stdio.h>

int main()
{
	int price=0,num=0,i=0,p,n,intave;
	float average;

	while(scanf("%d,%d",&p,&n)!=EOF)
	{
		price+=p*n;
		num+=n;
		i++;
	}
	average=(float)num/i;
	intave=(int)average;
	if(average-intave>=0.5){intave++;}
	printf("%d\n%d\n",price,intave);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
//vector<int> v,dp;


signed main()
{
    int n,i,k,j;
 //   cout << 1%-3;
   cin >> n ;
   vector<vector<int>> v(n,vector<int> (3,0)),dp(n,vector<int> (3,0));
    for(i =0;i < n;i++){
        for(j = 0;j < 3;j++)
            cin >> v[i][j];
    }
    vector<int> flag(3);
    flag[0] = 0;flag[1] = 1;flag[2] = 2;
    dp[0][0] = v[0][0];
    dp[0][1] = v[0][1];
    dp[0][2] = v[0][2];
    for(i = 1;i < n;i++){
       for(j = 0;j < 3;j++){
           dp[i][j] = v[i][j]+
                      max(dp[i-1][(j+3-1)%3],dp[i-1][(j+3+1)%3]);
       }
        
    }
   cout << max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
    return 0;
}


Measured memory_bytes: 13184
#include <cstdio>
#include <cstring>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main()
{
  int i,j;
  cin >> i >> j ;

  if(i==j)
    cout << "Draw" << endl;
  else if(i == 1){
    cout << "Alice"<<endl;
  }else if(j == 1){
    cout << "Bob"<<endl;
  }else{
    if(i<j)
      cout << "Bob"<<endl;
    else
      cout << "Alice" <<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

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


int main() {
    int a,b,n; cin >> n;
    if (n==1){
        cout << "Hello World" << endl;
    }else {
        cin >> a >> b;
        cout << a+b << endl;
    }

    return 0;
}


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

class UnionFind {
public:
	vector <int> par;  // 各元の親を表す配列
	vector <int> rank; // 素集合のランクを表す配列(0 で初期化)

	UnionFind(int n) : par(n), rank(n) {
		init(n);
	}

	void init(int n) {
		par.resize(n); for (int i = 0; i < n; ++i) par[i] = i;
		rank.assign(n, 0);		
	}

	int root(int x) {
		if (par[x] == x) return x;
		else return root(par[x]);
	}

	bool unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (rank[x] < rank[y]) {
			par[x] = y;
		}
		else { // rank[y] < rank[x]
			par[y] = x;
			if (rank[x] == rank[y]) rank[x]++;
		}
		return true;
	}

	bool isSame(int x, int y) { // 連結判定
		return root(x) == root(y);
	}

	int getRank(int x) {        // 素集合のランク
		return rank[root(x)];
	}
};

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

	vector<pair<int, int>> p(m);
	for (int i = 0; i < m; i++) {
		int tmp_a, tmp_b;
		cin >> tmp_a >> tmp_b;
		p[i].first = tmp_a - 1;
		p[i].second = tmp_b - 1;
	}

	int ans = 0;
	for (int i = 0; i < m; i++) {

		UnionFind uf(n);

		for (int j = 0; j < m; j++) {

			if (j != i && !uf.isSame(p[j].first, p[j].second)) {

				uf.unite(p[j].first, p[j].second);

			}

		}

		int cnt = 0;
		for (int j = 0; j < n; j++) {

			if (uf.par[j] == j) cnt++;

		}

		if (2 <= cnt) ans++;
	}

	cout << ans << endl;

	return 0;
}

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

LL RS(LL n, LL p, LL mod) {
  if (p == 0) return 1;
  else if (p % 2 == 0) {
    LL t = RS(n, p / 2, mod);
    return t * t % mod;
  } else {
    return n * RS(n, p - 1, mod) % mod;
  }
}

LL nck(LL n, LL k) {
  LL x = 1;
  const LL mod = 1e9 + 7;
  for (LL i = 0; i < k; i ++) {
    x *= (n - i);
    x %= mod;
  }

  LL y = 1;
  for (LL i = 1; i <= k; i ++) {
    y *= i;
    y %= mod;
  }

  return x * RS(y, mod - 2, mod) % mod;
}

int main() {
  LL n, a, b;
  cin >> n >> a >> b;

  const LL mod = 1e9 + 7;

  LL ans = RS(2, n, mod) - 1;
  ans -= (nck(n, a) + nck(n, b)) % mod;
  while (ans < 0) ans += mod;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;
int cnt[maxn];
bool chekp[maxn];
int main(){
        _ios;

        int n,m;
        cin>>n>>m;
        int ac = 0;
        int pena = 0;
        for(int i = 1; i<=n;i++){
            cnt[i] = 0;
            chekp[i] = false;
        }
        int x;
        string a;
        while(m--){

            cin>>x>>a;
            if(chekp[x])continue;
            if(a=="AC"){
                ac++;
                chekp[x] = true;
                pena+=cnt[x];
            }
            else if(a=="WA"){
                cnt[x]++;
            }
        }
        cout<<ac<<" "<<pena<<endl;




return 0;
}







Measured memory_bytes: 2432
#include <iostream>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
using namespace std;

int n;
double a[1010];
double ans = 0;

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        ans += 1/a[i];
    }
    cout << 1/ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
  const int inf = 1 << 25;
  int T;
  while(cin >> T, T) {
    int t[33];
    for(int i = 0; i < T; i++) cin >> t[i];
    int N; cin >> N;
    int W[101];
    int last = -1;
    fill(W, W + 101, inf);
    for(int i = 0; i < N; i++) {
      int D, M; cin >> D >> M; D--;
      W[D] = min(W[D], M);
      last = max(last, D+1);
    }
    int dp[101][33];
    fill(dp[0], dp[101], inf);
    dp[0][0] = 0;
    for(int i = 0; i < last; i++) {
      for(int j = 0; j < T; j++) {
	if(t[j] <= W[i]) dp[i + 1][(j+1)%T] = min(dp[i + 1][(j+1)%T], dp[i][j]);
	dp[i + 1][1] = min(dp[i + 1][1], dp[i][j] + 1);
      }
    }    
    cout << *min_element(dp[last], dp[last] + T) << endl;
  }
  return 0;
}

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

template <typename T>
using lim = numeric_limits<T>;

const int MAXN = 2e5;
int dp[2][2019];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	memset(dp, 0, sizeof dp);
	string s;
	cin >> s;

	int n = s.size();
	ll ans = 0;
	for (int i = 1; i <= n; i++){
		for (int j = 0; j < 2019; j++)
			dp[i%2][j] = 0;
		dp[i%2][s[i-1]-'0']++;
		for (int j = 0; j < 2019; j++){
			if (dp[(i-1+2)%2][j] > 0){
				dp[i%2][(j*10+s[i-1]-'0')%2019] += dp[(i-1+2)%2][j];
			}
		}
		ans += dp[i%2][0];
	}


	cout << ans << "\n";
}

Measured memory_bytes: 3800
#表計算を行うプログラムを作成。

r,c=gets.split(" ").map(&:to_i)
h = Array.new(r+1).map{Array.new(c+1,0)} 

for i in 0..r-1                                       # 変数 i を1からr-1まで増やして繰り返し処理する。(arrayゼロから始めるから)
    
a= gets.split.map(&:to_i)
    for j in 0..c-1                                   # 変数 i を0からc-1回まで増やして繰り返し処理する。
    h[i][j] =  a[j]                                   # array のループひとつづつ足していく
    h[i][c] += a[j]
    h[r][j] += a[j]
    h[r][c] += a[j]
    end
end
for i in 0..r
    for j in 0..c
      print " " unless j == 0
      print h[i][j]
    end
    print "\n"
  end




Measured memory_bytes: 7056
#include <iostream>
#include <set>

using namespace std; 

int
main(int argc, char const *argv[])
{
    uint64_t a, b, c, d, e, k;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;
    cin >> k;

    if ((e - a) > k) {
    cout << ":(" << endl;
    } else {
    cout << "Yay!" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	char a,b,c;
	scanf("%c%c%c",&a,&b,&c);
	printf("%d",a-48+b-48+c-48);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
const lli inf=1e18;
const int mod=1e9+7;
int main(){
IOS;
int a,b;
cin>>a>>b;
int x=1;
if(b==1){
    cout<<0<<endl;
}
else{
    x=1;
    int y=a;
    while(y<b){
        y=y+a-1;
        x++;
    }
    cout<<x<<endl;
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
  int n;
  cin >> n;
  int m = n/2;
  map<int, int> me;
  map<int, int> mo;
  int v;
  for(int i = 1; i <= n; i++){
    cin >> v;
    if(i % 2) mo[v]++;
    else me[v]++;
  }
  vector<P> ve;
  vector<P> vo;
  for(auto x : me){
   ve.push_back(P(x.second, x.first));
  }
  for(auto x : mo){
   vo.push_back(P(x.second, x.first));
  }
  ve.push_back(P(0,0));
  vo.push_back(P(0,0));
  sort(ve.begin(), ve.end(), greater<P>());
  sort(vo.begin(), vo.end(), greater<P>());
  int ans;
  if(ve[0].second != vo[0].second){
    ans = (m - ve[0].first) + (m - vo[0].first);
  } else {
    int a = (m - ve[0].first) + (m - vo[1].first);
    int b = (m - ve[1].first) + (m - vo[0].first);
    ans = min(a, b);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6136
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define I_L_Z_D ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 

std:: vector<int> v[300008];

int32_t main(){
 I_L_Z_D ;

int n = 5;
int t;
int a[n],cnt=0;

for(int i = 0 ;i < n ;i++) 
    cin >> a[i];
cin >> t;

  for(int i = 0 ; i < n ;i++)
    for(int j = i+1; j < n ; j++)
        if( a[j]-a[i] > t) {
			cnt++;           
        }
        
        if(cnt)
          cout<<":(";
          
        else
		 cout << "Yay!";       
  return 0;

}


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

using namespace std;
using ll = long long;
const ll mod = 1000000000 + 7;
ll dp[111][625];
bool ng[625];

int f(int a, int b, int c, int d) {
  return a * 125 + b * 25 + c * 5 + d;
}
// a:1, g:2, c:3, t:4

int main() {
  ll N;
  cin >> N;
  dp[0][0] = 1;

  for (int i = 0; i < 5; ++i) {
    ng[f(i, 1, 2, 3)] = true;
    ng[f(1, i, 2, 3)] = true;
    ng[f(1, 2, i, 3)] = true;
    ng[f(i, 2, 1, 3)] = true;
    ng[f(i, 1, 3, 2)] = true;
  }

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 625; ++j) {
      if (dp[i][j]) {
        for (int k = 1; k < 5; ++k) {
          int next = (j * 5 % 625) + k;
          if (ng[next])
            continue;
          dp[i + 1][next] += dp[i][j];
          dp[i + 1][next] %= mod;
        }
      }
    }
  }
  ll ans = 0;
  for (int i = 0; i < 625; ++i) {
    ans += dp[N][i];
  }
  ans %= mod;
  cout << ans << endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <functional>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
int main(){
    int n;
    cin >> n;
    
    map<int,int> mp;
    for(int i = 2;i <= n;i++){
        int k = i;
        for(int j = 2;j * j <= k;j++){
            while(k % j == 0){
                k /= j;
                mp[j]++;
            }
        }
        if(k != 1)mp[k]++;
    }

    int ans = 0;

    vector<int> cnt;
    for(auto p:mp){
        cnt.push_back(p.second+1);
    }

    int m = (int)mp.size();
    for(int i = 0;i < m;i++){
        if(cnt[i] >= 75)ans++;
    }

    for(int i = 0;i < m - 1;i++){
        for(int j = i+1;j < m;j++){
            if(cnt[i] >= 3 && cnt[j] >= 25)ans++;
            if(cnt[i] >= 25 && cnt[j] >= 3)ans++;
            if(cnt[i] >= 5 && cnt[j] >= 15)ans++;
            if(cnt[i] >= 15 && cnt[j] >= 5)ans++;
        }
    }

    for(int i = 0;i < m-2;i++){
        for(int j = i+1;j < m-1;j++){
            for(int k = j+1;k < m;k++){
                if(cnt[i] >= 3 && cnt[j] >= 5 && cnt[k] >= 5)ans++;
                if(cnt[i] >= 5 && cnt[j] >= 3 && cnt[k] >= 5)ans++;
                if(cnt[i] >= 5 && cnt[j] >= 5 && cnt[k] >= 3)ans++;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr);
#endif
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";cout<<endl;}
void solve(){
    vector<int> v(3);
    int k;
    for(auto &it:v)cin>>it;
    cin>>k;
    sort(all(v));
    int ans=v[1];
    ans+=v[0];
    ans+=v[2]*(1<<k);
    cout<<ans<<endl;
}
int32_t main(){
  IOS;
  solve();
  #ifdef LOCAL_DEFINE
  cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif
}

Measured memory_bytes: 256
n,m = map(int, input().split())
ac_list = [False]*(n+1)
pena_count = [0]*(n+1)
for i in range(m):
  p, s = input().split()
  p = int(p)
  if not ac_list[p]:
    if s == "AC":
      ac_list[p] = True
    else:
      pena_count[p] += 1
ac_count = 0
pena_c = 0
for i in range(1, n+1):
  if ac_list[i]:
    ac_count += 1
    pena_c += pena_count[i]
print(ac_count, pena_c)
      


Measured memory_bytes: 4596
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
 
#define se second
#define fi first
#define mp make_pair
#define pb push_back
 
using namespace std;
 
typedef long long ll;

int x, n;
pair<int, int>ans = mp(INT_MAX, INT_MAX);
map<int, int>w;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> x >> n;
	for(int i = 1, x; i <= n; i++){
		cin >> x;
		w[x] = 1;
	}
	for(int i = -100; i <= 200; i++){
		if(w[i])
			continue;
		int d = abs(i - x);
		if(d < ans.fi)
			ans = mp(d, i);
	}
	cout << ans.se;
}

Measured memory_bytes: 3668
import java.util.Scanner

object Main{
  def main(args: Array[String]): Unit = {
    val scanner = new Scanner(System.in)
    val n: Int = scanner.nextInt
    val words: List[String] = List.fill(n)(scanner.next)
    val already: List[String] = List(words.head)

    println(isEstablish(n, words.head, words.tail, already))
  }

  /**
    * しりとりが成立するか調べる
    * rule -> 未発言の単語　かつ　直前の単語の末尾とその単語の先頭が一致する
    * @return "Yes" or "No"
    */
  def isEstablish(n:Int, head:String, tail:List[String], already: List[String]) :String ={
    n match {
      case 1 => "Yes"
      case _ =>
        (head.last == tail.head.head) match {
          case false => "No"
          case true =>
            already.contains(tail.head) match {
              case true => "No"
              case false => isEstablish(n-1, tail.head, tail.tail, tail.head :: already)
            }
        }

    }
  }
}

Measured memory_bytes: 27344
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main() {
	// your code goes here
	ll n; cin>>n;
	vector<char> vec(n);
	for(int i=0;i<n;i++) cin>>vec[i];
	
	ll s=0; ll e = n-1;
	ll count=0;
	while(s<e){
		while(s<n && vec[s]=='R') s++;
		
		while(e>=0 && vec[e]=='W') e--;
		
		if(s<n && e>=0 && s<e){
			swap(vec[s],vec[e]);
			count++;
		}
		
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>

using namespace std;

int N;
typedef long long LL;
const int maxn = 55;
LL a[maxn];

int main(){
    while(cin >> N){
        for(int i = 1;i <= N;i++){
            scanf("%lld", &a[i]); 
        }
        LL ans = 0;
        while(true){
            bool flag = true;
            for(int i = 1;i <= N;i++){
                if(a[i] >= N){
                    flag = false;
                }
            }
            if(flag){
                break;
            }else{
                for(int i = 1;i <= N;i++){
                    if(a[i] >= N){
                        LL times = (a[i]) / N;
                        ans += times;
                        a[i] -= times * N;
                        for(int j = 1;j <= N;j++){
                            if(i != j){
                                a[j] += times;
                            }
                        }
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
A = set([int(input()) for _ in range(m)])
mod = 1000000007
dp = [0]*(n+1)
dp[0] = 1
for i in range(1,n+1):
    dp[i] = (dp[i-1] + dp[i-2])%mod
    if i in A:dp[i] = 0
print(dp[n])

Measured memory_bytes: 13192
#include<iostream>
#include<vector>
using namespace std;
static const int MAX = 500;

int n;
int s[MAX], l[MAX], p[MAX];

void solve(int dp[]){
  for ( int i = 0; i <= MAX; i++ ) dp[i] = -1;
  dp[0] = 0;
  for ( int i = 0; i <= MAX; i++ ){
    if ( dp[i] == -1 ) continue;
    for ( int k = 0; k < n; k++ ){
      for ( int j = i+s[k]; j <= i+l[k]; j++ ){
	if ( j > MAX ) continue;
	dp[j] = max(dp[j], dp[i] + p[k]);
      }
    }
  }
}

main(){
  int dp[MAX+1];
  int m, w;
  vector<int> ans;
  cin >> n;
  for ( int i = 0; i < n; i++ ) cin >> s[i] >> l[i] >> p[i];

  solve(dp);

  cin >> m;
  for ( int i = 0; i < m; i++ ){
    cin >> w;
    if ( dp[w] == -1 ){
      cout << -1 << endl; return 0;
    }
    ans.push_back(dp[w]);
  }
  for ( int i = 0; i < m; i++ ) cout << ans[i] << endl;
  
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30);
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
struct UnionFind {
    vector<int> par, siz;
    UnionFind(int n) {
        par.resize(n);
        siz.resize(n, 1);
        for(int i = 0; i < n; i++)
            par[i] = i;
    }
    int find(int x) {
        if(par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }
    bool unite(int u, int v) {
        u = find(u), v = find(v);
        if(u == v)
            return false;
        if(siz[u] < siz[v])
            swap(u, v);
        par[v] = u;
        siz[u] += siz[v];
        return true;
    }
    bool same(int u, int v) { return find(u) == find(v); }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    --k;
    s[k] = 'a' + (s[k] - 'A');
    cout << s << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		// 入力フェーズ
    int N = int.Parse(Console.ReadLine());
    List<input> list = new List<input>();
    for(int i=0; i<N; i++){
      string[] ab = Console.ReadLine().Split(' ');
      int a = int.Parse(ab[0]);
      int b = int.Parse(ab[1]);
      // Ai+Biを計算する
      int s = (a + b);

      var obj = new input(){A=a, B=b, SUM=s};
      //Console.WriteLine(s);
      //long[] l = {s, a, b};
      list.Add(obj);
      //Console.WriteLine(input[i][0] + "," + input[i][1] + "," + input[i][2]);
    }
    // SUMの大きい順にソート
    list.Sort((a, b) => b.SUM - a.SUM);

    // 大きい方から選びとる
    long a_point = 0; // 高橋
    long b_point = 0; // 青木
    for(int i=0; i<N; i++){

      // i%2 == 0の時は高橋くんのターン, else青木さんのターン
      if(i%2 == 0){
        a_point += list[i].A;
      }else{
        b_point += list[i].B;
      }
    }
		//出力
		Console.WriteLine(a_point - b_point);
	}

  class input
  {
    public int A {set; get;}

    public int B {set; get;}

    public int SUM {set; get;}
  }
}


Measured memory_bytes: 24124