akhauriyash/Code-Regression huggingface dataset:
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <list>
#include <bitset>

using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
//sum
#if 1
#include <array>
#include <unordered_set>
#include <unordered_map>
template<class T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

int N;
set<int> s;
LL sum = 0;
int main() {
	cin >> N;
	REP(i, 0, N) {
		int a;
		cin >> a;
		s.insert(a);
		sum += a;
	}

	int d = INF;
	for (int a : s) {
		if (a % 10 != 0) {
			d = a; break;
		}
	}
	cout << (sum % 10 == 0 ? (d == INF ? 0 : sum - d) : sum) << endl;
	return 0;
}

Measured memory_bytes: 256
use proconio::input;
use std::collections::BTreeSet;
use std::ops::Bound::Excluded;
use std::ops::Bound::Unbounded;
use rand::Rng;

const C:usize = 26;
const N_ITER:usize = 4000000;

fn main() {

    input!{
        d:usize,
        c:[i32;C],
        s:[[i32;C];d],
    };
    let mut rng = rand::thread_rng();
    let mut t:Vec<usize> = (0..d).map(|_|rng.gen::<usize>()%C).collect();
    let mut occs = vec![BTreeSet::<i32>::new();C];
    for occ in &mut occs {
        occ.insert(-1);
    }
    let mut ans = 0;
    for (day,&ti) in t.iter().enumerate() {
        ans += s[day][ti];
        occs[ti].insert(day as i32);
        for j in 0..26 {
            let sc = (c[j] as i32) * ((day as i32) -*occs[j].iter().last().unwrap());
            ans -= sc;
        }
    }
    for occ in &mut occs {
        occ.insert(d as i32);
    }    

    let sum_lr = |l,r,n| n*(l+r)/2;
    for _ in 0..N_ITER {
        let d = rng.gen::<usize>()%d;
        let q = rng.gen::<usize>()%C;
        let pre_q = t[d];
        let q = if q==pre_q {rng.gen::<usize>()%C} else {q};
        let pre_ans = ans;
        let mut try_change = |d:usize,q:usize|{
            let pre_q = t[d];
            ans-=s[d][pre_q];
            ans+=s[d][q];
            t[d]=q;
            let d = d as i32;
            // for pre_q
            let mut calc = |q:usize,is_ins:bool| {
                if is_ins {
                    occs[q].insert(d);
                }
                else {
                    occs[q].remove(&d);
                }
                let pre_d = *occs[q].range((Unbounded,Excluded(&d))).last().unwrap();
                let nex_d = *occs[q].range((Excluded(&d),Unbounded)).next().unwrap();
                let lbig = d - pre_d;
                let rbig = nex_d - pre_d -1;
                let lsml = 0;
                let rsml = nex_d-d-1;
                let sc = sum_lr(lbig,rbig,nex_d-d)-sum_lr(lsml,rsml,nex_d-d);
                sc
            };
            
            ans -= calc(pre_q,false)*c[pre_q];
            ans += calc(q,true)*c[q];
            ans
        };
        let now_ans = try_change(d,q);
        if now_ans<=pre_ans{
            try_change(d,pre_q);
        }
    }

    for tv in t {
        println!("{}",tv+1);
    }
}




Measured memory_bytes: 2724
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
const ll MOD = 998244353;
const ll INF = 1e18;
using namespace std;



main(){    
    #ifdef XOX
        freopen("D:\\V S Code\\cpp\\competitiveProgramming\\Input.txt", "r", stdin);
        freopen("D:\\V S Code\\cpp\\competitiveProgramming\\OPT.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n;
    cin >> n;

    char r = 'R', b = 'B';
    cout << "? ";
    for(int i = 0; i < n; i++){
        cout << i + 1 << " ";
    }
    cout << endl;

    string str;
    char tmp;
    cin >> str;
    tmp = str[0];
    if(tmp != r)    swap(r, b);

    int hi = n + 1, lo = 1;
    while(lo < hi){
        int mid = (hi + lo + 1) / 2;
        cout << "? ";
        for(int i = 0; i < n; i++)  cout << mid + i << " ";
        cout << endl;
        cin >> str;
        tmp = str[0];        
        if(tmp == r)    lo = mid;
        else    hi = mid - 1;
    }

    char res[2*n + 10];
    res[hi] = r;
    res[hi + n] = b;
    vector<int> red, blue;      
    for(int i = 1; i < hi; i++) {
        cout << "? " << i << " ";
        for(int j = 1; j < n; j++)  cout << hi + j << " ";
        cout << endl;
        cin >> str;
        tmp = str[0];        
        if(tmp == r)    res[i] = r;
        else    res[i] = b;
        if(tmp == r and red.size() < (n / 2))   red.push_back(i);
        if(tmp == b and blue.size() < (n / 2))   blue.push_back(i);
    }

    for(int i = hi + n + 1; i <= 2*n; i++){
        cout << "? " << i << " ";
        for(int j = 1; j < n; j++)  cout << hi + j << " ";
        cout << endl;
        cin >> str;
        tmp = str[0];        
        if(tmp == r)    res[i] = r;
        else    res[i] = b;
        if(tmp == r and red.size() < (n / 2))   red.push_back(i);
        if(tmp == b and blue.size() < (n / 2))   blue.push_back(i);
    }

    for(int i = 1; i < n; i++){
        cout << "? " << hi + i << " ";
        for(int x : red)    cout << x << " ";
        for(int x : blue)    cout << x << " ";
        cout << endl;
        cin >> str;
        tmp = str[0];
        res[i + hi] = tmp;
    }

    cout << "! ";
    for(int i = 1; i <= 2*n; i++){
        cout << res[i];
    }

}

Measured memory_bytes: 724
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
const int maxn = 1e5 + 10;
int n,m,x,y;
int fa[maxn],a[maxn];
int find_fa(int x){
    return x==fa[x] ? x : fa[x] = find_fa(fa[x]);
}
void Union(int x,int y){
    x = find_fa(x);
    y = find_fa(y);
    if(x != y) fa[x] = y;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) {
        fa[i] = i;
        scanf("%d",&a[i]);
    }
    
    for(int i=1;i<=m;i++){
        scanf("%d%d",&x,&y);
        Union(a[x], a[y]);
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        int x = find_fa(i);
        int y = find_fa(a[i]);
        if(x==y) ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j]
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
const int ma=1000000000;
int main(){
    int n,m; cin >> n >> m;
    if(n!=m) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    int n; cin >> n;
    vector<int> p(n);
    int cnt = 0;
    REP(i,n) {
        cin >> p[i];
        cnt += (p[i]!=i+1);
    }
    cout << (cnt==2 || cnt==0 ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
import collections

n,k=map(int,input().split())
a=list(map(int,input().split()))
L=[1]
count=1
nowt=1
roops=0
v=[False]*n
while(True):
    if v[a[nowt-1]-1]==True:
        roops=a[nowt-1]
        break

    L.append(a[nowt-1])
    v[a[nowt-1]-1]=True
    nowt=a[nowt-1]
    count+=1

play=0
for i in range(len(L)):
    if L[i]==roops:
        break
    play+=1

rooplen=len(L)-play

if k<play:
    print(L[k])
    exit() 

ans=L[play+(k-play)%rooplen]

print(ans)

    

Measured memory_bytes: 33916
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    string s; cin >> s;
    int zen = (s[0]-'0')*10 + (s[1]-'0');
    int kou = (s[2]-'0')*10 + (s[3]-'0');
    if(0<zen&&zen<13 && 0<kou&&kou<13) {
        print("AMBIGUOUS");
    }else if(0<zen&&zen<13) {
        print("MMYY");
    }else if(0<kou&&kou<13) {
        print("YYMM");
    }else {
        print("NA");
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define per(i,n) for ((i)=n;(i)>=(1);(i)--)
using namespace std;
const int mod=1e9+7;
int n,m,g[15],dp[1<<15],pw[235];
int main()
{
	int i,j,k;
	pw[0]=1;rep(i,230) pw[i]=pw[i-1]*2ll%mod;
	scanf("%d%d",&n,&m);rep(i,m){int x,y;scanf("%d%d",&x,&y);x--;y--;g[x]|=(1<<y);}
	dp[0]=1;
	for(i=1;i<(1<<n);i++)
	{
		if((i&1)==((i>>1)&1))
		{
			for(j=i;j;j=((j-1)&i))
			{
				if((j&1)==((j>>1)&1))
				{
					int coef=1;
					for(k=0;k<n;k++) if((i>>k)&1)
					{
						if((j>>k)&1) coef=1ll*coef*(1<<__builtin_popcount(g[k]&(i^j)))%mod;
						else coef=1ll*coef*((1<<__builtin_popcount(g[k]&j))-1)%mod;
					}
					dp[i]=(dp[i]+1ll*dp[i^j]*coef)%mod;
				}
			}
		}
	}
	cout<<(pw[m]-dp[(1<<n)-1]+mod)%mod<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
int main(){
  int a,b,k;
  std::cin >> a >> b >> k;
  std::vector<int> v(100);
  int cnt=0;
  int ans;
  for(int i=1;i<=100;i++){
    if((a%i)==0 && (b%i)==0){
      v.at(cnt) = i;
      cnt++;
    }
  }
  std::sort(v.begin(), v.end(), std::greater<int>());
  std::cout << v.at(k-1) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    cin>>n;
    ll arr[n+5]={0};
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    double avg=arr[0]+arr[1];
    avg/=2;
    for(int i=2;i<n;i++)
    {
        avg+=arr[i];
        avg/=2;
    }
    cout<<avg<<endl;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
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; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    ll k,s;
    cin>>k>>s;
    ll ans=0;
    rep(i,k+1){
        rep(j,k+1){
            if(s-i-j>=0&&s-i-j<=k){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    solve();


    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vector<string> a(n);
    rep(i,n)cin>>a[i];
    bool f=false;
    rep(i,n){
        rep(j,n){
            if(a[i][j]=='#'){
                f=true;
                break;
            }
        }
    }
    if(!f){
        cout<<-1<<endl;
        return;
    }
    int b=0;
    rep(i,n){
        rep(j,n){
            if(a[j][i]=='.'){
                b++;
                break;
            }
        }
    }
    vi v;
    rep(i,n){
        int c=0;
        rep(j,n){
            if(a[i][j]=='.')c++;
        }
        bool t=false;
        rep(j,n){
            if(a[j][i]=='#'){
                t=true;
                break;
            }
        }
        v.pb(c+!t);
    }
    cout<<*min_element(all(v))+b<<endl;
}

Measured memory_bytes: 512
/*
 * c.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

int as[26], cs[10];

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i += 2) as[s[i] - 'a']++;
  //for (int i = 0; i < 26; i++) printf("%d", as[i]); putchar('\n');

  for (int i = 0; i < 26; i++) cs[as[i]]++;
  //for (int i = 0; i < 10; i++) printf("%d ", cs[i]); putchar('\n');

  int len = 0, on = 0;
  for (int i = 1; i <= 9; i++)
    if (cs[i] > 0) {
      on++;
      if (i == 1) len += 2 * cs[i] - 1;
      else len += min(4 * cs[i] - 1, 2 * cs[i] + 3);
    }

  printf("%d\n", len + on - 1);
  return 0;
}

Measured memory_bytes: 1200
#my_string = input("Type your word: ")
my_string = input()
my_string = my_string.casefold()
if ((len(my_string)) < 3 or (len(my_string)) > 100):
    #print(len(my_string))
    print("No")
    quit()

reversed_string = reversed(my_string)

n = len(my_string)
#defining string [0:(n-1)/2]
first_chars = my_string[:int((n-1)/2)]
reversed_first_chars = reversed(first_chars)

#defining string [((n+3)/2):n-1]
last_chars = my_string[int((n+3)/2)-1:]
reversed_last_chars = reversed(last_chars)
#print(type(first_chars), first_chars)
#print(last_chars)
#print(n)

#checking if S is a palindrome
if list(my_string) == list(reversed_string):
    #checking if it is a strong palindrome
    if (list(first_chars) == list(reversed_first_chars)):
        if (list(last_chars) == list(reversed_last_chars)):
            print("Yes")
        else:
            print("No")
    else:
        print("No")
#if it is not a palindrome at all
else:
    print("No")

Measured memory_bytes: 3064
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
//  cout.precision(15); cout << fixed;

int main() {
  int n, k; cin >> n >> k;
  vector<int> C(n, 0);
  loop(i,0,k) {
    int d, a;
    cin >> d;
    loop(j,0,d) {
      cin >> a;
      a--;
      C[a]++;
    }
  }
  
  int cnt = 0;
  loop(i,0,n) cnt += C[i]==0;
  cout << cnt << endl;
  return 0;
}


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

	int H,W,flgW,flgH,flgEL;
	cin >> H >> W;
	vector<vector<char>> table(H,vector<char> (W));
	for (int i=0; i<H; i++){
		for (int j=0; j<W; j++){
			cin >> table.at(i).at(j);
		}
	}
	for (int i=0; i<H; i++){
		flgEL = 0;
		for (int j=0; j<W; j++){
			flgW = 0;
			flgH = 0;
			for (int k=0; k<W; k++){
				if (table.at(i).at(k) == '#'){
					flgW = 1;
					flgEL = 1;
				}
			}
			
			for (int k=0; k<H; k++){
				if (table.at(k).at(j) == '#'){
					flgH = 1;
				}
			}
			if ((flgW == 1) && (flgH == 1)){
				cout << table.at(i).at(j);
			}				
		}
		if (flgEL == 1){
		cout <<  endl;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define T int
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
auto clk=clock();
 
ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}

int main(){
    IOS
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int h, a;
    cin >> h >> a;
    int c = 0;
    while(h > 0){
        h -= a;
        c++;
    }
    cout << c;

    cerr<<endl<<endl<<"Time: "<<fixed<<setprecision(12)<<(long double)(clock()-clk)/CLOCKS_PER_SEC<<" ms"<<endl<<endl;
 
    return 0;
}

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

long long n;
long long c[10][10] = {0};

long long solve();

int main() {
  cin >> n;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0;
  for(int i = 1; i <= n; ++i) {
    long long now = i, pre = i % 10, suf = i % 10;
    while(now > 0) {
      suf = now % 10;
      now /= 10;
    }
    ++c[pre][suf];
  }
  for(int i = 0; i < 10; ++i)
    for(int j = 0; j < 10; ++j) res += c[i][j] * c[j][i];
  return res;
}

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

void solve(long long P, long long Q, long long R)
{
    array<long, 3> cost = {P, Q, R};

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

    cout << cost[0] + cost[1] << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long P;
    scanf("%lld", &P);
    long long Q;
    scanf("%lld", &Q);
    long long R;
    scanf("%lld", &R);
    solve(P, Q, R);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define	foreach( gg,itit )	for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define	mp make_pair
#define	pb push_back
#define sz(a) int((a).size())
#define all(a)  a.begin(), a.end()
#define	debug(ccc)	cout << #ccc << " = " << ccc << endl;
#define present(c,x) ((c).find(x) != (c).end())
const double eps = 1e-8;
#define EQ(a,b) (fabs((a)-(b))<eps)
inline int max(int a,int b){return a<b?b:a;}
inline int min(int a,int b){return a>b?b:a;}
inline ll max(ll a,ll b){return a<b?b:a;}
inline ll min(ll a,ll b){return a>b?b:a;}
const int mod = 1e9+7;
const int N = 1e6+10;
const ll inf = 1e18;

ll power(ll a,ll n){
	if(n==0){
		return 1;
	}
	ll b = power(a,n/2);
	b = b*b%mod;
	if(n%2) b= b*a%mod;
	return b;
}

int add(int a,int b){ return (a+b)%mod;}
int mul(int a,int b){ return (ll)a*b%mod;}

ll dp[2*N];


int main(){
 // 	freopen("nice.in","r",stdin);
 // freopen("nice.out","w",stdout);
	int n; scanf("%d",&n);
	ll sum = n-1, ans = 0;
	REPP(i,n+1,2*n) dp[i]=1;
	dp[n] = n; 
	
	for(int i=n-1;i>0;i--){
		dp[i] = sum + (1ll)*(n-1)*(n-1)%mod + dp[i+1];
		sum += dp[i+2];sum--;		
		sum%=mod;
		// printf("%d %lld\n",i,dp[i]);
	}

	dp[1] = (dp[1]+mod)%mod;
	printf("%lld\n",dp[1]);
	return 0;
}




Measured memory_bytes: 15872
import java.util.Scanner;
 
public class Main {

	public static final MyScanner in = new MyScanner();

	public static void main(String[] args) {

		int N = in.nextInt();

		int breakCnt = 0;
		int wanted = 1;
		for(int i=0; i<N; i++) {
			int target = in.nextInt();
			if (target == wanted) {
				wanted++;
			} else {
				breakCnt++;
			}
		}

		System.out.println(breakCnt == N ? -1 : breakCnt);

	}


	public static class MyScanner{
		Scanner sc = new Scanner(System.in);
		String nextLine() {return sc.nextLine();}
		String next() {return sc.next();}
		int nextInt() {return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next());}
	}
}

Measured memory_bytes: 50976
*T[99]={"OUT OF MAIN PANEL"},X[99],Y[99],V[99],W[99],c[99],w;P(p,d){for(c[p]=0;scanf("%a[^/>]>%d,%d,%d,%d<",T+w,X+w,Y+w,V+w,W+w)&&scanf("%*[^>]>%[<]",&d,c[p]++,P(w++)););}main(n,x,y,i){for(;scanf("%d\n<",&n)*n;)for(w=1,P(0);n--;printf("%s %d\n",T[i],c[i]))for(scanf("%d%d",&x,&y),i=w;--i&&x<X[i]|y<Y[i]|x>V[i]|y>W[i];);}

Measured memory_bytes: 0
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X, Y, Z = MAP()

if Y + 2 * Z > X:
    print(0)
else:
    print(1 + (X - Y - 2 * Z) // (Y + Z))


Measured memory_bytes: 27168
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto a = aryread!string();
    // writeln(a);
    writeln(a[0][0], a[1][0], a[2][0]);
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3640
N = int(input())
h = list(map(int, input().split()))
ans = 0
while max(h) > 0:
    k = 0
    flag = False
    for i in range(N):
        if h[i] > 0:
            h[i] -= 1
            flag = True
        elif flag:
            k += 1
            flag = False
    if flag:
        k += 1
    ans += k

print(ans)

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

using namespace std;
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
void reader(int& x) { int k, m = 0; x = 0; for (;;) { mygc(k); if (k == '-') { m = 1; break; }if ('0' <= k&&k <= '9') { x = k - '0'; break; } }for (;;) { mygc(k); if (k<'0' || k>'9')break; x = x * 10 + k - '0'; }if (m) x = -x; }
void writer(int x, char c) { int s = 0, m = 0; char f[10]; if (x<0)m = 1, x = -x; while (x)f[s++] = x % 10, x /= 10; if (!s)f[s++] = 0; if (m)mypc('-'); while (s--)mypc(f[s] + '0'); mypc(c); }
void writerLn(int x) { writer(x, '\n'); }
#define rep(i,n)for(int i=0;i<n;i++)
deque<int>E[100000];
int u[200000], v[200000], r[200000], ans[200000], d[100000], cnt = 1;
char b[200000], ok[100000]{ 1 };
deque<int>que;

void bfs(int u, int t) {
	que.emplace_back(u);
	while (!que.empty()) {
		int p = que.front(); que.pop_front();
		for (int v : E[p]) {
			if (t) {
				if (d[v] > d[p] && !ok[v]) {
					ok[v] = 1; cnt++; que.emplace_back(v);
				}
			}
			else if (!~d[v]) {
				d[v] = d[p] + 1; que.emplace_back(v);
			}
		}
	}
}
int main() {
	int n, m, q; reader(n); reader(m); reader(q);
	rep(i, m) {
		reader(u[i]); reader(v[i]);
		u[i]--; v[i]--;
		E[u[i]].emplace_back(v[i]); E[v[i]].emplace_back(u[i]);
	}
	memset(d, -1, sizeof(d));
	d[0] = 0; bfs(0, 0);
	rep(i, m) {
		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);
	}
	rep(i, n)E[i].clear();
	rep(i, q) {
		reader(r[i]); r[i]--;
		b[r[i]] = 1;
	}
	rep(i, m) {
		if (!b[i]) {
			if (d[v[i]] > d[u[i]]) {
				E[u[i]].emplace_back(v[i]);
			}
		}
	}
	bfs(0, 1);
	for (int i = q - 1; i >= 0; i--) {
		ans[i] = n - cnt;
		if (d[v[r[i]]] > d[u[r[i]]] && !ok[v[r[i]]]) {
			E[u[r[i]]].emplace_back(v[r[i]]);
			if (ok[u[r[i]]]) {
				cnt++; ok[v[r[i]]] = 1;
				bfs(v[r[i]], 1);
			}
		}
	}
	rep(i, q)writerLn(ans[i]);
}

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

int Bubble_sort(int A[], int N)
{
	int c = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = N - 1; j > i; j--)
		{
			if (A[j] < A[j-1])
			{
				swap(A[j], A[j-1]);
				c++;
			}
		}
	}
	for (int i = 0; i < N; i++)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << "\n";
	return c;
}
int main()
{
	int N;
	cin >> N;
	int A[N];
	for (int i = 0; i < N; i++)
		cin >> A[i];
	
	int c = Bubble_sort(A, N);
	cout << c << endl;
}




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

void solve() {
    int H, W, count = 0;
    cin >> H >> W;
    vector<string> A(H);
    for (int i = 0; i < H; i++) {
        cin >> A.at(i);
        for (int j = 0; j < W; j++) if (A.at(i).at(j) == '#') count++;
    }
    if (count != H + W - 1) {
        cout << "Impossible" << endl;
        return;
    }
    int i = 0, j = 0;
    while (i < H - 1 || j < W - 1) {
        bool r = false, d = false;
        if (i < H - 1 && A.at(i + 1).at(j) == '#') d = true;
        if (j < W - 1 && A.at(i).at(j + 1) == '#') r = true;
        if (!(d ^ r)) {
            cout << "Impossible" << endl;
            return;
        }
        if (d) i++;
        if (r) j++;
    }
    cout << "Possible" << endl;
    return;
}

int main() {
    solve();
}

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

string s;
cin>>s;
if(s=="zyxwvutsrqponmlkjihgfedcba") {cout<<"-1";
                                     system("pause");
                                     return 0;}
for(int i=0;i<s.size();i++)
for(int j=i+1;j<s.size();j++)
    if(s[i]==s[j]) {cout<<"-1";
                    system("pause");
                    return 0;}
string t="abcdefghijklmnopqrstuvwxyz";
for(int i=97;i<=122;i++)
for(int j=0;j<s.size();j++)
    if((char)i==s[j]) t[i-97]=' ';
for(int i=0;i<=25;i++)
    if(t[i]!=' ') {cout<<s<<t[i];
                   system("pause");
                   return 0;}   
for(int i=0;i<=25;i++)
    t[i]=s[i];
bool bol=true;
int cnt=0;
for(int i=25;i>=0;i--)
    {for(char j=(char)((int)s[i]+1);j<='z';j++)
        {s[i]=j;
         for(int ii=0;ii<=25;ii++)
         for(int jj=0;jj<=25;jj++)
             if(s[ii]==s[jj] and ii!=jj and s[ii]!=' ') {bol=false;
                                                         break;}
         for(int ii=0;ii<=25;ii++)
             if(s[ii]==t[ii]) cnt++;
         if(cnt>=26) bol=false;
         if(bol)  {cout<<s;
                   system("pause");
                   return 0;}
         cnt=0;
         bol=true;}
     s[i]=' ';
     if(s[i-1]!=' ') s[i-1]=(char)((int)s[i-1]+0.5);}  
  
system("pause");
return 0;
}

Measured memory_bytes: 504
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://agc011.contest.atcoder.jp/tasks/agc011_a>
問題文============================================================
 高橋空港には，毎日飛行機で N 人の乗客が到着します． i 番目の乗客は時刻 Ti に到着します．
 
 高橋空港に到着する乗客は全員バスで市内へ移動します．
 どのバスも定員は C 人であり，C 人以下の乗客を乗せることができます．
 飛行機の乗客は，飛行機の到着時刻よりも早く出発するバスには乗ることができません．
 また，飛行機の到着時刻から K の時間が経過した後にもバスに乗れていないと，怒り出してしまいます．
 そのため，i 番目の乗客は，出発時刻が Ti 以上 Ti+K 以下であるようなバスに乗れるようにしないといけません．
 
 この条件のもとで，うまくバスの出発時刻を定めるとき，必要なバスの数の最小値を求めてください．
 ただし，バスの出発時刻は必ずしも整数である必要はなく，同じ時刻に出発するバスが複数あってもかまいません．
=================================================================

解説=============================================================

 乗客を時間に関してソートして、
 順番に、定員or時間に関して条件に反しない限りバスに乗せていけば良い
 
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N,C,K; cin >> N >> C >> K;
    vector<ll> T(N);
    for(auto &in:T) cin >> in;
    sort(T.begin(),T.end());
    ll ans = 1;
    ll c = 0;
    ll from = 0;
    for(int i = 0; i < N;i++){
        if(c == C){
            ans++;
            c = from = 0;
        }
        
        if(c == 0){
            c++;
            from = T[i];
        }else{
            if(T[i] - from<=K){
                c++;
            }else{
                ans++;
                c = 1;
                from = T[i];
            }
        }
    }
    cout << ans << endl;
	return 0;
}


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

const int mod = 1e9 + 7;
map<ll, ll> p;

inline ll read() {
	ll s = 0, f = 1;
	char ch;
	for(; ch < '0' || ch > '9'; ch = getchar())	if(ch == '-')	f = -1;
	for(; ch >= '0' && ch <= '9'; ch = getchar())	s = (s << 1) + (s << 3) + ch - '0';
	return s * f;
}

inline void print(ll x) {
	if(x < 0)	putchar('-'), x = -x;
	if(x > 9)	print(x / 10);
	putchar(x % 10 + '0');
}

inline ll work(ll x) {
	if(p[x])	return p[x];
	else return p[x] = (work(x >> 1) + work((x - 1) >> 1) + work((x - 2) >> 1))%mod;
}

int main() {
	p[0] = 1;
    p[1] = 2;
	print(work(read()));
    puts("");
    return 0;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  for(int i = 1; i <= b; i++){
    if((a * i) % b == c){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int main() {
	int N, Q, a, b;
	scanf("%d%d", &N, &Q);
	vector<vector<int>> G(N + 1);
	vector<int> S(N + 1), q(N + 1, 0), f(N + 1, 0);
	rep(i, 0, N - 1)scanf("%d%d", &a, &b), G[a].push_back(b), G[b].push_back(a);
	rep(i, 0, Q)scanf("%d%d", &a, &b), q[a] += b;
	deque<int> path;
	path.push_front(1);
	f[1] = 1;
	S[1] = q[1];
	while (!path.empty()) {
		int p = path.front();
		path.pop_front();
		for (auto v : G[p]) {
			if (!f[v]) {
				f[v] = 1;
				S[v] = S[p] + q[v];
				path.push_front(v);
			}
		}
	}
	rep(i, 1, N + 1) {
		printf("%d\n", S[i]);
	}
	return 0;
}

Measured memory_bytes: 17140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.next().split("");
		int answer = 0;
		int answerKoho = 0;
		for(int i =0;i < s.length;i++) {
			if(s[i].equals("A")) {
				answerKoho++;
			}
			else if(s[i].equals("C")) {
				answerKoho++;
			}
			else if(s[i].equals("G")) {
				answerKoho++;
			}
			else if(s[i].equals("T")) {
				answerKoho++;
			}else {
				if(answerKoho > answer) {
					answer = answerKoho;
				}
				answerKoho = 0;
			}
			if(i == s.length-1) {
				if(answerKoho > answer) {
					answer = answerKoho;
				}
			}
		}
		System.out.println(answer);

	}
}

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

#define sc(x) scanf("%d",&x);
#define rep(x ,n) for(int x=0; x<n; x++)
#define ll long long
#define finish(x) return cout << x << endl,0;
#define scarr(a,n) for(int x=0; x<n; x++)scanf("%d",&a[x]);

int main()
{
    int a ,b ,t;
    sc(a)sc(b)sc(t)
    cout << (t/a)*b << endl;
}


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


const int MAX_N = 2 * 10e5;
int N, K;
int H[MAX_N];

void Main() {
  cin >> N >> K;
  rep(i, N) {
    cin >> H[i];
  }

  sort(H, H + N);

  ll ans = 0;
  rep(i, N - K) {
    ans += H[i];
  }

  cout << ans << endl;
}

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

Measured memory_bytes: 1024
val MaxNodes = 1000
val NewState = 1
val ActiveState = 2
val FinishState = 3
val nodeStatus = IntArray(MaxNodes, { NewState })
val edges = Array(MaxNodes) { mutableSetOf<Int>() }

fun main(args: Array<String>) {
    val (N, M) = readInputLine().split(" ").map { it.toInt() }

    for (i in 1..M) {
        val (A, B) = readInputLine().split(" ").map { it.toInt()  - 1 }
        edges[A].add(B)
    }

    var ret = existsCycle()

    if (!ret.first) {
        println(-1)
        return
    }
    
    ret.third.reverse()
    
    while (true) {
        // 次数チェック
        var routeArr = ret.third.toIntArray()
        
        var ok = true
        var unUsedStart = -1
        var unUsedEnd = -1
        for ((i, n) in routeArr.withIndex()) {
            val intersect = ret.third.intersect(edges[n])
            if (intersect.size != 1) {
                ok = false
                for (e in intersect) {
                    if (routeArr[(i + 1) % ret.third.size] != e) {
                        unUsedStart = n
                        unUsedEnd = e
                        break
                    }
                }
                break
            }
        }
        if (ok) {
            println(ret.third.size)
            for (n in ret.third) {
                println(n + 1)
            }
            return
        }

        // 余分なノードを除去
        val visited = mutableListOf(unUsedEnd)
        var current = edges[unUsedEnd].find { ret.third.contains(it) }!!
        while (current != unUsedStart) {
            visited.add(current)
            current = edges[current].find { ret.third.contains(it) }!!
        }
        visited.add(unUsedStart)
        ret = ret.copy(third = visited)
    }
}

fun readInputLine(): String {
    return readLine()!!
}

fun existsCycle(): Triple<Boolean, Boolean, MutableList<Int>> {
    for (v in 0 until MaxNodes) {
        if (nodeStatus[v] == NewState) {
            val ret = existsCycleSub(v)
            if (ret.first) {
                return ret
            }
        }
    }
 
    return Triple(false, false, mutableListOf<Int>())
}
 
fun existsCycleSub(source: Int): Triple<Boolean, Boolean, MutableList<Int>> {
    nodeStatus[source] = ActiveState
    
    for (e in edges[source]) {
        if (nodeStatus[e] == ActiveState) {
            return Triple(true, false, mutableListOf(e, source))
        } else if (nodeStatus[e] == NewState) {
            val ret = existsCycleSub(e)
            if (ret.first) {
                if (ret.second) {
                    return ret
                }
                if (ret.third.contains(source)) {
                    return ret.copy(second = true)
                }
                ret.third.add(source)
                return ret
            }
        }
    }
    nodeStatus[source] = FinishState

    return Triple(false, false, mutableListOf<Int>())
}


Measured memory_bytes: 52864
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main(){
    char x,y;
    cin >> x >> y;
    ll a=(ll)(x-'A');
    ll b=(ll)(y-'A');
    ll d=a-b;
    if(d>0){
        cout << '>' << endl;
    }
    else if(d==0){
        cout << '=' << endl;
    }
    else{
        cout << '<' << endl;
    }
}


Measured memory_bytes: 3588
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  Name:- OMHARI 
  Institution:- UNIVERSIT OF CALCUTTA(INFORMATION TECHNOLOGY)
  Email:- omharicu@gmail.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include<bits/stdc++.h>
using namespace std; 

#define F first
#define S second
#define ull unsigned long long
#define ll long long
#define ul unsigned long
#define db double
#define pb push_back
#define mp make_pair
#define el "\n"
#define vll vector <ll>
#define vl vector <long int>
#define vi vector <int>
#define all(v) (v.begin(), v.end()) 
#define rall(v) (v.rbegin(), v.rend()) 
const ll mod = 1e9+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
     #endif
    /***************-Code starts from here-***************/
    int a,b;
  cin>>a>>b;
  cout<<a*b;
    return 0; 
} 

Measured memory_bytes: 3612
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 998244353;
 const ll INFL = (1LL << 60);
 const int INFI = (1 << 30);

  ll pow_mod(ll x, ll n) {
    x %= MOD;
    if (n == 0) return 1;
    else if (n % 2 == 1) return (x * pow_mod(x, n - 1)) % MOD;
    else return pow_mod((x * x) % MOD, n / 2) % MOD;
  }

  const int MAX = 200002;

  vector<ll> fac(MAX), finv(MAX), inv(MAX);

  // テーブルを作る前処理
  void COMinit() {
     fac.at(0) = fac.at(1) = 1;
     finv.at(0) = finv.at(1) = 1;
     inv.at(1) = 1;
     for (int i = 2; i < MAX; i++){
         fac.at(i) = fac.at(i - 1) * i % MOD;
         inv.at(i) = MOD - inv.at(MOD % i) * (MOD / i) % MOD;
         finv.at(i) = finv.at(i - 1) * inv.at(i) % MOD;
     }
  }

  ll COM(int n, int k){
     if (n < k) return 0;
     if (n < 0 || k < 0) return 0;
     return fac.at(n) * (finv.at(k) * finv.at(n - k) % MOD) % MOD;
  }

 int main() {
   ll N, M, K;
   cin >> N >> M >> K;
   ll ans = 0;

   COMinit();

   for (ll i = 0; i <= K; i++) {
     ans += COM(N - 1, i) * pow_mod(M - 1, N - i - 1) % MOD;
     ans %= MOD;
   }
   ans = ans * M % MOD;
   cout << ans << endl;
 }


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

int N, K;
string S;

int main() {
  cin >> N >> K >> S;
  S[K - 1] = (S[K - 1] - 'A') + 'a';
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	ll K, N;
	ll P[5001];
	ll C[5001];
	cin >> N >> K;
	for(int i = 1; i <= N; i++){
		cin >> P[i];
	}
	for(int i = 1; i <= N; i++){
		cin >> C[i];
	}
	
	ll ans = -10000000000000;
	for(int i = 1; i <= N; i++){
		
		// 周期を調べる
		ll cycle = 0;
		{
			int place = i;
			for(int j = 1; j <= N; j++){
				place = P[place];
				if(place == i){
					cycle = j;
					break;
				}
			}
		}
		
		ll r = K % cycle;
		
		// 1週まで
		{
		ll tempAns = 0;
		ll place = i;
			for(int j = 0; j < K && j < N; j++){
			tempAns += C[P[place]];
			place = P[place];
			ans = max(ans, tempAns);
		}
		}
		// 2週以上するなら
		if(K > cycle){
			ll tempAns = 0;
			ll oneCycle = 0;
			ll place = i;
			for(int j = 0; j < cycle; j++){
				oneCycle += C[P[place]];
				place = P[place];
			}
			tempAns += oneCycle * (K/cycle - 1);
			ans = max(ans, tempAns);
			for(int j = 0; j < cycle + r; j++){
				tempAns += C[P[place]];
				place = P[place];
				ans = max(ans, tempAns);
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

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

    int ans=1;
    for(int i=1;i<N;i++){
        if(S[i]!=S[i-1]) ans++;
    }
    cout << ans << endl;

}

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

int mm(int a, int b) {
  if(a == 0) {
    if(b == 0) {
      return 0;
    }
    return 1;
  }
  if(a == 1) {
    if(0 <= b && b <= 2) {
      return 1;
    }
  }
  return 0;
}

int main() {
string S;
cin >> S;
int a = S[0] - '0';
int b = S[1] - '0';
int c = S[2] - '0';
int d = S[3] - '0';
  
int x = mm(a,b);
int y = mm(c,d);
  
if(x && y) {
  cout << "AMBIGUOUS" << endl;
} else if(x && !y) {
  cout << "MMYY" << endl;
} else if(!x && y) {
  cout << "YYMM" << endl;
} else if(!x && !y) {
  cout << "NA" << endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lmax LLONG_MAX
#define lmin LLONG_MIN
#define imax INT_MAX
#define imin INT_MIN
#define f(i,a,b) for(long long i=a;i<b;i++)
#define rf(i,a,b) for(long long i=a;i>=b;i--)
#define tc long long t;cin>>t;while(t--)
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define input(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define output(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" ";
#define up upper_bound
#define lo lower_bound
#define endl "\n"
#define mem(a) memset(a,-1,sizeof(a))
#define ll long long
#define umap unordered_map

ll modularExponentiation(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modularExponentiation((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

}
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    ll mod=1000000007;

    ll n;
    cin>>n;
    ll a[n];
    input(a,n);
    ll p=0;
    ll q=0;

    f(i,0,n){
        a[i]=a[i]%mod;
        p+=a[i];
        p%=mod;
        q+=(a[i]*a[i])%mod;
        q%=mod;
    }

    ll r = (p*p)%mod;
    ll x=modularExponentiation(2,mod-2,mod);
    cout<<((r-q+mod)%mod*x)%mod;

    return 0;
}

Measured memory_bytes: 5180
#include <stdio.h>
#include <math.h>

int main(void){
    int w,h,temp;

	while(1){
		scanf("%d %d", &w, &h);
		temp = h;
		for(;w != 0;w--){
			for(;h != 0;h--){
				printf("#");
			}
			printf("\n");
			h = temp;
		}
		if(w == 0 && h == 0){
			break;
		}
		printf("\n");
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> V(N);
  for (int i = 0, x, y; cin >> x >> y; i++) V.at(i) = {x, y};
  
  sort(V.begin(), V.end());
  int cnt = 0;
  long double sum = 0;
  do {
    for (int i = 0; i + 1 < N; i++) sum += hypot(V.at(i).first - V.at(i + 1).first, V.at(i).second - V.at(i + 1).second);
    cnt++;
  } while (next_permutation(V.begin(), V.end()));

  cout << fixed << setprecision(6) << sum / cnt << "\n";
}

Measured memory_bytes: 256