akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
//#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repm(i, a, n) for (int i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

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

int main(void)
{
    vll a(3);
    rep(i, 0, 3) cin >> a[i];
    sort_v(a);
    cout << (a[2] + 1) / 2 * a[1] * a[0] - a[2] / 2 * a[1] * a[0] << endl;
}

Measured memory_bytes: 256
s = sorted(input())
count = 0

if len(s)%2 == 1:
    print('No')

else:
    for i in range(0, len(s), 2):
        if s[i] == s[i+1]:
            continue
        else:
            count += 1

    if count == 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
#include <iostream>
#define N 15
using namespace std;
int jump(int,int);
int X,Y,data[N][N],dp[N][N];
int main(){
  bool q[N][N];
  while(1){
    cin >> X >> Y;
    if(X==0&&Y==0) break;
    for(int i=0;i<Y;i++)
      for(int j=0;j<X;j++) cin >> data[i][j],q[i][j]=false,dp[i][j]=0;
    for(int i=0;i<X;i++)
      if(data[0][i]==0) q[0][i]=true,dp[0][i]=1;
    for(int i=0;i<Y-1;i++){
      for(int j=0;j<X;j++){
	if(q[i][j]==true){
	  if(0<=j-1&&data[i+1][j-1]==0) dp[i+1][j-1]+=dp[i][j],q[i+1][j-1]=true;
	  if(j+1<X&&data[i+1][j+1]==0) dp[i+1][j+1]+=dp[i][j],q[i+1][j+1]=true;
	  if(data[i+1][j]==0) dp[i+1][j]+=dp[i][j],q[i+1][j]=true;
	  else if(data[i+1][j]==2){
	    int r=jump(i+1,j);
	    if(r==-1) dp[Y-1][j]+=dp[i][j];
	    else if(r!=-2) dp[r][j]+=dp[i][j],q[r][j]=true;
	  }
	}
      }
    }
    int cnt=0;
    for(int i=0;i<X;i++) cnt+=dp[Y-1][i];
    cout << cnt << endl;
  }
  return 0;
}
int jump(int y,int x){
  while(1){
    y+=2;
    if(y<Y&&data[y][x]==1) break;
    if(y>=Y-1) return -1;
    if(data[y][x]==0) return y;
  }
  return -2;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 2e5+5


int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int a,b,c,d;
        cin >> a >> b >> c;
        int ans=c-(a-b);
  if(ans<0) ans=0;
        cout << ans;
        
        

}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, A, B, C;
std::string S[100100];
bool check[3];
bool visited[100100][10][10][10];
std::stack<char> st;
std::stack<char> res;

bool dfs(int i, int a, int b, int c){
    if(i == N){
        until(st.empty()){
            res.emplace(st.top());
            st.pop();
        }
        return true;
    }

    visited[i][a][b][c] = true;

    if(S[i] == "AB"){
        if(a + 1 < 10 && b > 0 && !visited[i+1][a+1][b-1][c]){
            st.emplace('A');
            if(dfs(i + 1, a + 1, b - 1, c)){
                return true;
            }
            st.pop();
        }

        if(b + 1 < 10 && a > 0 && !visited[i+1][a-1][b+1][c]){
            st.emplace('B');
            if(dfs(i + 1, a - 1, b + 1, c)){
                return true;
            }
            st.pop();
        }
    }else if(S[i] == "BC"){
        if(b + 1 < 10 && c > 0 && !visited[i+1][a][b+1][c-1]){
            st.emplace('B');
            if(dfs(i + 1, a, b + 1, c - 1)){
                return true;
            }
            st.pop();
        }

        if(c + 1 < 10 && b > 0 && !visited[i+1][a][b-1][c+1]){
            st.emplace('C');
            if(dfs(i + 1, a, b - 1, c + 1)){
                return true;
            }
            st.pop();
        }
    }else{
        if(c + 1 < 10 && a > 0 && !visited[i+1][a-1][b][c+1]){
            st.emplace('C');
            if(dfs(i + 1, a - 1, b, c + 1)){
                return true;
            }
            st.pop();
        }

        if(a + 1 < 10 && c > 0 && !visited[i+1][a+1][b][c-1]){
            st.emplace('A');
            if(dfs(i + 1, a + 1, b, c - 1)){
                return true;
            }
            st.pop();
        }
    }

    return false;
}

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

  std::cin >> N >> A >> B >> C;

  for(int i=0;i<N;++i){
      std::cin >> S[i];
  }

  if(A > 0 && B > 0 && C > 0){
      std::cout << "Yes" << std::endl;
      
      for(int i=0;i<N;++i){
          if(S[i] == "AB"){
              std::cout << "AB"[check[0]] << std::endl;
              check[0] = !check[0];
          }else if(S[i] == "BC"){
              std::cout << "BC"[check[1]] << std::endl;
              check[1] = !check[1];
          }else{
              std::cout << "CA"[check[2]] << std::endl;
              check[2] = !check[2];
          }
      }
  }else{
      if(dfs(0, std::min(A, 3), std::min(B, 3), std::min(C, 3))){
          std::cout << "Yes" << std::endl;
          until(res.empty()){
              std::cout << res.top() << std::endl;
              res.pop();
          }
      }else{
          std::cout << "No" << std::endl;
      }
  }
}


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

using namespace std;

int main()
{
	long N, K;
	cin >> N >> K;
	
	vector<long> num(K + 1, 0);
	long answer = 0;
	
	// [1,N] の範囲に含まれる i mod K の個数を求める
	for (int i = 1; i <= N; i++)
    {
		 num[i % K]++;
	}
	
	// aの値を変動させる
	for(int a = 0; a < K; a++)
	{
		// 2 * (K − a)がKで割り切れる
		if ((2 * (K - a)) % K == 0)
		{
			answer += num[a] * num[a] * num[a];
		}
	}
	
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 1792
package main

import "fmt"

var n int
var w []string

func duplicate(i int, s string) bool {
	for j := 0; j < i; j++ {
		if w[j] == s {
			return true
		}
	}
	return false
}

func shiritori(s1, s2 string) bool {
	if s1[len(s1)-1] == s2[0] {
		return true
	}
	return false
}

func main() {
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var tmp string
		fmt.Scan(&tmp)
		w = append(w, tmp)
	}

	for i, v := range w {
		if i == 0 {
			continue
		}
		if duplicate(i, v) || !shiritori(w[i-1], v) {
			fmt.Println("No")
			break
		}
		if i == n-1 {
			fmt.Println("Yes")
		}
	}
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>

using namespace std;

char bucket[256];
char str[100000000];

int main()
{
	int n, m;
	char moto[2], saki[2];
	
	while (1){
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		for (int i = 0; i < 256; i++){
			bucket[i] = i;
		}
		
		for (int i = 0; i < n; i++){
			scanf("%s %s", moto, saki);
			bucket[moto[0]] = saki[0];
			//printf("%d\n", moto[0]);
		}
		
		scanf("%d", &m);
		
		for (int i = 0; i < m; i++){
			scanf("%s", &str[i]);
			//printf("%d\n", str[i]);
		}
		
		int len = strlen(str);
		
		for (int i = 0; i < len; i++){
			str[i] = bucket[str[i]];
		}
		
		printf("%s\n", str);
	}
	
	return (0);
}

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


int main(){
  int n, k; cin >> n >> k;
  vector<int> rsp(3);
  int r, s, p;  cin >> r >> s >> p;
  map<char, int> mp;
  mp['r'] = p;
  mp['s'] = r;
  mp['p'] = s;

  string str; cin >> str;
  ll point=0;
  vector<char> bef(n);
  for(int i=0; i<k; i++){
    point += mp[str[i]];
    bef[i] = str[i];
  }
  for(int i=k; i<n; i++){
    if(str[i]!=bef[i-k]){
      point += mp[str[i]];
      bef[i] = str[i];
    }else bef[i] = 'x';
  }
  cout << point << endl;
  
}


Measured memory_bytes: 512
import scala.io.Source.stdin

object Main extends App {
  def det(a00:Double,a01:Double,a10:Double,a11:Double) = a00*a11-a01*a10

  for( i <- stdin.getLines ) {
    val a = i.split(" ").map(_.toDouble)
    val detA = det(a(0),a(1),a(3),a(4))
    printf("%.3f %.3f\n",det(a(2),a(1),a(5),a(4))/detA+0.0,det(a(0),a(2),a(3),a(5))/detA+0.0)
  }
}

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

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x3, y3, x4, y4;
  int dx = x2 - x1;
  int dy = y2 - y1;
  x3 = x2 - dy;
  y3 = y2 + dx;
  x4 = x3 - dx;
  y4 = y3 - dy;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());

using ll = long long int;

int main(){
    int n;
    cin >> n;
    vector<int> dp(n + 1), h(n);
    in_arr(int, h, n);

    dp[0] = 0;

    rep(i, n - 1) {
        dp[i + 1] = dp[i] + abs(h[i] - h[i + 1]);
        if(i > 0) {
            dp[i + 1] = min(dp[i + 1], dp[i - 1] + abs(h[i - 1] - h[i + 1]));
        }
        //cout << dp[i + 1] << endl;
    }
    cout << dp[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int l[3]={a,b,c};
  sort(l,l+3);
  
  int count=0;
  count+= l[2]-l[1];
  l[0]+=l[2]-l[1];
  int aa=l[2]-l[0];
  if(aa%2==0){
      count+=aa/2;
  }else{
      count+=(aa+1)/2+1;
  }
  cout<<count;


return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc160
{
    class Program
    {
        static void Main(string[] args)
        {
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
			solve_abc160C2();
        }

        /*
        https://atcoder.jp/contests/abc160/submissions/11288794
        */
        public static void solve_abc160C2()
        {
            int[] kn = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int k = kn[0];
            int n = kn[1];
            int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int ans = 100000000;
            for (int i = 0; i < n; i++)
            {
                int l = a[i];
                int r = a[(i + n - 1) % n];
                if (l > r)
                {
                    r += k;
                }
                ans = Math.Min(ans, r - l);
            }
            Console.WriteLine(ans);
        }

        /*
        https://atcoder.jp/contests/abc160/submissions/11285262
        */
        public static void solve_abc160C()
        {
            int[] kn = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int k = kn[0];
            int n = kn[1];
            int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int max = 0;
            int prev = 0;
            /*
            Good way to compare items:
            current and previous:
            Another idea is to comapre a[i] and a[i - 1]
            But we need to think about the starting value.
            In this case it is 0.
            */
            for (int i = 0; i < n; i++)
            {
                max = Math.Max(max, Math.Abs(prev - a[i]));
                prev = a[i];
            }
            /*
            Main idea is that the distance from last to first house is 𝑘−𝑎[𝑛−1]+𝑎[0]
            */
            max = Math.Max(max, k - a[n - 1] + a[0]);
            Console.WriteLine(k - max);
        }

        public static void solve_abc160B()
        {
            int x = Convert.ToInt32(Console.ReadLine());
            int a = x / 500;
            int r = x % 500;
            int b = r / 5;
            Console.WriteLine(a * 1000 + b * 5);
        }

        public static void solve_abc160A()
        {
            string s = Console.ReadLine();
            Console.WriteLine(s[2] == s[3] && s[4] == s[5] ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 32604
#include <iostream>
#include <string>
#include <sstream>
#include <math.h>
#include<string>
using namespace std;

int main(){
    long long x;
    long long ans = 0;
    cin >> x;
    while(x >= 500){
        x -= 500;
        ans += 1000;
    }
    while(x >= 5){
        x -= 5;
        ans += 5;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
def getN():
    return int(input())

def getMN():
    return list(map(int, input().split()))

def getlist():
    return list(map(int, input().split()))

n = getN()
we = getlist()

ans = 10000000000
for i in range(n):
    tmp = abs(sum(we[:i]) - sum(we[i:]))
    if ans > tmp:
        ans = tmp

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define NL << endl
using namespace std;
using ll = long long;
const int INFINT = 1 << 30;
const ll INFLL = 1LL << 60;
const int MOD = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a%b) : a;}

int main() {

	int a, b;

	cin >> a >> b;

	FOR(i, 1, 4) {
		if ((a*b*i) % 2 == 1) {
			cout << "Yes" NL;
			return 0;
		}
	}
	cout << "No" NL;


	return 0;
}

Measured memory_bytes: 256
using System;

namespace AOJ
{
    class Sum_of_4
    {
        public static void Main()
        {
            int[] calc = new int[37];
            for (int a = 0; a <= 9; a++)
            {
                for (int b = 0; b <= 9; b++)
                {
                    for (int c = 0; c <= 9; c++)
                    {
                        for (int d = 0; d <= 9; d++)
                        {
                            calc[a + b + c + d]++;
                        }
                    }
                }
            }

            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }

                int test = int.Parse(input);
                if (test > 36) { Console.WriteLine("0"); }
                else { Console.WriteLine(calc[test]); }
            }
        }
    }
}

Measured memory_bytes: 5608
#include<cstdio>

const int MOD=1e9+7;
struct mint{int x;mint(int x=0):x(x){}};
inline mint operator+  (mint a,mint b){return a.x+b.x<MOD?a.x+b.x:a.x+b.x-MOD;}
inline mint operator-  (mint a){return MOD-a.x;}
inline mint operator-  (mint a,mint b){return a+-b;}
inline mint operator*  (mint a,mint b){return 1LL*a.x*b.x%MOD;}
inline mint operator<< (mint x,int y){mint r=1;for(;y;y>>=1,x=x*x)if(y&1)r=r*x;return r;}
inline mint operator~  (mint x){return x<<MOD-2;}
inline mint operator/  (mint a,mint b){return a*~b;}
inline mint&operator+= (mint&a,mint b){return a=a+b;}
inline mint&operator-= (mint&a,mint b){return a=a-b;}
inline mint&operator*= (mint&a,mint b){return a=a*b;}
inline mint&operator<<=(mint&x,int y){return x=x<<y;}
inline mint&operator/= (mint&a,mint b){return a=a/b;}

#define MN 3000
mint f[MN+5][MN+5],ff[MN+5][MN+5],ans;
int main()
{
	int n,m,i,j;
	scanf("%d%d",&n,&m);--m;
	for(i=1;i<=n;++i)f[0][i]=1;
	for(i=1;i<n;++i)ff[0][i]=1;
	for(i=0;i<m;++i)for(j=1;j<=n;++j)
	{
		f[i+1][j]+=f[i][j]+f[i][j];
		f[i+1][j-1]+=f[i][j];
		if(j<n)f[i+1][j+1]+=f[i][j];
		ff[i+1][j]+=ff[i][j]+ff[i][j];
		ff[i+1][j-1]+=ff[i][j];
		if(j+1<n)ff[i+1][j+1]+=ff[i][j];
	}
	for(i=1;i<=n;++i)ans+=f[m][i]-ff[m][i];
	printf("%d",4*ans);
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) (flag)?1:0
#define yn(f) cout<<(f?"yes":"no")<<endl
#define Yn(f) cout<<(f?"Yes":"No")<<endl
#define YN(f) cout<<(f?"YES":"NO")<<endl
#define COUT(x) cout<<(x)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

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

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

constexpr int MOD=1e9+7;

int main(void){
  int n; cin>>n; COUT(n<1200?"ABC":(n<2800?"ARC":"AGC"));
}













Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
 
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
 
    ll a,b;
    cin>>a>>b;
    for(ll i=b+1;i<=a+b-1;i++){
        ll t = i;
        ll x = t/a + (t - t/a*a);
        ll y = t/b;
        t -= y*b;
        y += t/a;
        t -= t/a*a;
        y += t;
        if(x < y){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


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

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

using ll = long long;
using pii = pair<int, int>;

void solve() {
    int n, m;
    cin >> n >> m;
    vt<int> p(n + 1), ac(n + 1);
    while (m--) {
        int x;
        string s;
        cin >> x >> s;
        if (s == "AC") ac[x] = 1;
        else if (!ac[x]) p[x]++;
    }

    int pen = 0;
    for (int i = 1; i <= n; i++) pen += p[i] * ac[i];
    cout << accumulate(all(ac), 0) << ' ' << pen;
}

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

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}


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


using namespace std;

#define MAXN 110

struct Info {
    string str;
    int pont;
    int ind;
};


string s[MAXN];
int p[MAXN];
Info v[MAXN];
int lug[MAXN];
int n;

struct Compara {
    bool operator()(Info x, Info y) {
        if (x.str != y.str) {
            return x.str < y.str;
        }
        return x.pont > y.pont;
    }
};

int main() {
    cin >> n;

    int i;
    for (i=1; i<=n; i++) {
        cin >> v[i].str >> v[i].pont;
        v[i].ind = i;
    }

    sort(v+1, v+1+n, Compara());

    for (i=1; i<=n; i++) {
        printf("%d\n", v[i].ind);
    }

    return 0;
}








Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=305;
const int mod=998244353;
int n,m,a[N][N],now[N],in[N],p[N][N],r;
inline int poww(int a,int b){
  int res=1;
  for(;b;b>>=1,a=1ll*a*a%mod)
    if(b&1)res=1ll*res*a%mod;
  return res;
}
int main()
{
  scanf("%d%d",&n,&m);
  for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++) scanf("%d",&a[i][j]);
  for(int i=1;i<=n;i++){
    memcpy(now,a[i],sizeof(now));
    for(int j=1;j<=m;j++)
      if(now[j]){
    if(in[j])for(int k=j;k<=m;k++)now[k]^=p[j][k];
    else{in[j]=1;memcpy(p[j],now,sizeof(p[j]));r++;break;}
      }
  }
  printf("%lld\n",1ll*(poww(2,n)-poww(2,n-r)+mod)%mod*poww(2,m-1)%mod);
  return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.lang.*;
public class Main
{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N=sc.nextInt();
        int K=sc.nextInt();
        String S=sc.next();
        String s[] = new String[N];
        for(int i=0; i<N;i++){
            s[i]=String.valueOf(S.charAt(i));
        }
        s[K-1]=s[K-1].toLowerCase();
        for(int j=0;j<N;j++){
            System.out.print(s[j]);
        }
    }
}

Measured memory_bytes: 23764
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 1e5 + 5;
int n;
int a[maxn];

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
  	scanf("%d", &a[i]);
  }
  return true;
}

long long k[maxn];

void solve() {
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		sum += a[i];
	}
	long long one = (long long) n * (n + 1) / 2;
	if (sum % one) {
		printf("NO\n");
		return;
	}
	long long s = sum / one;
	a[n] = a[0];
	for (int i = 0; i < n; i++) {
		int d = a[i + 1] - a[i];
		if (s < d || (s - d) % n) {
			printf("NO\n");
			return;
		}
		k[i + 1] = (s - d) / n;
	}
	k[0] = k[n];
	long long sk = 0;
	for (int i = 0; i < n; i++) {
		sk += k[i];
	}
	if (sk != s) {
		printf("NO\n");
		return;
	}
	long long a0 = k[0];
	for (int i = 1; i < n; i++) {
		a0 += (long long) (n - i + 1) * k[i];
		if (a0 > a[0]) {
			printf("NO\n");
			return;
		}
	}
	if (a0 != a[0]) {
		printf("NO\n");
		return;
	}
	printf("YES\n");
}

int main() {
  precalc();
#ifdef LOCAL
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}

Measured memory_bytes: 1408
N = int(input())
UK = [list(map(int,input().split())) for _ in range(N)]

class Graph:
    def __init__(self,vertex,edge):
        self.v = vertex
        self.e = edge
        self.v_color = [False for _ in range(N)]

    def color(self,u):
        self.v_color[u-1] = True

    def v_exists(self,u):
        flag = False
        for v in self.v:
            if (u,v) in self.e and self.v_color[v-1] == False:
                flag = True
                break
        return flag

V = [i+1 for i in range(N)]
E = []
for i in range(N):
    for j in range(len(UK[i])-2):
        E.append((i+1,UK[i][j+2]))

g = Graph(V,E)

ts = [[0 for _ in range(2)] for _ in range(N+1)]
time = 0

def dfs(u):
    global time
    time += 1
    g.color(u)
    if ts[u-1][0] == 0:
        ts[u-1][0] = time
    while g.v_exists(u):
        for v in g.v:
            if (u,v) in g.e and g.v_color[v-1] == False:
                dfs(v)
    time += 1
    if ts[u-1][1] == 0:
        ts[u-1][1] = time

for i in range(N):
    if g.v_color[i] == False:
        dfs(i+1)

for i in range(N):
    print(i+1,ts[i][0],ts[i][1])



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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ofstream of;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
// #define pn(s) cout << (#s) << " " << (s) << endl
#define pn(s) of << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

string extend(string s, ll len){
    stringstream ss;
    FOR(i, 0, len-s.size()){
        ss << '0';
    }
    ss << s;
    return ss.str();
}

const int MAX_DIGIT = 50;
// const int MAX_DIGIT = 5;

ll dp[100][2];

// すごく参考にした
// http://drken1215.hatenablog.com/entry/2019/02/04/013700

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

    // input
    ll N, K;
    cin >> N >> K;

    of.open("log.txt");

    FOR(i, 0, 100){
        FOR(j, 0, 2){
            dp[i][j] = -1;
        }
    }
    // memset(dp, -1, sizeof(dp));

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A[i];
    }

    // j : smallerなら1
    dp[0][0] = 0;

    // vprint(A);

    // 左からd桁目
    FOR(d, 0, MAX_DIGIT){
        pn('-');
        pn(d);
        ll mask = 1LL<<(MAX_DIGIT-d-1);

        // その桁の1の数
        ll num = 0;
        for(ll a : A){
            if(a&mask) num++;
        }
        // pn(num);

        // X の d 桁目を 0, 1 にしたときに得られる値
        ll cost0 = mask * num;
        ll cost1 = mask * (N - num);

        // smaller -> smaller
        if(dp[d][1]!=-1){
            // 値は自由
            chmax(dp[d+1][1], dp[d][1] + max(cost0, cost1));
        }

        // smaller -> exact
        // なし

        // exact -> smaller
        // 例 8357 -> 832*
        // その時、d桁目は0しか選べない
        if(dp[d][0]!=-1){
            // Kが1のときXを0にすることでsmallerになる
            if(K&mask){
                chmax(dp[d+1][1], dp[d][0] + cost0);
            }
        }

        // exact -> exact
        // d桁目はKの0/1に合わせる
        if(dp[d][0]!=-1){
            // Kのd桁目が0
            if((K&mask)==0){
                chmax(dp[d+1][0], dp[d][0] + cost0);
            }else{
                chmax(dp[d+1][0], dp[d][0] + cost1);
            }
        }

        // pn(dp[d+1][0]);
        // pn(dp[d+1][1]);
    }

    ll ma = max(dp[MAX_DIGIT][0], dp[MAX_DIGIT][1]);
    p(ma);
    
    return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		new Solution().solve(in, out);
		out.close();
	}
	
	private static class Solution {
		private long nextLong(InputReader in) {
			return Long.parseLong(in.next());
		}
		private long sum(long n) {
			return (n * (n + 1)) / 2;
		}
		private void solve(InputReader in, PrintWriter out) {
			long n = nextLong(in);
			long result = sum(n) - sum(n/3) * 3 - sum(n/5) * 5 + sum(n/15) * 15;
			out.println(result);
		}
	}
	
	private static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32678);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}
	}


}


Measured memory_bytes: 25624
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    ll n, k;
    cin >> n >> k;
    vll a(n), f(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.begin(), f.end());
    reverse(f.begin(), f.end());

    vp prod(n);
    rep(i, n) prod[i] = P(a[i] * f[i], f[i]);
    sort(prod.begin(), prod.end());
    reverse(prod.begin(), prod.end());

    auto pos = [](ll x, ll kk, ll n, vp p) {
        ll j = 0;
        while (kk > 0)
        {
            if (j >= n)
            {
                break;
            }
            if (p[j].first > x)
            {
                ll d = (p[j].first - x);
                d = (d + p[j].second - 1) / p[j].second;
                d = min(d, kk);
                kk -= d;
                p[j].first -= p[j].second * d;
                j++;
            }
            else
            {
                break;
            }
        }

        bool sat = true;
        rep(i, n) sat = sat && (p[i].first <= x);
        return sat;
    };

    ll l = 0,
       r = 1e18;

    while (l < r)
    {
        ll mid = (l + r) / 2;
        bool ok = pos(mid, k, n, prod);
        if (ok)
        {
            r = mid;
        }
        else
        {
            l = mid + 1;
        }
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 12824
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;
int gcd(int a, int b){
   if(a>b)return gcd(b,a);
   if(b%a==0) return a;
   else return gcd(b%a,a);
}

int main(){
   int N,M;
   cin >> N >>M;
   int a[N];
   long long k=1;
   for (int i = 0; i < N; i++)
   {
      cin >> a[i];
   }
   for (int i = 0; i < N; i++)
   {
      k *= (a[i]/2)/gcd(a[i]/2, k);
      if(k > M){
         cout << 0 << endl;
         return 0;
      }
   }
   for(int i = 0 ; i < N; i++){
      if((k/(a[i]/2))%2==0){
         cout << 0 << endl;
         return 0;
      }
   }
   cout << ((M/k)+1)/2 << endl;
   return 0;
}


Measured memory_bytes: 3972
#include <stdio.h>
int main(){
  for(;;){
    int n,i,j,k;
    int A={0},B={0};
    scanf("%d",&n);
    if(n==0){
      return 0;
    }
      for(i=0;i<n;i++){
      scanf(" %d %d",&j,&k);
      if(j>k){
        A+=(j+k);
      } else if(j<k){
        B+=(j+k);
      } else if(j==k){
        A+=j;
        B+=k;
      }
    }
    printf("%d %d\n",A,B);
  }
}

Measured memory_bytes: 2736
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw	 "\n"

int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	long double s,t;
	cin>>s>>t;
	if(s<t)cout<<"LESS"<<nw;
	else if (s>t) cout<<"GREATER"<<nw;
	else cout<<"EQUAL"<<nw;
		

}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                      \
  ifstream in("loadtolb/arc096_a.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  c *= 2;

  ll ans = 0;
  // 1. abを使う
  if (a + b > c) {
    int z = min(x, y);
    ans += z * c;
    x -= z;
    y -= z;

    if (x != 0) {
      ans += min(x * a, x * c);
    } else {
      ans += min(y * b, y * c);
    }

  } else {
    ans += a * x;
    ans += b * y;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin >> N;
  int cnt = 0;
  for(int i = 0; i < N; ++i){
    int x; cin >> x;
    if(x&1)cnt^=1;
  }
  cout << (cnt?"NO\n":"YES\n");
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int A;
  int B;
  int P;
  int M;
  int K;
  scanf("%d",&A);
  scanf("%d",&B);
  P=A+B;
  M=A-B;
  K=A*B;
  if((A==0)&&(B==0)){
    printf("0");
  } 
  if((-100<=A)&&(100>=A)&&(-100<=B)&&(100>=B)){
    if((A<0)&&(B<0)){
      printf("%d",K);
    }
    if((A<0)&&(B>0)){
      printf("%d",P);
    }
    if((A>0)&&(B<0)){
      printf("%d",M);
    }
    if(((A==1)&&(B>0))||((A>0)&&(B==1))||((A==1)&&(B==1))){
      printf("%d",P);    
    }
    if(((A!=1)&&(B>0)&&(B!=1)&&(A>0))||((A>0)&&(B!=1)&&(A!=1)&&(B>0))||((A>0)&&(B>0)&&(A!=1)&&(B!=1))){
      printf("%d",K);
    }   
    if(((A==0)&&(B>0))||((A>0)&&(B==0))){
      printf("%d",P);
    }
    if((A==0)&&(B<0)){
      printf("%d",M);
    } 
    if((A<0)&&(B==0)){
      printf("%d",K);
    }      
  }
  }   

Measured memory_bytes: 128
MAX = 10**5
is_prime = [True for i in range(MAX + 1)]
is_prime[0], is_prime[1] = False, False 
i = 2
while i ** 2 <= MAX:
    if is_prime[i]:
        j = 2 * i
        while j <= MAX:
            is_prime[j] = False
            j += i
    i += 1

a = [0 for i in range(MAX)]
for i in range(MAX + 1):
    if i % 2 == 0:
        continue
    if is_prime[i] and is_prime[(i + 1) // 2]:
        a[i] = 1

s = [0 for i in range(MAX + 2)]
for i in range(MAX):
    s[i + 1] = s[i] + a[i]
    
Q = int(input())
for q in range(Q):
    l, r = map(int, input().split())
    print(s[r + 1] - s[l])

Measured memory_bytes: 8056
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int n;
    int an=0,bn=0;
    cin>>n;
    int p[8],q[8];
    int pn=0,qn=0;
    REP(i,n)cin>>p[i];
    REP(i,n)cin>>q[i];
    for(int i=0;i<n;i++)
    {
        pn=pn*10+p[i];
        qn=qn*10+q[i];
    }
    vector<int>v,vv;
    REP(i,n)v.PB(i+1);
    do{
        int nn=0;
        REP(i,v.size())
        {
            nn=nn*10+v[i];
        }
        vv.PB(nn);
    }while(next_permutation(v.begin(),v.end()));
    sort(vv.begin(),vv.end());
    // REP(i,vv.size())cout<<vv[i]<<endl;
    int qq,pp;
    REP(i,vv.size()){
        if(vv[i]==pn)
        {
            pp=i;
        }

        if(vv[i]==qn)
        {
            qq=i;
        }
    }
    cout<<abs(pp-qq)<<endl;
    // cout<<pn<<" "<<qn<<endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

 class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans[] = {111,222,333,444,555,666,777,888,999};
		int val=111;
		for(int i=1;i<ans.length;i++) {
			if(n==ans[i]) {
				val=ans[i];break;
			} else
			if(ans[i-1]<n && ans[i]>=n) {
				val=ans[i];break;
			}
				
		}
		System.out.println(val);
	}
}


Measured memory_bytes: 23636
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
  }
  
  int cnt = 1;
  multiset<ll> mlt;
  mlt.insert(a.back());
  for (int i = n-2; i >= 0; --i) {
    auto itr = mlt.upper_bound(a[i]);
    if (itr == mlt.end()) {
      cnt += 1;
      mlt.insert(a[i]);
    } else {
      mlt.erase(itr);
      mlt.insert(a[i]);
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 5760
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String line = sc.nextLine();
while(!("0 0".equals(line))){
String[] inputs = line.split(" ");
int height = Integer.valueOf(inputs[0]);
int width = Integer.valueOf(inputs[1]);
StringBuilder result = new StringBuilder();
for(int i=0;i<height;i++){
for(int j=0;j<width;j++){
if(i==0||i==height-1||j==0||j==width-1) result.append("#");
else result.append(".");
}
result.append("\n");
}
System.out.println(result);
line = sc.nextLine();
}
}
}


Measured memory_bytes: 26980
#include<iostream>
using namespace std;
int main()
{
	int h,n,t,sum = 0;
	scanf("%d %d",&h,&n);
	for(int i = 0;i < n;i++)
	{
		scanf("%d",&t);
		sum += t;
	}
	if(sum < h)
		printf("No\n");
	else
		printf("Yes\n");
	return 0; 
}

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

int main(){
  int c[3][3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> c[i][j];
    }
  }
  int a1=0,a2=0,a3=0,b1=0,b2=0,b3=0;
  for(int i=0;i<3;i++){
    a1+=c[0][i];
    a2+=c[1][i];
    a3+=c[2][i];
    b1+=c[i][0];
    b2+=c[i][1];
    b3+=c[i][2];
  }
  int a12 = a2 - a1;
  int a13 = a3 - a1;
  int b12 = b2 - b1;
  int b13 = b3 - b1;
  a12 /= 3;
  a13 /= 3;
  b12 /= 3;
  b13 /= 3;
  for(int i=0;i<=100;i++){
    for(int j=0;j<=100;j++){
      if(i+j==c[0][0]&&i+b12+j==c[0][1]&&i+b13+j==c[0][2]&&i+j+a12==c[1][0]&&i+a12+j+b12==c[1][1]&&i+a12+j+b13==c[1][2]&&i+a13+j==c[2][0]&&i+a13+j+b12==c[2][1]&&i+a13+j+b13==c[2][2]){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

int solve(int n) {
	int ans = 0;
	while (n % 2 == 0) {
		n /= 2;
		ans++;
	}
	return ans;
}

int main() {
	int n;
	cin >> n;
	vl a(n);
	rep(i, n) cin >> a[i];

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

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

using namespace std;

int n;
double dp[302][302][302];
int a[301];

double dfs(int x, int y, int z){
  if(dp[x][y][z] >= 0) return dp[x][y][z];
  if(x == 0 && y == 0 && z == 0) return 0.0;

  double res = 0;
  if(x > 0) res += dfs(x-1, y, z) * x;
  if(y > 0) res += dfs(x+1, y-1, z) * y;
  if(z > 0) res += dfs(x, y+1, z-1) * z;
  res += n;
  res *= 1.0 / (x + y + z);
  return dp[x][y][z] = res;
}

int main(){
  cin >> n;
  int x = 0;
  int y = 0;
  int z = 0;
  for(int i = 0; i <= n+1 ; i++){
    for(int j = 0; j <= n+1 ; j++){
      for(int k = 0; k <= n+1; k++){
        dp[i][j][k] = -1;
      }
    }
  }
  for(int i = 0; i < n; i++){
    cin >> a[i];
    if(a[i] == 1) x++;
    else if(a[i] == 2) y++;
    else z++;
  }
  cout << setprecision(10) << dfs(x,y,z) << endl;
}


Measured memory_bytes: 215424
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

int main() {
	vector<int> a(4);
	cin >> a;
	sort(ALL(a));
	int ans = 1e9;
	do {
		int x = a[0] + a[1];
		int y = a[2] + a[3];
		setmin(ans, abs(x - y));
	} while(next_permutation(ALL(a)));
	
	OUT(ans);
}



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

using namespace std;

int main()
{
    int a[3];

    cin >> a[0] >> a[1] >> a[2];

    swap(a[0], a[1]);
    swap(a[0], a[2]);

    printf("%d %d %d\n", a[0], a[1], a[2]);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <utility>
#include <algorithm>
using namespace std;


int main(){
    int n;
    cin>>n;
    
    vector<int> v(n);
    for(int i=0; i<n; i++){
        cin>>v[i];
    }
    
    int maxh=v[0];
    int cnt=1;
    for(int i=1; i<n; i++){
        if(v[i]>=maxh){
            cnt++;
            maxh=v[i];
        }
    }
    
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), def = b - a, sum = 0;

		for(int i=1; i<=def; i++){
			sum += i;
		}
		System.out.println(sum-b);
	}
}

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

string N;
int K, l;
ll d[105][4][2]{};

void disp(int a, int b) {
    for (int i = 1; i <= l; i++) {
        cout << d[i][a][b] << " ";
    }
    cout << "\n";
}

int main() {

    cin >> N >> K;
    l = N.length();

    d[1][0][1] = 1;
    d[1][1][0] = 1;
    d[1][1][1] = N[0] - '0' - 1;
    for (int i = 1; i < l; i++) {
        ll s = N[i] - '0';
        if (s == 0) {
            for (int j = 0; j < 3; j++) {
                d[i + 1][j][0] = d[i][j][0];
            }
            for (int j = 0; j < 4; j++) {
                d[i + 1][j][1] = d[i][j][1];
            }
            for (int j = 0; j < 3; j++) {
                d[i + 1][j + 1][1] += d[i][j][1] * 9ll;
            }
        } else {
            for (int j = 0; j < 3; j++) {
                d[i + 1][j + 1][0] = d[i][j][0];
            }
            for (int j = 0; j < 4; j++) {
                d[i + 1][j][1] = d[i][j][1] + d[i][j][0];
            }
            for (int j = 0; j < 3; j++) {
                d[i + 1][j + 1][1] += d[i][j][1] * 9ll + d[i][j][0] * (N[i] - '0' - 1);
            }
        }

        
    }
    ll ans = 0;
    cout << d[l][K][0] + d[l][K][1] << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  signed long long N, K;
  cin >> N >> K;
  
  signed long long ans, min_num;
  //bool pf = false;
  
  
  while(true){
    /*if(abs(N-K) < N){
      N = abs(N-K);
      //cout << N <<" ";
    }
    else break;*/
    if( N % K == 0){
      N = 0;
      break;
    }
    else if(abs(N - K) > N ){
      break;
    }
    else{
      min_num = min(N%K, K%N);
      if(K%N!=0) {N = min_num;}
    }
  }
  cout << N;
}


Measured memory_bytes: 256