akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
  int a, b, c, rep;
  scanf("%d %d %d", &a, &b, &c);
  if(b > c){
    rep = c;
    c = b;
    b = rep;
  }
  if(a > b){
    rep = b;
    b = a;
    a = rep;
  }
  if(b > c){
    rep = c;
    c = b;
    b = rep;
  }

  printf("%d %d %d\n", a, b, c);
  return 0;
}



Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int N;
//エラトステネスの篩
bool is_prime[ 100000 + 1 ];
vector<int> P;
void Eratosthenes( const int N )
{
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;//初期化
    }    
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
}

int vector_finder(vector<int> vec, int number) {
  auto itr = find(vec.begin(), vec.end(), number);
  size_t index = distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main()
{
    N=100000;
    
    Eratosthenes( N );
    int a[N+1];
    a[0]=0;
    for(int i=1;i<N+1;i++){
      a[i]=a[i-1];
      if(vector_finder(P, i)){
        if(vector_finder(P, (i+1)/2)) a[i]++;
      }
    }
  int Q;
  cin >> Q;
  for(int i=0;i<Q;i++){
    int l,r;
    cin >> l >> r;
    cout << a[r]-a[l-1] << endl;
  }
}



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

typedef long long ll;

int main() {
    set<int> a,b;
    int n, m;
    cin >> n;
    for(int i=0; i<n; i++){
        int x;
        cin >> x;
        a.insert(x);
    }
    cin >> m;
    for(int i=0; i<m; i++){
        int x;
        cin >> x;
        b.insert(x);
    }
    
    vector<int> c;
    set_difference(a.begin(), a.end(), b.begin(), b.end(), back_inserter(c));
    
    for(int i=0; i<c.size(); i++){
        cout << c[i] << endl;
    }
    
}



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

#define REP(i,a,b) for(i=a; i<b; ++i)
#define rep(i,n) REP(i,0,n)

string mp[20];
char tank[4] = {'<', '^', '>', 'v'};
int dx[4] = { -1, 0, 1, 0 };
int dy[4] = { 0, -1, 0, +1 };
int w,h;

pair<int,pair<int,int> > getpos() {
    int i,j,k;
    rep(i,h) rep(j,mp[i].length()) rep(k,4)
        if(mp[i][j] == tank[k]) return make_pair(k,make_pair(i,j));
}

void solve(string com) {
    for(int i=0; i<com.length(); ++i) {
        int dir = getpos().first;
        int x = getpos().second.first;
        int y = getpos().second.second;

        if(com[i] == 'S') {
            while((x < h) && (x >= 0) && (y < w) && (y >= 0)) {
                if(mp[x][y] == '*') {
                    mp[x][y] = '.';
                    break;
                }else if(mp[x][y] == '#') {
                    break;
                }
                      x += dy[dir];
                      y += dx[dir];
            }
        }else if(com[i] == 'U') {
            if(x-1 < 0 || mp[x-1][y] != '.') mp[x][y] = '^';
            else {
                mp[x-1][y] = '^';
                mp[x][y] = '.';
            }
        }else if(com[i] == 'R') {
            if(y+1 >= w || mp[x][y+1] != '.') mp[x][y] = '>';
            else {
                mp[x][y+1] = '>';
                mp[x][y] = '.';
            }
        }else if(com[i] == 'D') {
            if(x+1 >= h || mp[x+1][y] != '.') mp[x][y] = 'v';
            else {
                mp[x+1][y] = 'v';
                mp[x][y] = '.';
            }
        }else if(com[i] == 'L') {
            if(y-1 < 0 || mp[x][y-1] != '.') mp[x][y] = '<';
            else {
                mp[x][y-1] = '<';
                mp[x][y] = '.';
            }
        }else assert(false);

    }
}

int main() {
    int t,n;
    string com;
    cin>>t;
    while(t--) {
        cin>>h>>w;
        for(int i=0; i<h; ++i) cin>>mp[i];
        cin>>n;
        cin>>com;

        solve(com);
        for(int i=0; i<h; ++i) cout<<mp[i]<<endl;
        if(t > 0) cout<<endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int,int>;
const int INF = 1e9+7;

int main() {
  int n; cin >> n;
  vec a(n); rep(i,n) cin >> a[i];
  sort(all(a), greater<int>());

  ll sum = 0;
  rep(i,n-1) {
    sum += a[(i+1)/2];
  }

  cout << sum << endl;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a,b,c,x,y; cin>>a>>b>>c>>x>>y;
	c*=2;
	int ans=0;
	ans=min(x,y)*(a+b);
	chmin(ans,min(x,y)*(c));
	if(x>y){
		int k=x-y;
		ans+=k*min(c,a);
	}
	else{
		int k=y-x;
		ans+=k*min(c,b);
	}
	cout<<ans<<endl;
	
	
	return 0;
}

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

#define NAME "rewind"
#define show(x) cout << (#x) << " is " << (x) << endl
#define ll long long
#define ms(arr,val) memset(arr,val,sizeof(arr))
#define len length()

const int maxn = 2e5;
double a[3000];
double dp[3000][3000];
int main(){
    //ifstream cin(NAME".inp");
    //ofstream cout(NAME".out");
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=i;j++) dp[i][j] = dp[i-1][j] * (1-a[i]) + dp[i-1][j-1]*a[i];
    }
    double ans =0;
    for(int i=n/2+1;i<=n;i++) ans+=dp[n][i];
    cout<<setprecision(12)<<fixed<<ans;
}


Measured memory_bytes: 49868
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long[] ary = new long[n];
        for (int i = 0; i < n; i++) {
            long a = Long.parseLong(sc.next());
            ary[i] = a;
        }
        boolean ans = true;
        for (int i = n - 1; i > 0; i--) {
            if (n == 1) {
                break;
            }
            if (ary[i - 1] > ary[i]) {
                ary[i - 1] = ary[i - 1] - 1;
            }
            if (ary[i - 1] > ary[i]) {
                break;
            }
        }
        for (int i = n - 1; i > 0; i--) {
            if (n == 1) {
                break;
            }
            if (ary[i - 1] > ary[i]) {
                ans = false;
                break;
            }
        }
        System.out.println(ans ? "Yes" : "No");
    }
}

Measured memory_bytes: 47896
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <stack>
#include <math.h>
#include <stdio.h>
#define ll long long
#define anf 0x3f3f3f3f
using namespace std;
//int main()
//{
//    int mi=0,a;
//    int mx=anf,b;
//    int t;
//    cin>>t;
//    while(t--)
//    {
//        scanf("%d %d",&a,&b);
//        mi=max(mi,a);
//        mx=min(mx,b);
//
//    }
//    cout<<mx-mi+1<<endl;
//    return 0;
//}
void swa(int a, int b, int c)
{
    if(a<b)
    swap(a,b);
    if(a<c)
    swap(a,c);
    if(b<c)
    swap(b,c);

}
int main()
{
    int a,b,c;
    while(cin>>a>>b>>c)
    {
        if(a<b)
        swap(a,b);
        if(a<c)
        swap(a,c);
        if(b<c)
        swap(b,c);

        int ans=0;
        ans+=a-b;
        c+=ans;
        if((a-c)%2==1)
            ans+=(a-c+1)/2+1;
        else
            ans+=(a-c)/2;
        cout<<ans<<endl;

    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int i,n;
  scanf("%d",&n);
  int S[10001];
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  int n2;
  int sum;
  int key;
  sum=0;
  scanf("%d",&n2);
  for(i=0;i<n2;i++){
    scanf("%d",&key);
    if(search(S,n,key))
      sum++;
  }
  printf("%d\n",sum);
	
  return 0;
}

int search(int S[],int n,int key){
  int j=0;
  S[n]=key;
  while(S[j]!=key)
    j++;
  return j!=n;
} 



Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll a,b;
	cin >> n >> a >> b;
	if(a > b){
		cout << "0\n";
		return 0;
	}
	if(n == 1){
		if(a != b){
			cout << "0\n";
		}else{
			cout << "1\n";
		}
		return 0;
	}
	ll mn = a*(n-1)+b;
	ll mx = b*(n-1)+a;
	cout << mx-mn+1 << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int rows,cols;
int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string temp;
    cin>>rows>>cols;
    for(int i=0;i<cols+2;++i)
    {
        cout<<'#';
    }
    cout <<endl;
    for(int i=0;i<rows;++i)
    {
        cout<<'#';
        cin>>temp;
        cout<<temp;
        cout<<'#'<<endl;
    }
    for(int i=0;i<cols+2;++i)
    {
        cout<<'#';
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const double PI  =3.141592653589793238463;
long long mod = 1000000007;
int stringToInteger(string x){
    int gg=0;
    stringstream geek(x);
    geek >> gg;
    return gg;
}

ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}

int main()
{
    int p,q,r;
    cin>>p>>q>>r;
    int ans = p+q;
    ans=min(ans,q+p);
    ans=min(ans,p+r);
    ans=min(ans,r+p);
    ans=min(ans,q+r);
    ans=min(ans,r+q);
    cout<<ans;
    
    
}








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

int main()
{
	int a, b;
	cin >> a >> b;
	int height = 0;
	for (int i = 1; i < b - a; i++)
		height += i;
	cout << height - a << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())

li = [[] for i in range(n)]
memo = [0 for i in range(m)]

def search(p,y):
    fst = 0
    lst = len(li[p])-1

    while(fst <= lst):
        mid = (fst+lst)//2
        if li[p][mid] == y:
            return mid

        elif li[p][mid] < y:
            fst = mid+1
        
        elif li[p][mid] > y:
            lst = mid-1


for i in range(m):
    p,y=map(int,input().split())
    p-=1
    memo[i] = [p,y]
    li[p].append(y)

for i in range(n):
    li[i].sort()

for i in range(m):
    a = memo[i][0]+1
    b = search(memo[i][0],memo[i][1])
    print("{:0>6}".format(a),end ="")
    print("{:0>6}".format(b+1))





Measured memory_bytes: 32840
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	// your code goes here
	string s,t;
	cin>>s;
	cin>>t;
	ll cnt = 0;
	ll len = s.length();
	for(ll i=0;i<len;i++){
	    if(s[i]!=t[i]) cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3836
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main(void){

  int n;    cin >> n;
  vector<int> p (n);
  for(int i = 0 ; i < n ; i++)    cin >> p[i];

  int ans = 0;
  for(int i = 1 ; i < n - 1 ; i++){
    if( (p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i + 1] < p[i] && p[i] < p[i - 1]) )
    ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>                                                                                       
                                                                                                         
int main(){                                                                                              
    char s[3], t[3];                                                                                     
    scanf("%s %s", s, t);                                                                                
    int ans = 0;                                                                                         
    for(int i = 0; i < 3; i++){                                                                          
        if(s[i] == t[i]){                                                                                
            ans++;                                                                                       
        }                                                                                                
    }                                                                                                    
    printf("%d\n", ans);                                                                                 
    return 0;                                                                                            
}                  

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
int n,m;
vector<PII> USkills[101];
vector<PII> DSkills[101];
bool used[101];

bool check(int idx, vector<PII>& current){
  vector<PII> cc(n,{0,1e9});
  for(PII p : USkills[idx]){
    int s = p.first;
    cc[s].first = max(cc[s].first,p.second);
  }

  for(PII p : DSkills[idx]){
    int s = p.first;
    cc[s].second = min(p.second,cc[s].second);
    if(cc[s].second < cc[s].first) return false;
  }

  used[idx] = true;
  bool pass = true;
  // cout << "cc" << endl;
  // rep(i,m){
  //   cout << cc[i].first << " " << cc[i].second << endl;
  // }
  // cout << "cc end------------" << endl;

  rep(i,m){
    if(used[i] == true) continue;
    // for(PII p : USkills[i]){
    //   int s = p.first;
    //   // cout << cc[s].first << " <= " << p.second << " <= " <<  cc[s].second << endl;
    //   if(cc[s].first <= p.second) continue;
    //   else{
    //     pass = false;
    //     break;
    //   }
    // }

    for(PII p : DSkills[i]){
      int s = p.first;
      if(p.second >= cc[s].first) continue;
      else{
        pass = false;
        break;
      }
    }

    if(pass == false) break;
  }

  if(pass == false) {
    used[idx] = false;
    return false;
  }

  current = cc;
  return true;
}

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

  cin >> m >> n;

  rep(i,m){
    int k;
    cin >> k;
    int s,t;
    string cmd;

    rep(j,k){
      cin >> s >> cmd >> t;
      s--;
      if(cmd == "<="){
        DSkills[i].push_back({s,t});
      }else if(cmd == ">="){
        USkills[i].push_back({s,t});
      }
    }
  }

  int okCnt = 0;
  vector<PII> current(n,{0,1e9});
  while(okCnt < m){
    bool flag = false;
    rep(i,m){
      if(used[i] == false && check(i,current)){
        // cout << "used " << i << endl;
        flag = true;
        break;
      }
    }
    if(flag == false) {
      cout << "No" << "\n";
      return 0;
    }
    okCnt++;
  }

  cout << "Yes" << "\n";
  return 0;
}



Measured memory_bytes: 3332
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  string n;
  cin>>n;
  int f=0;
  for (int i = 0; i < n.size(); ++i)
  {
    f+=n[i]-'0';
  }
  cout<<(stoi(n)%f==0?"Yes":"No");
}

Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d %d",$L,$R);
if($R-$L>=2019){
  //$R-$Lが2019以上なら間に2019の倍数を含むので最小剰余は必ず0
  $result = 0;
}elseif($R*($R-1)<2019){
  //$L*$Rが2019以上でない場合、最小剰余は$L*($L+1)
  $result = $L*($L+1);
}else{
  //1組目を初期値にする
  $result = (($L%2019)*(($L+1)%2019))%2019;
  //総当り
  for($i=$L;$i<=$R-1;$i++){
    if($result === 0){
      break;
    }
    for($j=$i+1;$j<=$R;$j++){
      if($result === 0){
        break;
      }
      //最小値更新
      if($result > (($i%2019)*($j%2019))%2019){
        $result = (($i%2019)*($j%2019))%2019;
      }
    }
  }
}
echo $result;


Measured memory_bytes: 3828
#include <stdio.h>

int main()
{
	int a[200],b[200],c[200],i=0,j,k;
	
	while(scanf("%d %d",&a[i],&b[i])!=EOF)
	{
			c[i] = a[i] + b[i];
			i++;
			if(i==200) break;
	}
	
	
	for(j=0; j<i; j++)
	{
		for(k=0; c[j]>=1; k++)	c[j]/=10;
		printf("%d\n",k);
	}
	
	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner

import scala.io.StdIn._
object Main extends App {

  val s = scala.io.StdIn.readLine()
  val t = scala.io.StdIn.readLine()

  def solve() = {
    if(s + t.last == t) "Yes" else "No"
  }

  println(solve())

}



Measured memory_bytes: 54724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string.h>
#include <cmath>
#include <set>
#include<list>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e9
#define pii pair<int, int>
typedef long long ll;
using namespace std;

int main() {
    int w, h, n;
    cin >> w >> h >> n;
    set<pii> xlist;
    set<pii> ylist;

    rep(i, n){
        int t, s;
        cin >> t >> s;
        xlist.insert(pii(t, s));
        ylist.insert(pii(s, t));
    }

    int x, y;
    x = 0;
    y = 0;
    int ans = 0;
    while(true){
        auto xp = xlist.begin();
        while((*xp).first == x){
            ylist.erase(pii((*xp).second, x));
            xp = xlist.erase(xp);
            if(xlist.empty()){
                break;
            }
        }

        if(ylist.empty()){
            break;
        }

        auto yp = ylist.begin();
        while((*yp).first == y){
            xlist.erase(pii((*yp).second, y));
            yp = ylist.erase(yp);
            if(ylist.empty()){
                break;
            }
        }

        if(xlist.empty()){
            break;
        }else{
            ++ans;

            if((*xlist.rbegin()).first - x > (*ylist.rbegin()).first - y){
                ++y;
            }else{
                ++x;
            }
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 12512
a,b,c,x,y=map(int,input().split())
price=0
if a+b>=c*2:
    min_point=min(x,y)
    price +=min_point*c*2
    x -=min_point
    y -=min_point
    if x>y:
        if a>=c*2:price +=c*2*x
        else:price +=a*x
    elif y>x:
        if b>=c*2:price +=c*2*y
        else:price +=b*y
    print(price)
else:
    print(a*x+b*y)


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

void swap(int *, int *);

int main(void) 
{
  int i, j, N, operation = 0;
  int *sequence;

  scanf("%d", &N);

  sequence = (int *) malloc(sizeof(int) * N);

  for (i = 0; i < N; i++) 
    scanf(" %d", &sequence[i]);

  for (i = 0; i < N; i++) {
    for (j = N - 1; j > i; j--) {
      if (sequence[j] < sequence[j - 1]) {
	swap(&sequence[j], &sequence[j - 1]);
	operation++;
      }
    }
  }

  for (i = 0; i < N - 1; i++) 
    printf("%d ", sequence[i]);

  printf("%d\n", sequence[N - 1]);
  printf("%d\n", operation);

  return 0;
}

void 
swap(int *x, int *y) {

  int tmp;

  tmp = *x;
  *x  = *y;
  *y  = tmp;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

#define mp make_pair
#define pb push_back
#define ppb pop_back

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;
typedef vector<vl> vvl;

ll doOp(string op);

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fors(i, n, s) for (int i = 0; i < (int)(n); i += s)
#define forn1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forn11(i, n) for (int i = 1; i < (int)(n); ++i)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

#define prOk(ok) cout << ((ok) ? "Yes" : "No")
#define in insert
#define rem remove

int main()
{

	string s;
	cin >> s;

	ll n = s.length();//stoll(s);

	ll sum = 0;

	ll tot = pow(2, n - 1);
	for(int i = 0; i < tot; i++)
	{
		string op(s);
		int pluses = 0;
		for(int j = 0; j < n-1; j++)
		{
			int bitj = (i & ( 1 << j )) >> j;

			if(bitj)
			{
				op.insert((size_t) j+1+pluses, "+");
				pluses++;
			}

		}
		sum += doOp(op);
	}

	cout << sum;

	return 0;
}

ll doOp(string op)
{
	ll p = op.find("+");

	ll sum = 0;
	while(p != op.npos)
	{
		sum += stoll(op.substr(0, p));
		op.erase(0, p+1);
		p = op.find("+");
	}

	sum += stoll(op.substr(0, p));
	return sum;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int SumDigit(int num){
  int sum=0;
  while(num>0){sum+=num%10;num/=10;}
  return sum;
}
int main(){
  int N;cin>>N;
  int a, b, tmp;
  int min=1e10;
  for(a=1;a<=N-1;a++){b=N-a;tmp = SumDigit(a)+SumDigit(b);if(min>tmp)min=tmp;}
  cout<<min<<endl;
}


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

const int MAXN = 410;
int n, m, xs[100010], ys[100010], ans;
std::bitset<MAXN> B[MAXN];
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> m;
	for (int i = 1; i <= m; ++i) std::cin >> xs[i] >> ys[i];
	for (int i = 1; i <= n; ++i) {
		B[i].set(i);
		for (int j = m; j; --j)
			if (B[i][xs[j]] && B[i][ys[j]]) B[i].set();
			else if (B[i][xs[j]]) B[i].set(ys[j]);
			else if (B[i][ys[j]]) B[i].set(xs[j]);
		B[i].reset(0);
	}
	for (int i = 1; i <= n; ++i)
		for (int j = i + 1; j <= n; ++j)
			ans += (B[i] & B[j]).none();
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main(){

int n; cin >> n;
int c0 = 0, c1 = 0, c2 = 0, c3 = 0;
for(int i = 0; i < n; i++){
string s; cin >> s;
  if(s == "AC"){c0++;}
  if(s == "WA"){c1++;}
  if(s == "TLE"){c2++;}
  if(s == "RE"){c3++;}
}
  
  cout << "AC x " << c0 <<endl;
  cout << "WA x " << c1 <<endl;
  cout << "TLE x " << c2 <<endl;
  cout << "RE x " << c3 <<endl;



return 0;}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include<utility>
#include<algorithm>

#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF 1e9+7
#define PI 3.141592653
#define inf 100007
#define P pair<ll,ll>

using namespace std;

int main(){
    int n;
    cin>>n;
    int c[n-1],f[n-1],s[n-1];
    pan(i,n-1) cin>>c[i]>>s[i]>>f[i];
    pan(i,n){
        int t=s[i]+c[i];
        pans(j,n-1,i+1){
            if(t==s[j]) t+=c[j]+f[j];
            else if(t>s[j] && ((t-s[j])%(f[j])!=0)){
                int fac=(t-s[j])/f[j];
                t=s[j]+c[j]+(fac+1)*f[j];
            }
            else if(t>s[j] && ((t-s[j])%(f[j])==0)){
                int fac=(t-s[j])/f[j];
                t+=c[j];
            }
            else if(t<s[j]) t=s[j]+c[j];
        }
        if(i==n-1) cout<<0;
        else cout<<t<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(998244353)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll n,m,ans;
VL a;

bool check(ll x){
	ll cnt=0LL;
	rep(i,n){
		ll pos=lower_bound(ALL(a), x-a[i])-a.begin();
		cnt+=n-pos;
	}
	return cnt<m;
}



signed main(){
	cin>>n>>m;
	a.resize(n); rep(i,n) cin>>a[i]; sort(ALL(a));

	ll ng=0, ok=LINF;
	while(abs(ok-ng)>1){
		ll mid=(ok+ng)/2;
		if(check(mid)) ok=mid;
		else ng=mid;
	}
	VL s(n+1,0LL); rep(i,n) s[i+1]=s[i]+a[i];
	rep(i,n){
		ll pos=upper_bound(ALL(a), ng-a[i])-a.begin();
		ll cnt=n-pos;
		ans+=cnt*a[i]+(s[n]-s[pos]);
		m-=cnt;
	}
	ans+=m*ng;
cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 4812
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
typedef long long ll;

using namespace std;

int main() {
    int k, x;
    cin >> k >> x;
    
    for(int i = 0; i < k; i++) {
        if(i == k - 1) {
            break;
        }
        cout << x - k + i + 1 << " ";
    }
    
    for(int i = 0; i < k; i++) {
        if(i == k - 1) {
            cout << x + i << endl;
        }
        else {
            cout << x + i << " ";
        }
    }
    
    return 0;
}



Measured memory_bytes: 256
//SAIKH SERAJ FAHIM, CSE-HSTU, DINAJPUR, BANGLADESH.

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,i;
    cin>>a;
    string s1;
    cin.ignore();
    cin>>s1;
    int len=s1.size();
    if(len<=a)cout<<s1<<"\n";
    else
    {
        char s2[101];
        for(i=0; i<a; i++)
        {
            s2[i]=s1[i];
        }
        s2[i]='\0';
        cout<<s2<<"..."<<"\n";
    }
    return 0;
}


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

using namespace std;

const int N = 1e2+7;

int n, res = 1;
string s;

int main()
{
    cin >> n >> s;
    for (int i = 1; i < n; ++i) {
        if (s[i] == s[i-1]) continue;
        else ++res;
    }
    cout << res << endl;
    return 0;
}


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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

// del

const i64 MAXN = 100;
const i64 m = 2019;

i64 l, r;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> l >> r;

    i64 R = ((l % m) * (r % m)) % m;

    set<i64> p;
    for (i64 i = l; i < r; i++) {
        i64 z = i % m;
        if (p.count(z)) {
            break;
        }
        p.insert(z);

        set<i64> q;
        for (i64 j = i + 1; j <= r; j++) {
            i64 e = j % m;
            if (q.count(e)) {
                break;
            }
            q.insert(e);

            i64 t = (z * e) % m;
            R = min(R, t);
        }
    }

    cout << R;


    return 0;
}


Measured memory_bytes: 512
n = int(input())


def factorization(n):
    retval = []
    tmp = n
    for i in range(2, int(-(-n**.5//1))+1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            retval.append([i, cnt])
    if tmp != 1:
        retval.append([tmp, 1])
    return retval


fact = factorization(n)
m = len(fact)
ans = 0
for i in range(1, 1000):
    for j in range(m):
        if i <= fact[j][1]:
            fact[j][1] -= i
            ans += 1
print(ans)

Measured memory_bytes: 9384
import itertools

N, M, r = map(int, input().split())
R = list(map(int, input().split()))
E = [[10 ** 20 if i != j else 0 for i in range(N)] for j in range(N)]
for _ in range(M):
    A, B, C = map(int, input().split())
    A -= 1
    B -= 1
    E[A][B] = C
    E[B][A] = C

for d in range(N):
    for v in range(N):
        for w in range(N):
            E[v][w] = min(E[v][w], E[w][v], E[v][d] + E[d][w])
            E[w][v] = E[v][w]

res = 10 ** 20
for case in itertools.permutations(R):
    tmp = 0
    c = list(case)
    for i in range(r - 1):
        tmp += E[c[i] - 1][c[i + 1] - 1]
    res = min(res, tmp)

print(res)

Measured memory_bytes: 55000
import java.util.Scanner;

 class Main {
  public static void main(String[] args){
	  Scanner s=new Scanner(System.in);
	  int a[]={s.nextInt(),s.nextInt(),s.nextInt(),s.nextInt(),s.nextInt(),s.nextInt()};
	  int q=s.nextInt();	
	  int qp[]=new int[2*q];
	  for(int i=0;i<2*q;i++){
		  qp[i]=s.nextInt();
	  }
	  s.close();
	  Dicelabel d=new Dicelabel(a[0],a[3],a[2],a[4],a[1],a[5]);
	  
	  for(int i=0;i<2*q;i++){
	  System.out.println(d.eNumberPrint(qp[i++],qp[i],d));
	  d.number=a[0];
  	  d.eroll=a[3];
  	  d.wroll=a[2];
  	  d.sroll=a[4];
  	  d.nroll=a[1];
  	  d.under=a[5];
	  }
  }
}
  class Dicelabel{
		int number;
	    int eroll;
	    int wroll;
	    int nroll;
	    int sroll;
	    int under;
	    Dicelabel(int number,int e,int w,int s,int n,int under){
	    	this.number=number;
	    	this.eroll=e;
	    	this.wroll=w;
	    	this.sroll=s;
	    	this.nroll=n;
	    	this.under=under;
	    }
		
		Dicelabel diceRoll(char direction){
			if(direction=='E'){
				return new Dicelabel(eroll,under,number,sroll,nroll,wroll);
			}
			if(direction=='W'){
				return new Dicelabel(wroll,number,under,sroll,nroll,eroll);
			}
			if(direction=='S'){
				return new Dicelabel(sroll,eroll,wroll,under,number,nroll);
			}
			if(direction=='N'){
				return new Dicelabel(nroll,eroll,wroll,number,under,sroll);
			}
			return null;
		}
		int eNumberPrint(int t,int b,Dicelabel d){
			//*??????eroll??§??????nroll?????????number?????????
			if(d.sroll==t)d=d.diceRoll('S');
			if(d.nroll==t)d=d.diceRoll('N');
		   for(int i=0;i<4;i++){
			   if(d.eroll==t)
				   break;
			   d=d.diceRoll('W');
		   }
		   
		   for(int i=0;i<4;i++){
			   if(d.nroll==b)
				   break;
			   d=d.diceRoll('S');
		   }
		   return d.number;
		   
		   
		}
  }

Measured memory_bytes: 26056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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;}

void solve(long long A, long long B){
    rep(i,10000){
        if(i*8/100==A&&i*10/100==B){
            cout<<i<<endl;
            return;
        }
    }
    cout<<-1<<endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
}


Measured memory_bytes: 256
#入力された値を各変数へ
a, b, c, d = map(int, input().split())
f1 = abs(c-a)
f2 = abs(b-a)
f3 = abs(b-c)
if f1 <= d or (f2 <= d and f3 <= d):
    print ("Yes")
else:
    print("No")

Measured memory_bytes: 2940
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 10000;/// 1e9 + 7;
const long long INF = 1e9;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int X;
	cin >> X;
	if (X >= 30)cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 3060
#include <stdio.h>

// 中間試験M,期末試験F,再試験Rが与えられ、以下の条件で成績判定
// 中間試験、期末試験のいずれかを欠席した場合成績は F。
// 中間試験と期末試験の合計点数が 80 以上ならば成績は A 。
// 中間試験と期末試験の合計点数が 65 以上 80 未満ならば成績は B。
// 中間試験と期末試験の合計点数が 50 以上 65 未満ならば成績は C。
// 中間試験と期末試験の合計点数が 30 以上 50 未満ならば成績は D。 
//		ただし、再試験の点数が 50 以上ならば成績は C。
// 中間試験と期末試験の合計点数が 30 未満ならば成績は F。
// すべて-1なら終了
int main()
{
	int iInputMid, iInputFinal, iInputRe;

	scanf("%d %d %d", &iInputMid, &iInputFinal, &iInputRe);
	while (iInputMid != -1 || iInputFinal != -1 || iInputRe != -1)
	{
		if ((iInputMid == -1 || iInputFinal == -1) || iInputMid + iInputFinal < 30)
		{
			printf("F\n");
		}
		else if (iInputMid + iInputFinal >= 80)
		{
			printf("A\n");
		}
		else if (iInputMid + iInputFinal >= 65)
		{
			printf("B\n");
		}
		else if (iInputMid + iInputFinal >= 50)
		{
			printf("C\n");
		}
		else if (iInputMid + iInputFinal >= 30)
		{
			if (iInputRe >= 50)
			{
				printf("C\n");
			}
			else
			{
				printf("D\n");
			}
		}
		else
		{
			printf("F\n");
		}

		scanf("%d %d %d", &iInputMid, &iInputFinal, &iInputRe);
	}

	return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N,d=1;
	cin >> N;
	rep(i, N) {
		ll a;
		cin >> a;
		if (a == d) {
			d++;
		}
	}
	if (d == 1) {
		cout << -1 << endl;
	}
	else {
		cout << N + 1 - d <<endl;
	}

	
}


Measured memory_bytes: 256
def MAP(): return list(map(int,input().split()))

n,A,B,C = MAP()
l = [int(input()) for _ in range(n)]
INF = 10**9

def dfs(cur,a,b,c):
    if cur == n:
        return abs(a-A) + abs(b-B) + abs(c-C) -30 if min(a,b,c)>0 else INF
    ret0 = dfs(cur+1,a,b,c)
    ret1 = dfs(cur+1,a+l[cur],b,c)+10
    ret2 = dfs(cur+1,a,b+l[cur],c)+10
    ret3 = dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))

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

int main() {
  int N;
  string S;
  int K;
  cin >> N >> S >> K;


  char k = S[K-1];
  for (int i = 0; i < N; i++) {
    if (k != S[i]) {
      S[i] = '*';
    }
  }
  cout << S << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::set<std::string> s;
    for (int i = 0; i < n; i++) {
        std::string t; std::cin >> t;
        s.insert(t);
    }
    std::cout << s.size() << std::endl;
    return 0;
}

Measured memory_bytes: 19224
#include <stdio.h>
int	main(void)
{
	int n,a,min,max,i;
	long sum;
	scanf("%d",&n);
	scanf("%d",&a);
	min=max=sum=a;
	for(i=1;i<n;i++){
		scanf("%d",&a);
		min=(a<min ? min=a : min);
		max=(a>max ? max=a : max);
		sum+=a;
	}
	printf("%d %d %ld\n",min,max,sum);
	return	0;
}

Measured memory_bytes: 600
package main

import (
    "fmt"
    "os"
    "bufio"
    "strconv"
    "sort"
)

var sc = bufio.NewScanner(os.Stdin)

var divide = [4]string{"dream", "dreamer", "erase", "eraser"}

func main() {
    //s := nextLine()
    var s string
    fmt.Scan(&s)

    s = strReverse(s)
    for i := 0; i < len(divide); i++ {
        divide[i] = strReverse(divide[i])
    }

    //fmt.Println(divide)

    i := 0
    f := true
    for i < len(s){
        f2 := false
        for _, str := range divide {
            if i+len(str)-1 < len(s) && s[i:i+len(str)] == str {
                i += len(str)
                f2 = true
                break
            }
        }
        if !f2 {
            f = false
            break
        }
    }

    if f {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }

}


func nextLine() string {
    sc.Scan()
    return sc.Text()
}

func nextInt() int {
    sc.Scan()
    i, _ := strconv.Atoi(sc.Text())
    return i
}

func storeIntArr(n int) []int {
    var a []int
    for i := 0; i < n; i++ {
        a = append(a, nextInt())
    }
    return a
}

// 数値を桁区切りのスライスにする
func digit(n int, list []int) []int {
   if n > 0 {
       return digit(n/10, append(list, n%10))
   }
   return list
}

func sortIntsRev(list []int) {
    sort.Sort(sort.Reverse(sort.IntSlice(list)))
}

func strReverse(s string) string {
    runes := []rune(s)
    for i := 0; i < len(s)/2; i++ {
        runes[i], runes[len(s)-1-i] = runes[len(s)-1-i], runes[i]
    }
    return string(runes)
}



Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    string s;
    int ans = 0;

    cin >> n;
    cin >> s;

    for (int i = 1; i < n; i++) {
        int kazu = 0;
        for (char c = 'a'; c <= 'z'; c++) {
            int left = 0;
            int right = 0;
            for (int j = 0; j < i; j++) {
                if (s[j] == c)
                    left = 1;
            }
            for (int k = i; k < n; k++) {
                if (s[k] == c)
                    right = 1;
            }
            if ((left == 1)&&(right == 1))
                kazu++;
        }
        if (kazu > ans)
            ans = kazu;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import itertools

n,m,q = map(int,input().split())
p = [list(map(int,input().split())) for i in range(q)]

Alist=itertools.combinations_with_replacement(range(1,m+1),n)

max_score = 0
for aa in Alist:
    a = list(aa)
    score = 0
    for l in range(q):
        if a[p[l][1]-1]-a[p[l][0]-1] == p[l][2]:
            score += p[l][3]
    max_score = max(max_score,score)
print(max_score)

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

int main(){
    string s;cin>>s;
    char c=s[0];
    int ans=0;
    for(int i=1;i<s.length();++i){
        if(s[i]!=c){
            ans++;
            c=s[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int A;
  int n; 
  cin >> N >> A;
  
  n = N % 500;
  
  if(n <= A){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  } 
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int X,Y,Z;
  scanf("%d%d%d",&X,&Y,&Z);
  int i,j=0;
  for (i=1;i<100000;i++){
    if((Y*i+Z*(i+1))>X){
      j=i-1;
      break;
    }
  }
  printf("%d",j);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

typedef long long ll;

//printf("%d", n);
//printf("%d", sum);
//scanf("%d", &n);
//scanf("%c", &c);
//scanf("%lf", &d);

#define NUM (10000)

int main(int argc, char** argv){
    int a, b, c;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);

    if(a + b + c >= 22){
        printf("bust\n");
    }else{
        printf("win\n");
    }


    return 0;
}




Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#define	Pi 3.14159265

void kock(int,double*,double*);

int main(){

  int n;

  scanf("%d",&n);

  double p1[2]={0,0};
  double p2[2]={100,0};

  printf("%.8f %.8f\n",p1[0],p1[1]);
  kock(n,p1,p2);
  printf("%.8f %.8f\n",p2[0],p2[1]);

  return 0;
}

void kock(int n,double *p1,double *p2){

  if(n==0)
    return;

  double co=cos(Pi/3);
  double si=sin(Pi/3);

  double s[2],t[2],u[2];
  s[0]=(2*p1[0]+p2[0])/3;
  s[1]=(2*p1[1]+p2[1])/3;
  t[0]=(p1[0]+2*p2[0])/3;
  t[1]=(p1[1]+2*p2[1])/3;
  u[0]=(t[0]-s[0])*co-(t[1]-s[1])*si+s[0];
  u[1]=(t[0]-s[0])*si+(t[1]-s[1])*co+s[1];

  kock(n-1,p1,s);
  printf("%.8f %.8f\n",s[0],s[1]);
  kock(n-1,s,u);
  printf("%.8f %.8f\n",u[0],u[1]);
  kock(n-1,u,t);
  printf("%.8f %.8f\n",t[0],t[1]);
  kock(n-1,t,p2);

  }

Measured memory_bytes: 640
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc117_a.cpp
 * time   : Fri May  1 14:34:42 2020
 * quest  : A - Entrance Examination
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t, x;
  cin >> t >> x;
  cout << float(t) / x << "\n";
  return 0;
}


Measured memory_bytes: 256
def main():
    X = int(input())
    for x in reversed(range(1, X + 1)):
        for a in range(1, int(x ** 0.5) + 1):
            for b in range(1, x):
                v = a ** b
                if v > x:
                    break
                if v == x:
                    return x
    return 1

print(main())



Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G ((c=A[a]+A[P[a]]+C[a])%k?c:0)+M(
typedef long long L;using namespace std;map<L,L>T U;L P U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;
L M(L f){return f?B[f]+M(f^f&-f):0;}L S(L i){for(c=G i++)-M(i);i<2e5;i+=i&-i)B[i]+=c;}
L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();
C[d-P[f]?P[d]=f,D(d),n=Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:d:0]=I++->second)d=I->first;}
L K(L f){return Z[a=X[f]]>Z[n=X[b]]?n=b,b=f,K(n):abs(M(O[f])-(a-n?-G O[a])-K(P[a]):M(O[b])));}
main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
for(D(0);Z[a=H[P[++n]]-n?n:0];)for(;!O[a];a=H[a],S(*Z=O[c]=++b))X[c=a]=n;
for(cin>>a;cin>>s>>a>>b;S(b=O[a]-1),a=H[a],S(b+1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}


Measured memory_bytes: 37248
#include<bits/stdc++.h>
typedef unsigned long long int ll;
using namespace std;
int main(){
	int n,p;
	cin>>n>>p;
	int arr[n];
	for(int i=0; i<n; i++){
		cin>>arr[i];
	}
	sort(arr, arr+n);
	int ans=0;
	for(int j = 0; j<p; j++){
		ans+=arr[j];
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

#define mod 1000000007LL
#define eps 0.0001
#define pi acos(-1)
#define INF 10000000000000000

#define rep(i, n) for(int i = 0;i < n;++i)
#define rep1(i, n) for(int i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define chmin

    

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------
    int sx ,sy , tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string ans ="";
    for(int i=sx;i<tx;i++){
        ans += "R";   
    }
    for(int i=sy;i<ty;i++){
        ans += "U";   
    }
    ans += "R";   
    for(int i=sy;i<ty;i++){
        ans += "D";   
    }
    ans += "D";   
    for(int i=sx;i<tx;i++){
        ans += "L";   
    }
    ans += "L";   
    ans += "U";   
    /////////////////////////////////
    for(int i=sy;i<ty;i++){
        ans += "U";   
    }
    for(int i=sx;i<tx;i++){
        ans += "R";   
    }
    ans += "U";   
    for(int i=sx;i<tx;i++){
        ans += "L";   
    }
    ans += "L";   
    for(int i=sy;i<ty;i++){
        ans += "D";   
    }
    ans += "D";   
    ans += "R";   
    pri(ans);


    
    return 0;
}



Measured memory_bytes: 256
n,m = map(int,input().split())
l = dict()
tl = []
for i in range(n+1):
  l[i] = []
for _ in range(m):
  a,b,c = map(int,input().split())
  l[a].append((b,c))
  l[b].append((a,-c))
  tl.append((a,b,c))
pos = [None]*(n+1)

def dfs(v,p,pos):
  q = [(v,p)]
  while q:
    cv,cp = q.pop()
    if pos[cv] != None:
      continue
    pos[cv] = cp
    for i,d in l[cv]:
      if pos[i] == None:
        q.append((i,cp+d))
  return

for i in range(1,n+1):
  if pos[i] == None:
    dfs(i,0,pos)
for a,b,c in tl:
  if pos[b] - pos[a] != c:
    print("No")
    break
else:
  print("Yes")

Measured memory_bytes: 99956
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int triple_max(int x, int y, int z){
    int ans = x;
    if (y > x && y > z) ans = y;
    else if (z > x && z > y) ans = z;

    return ans;
}

int main(){
    int n, a;
    cin >> n >> a;
    cout << n * n - a << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n, k;
    cin >> n >> k;
    vector<bool> vec(n, false);
    for (int i=0; i<k; i++){
        int d;
        cin >> d;
        for (int j=0; j<d; j++){
            int a;
            cin >> a;
            vec[a-1] = true;
        }
    }
    int cnt=0;

    for(int i=0; i<n; i++){
        if (vec[i] == false) {
            cnt++;
        }
    }
    out(cnt);
}

Measured memory_bytes: 3640