akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;


int main(void) {
	ll x, y;
	cin >> x >> y;
	bool ok = false;
	rep(i, x + 1) {
		ll kame = i;
		ll turu = x - i;
		if (y == (2 * turu + 4 * kame)) ok = true;
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

int main()
{
	map<char,int> count_s,count_t;
  	string s,t;
  	cin>>s>>t;
  	s+=s;
  	if(s.find(t)!=string::npos)
  	cout<<"Yes"<<endl;
  	else
    cout<<"No"<<endl;
  	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair <ll,ll>
#define vl vector <ll>
#define vp vector <pair<ll,ll>>
#define sort(x) sort(x.begin(), x.end())
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,ans = 0,m = 0;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    m = n+1;
    for(i=0;i<n;i++)
    {
        if(a[i] < m)
            ans++;
        m = min(a[i],m);
    }
    cout<<ans;
    return 0;
}


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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,start,end) for(int i=(start);i<=(end);i++)
#define all(n) begin(n),end(n)

#define DEBUG

int main()
{
	int a,b;
	cin >> a >> b;
	int ans = max(a+b, a-b);
	ans = max(ans, a*b);
	cout << ans << endl;
	return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" ";
#define LOGE if(DEBUG)cout<<endl;

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

lli dp[7000];

int main(){

	lli n,t;
	cin>>n>>t;

	///REP(i,0,4000)REP(j,0,7000)dp[i][j]=-INF;

	vector<pair<lli,lli>> v;
	REP(i,0,n){
		lli a,b;
		cin>>a>>b;
		v.push_back({a,b});
	}
	sort(v.begin(),v.end());

	REP(i,0,n){
		lli a = v[i].first;
		lli b = v[i].second;
		for(lli j=t-1;j>=0;j--){
			chmax(dp[j+a],dp[j]+b);
		}
	}

	lli ans = 0;
	REP(i,0,7000){
		chmax(ans,dp[i]);
	}
	cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3756
#include <iostream>

using namespace std;

int main() {
  char a, b, c, d;
  cin >> a >> b >> c >> d;
  if ((a == b && b == c) || (b == c && c == d)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3032
package main

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

type pair struct {
	a int
	b int
}

type pairs []*pair

func (p pairs) Len() int {
	return len(p)
}

func (p pairs) Less(i, j int) bool {
	return p[i].a < p[j].a
}

func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func main() {
	sc := NewScanner(os.Stdin)
	N, M := sc.NextInt(), sc.NextInt()
	var v pairs
	for i := 0; i < N; i++ {
		a, b := sc.NextInt(), sc.NextInt()
		v = append(v, &pair{a: a, b: b})
	}
	sort.Sort(v)

	sumbuy := 0
	money := 0
	for i := 0; i < N; i++ {
		nokori := M - sumbuy
		buy := min(v[i].b, nokori)
		money += v[i].a * buy
		sumbuy += buy
	}
	fmt.Println(money)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

// scanner
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner(r io.Reader) *Scanner {
	rdr := bufio.NewReaderSize(r, 1024)
	return &Scanner{r: rdr}
}

func (s *Scanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		line, isp, err := s.r.ReadLine()
		if err != nil {
			os.Exit(1)
		}
		s.buf = append(s.buf, line...)
		if !isp {
			break
		}
	}
}

func (s *Scanner) NextInt() int {
	i, err := strconv.Atoi(s.Next())
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	next := string(s.buf[start:s.p])
	s.p++
	return next
}

func (s *Scanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}


Measured memory_bytes: 7424
n = int(input())
b = list(map(int, input().split()))

a_max = [0]*n
a_max[0] = b[0]
a_max[-1] = b[-1]
for i in range(1, n-1):
    a_max[i] = min(b[i-1], b[i])

print(sum(a_max))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	int n,a[200020],s[200020],q;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		s[i]=a[i];
	}
	sort(a,a+n,cmp);
	for(int j=0;j<n;j++)
	{
		if(s[j]==a[0])
		{
			cout<<a[1]<<endl;
		}
		else
		{
			cout<<a[0]<<endl;
		}
	}
	return 0;	
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int    ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 44441e-8;

const ll infinity=1e15;

ll dp[110][100010];




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

    ll n,w;
    cin>>n>>w;

    ll W[n+1],V[n+1];

    for(ll i=0; i<n; i++)
    {
        cin>>W[i]>>V[i];
    }

    for(ll i=0; i<100; i++)
    {
        for(ll j=0; j<=100000; j++)
        {
            dp[i][j]=infinity;
        }
    }

    dp[0][0] = 0;
    dp[0][V[0]]= W[0];

    for(ll i=1; i<n; i++)
    {
        dp[i][0]=0;

        for(ll j=1; j<=100000; j++)
        {
            dp[i][j]=dp[i-1][j];

            if(j>=V[i])
                dp[i][j]= min(dp[i][j],W[i]+dp[i-1][j-V[i]]);
        }
    }

    ll ans;

    for(ll i=100000; i>=0; i--)
    {
        if(dp[n-1][i]<=w)
        {
            ans=i;
            break;
        }
    }
    cout<<ans<<nn;





}


/* Final check before submit :

1. array size or integer overflow,like uninitialised 0 index.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***
4. minus mod ans=(ans-k+mod)%mod;

*/






Measured memory_bytes: 81756
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)


def main():
    n, m = map(int, input().split())
    graph = [[] for _ in range(n)]
    for _ in range(m):
        x, y = map(lambda x: int(x) - 1, input().split())
        graph[x].append(y)
    dp = [-1 for _ in range(n)]
    # dp[i] := iから距離が最も長い頂点への距離

    def solve(v):
        if dp[v] != -1:
            return dp[v]
        res = 0
        for next_v in graph[v]:
            res = max(res, solve(next_v) + 1)
        dp[v] = res
        return dp[v]

    ans = 0
    for i in range(n):
        ans = max(ans, solve(i))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74540
#include <stdio.h>
int n, m, x, c[12]={}, a[12][12]={}, i, j, k, l, o, p, q, r, s, t, u, v, y, z[12], b, d = 1e9;
int main()
{
    scanf("%d%d%d", &n, &m, &x);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &c[i]);
        for (j = 0; j < m; j++)
        {
            scanf("%d", &a[i][j]);
        }
    }
    for (i = 0; i < 2; i++)
    {
        for (j = 0; j < 2; j++)
        {
            for (k = 0; k < 2; k++)
            {
                for (l = 0; l < 2; l++)
                {
                    for (o = 0; o < 2; o++)
                    {
                        for (p = 0; p < 2; p++)
                        {
                            for (q = 0; q < 2; q++)
                            {
                                for (r = 0; r < 2; r++)
                                {
                                    for (s = 0; s < 2; s++)
                                    {
                                        for (t = 0; t < 2; t++)
                                        {
                                            for (u = 0; u < 2; u++)
                                            {
                                                for (v = 0; v < 2; v++)
                                                {
                                                    y=i*c[0]+j*c[1]+k*c[2]+l*c[3]+o*c[4]+p*c[5]+q*c[6]+r*c[7]+s*c[8]+t*c[9]+u*c[10]+v*c[11];
                                                    for(b=0;b<m;b++){
                                                        z[b]=i*a[0][b]+j*a[1][b]+k*a[2][b]+l*a[3][b]+o*a[4][b]+p*a[5][b]+q*a[6][b]+r*a[7][b]+s*a[8][b]+t*a[9][b]+u*a[10][b]+v*a[11][b];
                                                        if(z[b]<x)break;
                                                    }
                                                    if(b==m&&y<d)d=y;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if(d==(int)1e9)puts("-1");
    else printf("%d",d);
    return 0;
}

Measured memory_bytes: 1736
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

vector<int> Acnt(100010, -1), Tcnt(100010, -1);

void Adfs(int cv, vector<vector<int>> &G){
    for(auto nv : G[cv]){
        if(Acnt[nv] == -1){
            Acnt[nv] = Acnt[cv] + 1;
            Adfs(nv, G);
        }
    }
    return ;
}

void Tdfs(int cv, vector<vector<int>> &G){
    for(auto nv : G[cv]){
        if(Tcnt[nv] == -1 && Acnt[nv] >= Tcnt[cv] + 1){
            Tcnt[nv] = Tcnt[cv] + 1;
            Tdfs(nv, G);
        }
    }
    return ;
}

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

    int n, u, v; cin>>n>>u>>v;
    u--, v--;
    vector<vector<int>> G(n);
    for(int i=0; i<n-1; i++){
        int a, b; cin>>a>>b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    Acnt[v] = 0;
    Adfs(v, G);
    Tcnt[u] = 0;
    Tdfs(u, G);

    int ans = 0;
    for(int i=0; i<n; i++){
        if(Tcnt[i] != -1){
            chmax(ans, Acnt[i] - 1);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define vso(x) sort( x.begin() , x.end() )
#define vre(x) reverse( x.begin() , x.end() ) ;
#define aso(x) sort( x , x + x.size() )
#define are(x) reverse( x , x + x.size() )
#define print(x) cout << x << endl 
#define no cout << "NO\n" 
#define yes cout << "YES\n"
typedef long long ll ; 
typedef unsigned long long ull ;
typedef long double ld ;
typedef pair<ll, ll> pairs ;
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("problem_name.out", "w", stdout) ;
    //freopen("problem_name.in", "r", stdin) ;
    //ull h = 798568968205 ; srand(h) ;
    ll n ; cin >> n ;
    cout << ( 1000 - (n%1000) ) % 1000 << endl ;
}

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

using namespace std;

typedef long long ll;

const int Mod=1e9+7;
int n;
ll jiecheng[4010];

ll ksm(ll a,ll b)
{
    ll res=1;
    while(b)
    {
        if(b&1) res*=a,res%=Mod;
        a*=a; a%=Mod;
        b>>=1;
    }
    return res;
}

ll ny(ll x)
{
    return ksm(x,Mod-2);
}

ll C(ll x,ll y)
{
    return jiecheng[x]*ny(jiecheng[x-y])%Mod*ny(jiecheng[y])%Mod;
}

int main()
{
    scanf("%d",&n);
    
    jiecheng[0]=1;
    for(int i=1;i<=4000;i++) jiecheng[i]=jiecheng[i-1]*i%Mod;
    
    ll ans=0;
    for(int i=1;i<=n/3;i++)
    {
        int p=n-i*2;
        ans=(ans+C(p-1,i-1)%Mod)%Mod;
    }

    printf("%lld",ans);

    return 0;
}

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

signed main(void){
    string s; cin >> s;
    if(s[0]==s[1] && s[1]==s[2]){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

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

int main(){
  char a,b,c,d;
  cin >> a >> b >> c >> d;
  
  string s="No";
  
  if(a==b&&c==d&&a!=c)
    s="Yes";
  else if(a==c&&b==d&&a!=b)
    s="Yes";
  else if(a==d&&b==c&&a!=b)
    s="Yes";
  
  cout << s << endl;
}

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

int main(){
  int n, a;
  int m = 1000000;
  int M = -1000000;
  int64_t s = 0;


  cin >> n;
  rep(i, n){
    cin >> a;
    m = min(a, m);
    M = max(a, M);
    s += a;
  }
  cout << m << " " << M << " " << s << endl;

}



Measured memory_bytes: 3092
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

string A;
string B;
string C;

int main(){
	
	cin>>A>>B>>C;
	
	A[0] += 'A'-'a';
	B[0] += 'A'-'a';
	C[0] += 'A'-'a';
	
	cout<<A[0]<<B[0]<<C[0]<<endl;
	
	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int selection_sort(int *A, int N)
{
    int minj;  // 未ソート部分の最小の要素
    int exchange_times = 0; // 交換回数
    int tmp;

    for (int i = 0; i < N; i++)
    {
        minj = i;
        for (int j = i; j < N; j++)
        {
            if (A[j] < A[minj])
            {
                minj = j;
            }
        }
        if (minj != i)
        {
            tmp = A[i];
            A[i] = A[minj];
            A[minj] = tmp;
            exchange_times += 1;
        }
    }

    return exchange_times;
}

int main(void)
{
    int N;
    int A[100];
    int times;

    scanf("%d", &N);
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &A[i]);
    }

    times = selection_sort(A, N);
    for (int i = 0; i < N; i++)
    {
        if (i == N - 1)
        {
            printf("%d\n", A[i]);
        }
        else
        {
            printf("%d ", A[i]);
        }
    }
    printf("%d\n", times);

    return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
typedef pair<ll,ll> l_l;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back


ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    string s;cin>>s;
    ll n;n=s.size();
    ll ans=0;
    if(n%2==0){
        rep(i,0,(n/2)-1){
            if(s[i]!=s[n-1-i]){
                ans++;
            }
        }
    }else{
        rep(i,0,(n-3)/2){
            if(s[i]!=s[n-1-i]){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	string S;
	scan(S);
	int ans=0;
	rep(i,S.size()){
		ans--;
		if(S[i]=='g') ans++;
		if(i%2==1) ans++;
	}
	prin(ans);
	return 0;
}


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

using namespace std;

class Node {
public:
    Node(int key, Node* parent = nullptr) : key_(key), parent_(parent), leftChild_(nullptr), rightChild_(nullptr) {}
    void insert(int key) {
        Node* y = nullptr;  // x の親
        Node* x = this;
        while (x != nullptr) {
            y = x;  // 親を設定
            if (key < x->key_) {
                x = x->leftChild_;  // 左の子へ移動
            }
            else {
                x = x->rightChild_; // 右の子へ移動
            }
        }
        Node* z = new Node(key, this);
        if (key < y->key_) {
            y->leftChild_ = z;
        }
        else {
            y->rightChild_ = z;
        }
    }
    void printInorder() {
        if (leftChild_ != nullptr) {
            leftChild_->printInorder();
        }
        cout << " " << key_;
        if (rightChild_ != nullptr) {
            rightChild_->printInorder();
        }
    }
    void printPreorder() {
        cout << " " << key_;
        if (leftChild_ != nullptr) {
            leftChild_->printPreorder();
        }
        if (rightChild_ != nullptr) {
            rightChild_->printPreorder();
        }
    }
private:
    int key_;
    Node* parent_;
    Node* leftChild_;
    Node* rightChild_;
};

class Tree {
public:
    Tree() : root_(nullptr) {}
    void insert(int key) {
        if (root_ != nullptr) {
            root_->insert(key);
        }
        else {
            root_ = new Node(key);
        }
    }
    void print() {
        if (root_ != nullptr) {
            root_->printInorder();
            cout << endl;
            root_->printPreorder();
            cout << endl;
        }
    }
private:
    Node* root_;
};

int main()
{
    int n;
    cin >> n;
    string operation;
    Tree tree;
    for (int i = 0; i < n; ++i) {
        cin >> operation;
        if (operation == "insert") {
            int x;
            cin >> x;
            tree.insert(x);
        }
        else {
            tree.print();
        }

    }
}



Measured memory_bytes: 26608
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	int N;
	int x;
	vector<int> a;
	cin >> N;
	cin >> x;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	sort(a.begin(), a.end());

	int i = 0;
	int sum = 0;

	while (i < N&&sum < x) {
		sum += a.at(i);
		i++;
	}

	if (sum != x) {
		i--;
	}

	cout << i << endl;

	return 0;
}

Measured memory_bytes: 256
import itertools
import math
import fractions
import functools

a, b, c, k = map(int, input().split())
sum = 0
if k <= a:
    print(k)
    quit()
else:
    sum = a
    k -= a
if k <= b:
    print(sum)
    quit()
else:
    k -= b
print(sum-k)


Measured memory_bytes: 72736
#include <bits/stdc++.h>
#define M 100005
using namespace std;
long long f[105][M];
int n, m, a[M][2];
int main(){
    cin >> n >> m;
    for(int i = 1; i <= n; ++i){
        cin >> a[i][0] >> a[i][1];
    }
    for(int j = 1; j <= m; ++j){
        for(int i = 1; i <= n; ++i){
            if(j >= a[i][0]) {
                    f[i][j] = max(f[i - 1][j], f[i - 1][j - a[i][0]] + a[i][1]);
            }
            else{
                f[i][j] = f[i - 1][j];
            }
        }
    }
    cout << f[n][m];
    return 0;
}


Measured memory_bytes: 78592
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
typedef pair<int, int> P;

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

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}

int main() {
  int X; cin >> X;
  int cnt = 0;
  int deg = 0;
  while (true) {
    ++cnt;
    deg += X;
    if (deg % 360 == 0) {
      cout << cnt << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3632
n,k = map(int, input().split())
h = sorted(map(int, input().split()))

t = min(n, k)
# print(t)
# print(h[0:t])
ans = sum(h[0:(n-t)])
print(ans)

# print(len(h))
# print(h)
# print(h[0:1])
# print(h[0:2])
# print(h[1:2])


Measured memory_bytes: 26024
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
typedef long long int ll;

using namespace std;

int main() {
    int N, K, Q;
    vector<int> A;

    cin >> N >> K >> Q;
    rep(i, Q) {
        int val;
        cin >> val;
        A.push_back(val);
    }

    int count[100000] = {0};
    for(auto val: A) count[val - 1]++;
    rep(i, N) cout << (K - Q + count[i] > 0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,p ,z;
    cin>>a;
   if(a/15>=1)
   {
       z=a/15;
     p=(11800*z)+(a-(z*15))*800;
     cout<<p;
   }
   else
   {
      p=a*800;
      cout<<p;
   }
	return 0;
	}





Measured memory_bytes: 3612
N ,a,b= list(map(int,input().split(' ')))


M = 10**9+7

def pow(x,n):
    if n==0:
        return 1
    res = pow((x*x)%M,n//2)
    if (n%2)==1:
        res = (res*x)%M
    return res


def power(x,n):
    res = 1
    if(n>0):
        res = power(x,n//2)
        if (n%2)==0:
            res = (res*res)%M
        else:
            res = (((res*res)%M)*x)%M
    return res

def comb(n,a):
    ans = 1
    for i in range(a):
        ans = (ans*(n-i))%M
        ans = (ans*power(i+1,M-2))%M 
    return ans

#print(pow(10,2))
#print(power(5,8))

print((power(2,N)-1-comb(N,a)-comb(N,b))%M)

Measured memory_bytes: 51036
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node{ int p, l, r;};
struct Node T[MAX];
int n, H, D[MAX];

int getDepth(int u){
  int d = 0;
  for(; T[u].p != NIL ;d++) u = T[u].p;
  return d;
}

void print(int u){
  int i, c;
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].p);
  printf("depth = %d, ", D[u]);

  if ( T[u].p == NIL ) printf("root, ");
  else if ( T[u].l == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i = 0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if (i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}

main(){
  int i, j, d, v, c, l;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) T[i].p = T[i].l = T[i].r = NIL;

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &v, &d);
    for ( j = 0; j < d; j++ ){
      scanf("%d", &c);
      if ( j == 0 ) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  
  H = 0;
  for ( i = 0; i < n; i++ ){
    D[i] = getDepth(i);
    if ( D[i] > H ) H = D[i];
  }

  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}



Measured memory_bytes: 3320
import java.util.*;

class Main{
    int a,b;
    ArrayList<Integer> a1,b1;

    void solve(){
	Scanner sc = new Scanner(System.in);

	while(true){
	    a = sc.nextInt();
	    b = sc.nextInt();
	    if(a==0 && b==0) break;

	    a1 = new ArrayList<Integer>();
	    b1 = new ArrayList<Integer>();
	    for(int i=1; i<=a; i++){
		if(a%i==0) a1.add(i);
	    }
	    for(int i=1; i<=b; i++){
		if(b%i==0) b1.add(i);
	    }

	    int min = Integer.MAX_VALUE;
	    for(int i=0; i<a1.size(); i++){
		int a2 = a/a1.get(i);
		for(int j=0; j<b1.size(); j++){
		    int b2 = b/b1.get(j);
		    int[] data = {a1.get(i),a2,b1.get(j),b2};
		    Arrays.sort(data);
		    int square = (data[1]-data[0])*(data[1]-data[0])+(data[2]-data[1])*(data[2]-data[1])+(data[3]-data[2])*(data[3]-data[2]);
		    min = Math.min(min,square);
		}
	    }

	    System.out.println(min);
	}
    }

    public static void main(String[] args){
	new Main().solve();
    }
}

Measured memory_bytes: 13000
// ABC142_D
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N, num;
    cin >> N;
    vector<tuple<ll, ll>> vec(N);
    REP(i, N) {
        cin >> num;
        vec[i] = make_tuple(num, i+1);
    }
    
    // calculation
    sort(vec.begin(), vec.end());
    REP(i, N) {
        if (i) cout << " ";
        cout << get<1>(vec[i]);
    }
    cout << "\n";
    
    return 0;
}

Measured memory_bytes: 2432
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B):
    def f(n):
        return ((n + 1) // 2) % 2 + (n if n % 2 == 0 else 0)

    return f(A-1) ^ f(B)


def main():
    A, B = read_int_n()
    # A = [read_int_n() for _ in range(N)]
    print(slv(A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5704
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
constexpr ll INF = 1000000000;
using namespace std;

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

	vector<int>l(m);
	vector<int>r(m);
	rep(i, m)cin >> l[i] >> r[i];

	priority_queue<ll> q;
	rep(i, m)q.push(l[i]);

	sort(r.begin(), r.end());

	int ma = q.top();
	int mi = r[0];

	int ans = mi - ma + 1;
	int qop = 0;
	if (ans >= 0) {
		cout << ans << endl;
	}
	else {
		cout << qop << endl;
	}
}

Measured memory_bytes: 2168
#include<stdio.h>

int main() {
  int n, t, d, m, i, j;
  int c[500], s[500], f[500];
  scanf("%d", &n);
  for (i = 0; i < n - 1; ++ i) {
    scanf("%d %d %d", c + i, s + i, f + i);
  }
 
  for (i = 0; i < n - 1; ++ i) { 
    t = c[i] + s[i];
    for (j = i + 1; j < n - 1; ++ j) {
      d = t - s[j];
      if (d > 0) {
        m = d % f[j];
        if (m > 0) {
          t += c[j] + f[j] - m;
        } else {
          t += c[j];
        }
      } else {
        t = c[j] + s[j];
      }
    }
    printf("%d\n", t);
    fflush(stdout);
  }
  printf("0\n");
  fflush(stdout);
  return 0;
}

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

int main()
{
  char str[10],x[10],y[10];
  int a,b,i=0,j=0;
  int s,ty;
 
    fgets(str,sizeof(str),stdin);
    
    for(;;){
      if(str[i]==' '){
	break;
      }
      x[i]=str[i];
      i++;
  }
    
  for(;;){
    if(str[i]=='\0'){
      break;
    }
    y[j]=str[i];
    i++;
    j++;
  }
  a=atoi(x);
  b=atoi(y);

  if(a<1 || 100<b){
    printf("Error!!\n");
      }else{
    s=a*b;
    ty=(a*2)+(b*2);
    
    printf("%d %d\n",s,ty);
  }
  
  return 0;
}

Measured memory_bytes: 528
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

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

	rep(i,0,n)
		cin >> a[i];

	int d = n - 1;
	rep(i,0,n){
		int num = a[i];
		rep(j,0,n){
			if(i == j )
				continue;

			if( (num - a[j] ) % d == 0 ){
				cout << num << " " << a[j] << endl;
				ret 0;
			}
		}
	}
	ret 0;
}


Measured memory_bytes: 3088
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from sys import stdin
from collections import deque


def main():
  # input
  N = int(input())
  An = list(map(int, stdin.readline().rstrip().split()))
  An = sorted(An)
  Bn_p,Bn_n = [deque(),deque()]
  for a in An:
    if a >= 0:
      Bn_p.append(a)
    else:
      Bn_n.append(a)
  Bn_n = deque(sorted(Bn_n,reverse=True))

  xy = deque()
  ans = 0
  if len(Bn_p)==0:
    ## 負数のみ
    ans = Bn_n[0]
    for i in range(1,len(Bn_n)):
      x = ans
      y = Bn_n[i]
      xy.append([x,y])
      ans = x-y
  elif len(Bn_n)==0:
    ## 正数のみ
    ans = Bn_p[0]
    for i in range(1,len(Bn_p)-1):
      x = min([Bn_p[i],ans])
      y = max([Bn_p[i],ans])
      xy.append([x,y])
      ans = x-y
    xy.append([Bn_p[-1],ans])
    ans = Bn_p[-1]-ans
  else:
    ## 正負混在
    ans_n = Bn_p.popleft()
    ans_p = Bn_n.popleft()
    ### 正数はminを作り続ける
    for i in range(len(Bn_p)):
      x = ans_p
      y = Bn_p[i]
      xy.append([x,y])
      ans_p = x-y

    Bn_n.append(ans_p)
    ### 負数はmaxを作り続ける
    for i in range(len(Bn_n)):
      x = ans_n
      y = Bn_n[i]
      xy.append([x,y])
      ans_n = x-y
    ans = ans_n

  print(ans)
  for x,y in xy:
    print(x,y)

if __name__ == "__main__":
  main()

Measured memory_bytes: 23592
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

int main(){
	int n;cin>>n;
	VS s(n);
	rep(i,n)cin>>s.at(i);
	rep(i,n){
		sort(all(s.at(i)));
	}		
	LL ans=0;
	map<string,int> mp;
	rep(i,n){
		mp[s.at(i)]++;
	}
	for(auto itr=mp.begin();itr != mp.end();itr++){
		LL m=itr->second;
		ans+=m*(m-1)/2;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
 
#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
 
#define ll long long
 
#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));
 
int main(){
	string s;
  cin >> s;
    if(s == "Sunny"){
      cout << "Cloudy" << endl;
    }else if(s == "Cloudy"){
      cout << "Rainy" << endl;
    }else if(s == "Rainy"){
      cout << "Sunny" << endl;
    }
  
return 0;
}

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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int x;
	cin >> x;
	int ans = 0;
	ans += x/500*1000;
	x %= 500;
	ans += x/5*5;
	cout << ans << endl;
}

Measured memory_bytes: 256
from itertools import permutations

d, g = map(int, input().split())
g = g // 100
p = []
c = []

for _ in range(d):
	pp, cc = map(int, input().split())
	p.append(pp)
	c.append(cc // 100)

ans = float("inf")
for array in permutations(range(d)):
	gap = g
	num = 0
	for a in array:
		if p[a] * (a + 1) >= gap:
			num += (gap - 1) // (a + 1) + 1
			break
		elif p[a] * (a + 1) + c[a] >= gap:
			num += p[a]
			break
		else:
			num += p[a]
			gap -= p[a] * (a + 1) + c[a]

	if num < ans:
		ans = num

print(ans)


Measured memory_bytes: 41068
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
ans = 0

List = [0]*100000
for i in A:
  List[i-1] += 1
  ans += i

dic = {}
for i in range(100000):
  if List[i] != 0:
    dic[i+1] = List[i]



tmp = 0
for i in range(Q):
  B,C= map(int, input().split())
  if B in dic:
    tmp = dic[B]
  else:
    print(ans)
    continue
  ans = ans + tmp*(C-B) 
  print(ans)
  if C in dic:
    del dic[B]
    dic[C] += tmp
  else:
    del dic[B]
    dic[C] = tmp

Measured memory_bytes: 85328
N = gets.to_i
V = gets.split(" ").map(&:to_i)
C = gets.split(" ").map(&:to_i)

r = V.zip(C).map{ |x, y| x - y}.select{|a| a > 0}.reduce(:+)
if r == nil
  puts 0
else
  puts r
end

Measured memory_bytes: 1788
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String x;
		int a, b, c, count = 0;
		x = br.readLine();
		String[] ary = x.split(" ");
		a = Integer.parseInt(ary[0]);
		b = Integer.parseInt(ary[1]);
		c = Integer.parseInt(ary[2]);
		
		for(int i = a; i <= b; i++){
			if(c%i==0){
				count++;
			}
		}
		
		System.out.println(count);

	}
}

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

using namespace std;

int main()
{
    int n, m, xc, yc;
    cin >> n >> m >> xc >> yc;
    bool flag=false;

    vector<int> x(n);
    for(int i=0;i<n;i++)
    {
        cin >> x.at(i);
    }
    sort(x.begin(), x.end());

    vector<int> y(m);
    for(int i=0;i<m;i++)
    {
        cin >> y.at(i);
    }
    sort(y.begin(), y.end());

    for(int i=x.at(n-1)+1;i<=y.at(0);i++)
    {
        if(xc<i&&i<=yc)
        {
            flag = true;
            break;
        }
    }
    if(flag)
    {
        cout << "No War" << endl;
    }
    else
    {
        cout << "War" << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);

		int A = scanner.nextInt();
		int B = scanner.nextInt();
		int C = scanner.nextInt();
		int K = scanner.nextInt();
		
		if (K<=A) {
			System.out.println(K);
		}else if(K<=A+B) {
			System.out.println(A);
		}else {
			System.out.println(A-(K-A-B));
		}

	}

}

Measured memory_bytes: 27072
open System.IO
open System

let [| n; m;|] = stdin.ReadLine().Split()|>Array.map int
let preYearPairs = [| for _ in 1..m -> stdin.ReadLine().Split() |> Array.map int |]

let sw = new StreamWriter(Console.OpenStandardOutput()) 
sw.AutoFlush <- false
Console.SetOut(sw)

preYearPairs 
|> Seq.mapi (fun i [| pre; year|] -> (year, i+1 , pre))
|> Seq.groupBy (fun (year,city,pre) -> pre)
|> Seq.map (fun (pre, elem) -> elem |> Seq.sort |> Seq.mapi (fun i (_,city,pre) -> (city,i+1,pre) ))
|> Seq.collect(fun x -> x)
|> Seq.sort
|> Seq.map (fun (_,num,pre) -> pre.ToString("000000") + num.ToString("000000"))
|> Seq.iter(stdout.WriteLine)

stdout.Flush()

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

using namespace std;

int cal_digits(int N, int K){
    int count = 1;
    int remain=N;
    while(remain >= K){
        remain = remain/K;
        count ++;
    }
    return count;
}
//10 - > 1010
int main(){
    int N,K;
    cin >> N >> K;
    cout << cal_digits(N,K) << endl;
    return 0;
}

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

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;

int main(){
    int n,m;
    std::cin >> n>>m;
    int ca=0,cw=0;
    std::vector<int> a(n),w(n);
    rep(i,m){
        int p;
        string s;
        std::cin >> p>>s;
        p--;
        if(s=="AC"){
            if(a[p]==0){
                ca++;a[p]=1;
                cw+=w[p];
            }
        }
        else{
            w[p]++;
        }
    }
    ppri(ca,cw);;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;
 
struct UnionFind{
    vector<int> par;
    vector<int> siz;
 
    UnionFind(int n){
        init(n);
    }
    
    void init(int n){
        par.resize(n);
        siz.resize(n);
        for(int i = 0; i < n; i++){
            par[i] = i;
            siz[i] = 1;
        }
    }
 
    int root(int x){
        if(par[x] == x) return x;
        else return par[x] = root(par[x]);
    }
 
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
    }
 
    bool same(int x, int y){
        return root(x) == root(y);
    }
 
    int size(int x){
        return siz[root(x)];
    }
};
 
signed main(){
    int n,m;
    cin >> n >> m;
    ll a[n];
    REP(i,n){
        cin >> a[i];
    }
    UnionFind uf(n);
    REP(i,m){
        int x,y;
        cin >> x >> y;
        uf.unite(x, y);
    }
    if(m == n - 1){
        cout << 0 << endl;
        return 0;
    }
    vector<pair<ll, int>> mn(n, pair<ll, int> (LINF, 0));
    for(int i = 0; i < n; i++){
        if(a[i] < mn[uf.root(i)].first){
            mn[uf.root(i)].first = a[i];
            mn[uf.root(i)].second = i;
        }
    }
    ll ans = 0;
    int cnt = 0;
    bool used[n] = {};
    for(int i = 0; i < n; i++){
        if(mn[i].first != LINF){
            ans += mn[i].first;
            used[mn[i].second] = true;
            cnt++;
        }
    }
    vector<ll> v;
    for(int i = 0; i < n; i++){
        if(!used[i]){
            v.emplace_back(a[i]);
        }
    }
    if(v.size() < cnt - 2){
        cout << "Impossible" << endl;
        return 0;
    }
    sort(ALL(v));
    for(int i = 0; i < cnt - 2; i++){
        ans += v[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4600
S = input()

t = {}

for c in S:
	if c in t:
		t[c] += 1
	else:
		t[c] = 1

if len(t) != 2:
	print("No")
elif len(list(filter(lambda c: t[c] != 2, t))) > 0:
	print("No")
else:
	print("Yes")



Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

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

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  char c;
  cin >> c;
  cout << char(ll(c)+1) << endl;
}

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

Measured memory_bytes: 3560
using System;
using System.Collections.Generic;
using System.Linq;

namespace ProgramingStudying2
{
    class Program
    {
        static int h;
        static int w;
        static string[] field;
        static bool[,] visited;
        static int[,] ansMap;

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


        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            h = input[0];
            w = input[1];

            field = new string[h];

            for (int i = 0; i < h; i++)
            {
                field[i] = Console.ReadLine();
            }

            visited = new bool[h, w];
            ansMap = new int[h, w];
            bfs();

            var ans = 0;

            for (int i = 0; i < h; i++)
            {
                for(int j = 0; j < w; j++)
                {
                    if (ansMap[i,j] > ans)
                    {
                        ans = ansMap[i, j];
                    }
                }
            }
            Console.WriteLine(ans);
        }

        static void bfs()
        {
            var que = new Queue<(int, int)>();

            for(int i = 0; i < h; i++)
            {
                for(int j = 0; j < w; j++)
                {
                    if(field[i][j] == '#')
                    {
                        que.Enqueue((i, j));
                        visited[i, j] = true;
                    }
                    
                }
            }

            while(que.Count > 0)
            {
                var (x, y) = que.Dequeue();
                for(int i = 0; i < 4; i++)
                {
                    var nx = x + dx[i];
                    var ny = y + dy[i];

                    if(nx < 0 || nx >= h)
                    {
                        continue;
                    }
                    if (ny < 0 || ny >= w)
                    {
                        continue;
                    }

                    if (visited[nx, ny])
                    {
                        continue;
                    }
                    if (field[nx][ny] == '#')
                    {
                        continue;
                    }

                    que.Enqueue((nx, ny));
                    visited[nx, ny] = true;
                    ansMap[nx, ny] = ansMap[x, y] + 1;
                }
            }
            return;
        }
    }
}


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

int n,m;

std::vector<int> G[200000];

bool used[200000];

bool dfs(int m,int cnt) {
    if(m==n-1)
        return true;

    if(cnt>2)
        return false;

    used[m]=true;

    for(auto&& x : G[m]){
        if(!used[x]&&dfs(x,cnt+1))
            return true;
    }

    used[m]=false;

    return false;
}

int main() {

    std::cin>>n>>m;

    int a,b;

    for(int i=0;i<m;++i){
        std::cin>>a>>b;
        --a;
        --b;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    if(dfs(0,1))
        std::cout<<"POSSIBLE"<<std::endl;
    else
        std::cout<<"IMPOSSIBLE"<<std::endl;

    return 0;
}

Measured memory_bytes: 12144