akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;
typedef unsigned long long uli;

#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define test ll t;cin>>t;while(t--)
#define nin ll n;cin>>n;
#define ain ll n;cin>>n;ll arr[n];for(ll i=0;i<n;i++){cin>>arr[i];}
#define out(arr,n) for(ll i=0;i<n;i++){cout<<arr[i]<<" ";}cout<<'\n';
#define fr(i,n) for(ll i=0;i<n;i++)
#define fri(i,l,n) for(ll i=l;i<n;i++)
#define sr(a,n) sort(a,a+n);
#define gr(a,n) sort(a,a+n,greater<ll>());
#define cen cout<<endl;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>


const ll MAX = 1e5 + 10;
const ll mod = 1e9 + 7;


int main() {
    fastio;
    //test{}
    //test{ ain;}
    ll k;
    cin>>k;
    string s;
    cin>>s;
    ll len = s.length();
    if(len<=k){
        cout<<s;
    }else{
    for(ll i=0;i<k;i++){
      cout<<s[i];
    }
    cout<<"...";}








}


Measured memory_bytes: 3636
import sys
#input = sys.stdin.buffer.readline

def main():
    N,K = map(int,input().split())
    S = str(input())
    if S[0] == "1":
        z,o = [0],[]
    else:
        z,o = [0],[0]
        
    for i in range(N-1):
        if S[i+1] != S[i]:
            if S[i] == "1":
                o.append(i+1)
            else:
                z.append(i+1)
                
    o.append(N)            
    if S[-1] == "0":
        z.append(N)

    l = len(o)
    if l == 1:
        print(N)
    else:
        if K+1 > l:
            print(N)
        else:
            ans = 0
            for i in range(l-K):
                u = o[i+K]-z[i]
                ans = max(ans,u)
            print(ans)
        
if __name__ == "__main__":
    main()


Measured memory_bytes: 7160
"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.trim().split(/ |\n/), cid = 0;

function main() {
    let ans = cin[0].split("").map(x => x == '?' ? 'D' : x);
    console.log(ans.join(''));
}
main();


Measured memory_bytes: 41964
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define nn int n=0
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool; 
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
int x = 0, y = 0;
//BEGIN OF CODE.
int main(void){
	int a, b;
	cin >> a >> b;
	if (a < 6)cout << 0 << rt;
	else if (a < 13)cout << b / 2 << rt;
	else cout << b << rt;
	please AC;
}
//THE END.

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

int main() {
	int n;
	cin >> n;
	int y = 0;
	double b = 0;
	for(int i=0;i<n;i++)
	{
		double x;
		string jb;
		cin >> x >> jb;
		if(jb == "JPY")
		{
			y += x;
		}
		else
		{
			b += x;
		}
	}
	double k = y + (b * 380000);
	cout << k << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int Maxn=10000+10;
int n,k;
int a[Maxn];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)
	scanf("%d",a+i);
	sort(a+1,a+1+n);
	int ans=0;
	for(int i=1;i<=k;++i)
	ans+=a[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3832
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n : u32 = read();

    for i in 1..n+1
    {
        let mut count = 0;

        for x in 1..n+1
        {
            let mut is_yz_1 = false;

            for y in 1..n+1
            {
                let mut is_z_1 = false;

                for z in 1..n+1
                {
                    // let ret = x.pow(2)+y.pow(2)+z.pow(2)+x*y+y*z+z*x;
                    let ret = (x+y+z)*(x+y+z)-x*y-y*z-z*x;
                    // eprintln!("  ({}) : ({},{},{}) -> {}", i, x, y, z, ret);

                    
                    if ret == i
                    {
                        count += 1;
                        // z_add = true;
                    }
                    else if ret > i
                    {
                        if z == 1
                        {
                            is_z_1 = true;

                            if y == 1
                            {
                                is_yz_1 = true;
                            }
                        }
                        break;
                    }
                }
                
                if is_z_1
                {
                    break;
                }
            }

            if is_yz_1
            {
                break;
            }
        }

        println!("{}", count);
    }
}


Measured memory_bytes: 2012
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
const int INF = 1<<29;
typedef long long ll;

int main(){
  string S;cin >> S;
  bool flg = true;
  if(S.size() % 2 == 0){
    for(int i = 0;i < S.size();i += 2)
      if(S[i] != 'h' || S[i + 1] != 'i')
        flg = false;
  }else{
    flg = false;
  }
  cout << ((flg) ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	string S;

	cin >> S;

	int c[255] = {0};
	for (int i = 0; i < 4; i++) {
		c[S[i]]++;
	}
	int a = 0;
	for (int i = 0; i < 255; i++) {
		if (c[i] == 2) {
			a++;
		}
	}
	if (a == 2) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
using namespace std;
int main()
{
    int a, b, k;
    set<int> ans;
    cin >> a >> b >> k;
    for(int i = a; i <= b && k > i - a; i++){
        ans.insert(i);
    }
    for(int i = b; i >= a && k > b - i ; i--){
        ans.insert(i);
    }
    auto itr = ans.begin();
    while(itr != ans.end()){
        cout << *itr << endl;
        itr++;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

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


//区間最大
struct RBQ{
    ll n;
    vector<ll>data;
    RBQ(ll vs){
        n=1;
        while(n<vs)n*=2;
        data.resize(2*n-1,0);
    }
    void update(ll k,ll a){
        k+=n-1;
        data[k]=a;
        while(k>0){
            k=(k-1)/2;
            data[k]=max(data[2*k+1],data[2*k+2]);
        }
    }
    ll query(ll a,ll b,ll k,ll l,ll r){
        if(r<=a||b<=l)return -inf;
        if(a<=l&&r<=b){
            return data[k];
        }else{
            ll vl=query(a,b,2*k+1,l,(l+r)/2);
            ll vr=query(a,b,2*k+2,(l+r)/2,r);
            return max(vl,vr);
        }
    }
    ll query(ll a,ll b){return query(a,b,0,0,n);}//[a,b)の最大値
};
//////////////////////////////////////////////////////


int main(){fastio
    ll n;cin>>n;
    ll h[n];rep(i,0,n-1)cin>>h[i];
    ll a[n];rep(i,0,n-1)cin>>a[i];
    RBQ u(n+1);
    ll dp[n];
    rep(i,0,n-1){
        dp[i]=u.query(0,h[i])+a[i];
        u.update(h[i],dp[i]);
    }
    cout<<u.query(0,n+1)<<endl;
    
    return 0;
}



Measured memory_bytes: 9088
//解説AC
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

ll N,X,Y;

vector<vector<int>> to; vector<bool> visited;
vector<int> v;

void dfs( int i , int depth){
  if (depth % 2){ //このときdepthは奇数→　i　は　必ず　X　集合上の点
    X++;} else{ Y++;}
  visited[i] = true;
  v.push_back( i);
  for(int j = 0; j < (int) to[i].size(); j++){
    int k = to[i][j];
    if( visited[k] ){ continue;}
    else{ dfs( k, depth + 1);}}
}
    

int main(){
  cin >> N; to.resize(201010); visited = vector<bool> ( 201010, false);
  for(int i = 0; i < N; i++){ int x,y; 
   cin >> x >> y; 
   to[x].push_back( y + 100010);
   to[y + 100010].push_back(x);}
  
  ll ans = 0;
  
  for(int i = 0; i < 201010; i++){
    if( visited[i] || !to[i].size()){ continue;}
    
     X = 0; Y = 0;  v.clear();
    dfs( i , 1); //iノードからdepth1 で　開始して、 連結成分の大きさを更新( X, Y);
    ll res = 0;
    for(int p = 0; p < (int) v.size(); p++){ res += (ll)to[v[p]].size();}
    res /= 2;
    ans += X * Y - res;}
  
  cout << ans << endl; return 0;}
  
  

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

using namespace std;
using p = pair<int,int>;
using ll = long long;
p fl(int x){
    int i = x%10;
    int j = x;
    while(j/10){
        j/=10;
    }
    return make_pair(j,i);
}

ostream& operator<<(ostream& os,const p& i){
	os << i.first << " " << i.second<< " ";
	return os;
}

int main()
{
    int n;
    cin >> n;
    map<p,int> m;
    for(int i=1;i<=n;i++) {
      m[fl(i)]++;
    }
  
    ll ans =0;
    for(int i=1;i<=n;i++) {
      auto s = fl(i);
      ans+=m[make_pair(s.second,s.first)];
    }
  
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]
ss = [''.join(sorted(s_tmp)) for s_tmp in s]
ss.sort()
count = 1
ans = 0
for i in range(n-1):
    if ss[i] == ss[i+1]:
        count += 1
    else:
        ans += int((count*(count-1))/2)
        count = 1
ans += int((count*(count-1))/2)
print(ans)


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

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
typedef long long ll;

int main() {
	ll x;
	cin >> x;
	ll point = 0;
	point += x / 11 * 2;
	if (x % 11 > 6) {
		point += 2;
	}
	else if (x % 11 > 0) {
		point++;
	}
	cout << point << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#include<functional>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;


int main(){
	ll n, k; cin >> n >> k;
	ll num = 1;
	rep(i, n){
		if (num + k > num * 2) num *= 2;
		else num += k;
	}cout << num << endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
s = {}
for i in 1..n do
  str = gets.chomp
  if !s[str]
    s[str] = 1
  else
    s[str] += 1
  end
end
m = gets.chomp.to_i
t = {}
for i in 1..m do
  str = gets.chomp
  if !t[str]
    t[str] = 1
  else
    t[str] += 1
  end
end

ans = 0
for str in s.keys do
  if ans < s[str].to_i - t[str].to_i
    ans = s[str].to_i - t[str].to_i
  end
end
printf("%d\n",ans)

Measured memory_bytes: 1788
#include<iostream>
#define rep(i,n) for((i)=0;(i)<(n);i++)

using namespace std;

int v[3],n,c;
string s;

int f(){
  n++;
  int r;
  if(s[n-1]=='(')r=f(),n++,r=s[n-1]=='+'?max(r,f()):min(r,f()),n++;
  if(isdigit(s[n-1]))r=s[n-1]-'0';
  if(isupper(s[n-1]))r=v[s[n-1]-'P'];
  if(s[n-1]=='-')r=2-f();
  return r;
}

int main(){
  while(cin >> s,s!="."){
    c=0;
    rep(v[0],3)rep(v[1],3)rep(v[2],3)n=0,c+=f()/2;
    cout << c << endl;
  }
  return 0;
}

Measured memory_bytes: 1184
#include<iostream>
#include <cstdio>
#include<cstring>
#include<string>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<list>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
#define LEN 100005
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(ll i=0;i<n;i++)
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) { if (x % y == 0) return y;else return LGCD(y, x % y); }
ll LLCM(ll x, ll y) { return x * y / LGCD(x, y); }

int GCD(int x, int y) { if (x % y == 0) return y;else return GCD(y, x % y); }
int LCM(int x, int y) { return x * y / GCD(x, y); }
ll dpc[10000][10000];

//void nCr(ll n, ll r) {
//	ll ans = 1;
//	for (int i = n; i > n - r; --i) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; ++i) {
//		ans = ans / i;
//	}
//	printf("%d",ans);
//}

ll combination(ll n, ll r) {
	if (n == r) { return dpc[n][n] = 1; }
	else if (r == 0) { return dpc[n][0] = 1; }
	else if (r == 1) { return dpc[n][1] = n; }
	else if (dpc[n][r]) { return dpc[n][r]; }
	else { return dpc[n][r] = combination(n - 1, r - 1) + combination(n - 1, r); }
}

//cout << fixed << setprecision(10);

int main() {
	ll n;
	string s;
	cin >> n >> s;
	ll  ans = 0;
	Rep(i,10) {
		Rep(j,10) {
			Rep(k,10) {
				int count = 0;
				Rep(l, s.size()) {
					if (s[l] - '0' == i&&count==0) count++;
					else if (s[l] - '0' == j && count == 1)count++;
					else if (s[l] - '0' == k && count == 2) {
						count++;break;
					}
				}if (count == 3)ans++;

			}
		}
	}

	cout << ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
/////////////////////////(๑•﹏•๑｀)/////////////////////////
int n,m;
int a[200000];
int b[200000];

int binary_search(int key){
	// <= left never satisfy
	// right <= always satisfy

	int left = -1; 
	int right = n; // index of size + 1;

	while(right - left > 1){
			int mid = left + (right - left) / 2;

			if (a[mid] >= key) right = mid;
			else left = mid;
	}

	// left is the maximum that don't satisfy the condition.
	// right is the minimum that satisfies the condtion.

	return right; 

}

int main(){
	SCD(n);	
	REP(i,n){
		int x; SCD(x);
		a[i] = x;
	}

	SCD(m);
	REP(i,n){
		int x; SCD(x);
		b[i] = x;
	}

	int ans = 1;

	REP(i,m){
		int k = b[i];
		if (a[binary_search(k)] != k) ans = 0;
	}

	PRINTD(ans);
	return 0;
}
	
	



Measured memory_bytes: 4780
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    int R,G;
    cin>>R>>G;
    
    cout<<G+G-R<<endl;
}



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

int main(){
  int n;
  cin>>n;
  ll vec[n],veca[n],vecb[n];
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  for(int i=0;i<n;i++){
    veca[i]=25000*(i+1);
    vecb[i]=25000*(n+1)-veca[i];
  }
  for(int i=0;i<n;i++){
    veca[vec[i]-1]+=i;
  }
  for(int i=0;i<n;i++){
    cout<<veca[i]<<" ";
  }
  cout<<endl;
  for(int i=0;i<n;i++){
    cout<<vecb[i]<<" ";
  }
}

Measured memory_bytes: 1152
using System;

namespace ABC067B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] bufs = Console.ReadLine().Split(' ');
            int N = int.Parse(bufs[0]);
            int K = int.Parse(bufs[1]);
            int[] A = new int[N];

            bufs = Console.ReadLine().Split(' ');
            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse(bufs[i]);
            }

            int res = 0;
            Array.Sort(A);
            for (int k = 1; k <= K; k++)
            {
                res += A[N - k];
            }
            
            Console.WriteLine(res);
        }
    }
}


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

int main() {
	string str;
	cin >> str;

	int n = str.length();
	if (n <= 1)
		cout << "-1 -1";
	else  {
		bool flag = false;
		if (str[1] == str[0]) {
			cout << "1 2";
			flag = true;
		}
		else {
			for (int i=2; i<str.length(); i++) {
				if (str[i] == str[i-1]) {
					cout << i-1+1 << " " << i+1;
					flag = true;
					break;
				}
				if (str[i] == str[i-2]) {
					cout << i-2+1 << " " << i+1;
					flag = true;
					break;
				}
			}
		}

		if (flag == false) {
			cout << "-1 -1";
		}
	}
}

Measured memory_bytes: 3756
//https://atcoder.jp/contests/abc143/tasks/abc143_d

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main(){

    int n;
    cin >> n;

    vector<int> Ln(n);

    for(int i = 0; i < n; i++){
        cin >>  Ln[i];
    }

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

    int ans = 0;

    for (int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            for(int k = n - 1 ; k > j; k--){

                if(Ln[k] < Ln[i] + Ln[j]){
                    ans += k - j;
                    break;                    
                }

            }
        }
    }

    cout << ans << endl;

    return 0;

}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    ll n, w, w_0, wt, v;
    cin >> n >> w;
    vvll vals(4);
    for (int i = 0; i < n; i++){
        cin >> wt >> v;
        if (i == 0) w_0 = wt;
        vals[wt - w_0].push_back(v);
    }
    for (int i = 0; i < 4; i++){
        sort(all(vals[i]), greater<ll>());
    }

    vvll pfx(4, vll(n+1, 0));
    for (int i = 0; i < 4; i++){
        ll sm = 0LL;
        for (int j = 1; j <= vals[i].size(); j++){
            sm += vals[i][j-1];
            pfx[i][j] = sm;
        }
    }

    ll ans = 0LL;
    for (int i = 0; i <= vals[0].size(); i++){
        for (int j = 0; j <= vals[1].size(); j++){
            for (int k = 0; k <= vals[2].size(); k++){
                for (int l = 0; l <= vals[3].size(); l++){
                    // Take i items of w_0, j of w_1, k of w_2, l of w_3
                    wt = (w_0 * (i + j + k + l)) + j + 2*k + 3*l;
                    if (w >= wt){
                        v = pfx[0][i] + pfx[1][j] + pfx[2][k] + pfx[3][l];
                        ans = max(ans, v);
                    }
                }
            }
        }
    }

    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define INFll (1LL << 60)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n;
    string s;
    cin >> n >> s;

    if(n&1) {
        cout << "No" << '\n';
        return 0;
    }
    int tmp = n/2;
    bool flag = s.substr(0, tmp) == s.substr(tmp, tmp);
    cout << (flag ? "Yes" : "No") << '\n';
    return 0;
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main()
{
    lli n, k;
    cin >> n >> k;

    lli sum = k;
    for(int i=(n-1); i>0; i--){
        sum *= (k-1);
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
/**
 * author:  virenkathiriya96
 * created: 2020.08.31 14:34:20 
**/

#include<bits/stdc++.h>

using namespace std;

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int c;
  cin >> c;
  cout << ((c >= 30) ? "Yes" : "No") << "\n";
  return 0;
}

Measured memory_bytes: 3656
def solve():
    n = int(input())
    oc = [list(map(int, input().split())) for _ in range(n)]
    prof = [list(map(int, input().split())) for _ in range(n)]

    inf = 10 ** 16
    ans = - inf

    for a in range(1, 1 << 10):
        res = 0
        for i in range(n):
            cnt = 0
            for x in range(10):
                if a >> x & 1 and oc[i][x] == 1:
                    cnt += 1
            res += prof[i][cnt]
        ans = max(ans, res)
    print(ans)


solve()


Measured memory_bytes: 9212
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        aa: [(f64, String); n]
    }
    let mut sum: f64 = 0.0;
    for (x,u) in aa {
        sum += match &u[..] {
            "JPY" => x,
            "BTC" => x * 380000.0,
            _     => panic!()
        };
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
         
        if (a > b)
            System.out.println("a > b");
        else if (a < b)
            System.out.println("a < b");
        else
            System.out.println("a == b");
        scanner.close();
    }
}


Measured memory_bytes: 26116
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int a[3],sa1,sa2,ans=0;
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    while(a[0]!=a[1]||a[1]!=a[2]){
        sa1=abs(a[2]-a[0]);sa2=abs(a[2]-a[1]);
        if(sa1==1&&sa2==1){a[0]++;a[1]++;}
        else a[0]+=2;
        ans++;
        sort(a,a+3);
    }
    cout<<ans<<endl;
    
    
    return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<int>u(N-1),v(N-1),w(N-1);
  for(int i=0;i<N-1;i++)cin>>u[i]>>v[i]>>w[i];
  for(int i=0;i<N-1;i++)u[i]--,v[i]--;
  struct E{
    int to,cost;
  };
  vector<vector<E>>e(N);
  for(int i=0;i<N-1;i++){
    e[u[i]].push_back({v[i],w[i]});
    e[v[i]].push_back({u[i],w[i]});
  }
  for(int i=0;i<N-1;i++)w[i]%=2;
  vector<bool>used(N,false);
  vector<int>ans(N);
  ans[0]=0;
  queue<int>q;
  q.push(0);
  while(q.size()){
    int now=q.front();
    int color=ans[now];
    q.pop();
    if(used[now])continue;
    used[now]=true;
    for(auto it:e[now]){
      int next=it.to;
      if(used[next])continue;
      int cost=it.cost;
      ans[next]=(cost+color)%2;
      q.push(next);
    }
  }
  for(auto it:ans)cout<<it<<endl;
  return 0;
}


Measured memory_bytes: 8064
#include<stdio.h>

int main(){
    int N,K;
    char S[50];
    scanf("%d %d",&N,&K);
    scanf("%s",&S);
    if(S[K-1]=='A') S[K-1]='a';
    else if(S[K-1]=='B') S[K-1]='b';
    else S[K-1]='c';

    printf("%s",&S);
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

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

signed main() {
    cin >> N;
    vi a(N);
    cin >> a;
    vector<ll> v(N - 1);
    REPS(i, N - 1) {
        v[i - 1] = a[0] ^ a[i];
    }
    REP(i, N - 1) {
        ans ^= v[i];
    }
    X = ans ^ a[0];
    cout << X << " ";
    REP(i, N - 1) {
        cout << (v[i] ^ X) << " ";
    }
}

Measured memory_bytes: 5616
def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort(reverse=True)

    Alice = 0
    Bob = 0

    for i in range(N):
        if i % 2 == 0:
            Alice += A[i]
        else:
            Bob += A[i]

    print(Alice - Bob)


if __name__ == "__main__":
    main()


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

using ll = long long;
using ld = long double;
using namespace std;

#define rep(i, n) for (i = 0; i < (ll)n; ++i)
#define all(x) begin(x), end(x)

int main()
{
  ll N, K;
  cin >> N >> K;

  ll ans{0};
  ll mod = pow(10, 9) + 7;
  for (ll k{K}; k <= N + 1; ++k)
  {
    ll tmp = N*k - k*k + k + 1;
    ans += tmp;
    ans %= mod;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,m;cin>>n>>m;
	cout << n * (n - 1) /2 + m  * (m - 1) / 2<< endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  while(cin >>s){
    int num[10][10] = {0};
    for(int i=0; i<10; i++) num[i][0] = s[i]-'0';
    for(int i=1; i<10; i++) for(int j=0; j<10-i; j++) num[j][i] = (num[j][i-1]+num[j+1][i-1])%10;
    cout <<num[0][9]<<endl;
  }
  return 0;
}

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

int main(void) {
  int N, K;
  cin >> N >> K;
  int x = 1;
  for (int i = 0; i < N; i++) {
    x = min(x * 2, x + K);
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using pdd = pair<double, double>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int T;
    cin >> T;
    for (int query = 0; query < T; ++query) {
        ll A, B, C, D;
        cin >> A >> B >> C >> D;
        if (D < B || A < B) {
            cout << "No\n";
            continue;
        }
        if (B <= C) {
            cout << "Yes\n";
            continue;
        }

        A %= B, D %= B;
        ll g = gcd(B, D);
        ll BB = B / g, DD = D / g, CC = C - A;
        if (CC < 0)
            CC += B;
        ll tmp = CC / g + 1;
        tmp *= g;
        if ((A + tmp) % B > C)
            cout << "No\n";
        else
            cout << "Yes\n";
    }

    return 0;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

typedef long long ll;

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


int main() {
    ll a,b,c,ans=0;
    cin>>a>>b>>c;

    while(a%2==0&&b%2==0&&c%2==0){
        if(a==b||b==c||c==a){
            cout<<-1<<endl;
            return 0;
        }

        ll aa=(b+c)/2;
        ll bb=(a+c)/2;
        ll cc=(a+b)/2;

        a=aa;
        b=bb;
        c=cc;

        aa=0;bb=0;cc=0;

        ans++;
    }

    cout<<ans<<endl;


}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

template<typename Integer>
Integer GCD(Integer a, Integer b){
  if(!b)return a;
  else return GCD(b,a%b);
}

int main(){
while(true){
int a,b;
cin>>a>>b;
if(cin.eof())break;
cout<<GCD(a,b)<<endl;
}
return 0;
}

Measured memory_bytes: 0
s = input()

ls = [0 for _ in range(len(s))]

i = 0
cnt = 0
now = 'R'
while True:
    if s[i] == now:
        cnt += 1
        i += 1
    if i == len(s) or s[i] != now:
        if now == 'R':
            ls[i] += cnt // 2
            if cnt % 2 == 0:
                ls[i-1] += cnt // 2
            else:
                ls[i-1] += cnt // 2 + 1
            now = 'L'
        else:
            ls[i-cnt-1] += cnt // 2
            if cnt % 2 == 0:
                ls[i-cnt] += cnt // 2
            else:
                ls[i-cnt] += cnt // 2 + 1
            now = 'R'

        cnt = 0
    if i == len(s):
        break

print(' '.join(map(str, ls)))



Measured memory_bytes: 17060
i = list(map(int,input().split()))

a = i[0]
b = i[1]

plus = a + b
minus = a - b
add = a * b

list = [plus, minus, add]

flag = True
for l in list :
    if flag :
        box = l
        flag = False
    else :
        if l >= box :
            box = l
print(box)

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

using namespace std;

const int nax = 1e6+5;

int main() {
    int n, x;
    cin >> n;
    vector<int> div(nax, 0), primes; 
    vector<int> smallestprime(nax, -1);
    for(int i = 2; i <= nax; i++) {
        if(smallestprime[i] == -1) {
            smallestprime[i] = i;
            for(int st = 2*i; st <= nax; st+=i) {
                if(smallestprime[st] == -1) {
                    smallestprime[st] = i;
                }
            }
            primes.push_back(i);
        }
    }
    for(int i = 0; i < n; i++) {
        cin >> x;
        while(x != 1) {
            int num = smallestprime[x];
            //cout << x << ' ' << num << endl;
            div[num]++;
            while(!(x%num)) {
                x/=num;
                //cout << x << ' ' << num << endl;
            }
        }    
    }
    bool ispcoprime = true, isscoprime = true;
    for(int i = 0; i < primes.size(); i++) {
        if(div[primes[i]] == n) {
            ispcoprime = isscoprime = false;
            break;
        }
        else if(div[primes[i]] > 1) {
            ispcoprime = false;
        }
    }
    if(ispcoprime) cout << "pairwise coprime";
    else if(isscoprime) cout << "setwise coprime";
    else cout << "not coprime";
    return 0;
}

Measured memory_bytes: 11760
#include<cstdio>
int a,b,h;
int main()
{
	scanf("%d%d",&a,&b);
	for(int i=a;i<=b;i++)
	{
		int a1,a2,a3,a4;
		a1=i%10;
		a2=i/10000;
		a3=i/10%10;
		a4=i/1000%10;
		if(a1==a2&&a3==a4)
			h++;
	}
	printf("%d",h);
}

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

int main() {
	int r,g,b,n;
	cin >> r>>g>>b>>n;
	int ans = 0;
	for (int i = 0; i <= n / r; i++) {
		for (int j = 0; j <= (n - r * i) / g; j++) {
			if (r * i + g * j > n) {
				break;
			}
			else if ((n - (r * i + g * j)) % b == 0) {
				ans += 1;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"
import "bufio"
import "os"
import "strconv"
import "sort"

var _sw = bufio.NewScanner(os.Stdin)

func main() {
	var s string
	fmt.Scanln(&s)
	sum := 0
	for _, c := range s {
		sum = (sum + int(c-'0')) % 9
	}

	if sum == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func init() {
	_sw.Split(bufio.ScanWords)
}

func NextInt() int {
	if _sw.Scan() == false {
		panic(_sw.Err())
	}
	i, e := strconv.Atoi(_sw.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func NextInts(n int) []int {
	a := make([]int, n)
	for i := range a {
		a[i] = NextInt()
	}
	return a
}

func NextString() string {
	if _sw.Scan() == false {
		panic(_sw.Err())
	}
	return _sw.Text()
}

func Max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func Min(x, y int) int {
	if x > y {
		return y
	}
	return x
}

func Bounded(lower, n, upper int) int {
	return Min(upper, Max(lower, n))
}

func SortInts(xs []int) {
	sort.Sort(sort.IntSlice(xs))
}

func ReverseSortInts(xs []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(xs)))
}


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

int main () {
  int N;
  string S;
  cin >> N >> S;
  long long R = 0;
  long long G = 0;
  long long B = 0;
  
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'R'){
      R++;
    }
    else if (S.at(i) == 'G'){
      G++;
    }
    else if (S.at(i) == 'B'){
      B++;
    }
  }
  long long ans = R*G*B;
  
  for (int i = 0; i < N-2; i++) {
    for (int dis = 1; dis < (N-i+1)/2; dis++) {
      if (S.at(i) != S.at(i+dis) && (S.at(i) != S.at(i+dis*2) && S.at(i+dis) != S.at(i+dis*2))){
        ans--;
      }
    }
  }
  cout << ans << endl;
}
  
    
    
    

Measured memory_bytes: 3640
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	public static void main(String[] args) {
			int N=sc.nextInt();
			int B[]=new int[N-1];
			
			
			for(int i=0;i<N-1;i++) {
				B[i]=sc.nextInt();				
			}
			
			
			int A[]=new int[N];
			A[0]=B[0];
			for(int i=1;i<N-1;i++) {
				A[i]=Math.min(B[i-1], B[i]);
			}
			A[N-1]=B[N-2];
			int ans=0;
			for(int i:A) {
				ans+=i;
			}
			
			p(ans);
			
	}

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
 
#define fio() ios_base::sync_with_stdio(false);\
cin.tie(NULL);
 
#define md 1000000007
typedef long long int lli;
typedef float fl;
#define mem(arr,x) memset(arr,x,sizeof(arr))

typedef struct tim
            {
               lli a; 
               lli pos;
            }an;


lli comparator(an p,an q) 
{ 
    return (   p.a < q.a ) ; 
} 

lli power(lli x, lli y, lli p) 
{ 
    lli res = 1;    
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
  
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
}
 

int main()
{    
    fio();
   
    	lli i,j,k=0,l,m,n;
		cin>>n;
		lli ar[n][3];
		lli dp[4][n+1];
		for(i=0;i<n;i++)	cin>>ar[i][0]>>ar[i][1]>>ar[i][2];
		dp[0][0]=ar[0][0];
		dp[1][0]=ar[0][1];
		dp[2][0]=ar[0][2];
		for(i=1;i<n;i++)
		{
			dp[0][i]=ar[i][0]+max(dp[1][i-1],dp[2][i-1]);
			dp[1][i]=ar[i][1]+max(dp[0][i-1],dp[2][i-1]);
			dp[2][i]=ar[i][2]+max(dp[1][i-1],dp[0][i-1]);
		//	cout<<dp[0][i]<<" "<<dp[1][i]<<" "<<dp[2][i];
		//	cout<<endl;
		}
		cout<<max({dp[0][n-1],dp[1][n-1],dp[2][n-1]});
    
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define debug0(x) printf("! %d\n", x);
#define debug1(x, a, b) for(int (ii)=(a);(ii)<(b);(ii++)) printf("%d: %d\n", ii, x[ii]);
#define nono(x, ite) for(__typeof((x).begin()) (ite)=(x).begin();(ite)!=(x).end();(ite++))

typedef long long ll;

const int N = 1e5 + 10;

int n, nom[N];
char str[N];

bool check(int u) {
  if (str[u] == 'o') {
    if (nom[u] == 1) {
      return nom[(u + 1) % n] == nom[(u - 1 + n) % n];
    } else {
      return nom[(u + 1) % n] != nom[(u - 1 + n) % n];
    }
  } else {
    if (nom[u] == 0) {
      return nom[(u + 1) % n] == nom[(u - 1 + n) % n];
    } else {
      return nom[(u + 1) % n] != nom[(u - 1 + n) % n];
    }
  }
}

int main() {
  scanf("%d%s", &n, str);
  for (int t1 = 0; t1 < 2; t1++) {
    for (int t2 = 0; t2 < 2; t2++) {
      memset(nom, -1, sizeof nom);
      nom[0] = t1, nom[1] = t2;
      for (int j = 1; j < n - 1; j++) {
        if (str[j] == 'o') {
          if (nom[j] == 0) {
            nom[j + 1] = nom[j - 1] ^ 1;
          } else {
            nom[j + 1] = nom[j - 1];
          }
        } else {
          if (nom[j] == 1) {
            nom[j + 1] = nom[j - 1] ^ 1;
          } else {
            nom[j + 1] = nom[j - 1];
          }
        }
      }
      if (check(n - 1) && check(0)) {
        for (int i = 0; i < n; i++) {
          printf("%c", (nom[i] == 1 ? 'S' : 'W'));
        }
        puts("");
        return 0;
      }
    }
  }
  puts("-1");
  return 0;
}



Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define F first
#define S second
using namespace std;
ll mod=1e9+7;

ll add(ll a,ll b){
    return ((a%mod)+(b%mod))%mod;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n; cin>>n; ll sum=0; ll pre=0;
    for(int i=0;i<n;i++){
        ll x; cin>> x;
        sum=add(sum,mul(pre,x));
        pre+=x;

    }
    cout<<sum<<endl;


}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl
 
vector<bool> visited(200005, false);
 
int main(){
    ll n, q2;
    cin >> n >> q2;
 
    vector<vector<ll>> tree(n);
    for(int i = 0; i < n-1; i++){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
 
    vector<ll> ans(n,0);
    for(int i = 0; i < q2; i++){
        ll p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
 
    queue<ll> q;
    q.push(0);
    visited[0] = true;
    while(!q.empty()){
        ll now = q.front();
        q.pop();
        for(int i = 0; i < tree[now].size(); i++){
            if(visited[tree[now][i]] == false){
                q.push(tree[now][i]);
                ans[tree[now][i]] += ans[now];
                visited[tree[now][i]] = true;
            }
        }
 
 
    }
 
    for(int i = 0; i < n; i++){
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
 
}

Measured memory_bytes: 17904
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    alf = input().rstrip()

    s = ['q','w','e','r','t','y','u','i','o','p','a','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m']

    if alf in s:
        res = 'a'
    else:
        res = 'A'

    print(res)



main()


Measured memory_bytes: 9040
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    const ll mv = a.back();
    ll index = lower_bound(a.begin(), a.end(), (mv + 1) / 2) - a.begin();
    if(index != a.size() - 1 && index > 0){
        const ll d1 = a.at(index);
        const ll d2 = a.at(index - 1);
        const ll f1 = min(abs(d1 - mv / 2), abs(d1 - (mv + 1) / 2));
        const ll f2 = min(abs(d2 - mv / 2), abs(d2 - (mv + 1) / 2));
        if(f1 < f2){
            cout << mv << ' ' << d1 << endl;
        }else{
            cout << mv << ' ' << d2 << endl;
        }
    }else if(index == 0){
        cout << mv << ' ' << a.at(index) << endl;
    }else{
        cout << mv << ' ' << a.at(index - 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
n,m=gets.chomp.split.map(&:to_i)
p = []
y = []

py = Array.new(n+1).map{Array.new()}

m.times do |i|
    pp, yy = gets.chomp.split.map(&:to_i)
    p << pp
    y << yy

    py[pp] << yy
end

ph = Array.new(n+1).map{Hash.new()}
py.each_with_index do |v, i|
    v.sort!
    v.each_with_index do |vv, j|
        ph[i][vv] = j+1
    end
end

0.upto(m-1) do |i|
    printf("%06d%06d\n", p[i], ph[p[i]][y[i]])
end

Measured memory_bytes: 52576
// choices and belief 

#include <bits/stdc++.h>
using namespace std;
const int N = 1234567;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef priority_queue<pii, vector<pii>, greater<pii>> min_pq;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define whatis(x) cout << #x << " is " << x << endl;
#define inf 1e18
int main()
{
	ios_base:: sync_with_stdio(false); cin.tie(0);
	// freopen ("inp","r",stdin);
	// freopen ("out","w",stdout);

	string s;
	cin>>s;
	int last=-1;
	std::size_t found = s.find("FESTIVAL");
	if(found!=-1)last=(int)found;
	while (found!=std::string::npos)
    {
    	// std::cout << "first 'needle' found at: " << found << '\n';
    	if(found!=-1)last=(int)found;
    	found=s.find("FESTIVAL",found+1,8);
    	
    }
    // cout<<last<<endl;
    if(last!=-1)
    {
    	cout<<s.substr(0,last)<<endl;
    }

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long int ll;
const ll mod=1e9+7;
int main()
{
    ll n;
    cin>>n;
    ll i,p1=1,p2=1,p3=1;
        for(i=1;i<=n;i++)
        {
            p1=((p1%mod)*(10%mod))%mod;
            p2=((p2%mod)*(9%mod))%mod;
            p3=((p3%mod)*(8%mod))%mod;
        }
        ll ans=((p1%mod)-((p2)%mod)-((p2)%mod)+(p3%mod)+mod+mod+mod)%mod;
        cout<<ans<<"\n";
    cerr<<"\nTime elapsed:"<< 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 3644