akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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(){
  ll N,K;
  cin >> N >> K;
  vector<vector<ll>> G(N);
  for(int i=0; i<N; i++){
    ll t,d;
    cin >> t >> d;
    t--;
    G[t].push_back(d);
  }
  vector<ll> y0,y1;
  for(int i=0; i<N; i++){
    if(G[i].size() == 0) continue;
    sort(G[i].begin(),G[i].end(),greater<ll>());
    for(int j=0; j<G[i].size(); j++){
      if(j){
        y0.push_back(G[i][j]);
      }else{
        y1.push_back(G[i][j]);
      }
    }
  }
  sort(y0.begin(),y0.end(),greater<ll>());
  sort(y1.begin(),y1.end(),greater<ll>());
  ll ans = 0;
  ll var= max(0,(int)(K-y0.size()));
  ll res = 0;
  for(int i=0; i<var; i++){
    res += y1[i];
  }
  for(int i=0; i<K-var; i++){
    res += y0[i];
  }
  while(1){
    ans = max(ans,res + var*var);
    if(K<=var || y1.size()<=var){
      break;
    }
    res += y1[var];
    res -= y0[K-var-1];
    var++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6904
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
import re
 
s = input()
k = int(input())
#  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
c = collections.Counter(s)

def nchars(s, n):
    """文字列 s に、同じ文字が n 個以上連続している部分文字列を見つける
    """
    assert n > 0
    reg = re.compile("(.)\\1{%d,}" % (n - 1))  # カンマを取ると n 個ちょうどになる
    while True:
        m = reg.search(s)
        if not m:
            break
        yield m.group(0)
        s = s[m.end():]

ans = 0

chains = list(nchars(s, 2))

if len(c) == 1:
    print(len(s) * k // 2)
else:
    #print(chains)
    #print(len(chains[0]), len(chains[-1]), k)
    for r in chains:
        ans += len(r) // 2

    if chains and chains[0] == chains[-1]:
        print(ans * k + (k - 1 if chains[0] == chains[-1] else 0))
    else:
        print(ans * k)


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}

int main() {
  string n;
  int ans=0;
  cin>>n;
  rep(i,4){
    if(n[i]=='2') ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
const int DX[8]={-1,0,1,0,-1,-1,1,1},DY[8]={0,-1,0,1,-1,1,-1,1};


int main(){;
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0) break;
		vi a(m);
		for(int i=0;i<n;i++){
			int x,y;
			cin>>x>>y;
			x--;
			a[x]=max(a[x],y);
		}
		int res=0;
		for(auto i:a) res+=i;
		cout<<res<<endl;
	}
}


Measured memory_bytes: 3108
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

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

  sort(a,a+n);
  int l = 0, r = a[n-1];
  rep(i, n) if (abs(r-l*2)>abs(r-a[i]*2)) l = a[i];
  cout << r << " " << l << endl;
  return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound 
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define vi vector<int> 
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
    
	const int N =1e5+10;
    
     int mod= 998244353;
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};
  
  void solve() {
     
    int a,b;
    cin>>a>>b;
    
    int mdl=(a+b)/2;
    int mdb=floor((float)(a+b)/2);
    int mdh=ceil((float)(a+b)/2);
    
    if(abs(a-mdl)==abs(b-mdl))
      cout<<mdl<<endl;
      
    else if(abs(a-mdb)==abs(b-mdb))
      cout<<mdb<<endl;
      
        
    else if(abs(a-mdh)==abs(b-mdh))
      cout<<mdh<<endl;
      
     else
        cout<<"IMPOSSIBLE\n";
 
    
  }          
         
 
   
  int32_t main() {
    cool;
    int t=1;
    while(t--)
       solve();
  
       return 0;	   
   }


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <queue>

using namespace std;

map<long long,long long> decomposite(long long N, map<long long,long long> & primes,long long next_p = 2){
    if (N == 1){
        return primes;
    }


    while (next_p * next_p <= N ) {
        if (N % next_p == 0) {
            primes[next_p] += 1;
            return decomposite(N/next_p,primes,next_p);
        } else {
            next_p++;
        }
    }
    primes[N] += 1;
    return primes;
}

long long myPow(long long x, long long  n, long  long m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int main()
{
    // 整数の入力
    long long N,counter;
    cin >>  N;
    long long i = 1;
    counter = 0;
    while (i < (N /i - 1)){
        // cout << i << endl;
        if (N % i == 0){
            counter +=  N/i - 1;
        }
        i++;
    }

    cout << counter << endl;
    return 0;
}


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

using namespace std;

int main(){
        string s1,s2,s3;
        cin >> s1 >> s2;
        int len1,len2;
        len1 = s1.size();
        len2 = s2.size();
        if(len1 > len2){
                cout << "GREATER" << endl;
                return 0;
        }else if(len1< len2){
                cout << "LESS" << endl;
        }else{
                for(int i = 0;i<len1;i++){
                        if(s1[i] > s2[i]){
                                cout << "GREATER" << endl;
                                return 0;
                        }else if(s1[i] < s2[i]){
                                cout << "LESS" <<endl;
                                return 0;
                        }
                }
                cout << "EQUAL" << endl;
        }
        return 0;
        }

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int l;
    bool a[26];
    string s;
    cin>>s;
    l=s.length();
    for(bool &x:a){
        x=false;
    }
    if(l<26){
        for(int i=0;i<l;i++){
            a[s[i]-'a']=true;
        }
        for(int i=0;i<26;i++){
            if(!a[i]){
                char c='a'+i;
                cout<<s<<c<<endl;
                return 0;
            }
        }
    }else{
        for(int i=0;i<25;i++){
            a[s[25-i]-'a']=true;
            if(s[24-i]<s[25-i]){
                for(int j=0;j<26;j++){
                    if(a[j]&&j>s[24-i]-'a'){
                        char c='a'+j;
                        cout<<s.substr(0,24-i)<<c<<endl;
                        return 0;
                    }
                }
                
            }
        }
        cout<<-1<<endl;
        return 0;
    }
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int b,c,n,m,x=0,y=0,i;
    int a[4];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    for(i=0; i<3; i++)
    {
        if(a[i]==5)
        {
            x++;
        }
        if(a[i]==7)
        {
            y++;
        }
    }
    if(x==2 && y==1)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
int n,m;
int main()
{
	scanf("%d %d",&n,&m);
	int a = (n+2)/2;
	if(n>a)
	{
		for(int i=0;i<a;i++)printf("0 ");
		for(int i=0;i<n-a-1;i++)printf("%d ",m);
		printf("%d\n",m);
	}
	else
	{
		if(n==1)printf("0\n");
		if(n==2)printf("0 0\n");
	}
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

 
int main() {

    int n;
    cin >> n;
 
    int c[10][10] = {};
 
    for (int i = 1; i <= n; i++) {
        string di = to_string(i);
        int v = di.size();
        c[di[0] - '0'][di[v-1] - '0']++;
    }
 
    int res = 0;
 
    rep(i, 10) {
        rep(j, 10) {
            res += c[i][j] * c[j][i];
        }
    }
    cout << res << endl;

 return 0;
}

Measured memory_bytes: 256
EPS = 1e-10
X, Y, L = 0, 1, 2

class Point
  include Comparable
  attr_accessor :x, :y
  def initialize(x=0.0, y=0.0)
    @x, @y = x.to_f, y.to_f
  end
  def <=>(p)
    @x != p.x ? @x <=> p.x : @y <=> p.y
  end
  def +(p)
    Point.new(@x+p.x, @y+p.y)
  end
  def -(p)
    Point.new(@x-p.x, @y-p.y)
  end
  def -@
    Point.new(-@x, -@y)
  end
  def times(f)
    Point.new(@x*f, @y*f)
  end
  def dot(p)
    @x*p.x + @y*p.y
  end
  def cross(p)
    @x*p.y - @y*p.x
  end
  def abs
    Math::hypot(@x, @y)
  end
  def norm
    @x**2 + @y**2
  end
end

class Circle
  include Comparable
  attr_accessor :x, :y, :r
  def initialize(x=0.0, y=0.0, r=1.0)
    @x, @y, @r = x.to_f, y.to_f, r.to_f
  end
  def <=>(c)
    @x!=c.x ? @x<=>c.x : (@y!=c.y ? @y<=>c.y : @r<=>c.r)
  end
  def point
    Point.new(@x, @y)
  end
  def distance(c)
    (point-c.point).abs
  end
  def include?(p)
    (point-p).abs - @r <= EPS
  end
  def in?(c)
    distance(c) - (@r-c.r).abs < EPS
  end
  def touch?(c)
    distance(c) <= @r + c.r
  end
  def crossPoint(c)
    angle = Math::atan2(c.y-@y, c.x-@x)
    d = distance(c)
    add = Math::acos((d**2 + @r**2 - c.r**2) / (2.0*d*@r))
    p1 = Point.new(@x+@r*Math::cos(angle+add), @y+@r*Math::sin(angle+add))
    p2 = Point.new(@x+@r*Math::cos(angle-add), @y+@r*Math::sin(angle-add))
    [p1, p2]
  end
end

def check(height)
  result = false
  circle = Array.new
  @rope.each do |rope|
    return false if rope[L] < height
    circle.push(Circle.new(rope[X], rope[Y], Math::sqrt(rope[L]**2-height**2)))
  end
  crossPoint = Array.new
  circle.each do |c1|
    crossPoint.push(c1.point)
    circle.each do |c2|
      next if c1 == c2
      next if c1.in?(c2)
      next unless c1.touch?(c2)
      crossPoint.push(*c1.crossPoint(c2))
    end
  end
  crossPoint.each do |p|
    ok = true
    circle.each do |c|
      ok = false unless c.include?(p)
    end
    result = true if ok
  end
  result
end

until (@n=gets.to_i).zero?
  @rope = Array.new
  @n.times {@rope.push(gets.split.map(&:to_f))}
  mid = 0.0
  low = 0.0
  high = 300.0
  until high-low < EPS
    mid = (high+low) / 2.0
    case check(mid)
      when true
        low = mid
        answer = mid
      when false
        high = mid
    end
  end
  p mid
end

Measured memory_bytes: 6292
#include<iostream>
using namespace std;
int m, n;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int divi[100][100];
int used[100][100];
int r;
void solve(int x, int y, int res);
int main(){
  while(1){
    cin >> m;
    cin >> n;
    r = 0;
    if(m == 0 && n == 0) break;
    for(int i = 0; i < n; i++){
      for(int j = 0; j < m; j++){
	cin >> divi[i][j];
      }
    }
    for(int i = 0; i < n; i++){
      for(int j = 0; j < m; j++){
	if(divi[i][j] == 1){
	  solve(j, i, 1);
	}
      }
    }
    cout << r << endl;
  }
} 
void solve(int x, int y, int res){
  r = max(r, res);
  used[y][x] = 1;
  for(int i = 0; i < 4; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(divi[ny][nx] != 0 && nx >= 0 && nx < m && ny >= 0 && ny < n && used[ny][nx] == 0){
      solve(x + dx[i], y + dy[i], res + 1);	
    }
  }
  used[y][x] = 0;
}

Measured memory_bytes: 1228
# n,m=map(int,input().split())
# a,b,c=map(int,input().split())
# s=input()
# s,t=map(str,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
L=[]
L.append(A)
L.append(B)
L.append(C)
n=int(input())

for i in range(n):
  x=int(input())
  for a in range(3):
    for b in range(3):
      if L[a][b] == x:
        L[a][b]=0

if L[0][0]==0 and L[0][1]==0 and L[0][2]==0:
  print("Yes")
  exit()

if L[1][0]==0 and L[1][1]==0 and L[1][2]==0:
  print("Yes")
  exit()

if L[2][0]==0 and L[2][1]==0 and L[2][2]==0:
  print("Yes")
  exit()

if L[0][0]==0 and L[1][0]==0 and L[2][0]==0:
  print("Yes")
  exit()
if L[0][1]==0 and L[1][1]==0 and L[2][1]==0:
  print("Yes")
  exit()
if L[0][2]==0 and L[1][2]==0 and L[2][2]==0:
  print("Yes")
  exit() 
if L[0][0]==0 and L[1][1]==0 and L[2][2]==0:
  print("Yes")
  exit()
if L[0][2]==0 and L[1][1]==0 and L[2][0]==0:
  print("Yes")
  exit()


print("No")
    
    

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
ll n[500010];
ll m[500010];
int main() {
	string s;
	cin>>s;
	s='0'+s+'0';
	char ch='<';
	for(ll i=1;i<s.size();i++){
		char now=s[i];
		if(s[i]!=ch){
			n[i]=0;
		}
		else{
			n[i]=n[i-1]+1;
		}
	}
	reverse(s.begin(),s.end());
	ch='>';
	for(ll i=1;i<s.size();i++){
		char now=s[i];
		if(s[i]!=ch){
			m[i]=0;
		}
		else{
			m[i]=m[i-1]+1;
		}
	}
	//for(ll i=0;i<s.size()-1;i++){
	//	cout << n[i];
	//}
	//cout <<endl;
	//for(ll i=0;i<s.size()-1;i++){
	//	cout << m[i];
	//}
	//cout <<endl;
	ll ans=0;
	for(ll i=0;i<s.size()-1;i++){
		ans+=max(n[i],m[s.size()-2-i]);
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 8728
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

set<int> bad;

bool good(int n) {
    while (n) {
        if (bad.count(n % 10)) {
            return false;
        }
        n /= 10;
    }
    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;

    int n, k;
    cin >> n >> k;
    for (int i = 0; i < k; i++) {
        int a;
        cin >> a;
        bad.insert(a);
    }
    while (true) {
        if (good(n)) {
            cout << n << '\n';
            return 0;
        }
        n++;
    }

    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using coord= pair<int, int>;


bool is_valid_move(vector<string> &board, vector<vector<int>> &checked, int x, int y) {
  int H= board.size();
  int W= board.at(0).size();
 
  // 移動先がマス目の外である場合
  if (x <= -1 || x >= H || y <= -1 || y >= W) {
    return false;
  }
  // 移動先が壁マス
  if (board.at(x).at(y) == '#') {
    return false;
  }
  // 既に調べているマスへの移動は調べないのでfalseを返す
  if (checked.at(x).at(y)!= -1) {
    return false;
  }
 
  // それ以外なら正しい移動
  return true;
}

int BFS(vector<string> &board, coord s, coord g){
  int H= board.size();
  int W= board.at(0).size();

  const vector<coord> diff= {make_pair(0,-1),
                             make_pair(-1,0), make_pair(1,0),
                             make_pair(0,1)};                   // 探索方向

  vector<vector<int>> checked(H, vector<int>(W, -1));
  checked.at(s.first).at(s.second)= 0;

  queue<coord> bfs;
  bfs.push(s);
  while( !bfs.empty() ){
    coord p= bfs.front();
    int x= p.first;
    int y= p.second;
    if(p==g){
      break;
    }
    else{
      for(auto ds:diff){
        int dx= ds.first;
        int dy= ds.second;
        if(is_valid_move(board, checked, x+dx, y+dy) ){
          checked.at(x+dx).at(y+dy)= checked.at(x).at(y)+ 1;
          bfs.push(make_pair(x+dx, y+dy));
        }
      }
      bfs.pop();
    }
  }

  return checked.at(g.first).at(g.second);
}
int main() {
  int H,W;
  cin >> H >> W;

  int cnt_black= 0;
  vector<string> Board(H);
  for(int i=0; i<H; i++){
    cin >> Board.at(i);
    for(int j=0; j<W; j++){
      if(Board.at(i).at(j)=='#'){
        cnt_black++;
      }
    }
  }

  int ans;
  int cnt_path= 1+ BFS(Board, make_pair(0,0), make_pair(H-1,W-1));
  if(cnt_path>0){
    ans= H*W- cnt_path- cnt_black;
  }
  else{
    ans= -1;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <boost/multiprecision/cpp_int.hpp>
#include <limits.h>

using namespace std;
using namespace boost::multiprecision;

int N, C;
int D[500][500];
int a[3][30];

void solve() {
	cin >> N >> C;
	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++) {
			cin >> D[i][j];
		}
	}
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < C; j++) {
			a[i][j] = 0;
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			int c;
			cin >> c;
			c--;
			a[(i + j) % 3][c]++;
		}
	}
	int ans = INT_MAX;
	for (int p = 0; p < C; p++) {
		for (int q = 0; q < C; q++) {
			for (int r = 0; r < C; r++) {
				if (p == q || q == r || r == p)continue;
				int temp = 0;
				for (int c0 = 0; c0 < C; c0++)temp += D[c0][p] * a[0][c0];
				for (int c1 = 0; c1 < C; c1++)temp += D[c1][q] * a[1][c1];
				for (int c2 = 0; c2 < C; c2++)temp += D[c2][r] * a[2][c2];
				ans = min(ans, temp);
			}
		}
	}
	cout << ans << endl;
	return;
}

Measured memory_bytes: 256
#include<iostream>
int main(){
  int i,j,h,w;
  while(1){
    std::cin >> h >> w;
    if(h == 0 && w == 0) return 0;
    for(i=0; i<h; i++){
      for(j=0; j<w; j++) std::cout << "#";
      std::cout << std::endl;
    }
    std::cout << std::endl;
  }
}

Measured memory_bytes: 3032
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 998244353
#define INF 1LL<<60
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) (a)<=(i) && (i)<(b)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;

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

  string s;
  cin >> s;

  int n = s.size();

  REP(i,7){
    string t;
    REP(j,i){
      t += s[j]; 
    }
    FOR(j,n-7+i,n) t += s[j];
    if(t == "keyence"){
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int w,i,l,a,b,d;
   scanf("%d %d %d",&w,&a,&b);
   if(a<b){
       l=a+w;
       d=b-l;
       if(d>0)
        printf("%d",d);
       else
        printf("0");
   }
   if(a>b){
       i=b+w;
       d=a-i;
       if(d>0)
        printf("%d",d);
       else
        printf("0");
   }
   if(a==b)
    printf("0");

   return 0;
}



Measured memory_bytes: 256
function Main(input){
  x = BigInt(input.trim());
  var i = 0n;
  var money = 100n;
  while (money < x){
    money = money +  money/100n;
    i++;
  }
  console.log(String(i));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30336
#include<iostream>
using namespace std;
void Draw(int h,int w)
{
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++)
			cout<<"#";
		cout<<endl;
	}	
}

int main()
{
	int h ,w;
	while(true){
		cin>>h>>w;
		if(h==0&&w==0)
			break;
		Draw(h,w);
		cout<<endl;	
	}	
	return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define REP(i, a, b) for(long long i=a; i<=b; ++i)
#define REPN(i, a, b) for(long long i=a; i<=b; --i)
#define rep(i, a, b) for(long long i=a; i<b; ++i)
#define rep0(i,b) for(long long i=0; i<b; ++i)
#define REP0(i,b) for(long long i=0; i<=b; ++i)
#include<cmath>
#include <iomanip>
using namespace std;


typedef long long ll;

int MODE = 1e9+7;

int main()
{

    int n;
    cin>>n;
    ll dp[n][n];
    memset(dp, -1, sizeof(dp));
    ll arr[n];
    rep0(i, n)
    {
        cin>>arr[i];
    }
    ll prefix[n+1];
    prefix[0] = 0;
    rep0(i, n+1)
    {
        prefix[i] = prefix[i-1] + arr[i];
    }
    for(int i=0; i<n; ++i)
    {
        dp[i][i] = 0;
    }

    for(int i=n-2; i>=0; --i)
    {

        for(int j=i+1; j<n; ++j)
        {
            dp[i][j] = 1e18+5;
            ll s =  prefix[j] - prefix[i-1];           
            for(int k = i; k<j; ++k)
            {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + s);
            }
        }
    }

    cout<<dp[0][n-1]<<endl;



    return 0;

}


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

using namespace std;

int main() {
    string s;
    bool f = false;
    cin >> s;
    if (s.front() != 'A') {
        cout << "WA" << endl;
        return 0;
    }
    if (s.at(1) < 'a' || s.at(1) > 'z') {
        cout << "WA" << endl;
        return 0;
    }
    for (int i = 2; i < s.size() - 1; ++i) {
        if (s.at(i) >= 'a' && s.at(i) <= 'z') continue;
        if (s.at(i) == 'C') {
            if (f) {
                cout << "WA" << endl;
                return 0;
            }
            else f = true;
        } else {
            cout << "WA" << endl;
            return 0;
        }
    }
    if (s.back() < 'a' || s.back() > 'z') {
        cout << "WA" << endl;
        return 0;
    }
    cout << (f ? "AC" : "WA") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i=0; i<N; i++) cin >> A[i];
  map<ll, int> dict; // 登場する数字と登場回数
  for (int i=0; i<N; i++) {
    if (dict.count(A[i])) dict[A[i]]++;
    else dict[A[i]] = 1;
  }
  vector<ll> can;
  for (auto p: dict) {
    auto key = p.first;
    auto value = p.second;
    if (value>=2) can.push_back(key);
  }
  if (can.size()==0) cout << 0 << endl;
  else if (can.size()==1) {
    if (dict[can[0]]>=4) cout << can[0]*can[0] << endl;
    else cout << 0 << endl;
  }
  else {
    reverse(can.begin(), can.end());
    if (dict[can[0]]>=4) cout << can[0]*can[0] << endl;
    else cout << can[0]*can[1] << endl;
  }
  return 0;
}

Measured memory_bytes: 10156
import java.util.Scanner;

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

		String c = s.next();
		int max = c.length();

		for (int i=1; i < c.length(); i++) {
      if (c.charAt(i) != c.charAt(i-1)) {
        max = Math.min(max, Math.max(i ,c.length()-i));
      }
    }

		System.out.println(max);
	}
}


Measured memory_bytes: 26108
/**akshaykumar99**/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
template<typename T> using id_setp = tree<pair<T,T>,null_type,less<pair<T,T>>,rb_tree_tag,tree_order_statistics_node_update> ;

#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+1;
 
typedef long long ll;
typedef long double ld;
 
int main()
{
    IOS();
   
   	int n,i,ans=0;
   	string s;
   	cin>>s;
   	n=s.length();
   	f(i,0,n/2)
   	{
   		if(s[i]!=s[n-1-i])
   			ans++;

   	}
   	cout<<ans<<'\n';

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#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>

using namespace std;
static const double EPS = 1e-8;
typedef long long ll;


const int MAX = 501;
bool edge[MAX][MAX];
bool flow[MAX][MAX];

int N, E, Q;

bool used[500];
bool _dfs(int s, int t)
{
	if (s == t)
		return true;

	used[s] = true;
	for (int i = 1; i <= N; ++i)
	{
		if (!used[i] && edge[s][i])
		{
			if (!flow[s][i])
			{
				if (_dfs(i, t))
				{
					if (flow[i][s])
						flow[i][s] = false;
					else
						flow[s][i] = true;
					//flow[s][i] = true;
					return true;
				}
			}
			else if (flow[i][s])
			{
				if (_dfs(i, t))
				{
					flow[i][s] = false;
					return true;
				}
			}
		}
	}
	return false;
}
bool dfs(int s, int t)
{
	fill(used, used+N+1, false);
	return _dfs(s, t);
}
void p()
{
	for (int i = 1; i <= N; ++i)
	{
		printf("%2d: ", i);
		for (int j = 1; j <= N; ++j)
			if (flow[i][j])
				printf("f%2d ", j);
			else if (edge[i][j])
				printf("e%2d ", j);
		printf("\n");
	}
}
int main()
{
	scanf("%d%d%d", &N, &E, &Q);
	for (int i = 0; i < E; ++i)
	{
		int f, t;
		scanf("%d%d", &f, &t);
		edge[f][t] = edge[t][f] = true;
	}

	int res = 0;
	while (dfs(1, N))
		++res;

	for (int i = 0; i < Q; ++i)
	{
		int	m, a, b;
		scanf("%d%d%d", &m, &a, &b);

		if (m == 1)
		{
			edge[a][b] = edge[b][a] = true;
			if (dfs(1, N))
				++res;
		}
		else
		{
			edge[a][b] = edge[b][a] = false;

			if (flow[a][b] && !dfs(a, b))
			{
				dfs(a, 1);
				dfs(N, b);
				--res;
			}
			if (flow[b][a] && !dfs(b, a))
			{
				dfs(b, 1);
				dfs(N, a);
				--res;
			}
			flow[a][b] = flow[b][a] = false;
		}

		printf("%d\n", res);
	}
	return 0;
}

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

int main(){
  int K, A, B;
  cin >> K >> A >> B;

  if(B/K-A/K >= 1){
    cout << "OK" << endl;
  }
  else{
    if(A%K==0 || B%K==0){
      cout << "OK" << endl;
    }
    else{
      cout << "NG" << endl;
    }
  }
}

Measured memory_bytes: 3588
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


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


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


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    D = LIST()
    if D[0] > 0 or D.count(0) > 1:
        print(0)
        exit()

    D.sort()
    ct = [1] * (max(D)+1)
    for i in range(N):
        if D[i] - D[i-1] > 1:
            print(0)
            exit()
        elif D[i] - D[i-1] == 0:
            ct[D[i]] += 1
    ans = 1
    for i in range(1, max(D)+1):
        ans *= pow(ct[i-1], ct[i], 998244353)
        ans %= 998244353

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 16264
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>
 
#define MOD 1000000007
#define INF 2147483647
#define NINF (-2147483647-1)
#define LLINF 9223372036854775807
using ll = long long;
using namespace std; 
 
int main() {
    string S;
    cin >> S;
    if (S.length() == 2) {
        cout << S << endl;
    }
    else {
        cout << S[2] << S[1] << S[0] << endl;
    }
    getchar(); getchar();
    return 0;
}

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

#define int long long int

struct item{
    int weight;
    int val;
};

void max_self(int &a, int b){
    a=max(a,b);
}

int32_t main(){

    int n;cin>>n;
    int W;cin>>W;
    item a[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i].weight>>a[i].val; 
    }

    vector<vector<int>> dp(n+1, vector<int> (W+1));
    dp[1][a[1].weight]=a[1].val;

    for(int i=2;i<=n;i++){
        for(int j=0;j<=W;j++){
            dp[i][j]=dp[i-1][j];
            if(j>=a[i].weight){
                max_self(dp[i][j], dp[i-1][j-a[i].weight]+a[i].val);
            }
        }
    }
	cout<<*max_element(dp[n].begin()+1, dp[n].end())<<endl;

return 0;
}


Measured memory_bytes: 83232
s = $stdin.gets.chomp.split("").map(&:to_i)
a = 0
b = 0

s.size.times do |i|
  if i % 2 == 0
    if s[i] == 0
      a += 1
    else
      b += 1
    end
  else
    if s[i] == 1
      a += 1
    else
      b += 1
    end
  end
end

puts [a,b].min

Measured memory_bytes: 7676
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[10],b[10];
	for(int i=0;i<10;i++){
		cin>>a[i];
	}
	for(int i=0;i<10;i++){
		cin>>b[i];
	}
	sort(a,a+10);
	sort(b,b+10);
	cout<<a[7]+a[8]+a[9]<<" "<<b[7]+b[8]+b[9]<<endl;
	return 0;
}	


Measured memory_bytes: 3100
import sys
input = sys.stdin.readline
N = int(input())
mx = 1
a = []
for _ in range(N): a.append(int(input()))
res = a[0] - 1
a[0] = 1
for i in range(1, N):
  ok = mx + 1
  ng = a[i]
  ch = (a[i] - 1) // (mx + 1)
  while ng - ok > 1:
    m = (ok + ng) // 2
    if (a[i] - 1) // m == ch:
      ok = m
    else: ng = m
  res += (a[i] - 1) // ok
  if (a[i] - 1) // ok: a[i] = 1
  mx = max(mx, a[i])
  #print(res, mx, a)
print(res)

Measured memory_bytes: 44892
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
if a[0]>x:
    print(0)
    exit()
cnt=1
for i in range(1,n):
    a[i]+=a[i-1]
    if a[i]>x:
        break
    cnt+=1
if cnt==n and a[-1]!=x:
    cnt-=1
print(cnt)

Measured memory_bytes: 3064
def main():
    a, b, m = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    ans = min(A) + min(B)
    for _ in range(m):
        x, y, c = map(int, input().split())
        ans = min(ans, A[x - 1] + B[y - 1] - c)
    print(ans)

if __name__ == '__main__':
    main()

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

int main(){
	int k;
	int a[5];
	for(int i=0;i<5;i++) cin>>a[i];
	cin>>k;
	for(int i=0;i<5;i++){
		for(int j=0;j<5;j++){
			if(i==j) continue;
			if(abs(a[i]-a[j])>k){
				cout<<":(";
				return 0;
			}
		}
	}
	cout<<"Yay!";
}

Measured memory_bytes: 256
S=[]
T=[]
n=int(input())
s=input().split()
for i in range(n):
	S.append(s[i])
q=int(input())
t=input().split()
for j in range(q):
	T.append(t[j])
cnt=0
for i in range(q):
	for j in range(n):
		if T[i]==S[j]:
			cnt+=1
			break
print(cnt)


Measured memory_bytes: 6328
main = do
  [_,t] <- map read . words <$> getLine :: IO [Int]
  ts <- map read . words <$> getLine :: IO [Int] 
  print $ solve ts t

solve :: [Int] -> Int -> Int
solve [_] t = t
solve (x:y:xs) t = min t (y-x) + solve (y:xs) t

Measured memory_bytes: 72060
#include<stdio.h>
#include<string.h>
int main()
{
    int i,x,y;
   
    int n;
    char a[10011];
    scanf("%d",&n);
    getchar();
    scanf("%s",a);
    x=strlen(a);
    for(i=0;i<x;i++)
    {
        if(a[i]+n>'Z')
        y=64+a[i]+n-'Z';
        else
        y=a[i]+n;
        printf("%c", y);
    }
    
}

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

int main(){
	ll n,a,b,c,d,e;cin>>n>>a>>b>>c>>d>>e;
	ll f=min({a,b,c,d,e});
	cout<<(n+f-1)/f+4<<endl;
}

Measured memory_bytes: 3620
#include <stdio.h>

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

	int fifty = 0, ten = 0, five = 0, n = 0;
	while (1) {
		five++;

		if (five > c) {
			five = 0;
			ten++;
		}

		if (ten > b) {
			ten = 0;
			fifty++;
		}

		if (fifty > a) {
			break;
		}

		if (fifty * 500 + ten * 100 + five * 50 == x && fifty <= a && ten <= b && five <= c) {
			n++;
		}
	}

	printf("%d\n", n);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second


signed main(){
  string s;
  cin>>s;
  if(s=="Sunny")cout<<"Cloudy"<<endl;
  if(s=="Cloudy")cout<<"Rainy"<<endl;
  if(s=="Rainy")cout<<"Sunny"<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#define mod 1000000007
#define ll long long int
#define inf (ll)1e15
#define shazam cin.tie(NULL);cout.tie(NULL);ios_base::sync_with_stdio(false)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define deb(x) cout<<#x<<" "<<x<<endl
#include <bits/stdc++.h>
using namespace std;
ll n,m;
vector<int> adj[100001];
ll dp[100001],ans[100001];
ll bpow(ll a,ll b)
{
	if(b==0)
	return 1;
	ll val=bpow(a,b/2);
	val=(val*val)%m;
	if(b&1)
	return (val*a)%m;
	return val;
}
void dfs(int u,int vis[])
{
	vis[u]=1;
	ll loc=1;
	for(int i=0;i<adj[u].size();i++)
	{
		if(!vis[adj[u][i]])
		{
			dfs(adj[u][i],vis);
			ll val=1+dp[adj[u][i]];
			loc=(loc*val)%m;
		}
	}
	dp[u]=loc;
}
void dfs1(int u,int vis[],ll val)
{
	vis[u]=1;
	ans[u]=(dp[u]+dp[u]*val)%m;
	ll loc1;
	vector<int> v1;v1.clear();
	for(int i=0;i<adj[u].size();i++)
	{
	    if(vis[adj[u][i]])
	    continue;
	    v1.pb(adj[u][i]);
	}
	ll pre[v1.size()],suf[v1.size()];
	for(int i=0;i<v1.size();i++)
	{
	    if(i==0)
	    pre[i]=1+dp[v1[i]];
	    else
	    pre[i]=(pre[i-1]*(1+dp[v1[i]]))%m;
	}
	for(int i=v1.size()-1;i>=0;i--)
	{
	    if(i==v1.size()-1)
	    suf[i]=1+dp[v1[i]];
	    else
	    suf[i]=(suf[i+1]*(1+dp[v1[i]]))%m;
	}
	for(int i=0;i<v1.size();i++)
	{
		if(i==0)
		{
		    if(v1.size()==1)
		    loc1=1;
		    else
		    loc1=suf[i+1];
		}
		else if(i==v1.size()-1)
		{
		    loc1=pre[i-1];
		}
		else
		{
		    loc1=(pre[i-1]*suf[i+1])%m;
		}
		loc1=(loc1*(1+val))%m;
		dfs1(v1[i],vis,loc1);
	}
}
int main()
{
	shazam;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	adj[i].clear();
	memset(ans,0,sizeof(ans));
	ll u,v;
	for(int i=0;i<n-1;i++)
	{
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	int vis[n+1];
	memset(vis,0,sizeof(vis));
	dfs(1,vis);
	memset(vis,0,sizeof(vis));
	dfs1(1,vis,0);
	for(int i=1;i<=n;i++)
	cout<<ans[i]<<endl;
}

Measured memory_bytes: 20096
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<cstring>
#include<string>
using namespace std;
char a[105];
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%s",a);
	int len=strlen(a),k1=0,k2=0;
	for(int i=0;i<len;i++){
		if(a[i]=='C')k1=1;
		if(k1&&a[i]=='F')k2=1;
	}
	if(k1&&k2)printf("Yes\n");
		else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define s(x) scanf("%d",&x)
#define rep(i,x) for(int i=0;i<x;i++)
int x[5005],y[5005];
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x[i]);
	}
	for(int j=1;j<=m;j++)
	{
		scanf("%d",&y[j]);
	}
	int ret=0;
	for(int j=1;j<=m;j++)
	{
		if(m-j+1<=ret) break;
		int cur=j;
		for(int i=1;i<=n;i++)
		{
			if(cur<=m && x[i]==y[cur])
			{
				cur++;
			}
		}
		ret=max(ret,cur-j);
	}
	printf("%d\n",ret);
}

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

int main() {
  string s;
  cin>>s;
  int y=0,m=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
      y++;
      m=max(m,y);
    }
    else  y=0;
  }
  cout<<m<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define rep(i, n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
  int N;
  cin >> N;
  int A[200000];
  rep(i, N) cin >> A[i];
  
  sort(A, A + N, greater<int>());
  long long ans = 0;
  for (int i = 1; i < N; i++) {
    ans += A[i/2];
  }
  cout << ans;
}

Measured memory_bytes: 4388
def main():
    k = int(input())
    num = 1
    n = 7

    if (k % 2 == 0):
        print(-1)
        return
    
    for i in range(1000000):
        if (n % k == 0):
            print(num)
            return
        else:
            n = (n*10 + 7) %k
            num += 1
    print(-1)

if __name__ == '__main__':
    main() 

Measured memory_bytes: 9088
//  Created by conan1024hao in 2020.
//  Copyright © 2020 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e17
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------
ll minrout=INF;ll s,t;ll rout=0;V<ll>a[1000001];ll tmp1,tmp2;

ll solve(){
    ll d[100001][3];
    memset(d,-1,sizeof(d));
    d[s][0]=0;
    queue<Pll>q;
    q.push({s,0});
    while(!q.empty()){
        Pll now=q.front();q.pop();
        for(ll i=0;i<a[now.fi].size();i++){
            ll p=(now.se+1)%3;
            if(d[a[now.fi][i]][p]==-1){
                d[a[now.fi][i]][p]=d[now.fi][now.se]+1;
                q.push({a[now.fi][i],p});
            }
        }
    }
    if(d[t][0]==-1)return -1;
    else return d[t][0]/3;
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????统一类型        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n,m;cin>>n>>m;
    
    for(ll i=0;i<m;i++){
        ll u,v;cin>>u>>v;u--;v--;
        a[u].pb(v);
    }
    cin>>s>>t;s--;t--;
    cout<<solve();
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------







Measured memory_bytes: 29312
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
#ifdef JOSHUA
    freopen("E:\\src\\clion-workspace\\oj\\data.in","r",stdin);
    freopen("E:\\src\\clion-workspace\\oj\\data.out","w",stdout);
#endif
    char ch;
    int i = 0, j = 0;
    while (cin >> ch) {
        ++i;
        if (ch == 'p') {
            ++j;
        }
    }
    i = i - j - (i + 1) / 2;
    i = i > 0 ? i : 0;
    cout << i << endl;
    return 0;
}

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

int main(){
	double r;
	const double PI = 3.141592653589;
	//scanf ("%lf",&r);
	cin >> r;
	//cout << int(a/b) << " " << (a % b) << " " << fixed << (double)a / (double)b << endl;
	printf("%lf %lf\n",r * r * PI, r* 2* PI);
	return 0;
}

Measured memory_bytes: 1236
#include<stdio.h>

int main(void)
{
    int N, D, X;
    int eat;
    int a;

    scanf("%d%d%d", &N, &D, &X);

    for (int i = 0; N > i; i++) {
        scanf("%d", &a);
        for (int j = 1; D >= j; j += a) {
            eat++;
        }
    }
    printf("%d\n", X + eat);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>

using namespace std;

int main()
{
	int n, k, s;

	cin >> n >> k >> s;

	int i = 0;

	if (s >= 1000000000)
	{
		s--;
		k = n - k;
	}

	while (i < n - k)
	{
		cout << s+1 << " ";
		++i;
	}

	while (i < n)
	{
		cout << s << " ";
		++i;
	}
	cout << endl;

	cin >> n;

	return  0;
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <vector>

using namespace std;

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

int main(void)
{
  int N,tmp,max;

  scanf("%d",&N);
  vector<int> B(N);
  rep(i,N-1) scanf("%d",&B[i]);
  
  vector<int> A(N);
  rep(i,N){
    if(i==0) A[i] = B[i];
    else if(i==N-1) A[i] = B[i-1];
    else{
      if(B[i-1]<B[i]) A[i] = B[i-1];
      else A[i] = B[i];
    }
  }
  
  max = 0;
  rep(i,N) max += A[i];

  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 256
def prime_factorize(n):
  a = []
  while n % 2 == 0:
    a.append(2)
    n //= 2
  f = 3
  while f * f <= n:
    if n % f == 0:
      a.append(f)
      n //= f
    else:
      f += 2
  if n != 1:
      a.append(n)
  return a

n=int(input())

x=[0]*1000
for i in range(2,n+1):
  p=prime_factorize(i)
  for _ in p:
    x[_]+=1

ans=1
for _ in x:
  if _ > 0:
    ans=(ans*(_+1))%(10**9+7)

print(ans)





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

int a[200010];
int ans[200010];

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


Measured memory_bytes: 5348
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
long long C[10][10] = {};
int main(){
    int N,K,S;
    cin >> N >> K >> S;
    if(S == 1000000000){
        rep(i,K) cout << S << " ";
        rep(i,N-K) cout << 1 << " ";
        cout << endl;
    }else{
        rep(i,K) cout << S << " ";
        rep(i,N-K) cout << S+1 << " ";
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
n,i=1;main(r){
for(scanf("%d",&n),r=n;i*i<=n;)if(n%++i==0)for(r=1.*r*(i-1)/i;n%i==0;n/=i);
if(--n)r=1.*r*n/++n;
n=!printf("%d\n",r);
}

Measured memory_bytes: 592