akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<utility>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#define maxn 1010
#define INF 0x3f3f3f3f
#define LL long long
#define ULL unsigned long long
#define E 1e-8
#define mod 1000000007
#define P pair<int,int>
using namespace std;
int main()
{
    int a[3];
    while(cin>>a[0]>>a[1]>>a[2])
        {
            int sum = 0,sum2 = 0;
        for(int i=0;i<3;i++){
            if(a[i] == 5)
            sum++;
        else
            if(a[i] == 7)
            sum2++;
        }
        if((sum == 2) && (sum2 == 1))
            cout << "YES" <<endl;
        else
            cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){

  int n,m;
  int i,j,k;
  int taro[100];
  int hanako[100];
  int temp;
  int totaltaro2;
  int totalhanako2;
  int ec1 = 0;
  int ec2 = 0;
  int c;

  while(1){

    scanf("%d%d",&n,&m);
    if( n == 0 && m == 0 )break;

    for( i = 0 ; i < n ; i++ ){
      scanf("%d",&taro[i]);
    }
    for( i = 0 ; i < m ; i++ ){
      scanf("%d",&hanako[i]);
    }
    
    ec1 = 0;
    ec2 = 0;
    c = 0;

	for( i = 0 ; i < n ; i++ ){
	  for( j = 0 ; j < m ; j++ ){

	    totaltaro2 = 0;
	    totalhanako2 = 0;
	    

	    temp = taro[i];
	    taro[i] = hanako[j];
	    hanako[j] = temp;

	    for( k = 0 ; k < n ; k++ ){
	      totaltaro2 += taro[k];
	    }
	    for( k = 0 ; k < m ; k++ ){
	      totalhanako2 += hanako[k];
	    }

	    if( totaltaro2 == totalhanako2 && c == 0 ){
	      ec1 = hanako[j];
	      ec2 = taro[i];
	      c++;
	    }
	    if(totaltaro2 == totalhanako2 && ec1 > hanako[j] && ec2 > taro[i]){
	      ec1 = hanako[j];
	      ec2 = taro[i];
	    }

	    temp = taro[i];
	    taro[i] = hanako[j];
	    hanako[j] = temp;
	  }
	}
	if( ec1 == 0 && ec2 == 0 ) printf("-1\n");
	else  printf("%d %d\n", ec1, ec2);
  }
  return 0;
}

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

int main(){
    int n, ans = 0;
    cin >> n;

    int b[100020] = {0};
    rep(i,n){
        int a;
        cin >> a;
        b[a] += 1;
    }
    rep(i, 100010) ans = max(ans, b[i] + b[i+1] + b[i+2]);
    cout << ans << endl;
}

Measured memory_bytes: 640
n = int(input())
w = list(map(int, input().split()))
 
subsum_w = [0 for i in range(n)]
subsum_w[0] = w[0]
 
for i in range(1, n):
    subsum_w[i] = subsum_w[i - 1] + w[i]
 
min_diff = sum(w)
 
for i in range(n):
    if abs((sum(w) - subsum_w[i]) - subsum_w[i]) <= min_diff:
        min_diff = abs((sum(w) - subsum_w[i]) - subsum_w[i])
 
print(min_diff)

Measured memory_bytes: 3064
L, R = map(int, input().split())

L_q = L // 2019
R_q = R // 2019
mod = 2018

if L_q + R_q == 0:
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            mod = min(i * j % 2019, mod)

    print(mod)

else:
    if R_q - L_q > 1:
        print(0)

    else:
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                mod = min(i * j % 2019, mod)

        print(mod)

Measured memory_bytes: 41068
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    public class CodeABC141B
    {
        static void Main(string[] args)
        {
            var line = System.Console.ReadLine();
            var ret = string.Empty;
            var IsOdd = true;

            ret = "Yes";
            foreach (var step in line.ToCharArray())
            {
                if (!((step == 'U') || (step == 'D') || (step == 'R' && IsOdd) || (step == 'L' && !IsOdd)))
                {
                    ret = "No";
                    break;
                }

                IsOdd = !IsOdd;
            }

            Console.WriteLine(ret);
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

string s;


int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  cin >> s;
  ll n=s.size();
  
  vvll dp(n+1,vll(11,-1));
  
  dp[0][0]=0;
  
  rep(i,0,n){
    rep(j,0,11){
     if(dp[i][j]==-1) continue;
      
      for(ll k=1;k<=10&&i+k<=n;k++){
        if(j!=k||s.substr(i-j,j)!=s.substr(i,k)){
          dp[i+k][k]=max(dp[i+k][k],dp[i][j]+1);
        }
      }
    }
  }
  
  cout << *max_element(dp[n].begin(),dp[n].end()) << endl;
  
}

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

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 ***/

int main(){
    double pai=3.141592653589;
    int a,b,c;
    for(;;){
        scanf("%d %d %d",&a,&b,&c);
        if(a+b+c==-3){
            break;
        }else if(a+b>=80){
            printf("A\n");
        }else if(a+b>=65){
            printf("B\n");
        }else if(a+b>=50 || (a+b>=30 && c>=50)){
            printf("C\n");
        }else if(a+b>=30 && a!=-1 && b!=-1){
            printf("D\n");
        }else{
            printf("F\n");
        } 
            
    }
    return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if(a < b && b < c){
			System.out.printf("Yes\n");
		}else{
			System.out.printf("No\n");
		}
	}
}




Measured memory_bytes: 26260
use std::io::{stdin, stdout, BufReader, BufRead, StdinLock, Write, BufWriter};

fn main() {
    let std_in = stdin();
    let mut br = BufReader::new(std_in.lock());
    let std_out = stdout();
    let mut bw = BufWriter::new(std_out.lock());
    
    let tmp = rvn::<usize>(&mut br);
    let (n, a, b) = (tmp[0], tmp[1], tmp[2]);
    if a * n < b {
        writeln!(&mut bw, "{}",a*n);
    } else {
        writeln!(&mut bw, "{}",b);
    }
}


//////////////////////////////////////////////////////////////////////////////////
#[allow(dead_code)]
fn rs(br: &mut BufReader<StdinLock>) -> Vec<char> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().chars().collect()
}

#[allow(dead_code)]
fn rn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> T {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn rvs(br: &mut BufReader<StdinLock>) -> Vec<Vec<char>> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.chars().collect()).collect()
}

#[allow(dead_code)]
fn rvn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> Vec<T> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>
int min(int x, int y) { return x < y ? x : y; }
int main() {
	char s[100001];
	int Rnum = 0, Bnum = 0;
	scanf("%s", s);
	for (int i = 0; i < strlen(s); i++) {
		if (s[i] == '0') {
			Rnum++;
		} else {
			Bnum++;
		}
	}
	printf("%d\n", min(Rnum, Bnum) * 2);
	return 0;
}

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

int main(int argc, char **argv){
    int N;
    std::cin >> N;
    std::vector<int> a(N);

    int quad = 0;
    int odd = 0;
    int bi = 0;
    for(int i = 0; i < N; i++){
        std::cin >> a.at(i);
        if(a.at(i) % 4 != 0 && a.at(i) % 2 == 0) bi++;
        if(a.at(i) % 4 == 0) quad++;
        if(a.at(i) % 2 == 1) odd++;
    }
    bool flag = false;
    if(odd == 0){
        flag = true;
    }else if(bi > 0){
        if(odd <= quad) flag = true;
    }else{
        if(odd-1 <= quad) flag = true;
    }
    
    if(flag)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
    
}


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

int main()
{
    int N;
    cin >> N;
    int maxn = 0;
    int sum = 0;
    for(int i = 0 ; i < N ; i++)
    {
        int t;
        cin >>t;
        sum += t;
        maxn = max(t,maxn);
    }
    sum-=(maxn/2);
    if(maxn%2==0)
    {
        cout<<sum<<endl;
    }
    else{
        cout<<sum-1<<"."<<"5"<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
      
public class Main
{
    public static void main (String[] args)
    {
        Scanner scanner = new Scanner(System.in);
      
        for(int i = 1; i<=10000; i++){
         int x = scanner.nextInt();
         if(0 < x && x <= 10000){
          System.out.println("Case " + i +": "+ x);
         }else{
         }
        }
   }
}

Measured memory_bytes: 42656
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define ff               first
#define ss               second
#define pb               push_back
#define all(x)           (x).begin(), (x).end()
#define mem0(x)          memset(x, 0, sizeof (x))
#define mem1(x)          memset(x, -1, sizeof (x))

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector <ii> vii;
typedef vector<vii> vvii;
typedef vector <ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;

int cp[200010]; //components
int sz[200010]; //components
int find(int x){ return cp[x] = cp[x] == x ? x:find(cp[x]);}

void union_(int x, int y){ cp[find(x)] = find(y);}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T=1, n;
    while (T--) {
        cin >> n;
        for (int j = 0; j < n + 2; ++j) {
            cp[j] = j;
            sz[j] = 1;
        }
        vector <pair<ii, int>> A(n), big;
        vi nxt(n, n);
        vi low;

        for (int i = 0; i < n; ++i) {
            cin >> A[i].ff.ff >> A[i].ff.ss;
            A[i].ss = i;
        }
        for (int l = 0; l < 2; ++l) {
            sort(all(A));
            for (int k = 0; k < n; ++k) {
                while (big.size() && big.back().ff.ff < A[k].ff.ff &&
                       big.back().ff.ss < A[k].ff.ss) { //actual con menores a el
                    if (find(big.back().ss) != find(A[k].ss)) {
                        //cout << big.back().ff.ff << " " << big.back().ff.ss << " : " << A[k].ff.ff << " " << A[k].ff.ss << "\n";
                        sz[find(A[k].ss)] += sz[find(big.back().ss)];
                        union_(big.back().ss, A[k].ss);
                    }
                    big.pop_back();
                }
                big.pb(A[k]);
            }
            big.clear();
            for (int k = n - 1; k >= 0; --k) {
                while (big.size() && big.back().ff.ff > A[k].ff.ff && big.back().ff.ss > A[k].ff.ss) { //actual con mayores
                    if (find(big.back().ss) != find(A[k].ss)) {
                        //cout << big.back().ff.ff << " " << big.back().ff.ss << " : " << A[k].ff.ff << " " << A[k].ff.ss << "ddd\n";
                        sz[find(A[k].ss)] += sz[find(big.back().ss)];
                        union_(big.back().ss, A[k].ss);
                    }
                    big.pop_back();
                }
                big.pb(A[k]);
            }
            big.clear();
            for (int i = 0; i < n; ++i) {
                swap(A[i].ff.ff, A[i].ff.ss);
            }
        }
        for (int l = 0; l < n; ++l) {
            cout << sz[find(l)] << "\n";
        }
    }
}

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

#define ld          long double
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD         1000000007
#define sd(t)       scanf("%d",&(t))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define hii         cout << "hii" << endl
#define okay        cout << "okay" << endl
#define hey         cout << "hey" << endl

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int inf = 1e18;
const int mod = 1e9+7;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
} 

clock_t time_p=clock();
void starboy1299()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

const int N = 2e5+5;
int arr[N];

void solve()
{
    int n;
    cin >> n;

    rep(i, 1, n+1){
        cin >> arr[i];
    }
    mi mp;
    int ans = 0;
    rep(i, 1, n+1){
        int curr = -i+arr[i];
        ans += mp[curr];
        mp[-i-arr[i]]++;
    }

    cout << ans << endl;
}                                   

int32_t main(){
    fast();
    int t = 1;
    // cin>> t;
    for(int i=1; i<=t; i++){
        // cout << "Case #" << i << ": ";
        solve();
    }
    starboy1299();
}

Measured memory_bytes: 27984
s=input()
for i in range(8):
  a=""
  for j in range(3):
    a+=s[j]
    if(i&1<<(2-j)):
      a+="+"
    else:
      a+="-"
  a+=s[-1]
  if(eval(a)==7):
    print(a+"=7")
    break

Measured memory_bytes: 3060
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	int c[3][3];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>c[i][j];
		}
	}
  	int x,y,z,p,q,r;
	for(int i=0;i<=100;i++){
      x=i;
      p=c[0][0]-x;
      if(p<0) break;
		for(int j=0;j<=100;j++){
          y=j;
          q=c[1][1]-y;
          if(q<0) break;
			for(int k=0;k<=100;k++){
				z=k;				
				r=c[2][2]-z;
              	if(r<0) break;
				if(x+q==c[0][1]&&x+r==c[0][2]
					&&y+p==c[1][0]&&y+r==c[1][2]
					&&z+p==c[2][0]&&z+q==c[2][1]){
						cout<<"Yes"<<endl;
						return 0;
					}
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

int main() {
    int N; cin >> N;
    bool four = false;
    for (int i = 0; i < N; i++) {
        char a; cin >> a;
        if (a == 'Y') four = true;
    }
    if (four) cout << "Four" << endl;
    else cout << "Three" << endl;
}

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

using namespace std;

int main(){
    int a[4] = {0};
    for (int i = 0; i < 4; i++){
        cin >> a[i];
        if (a[i] != 1 && a[i] != 9 && a[i] != 7 && a[i] != 4){
            cout << "NO" << endl;
            return 0;
        }else {
            if(i>0){
                for(int j = 0; j < i; j++){
                    if( a[j] == a[i]){
                        cout << "NO" << endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout << "YES" << endl;

    return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> imos(n + 2, 0);
  REP(i, m) {
    int c, d;
    cin >> c >> d;
    imos[c]++;
    imos[d]--;
  }
  REP(i, n + 1) imos[i + 1] += imos[i];
  int ans = n + 1;
  REP(i, n + 2) {
    if (imos[i] > 0) ans += 2;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3088
#include<iostream>
#include<algorithm>
#include<vector>
typedef long long int ll;
using namespace std;

int main(){
	int n; cin >>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >>a[i];
	}
	int ans=0;
	for(int i=1;i<n-1;i++){
		if(a[i]==a[i]+a[i-1]+a[i+1]-max(a[i],max(a[i+1],a[i-1]))-min(a[i],min(a[i+1],a[i-1]))){
			ans++;
		}
	}
	cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n;
  ll z, w;
  cin >> n >> z >> w;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  if(n == 1) cout << abs(a[0]-w) << endl;
  else cout << max(abs(w-a[n-1]), abs(a[n-1]-a[n-2])) << endl;
}

Measured memory_bytes: 3636
a = list(input())

for i in range(2 ** 3):
    switch = [0] * 3
    for j in range(3):
        if ((i >> j) & 1):
            switch[j] = 1

    sum = int(a[0])
    for k in range(3):
        if switch[k] == 0:
            sum -= int(a[k + 1])
        else:
            sum += int(a[k + 1])
    if sum == 7:
        for k in range(3):
            print(a[k], end="")
            if switch[k] == 1:
                print("+", end="")
            else:
                print("-", end="")
        print(a[3], end="")
        print("=7")
        break 

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


#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
typedef long long int lli;
typedef long long ll;
typedef long double ld;


signed main(){
    fast_IO;
    int t=1;
    //cin>>t;
    while(t--){
        ll n;
        cin>>n;
        vector<ll> a(n);
        map<ll,int> mp;
        ll sum=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            sum+=a[i];
            mp[a[i]]++;
        }
        ll q;
        cin>>q;
        ll b,c;
        for(int i=0;i<q;i++){
            cin>>b>>c;
            sum-=mp[b]*b;
            sum+=mp[b]*c;
            mp[c]+=mp[b];
            mp[b]=0;
            cout<<sum<<endl;
        }
    }   
    return 0;
}


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

#define ll long long
// #define MULTI_TEST

int n;
string p[] = {"pon", "pon", "hon", "bon", "hon", "hon", "pon", "hon", "pon", "hon"};

void solve() {
	cin >> n;
	cout << p[n%10];
}



int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
#ifdef MULTI_TEST
	int t;
	cin >> t;
	while(t--) {
		solve();
		cout << "\n";
	}
#else
	solve();
	cout << "\n";
#endif

	return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>
int main(void){
    int N, i, j, tunc;
    int a[101];
    int min, count = 0, place=0;
    scanf("%d", &N);
    for (i = 0; i < N;i++){
        scanf("%d", &a[i]);
    }
    for (i = 0; i < N;i++){
        min = 101;
        for (j = i; j < N; j++){
            if(a[j] < min){
                min = a[j];
                place = j;
            }
            }
            if (min != a[i]){
                count++;
                tunc = a[i];
                a[i] = a[place];
                a[place] = tunc;
            }
    }
    printf("%d", a[0]);
    for (i = 1; i < N; i++){
        printf(" %d", a[i]);
    }
    printf("\n");
    printf("%d\n", count);
}


Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
vector<int>a;
int n,t,b,c,x,ans,max1;
int main(){
	cin>>n>>t;

	for(int i=0;i<=n-1;i++) cin>>x,a.push_back(x);
	b=a[0];
	max1=-100;	
	for(int i=1;i<=n-1;i++)
	{    
		if(a[i]>b) 
		{
		    c=a[i]-b;
			if(c==max1) 
			    ans++;
			    
			else 
			  if(c>max1)
			    {max1=c;ans=1;}
		}
		else 
		   b=a[i]; 
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

// #define int long long

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define single_test

void solve() {
    int n;
    cin >> n;
    vector<pair<int,int>> v(n);
    for (auto &it: v) {
        cin >> it.first >> it.second;
    }
    int ans = 0;
    map<int,int> diff, add;
    for (auto [x, y]: v) {
        diff[x - y]++;
        add[x + y]++;
    }
    auto rem = [&] (int v, map<int,int> &mp) {
        int t = --mp[v];
        if (!t) mp.erase(v);
    };
    auto readd = [&] (int v, map<int,int> &mp) {
        mp[v]++;
    };
    for (auto [x, y]: v) {
        rem(x - y, diff);
        rem(x + y, add);

        if (!add.empty()) {
            int now = x + y;
            auto it = add.begin();
            ans = max(ans, now - it->first);
        }
        if (!diff.empty()) {
            int now = -x + y;
            auto it = prev(diff.end());
            ans = max(ans, now + it->first);
        }
        readd(x - y, diff);
        readd(x + y, add);
    }
    cout << ans << '\n';
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }

    return 0;
}

Measured memory_bytes: 23520
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;
int main() {
	string s;	cin >> s;
	for (int i = 0; i < s.size(); ++i) {
		if (i % 2 == 0) {
			cout << s[i];
		}
	}

	cin >> s;
}

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

int main() {
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    if(a1 + a2 + a3 >= 22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
using namespace std;

int main(){
  int m;
  scanf("%d",&m);
  while(m-->0){
    set <string> s;
    string t;
    cin >> t;

    s.insert(t);
    reverse(all(t));
    s.insert(t);
    reverse(all(t));
    int len=t.size();
    for(int i=1;i<len;i++){
      string t1 = t.substr(0,i);
      string t2 = t.substr(i,t.size());
      
      s.insert(t2+t1);
      reverse(all(t2));
      s.insert(t2+t1);
      s.insert(t1+t2);
      reverse(all(t1));
      s.insert(t1+t2);
      s.insert(t2+t1);
      reverse(all(t2));
      s.insert(t2+t1);
      s.insert(t1+t2);
    }
    cout << s.size() << endl;
  }
}

Measured memory_bytes: 1312
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n;
    cin >> n;
    
    vector<int> v(n);
    for (auto &x : v) cin >> x;
    partial_sum(ALL(v), v.begin());
    
    vector<vector<int>>  dp(n, vector<int>(n, INF));
    vector<vector<int>> lst(n, vector<int>(n,  -1));
    for (int i = 0; i < n; ++i) dp[i][i] = 0;
    for (int len = 2; len <= n; ++len) {
        for (int l = 0, r = len-1; r < n; ++l, ++r) {
            for (int m = l; m < r; ++m) {
                dp[l][r] = min(dp[l][r], dp[l][m] + dp[m+1][r]);
            }
            dp[l][r] += v[r] - (l ? v[l-1] : 0);
        }
    }
    
    cout << dp[0][n-1] << "\n";
    
    return 0;
}

Measured memory_bytes: 2816
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String sa = sc.next();
    String sb = sc.next();
    String sh = sc.next();

    System.out.println(solve('a', sa, sb, sh));
  }

  static String solve(char next, String a, String b, String c) {
    if (next == 'a' && a.isEmpty()) {
      return "A";
    } else if (next == 'b' && b.isEmpty()) {
      return "B";
    } else if (next == 'c' && c.isEmpty()) {
      return "C";
    } else {
      if (next == 'a') {
        return solve(a.charAt(0), a.substring(1), b, c);
      } else if (next == 'b') {
        return solve(b.charAt(0), a, b.substring(1), c);
      } else if (next == 'c') {
        return solve(c.charAt(0), a, b, c.substring(1));
      } else {
        return "0";
      }
    }
  }
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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 INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string a,b; cin>>a>>b;
  bool ok=a.size()==b.size();
  rep(i,a.size()){
    cout<<a[i];
    if(i==a.size()-1){
      if(!ok) continue;
    }
    cout<<b[i];
  }
  cout<<endl;
}

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

int main(){
    int A, B;
    cin >> A >> B;
    int C = A + B;
    if(C == 3){
        cout << 3 << endl;
    }
    else if(C == 4){
        cout << 2 << endl;
    }
    else if(C == 5){
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define all(_v) _v.begin(), _v.end()

ll n, k, sum;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	while(k--) {
        int x;
        cin >> x;
        sum += x;
	}
	cout << max(-1ll, n - sum);
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

string s;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> s;
  if (s.size() % 2 == 0) {
    int l, r;
    char ch = s[s.size()/2];
    l = s.size()/2-1;
    r = s.size()/2;
    while (l >= 0 && r < s.size() && s[l] == ch && s[r] == ch) {
      l--; r++;
    }
    cout << r << endl;
  } else {
    int l, r;
    char ch = s[s.size()/2];
    l = s.size()/2-1;
    r = s.size()/2+1;
    while (l >= 0 && r < s.size() && s[l] == ch && s[r] == ch) {
      l--; r++;
    }
    cout << r << endl;
  }  

  return 0;
}

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

int main(){
	int c[3][3];
	for (int i=0; i<3; i++){
		for (int j=0; j<3; j++){
			cin >> c[i][j];
		}
	}

	// i方向の差
	for (int i=0; i<2; i++){
		int temp[3];
		for (int j=0; j<3; j++){
			temp[j] = (c[i+1][j] - c[i][j]);
		}
		if (temp[0] != temp[1] || temp[1] != temp[2]){
			cout << "No" << endl;
			return 0;
		}
	}

	// j方向の差
	for (int j=0; j<2; j++){
		int temp[3];
		for (int i=0; i<3; i++){
			temp[i] = (c[i][j+1] - c[i][j]);
		}
		if (temp[0] != temp[1] || temp[1] != temp[2]){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<set>
#include<complex>
#include<map>
using namespace std;
typedef long long ll;
inline int ri()
{
	register int x=0;
	bool f=0;
	register char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')	f=1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=(x<<3)+(x<<1)+ch-'0';
		ch=getchar();
	}
	if(f)	return -x;
	else	return x;
}
void wi(int x)
{
	if(x<0)	putchar('-'),x=-x;
	if(x>9)	wi(x/10);
	putchar(x%10+'0');
}
const int N=11000;
char ch[N];
int a[N],b[N],f[2010][2010],g[2010][2010],dp[2010][2010],i,j,n,pos[3][2010];
int main()
{
	n=ri();
	for(i=1;i<=2*n;i++)
	{
		scanf("%s",ch);
		a[i]=ch[0]=='W'?0:1;
		b[i]=ri();
		pos[a[i]][b[i]]=i;
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=2*n;j++) 
		{
			if(a[j]==0&&b[j]==i) break;
			if(a[j]==0&&b[j]<i) continue;
			else f[i][0]++;
		}
		for(j=1;j<=n;j++)
			f[i][j]=f[i][j-1]-(pos[1][j]<pos[0][i]);
	}
	for(j=1;j<=n;j++)
	{
		for(i=1;i<=2*n;i++) 
		{
			if(a[i]==1&&b[i]==j) break;
			if(a[i]==1&&b[i]<j) continue;
			else g[0][j]++;
		}
		for(i=1;i<=n;i++)
			g[i][j]=g[i-1][j]-(pos[0][i]<pos[1][j]);
	}
	memset(dp,0x3f,sizeof(dp));
	dp[0][0]=0;
	for(i=0;i<=n;i++)
		for(j=0;j<=n;j++)
		{
			if(i!=0) dp[i][j]=min(dp[i][j],dp[i-1][j]+f[i][j]);
			if(j!=0) dp[i][j]=min(dp[i][j],dp[i][j-1]+g[i][j]);
		}
	wi(dp[n][n]);putchar('\n');
}

Measured memory_bytes: 47616
#include <stdio.h>
int main(){
  int N;
  scanf("%d",&N);
  int A[100000]; 
  int B[100000]; 
  for(int i=0;i<N;i++){
    scanf("%d",&A[i]);
    B[A[i]-1]=i+1;
  }
  for(int i=0;i<N;i++){
printf("%d ",B[i]);
  }
}

Measured memory_bytes: 1536
#include <iostream>

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;

	int size = s.size();
	string r;
	bool yes = false;
	for (int i = 0; i < size && !yes; ++i) {
		if (s[i] != t[0])
			continue;
		
		r = s.substr(i, size - i) + s.substr(0, i);
		if (r == t)
			yes = true;
	}
	
	if (yes)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define rep(i, a, b) for(int i = a; i < b; i++)
using namespace std;

int main() {
  string s;
  cin >> s;
  rep(i, 0, 19) {
    if(i == 5 || i == 13) cout << " ";
    else cout << s[i];
  }
  cout << "\n";
}


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

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

	ll x = N / K;
	ll y = 0;
	if (K % 2 == 0) {
		y = x;
		ll t = (N / K) * K + K / 2;
		if (t <= N) y++;
	}

	ll res = pow(x, 3) + pow(y, 3);
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 512
import sys
input_lines = sys.stdin.readlines()[1:]

bls = [[[0] * 10 for i in range(3)] for j in range(4)]
for line in input_lines:
    [b,f,r,v] = [int(i) for i in line.split()]
    bls[b-1][f-1][r-1] += v
for i in range(4):
    for f in bls[i]:
        print(''.join([' {0}'.format(v) for v in f]))
    if i<3:
        print('#'*20)



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

main() {
    ll a,b,x; cin >> a >> b >> x;
    if(a>0){
    cout << b/x-(a-1)/x << endl;
    }
    else cout << b/x+1 << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
H = [int(n) for n in input().split()]

def count_divided(H):
    indices = [i for i, h in enumerate(H) if h > 0]
    counter = 0
    for i in range(len(indices) - 1):
        if H[indices[i] + 1] <= 0:
           counter += 1
    if len(indices) != 0:
        if indices[-1] == len(H) - 1:
            counter += 1
        if H[-1] <= 0:
            counter += 1
    return counter

def all_negative(H):
    flag = True
    for h in H:
        if h >= 0:
            flag = False
    return flag

counter = 0

while(not all_negative(H)):
    counter += count_divided(H)
    H = [h - 1 for h in H]

print(counter)

Measured memory_bytes: 3064
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        n: Chars,
    }

    let mut sum: i64 = 9;

    for c in n {
        sum += c as i64 - 48;
    }

    if sum % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 3004
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
using namespace std;

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

const int MAX = 210000;
long long fac[MAX], finv[MAX], inv[MAX];

void combination_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long combination(int n, int k) {
  if(n < k) return 0;
  if(n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  combination_init();
  int y = H - A - 1;
  int x = B;
  ll ans = 0;
  while(x <= W - 1 && y >= 0) {
    ans = (ans + combination(x + y, y) * combination(H + W - x - y - 2, H - y - 1) % MOD) % MOD;
    x++;
    y--;
  }
  cout << ans << endl;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 1e5 + 7;
bool first_win(vector <int> a) {
    int n = a.size();
    vector <int> pref(n + 1), post(n + 1);
    for (int i = 0; i < n; ++i)
        pref[i + 1] = __gcd(pref[i], a[i]);
    for (int i = n - 1; i >= 0; --i)
        post[i] = __gcd(post[i + 1], a[i]);
    int sum = 0;
    for (int i = 0; i < n; ++i)
        sum += a[i];
    if ((sum - n) % 2 == 1)
        return 1;
    for (int i = 0; i < n; ++i) {
        if (a[i] > 1) {
            int d = __gcd(__gcd(pref[i], post[i + 1]), a[i] - 1);
            if (d % 2 == 0) {
                vector <int> b = a;
                for (int j = 0; j < n; ++j) 
                    b[j] /= d;      
                if (!first_win(b))
                    return 1;
            }    
        }
    }   
    return 0;
}   

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    if (first_win(a))
        cout << "First" << endl;
    else
        cout << "Second" << endl;
}   

Measured memory_bytes: 75520
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()



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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>      // std::setprecision
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define IN(i,l,r) (l<i&&i<r) //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define F(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FF(i,L,R) for (int i = L; i > R; i--)
#define FFE(i,L,R) for (int i = L; i >= R; i--)
#define char2Int(c) (c-'0')
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define REMAX(a,b) (a)=max((a),(b)) // set a to the maximum of a and b
#define REMIN(a,b) (a)=min((a),(b));
#define FENWICK(k) (k&-k)
#define FOREACH(i,t) for (auto i=t.begin(); i!=t.end(); i++) // traverse an STL data structure
#define ALL(c) (c).begin(),(c).end() //handy for function like "sort()"
#define PRESENT(c,x) ((c).find(x) != (c).end()) 
#define CPRESENT(c,x) (find(ALL(c),x) != (c).end()) 
#define LL long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF 1001001001
#define PI 3.1415926535897932384626
//for map, pair
#define mp make_pair
#define fi first
#define se second
//for vectors
#define pb push_back
typedef int elem_t;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
// directions
const int fx[4][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}};
const int fxx[8][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}, {1,1}, {1,-1}, {-1,1}, {-1,-1}};
const int rogi[4][2] = { {1,1}, {1,-1}, {-1,1}, {-1,-1} };

string s;
//0 -> parzysta ilosc ruchow
//1 -> nieparzysta ilość ruchow
int c[111111];

void licz(int pos) {
	//cout<<"LICZ : "<<pos<<endl;
	//szukamy po prawo R
	int acc_r = pos;
	while(acc_r >= 0 && s[acc_r] == 'R') {
		int roz = pos - acc_r;
		if(roz % 2 == 0) {
			c[pos]++;
		} else {
			c[pos+1]++;
		}
		acc_r--;
		//cout<<"R\n";
	}

	int acc_l = pos+1;
	while(acc_l < s.length() && s[acc_l] == 'L') {
		int roz = acc_l - pos;
		if(roz % 2 == 0) {
			c[pos]++;
		} else {
			c[pos+1]++;
		}
		acc_l++;
		//cout<<"L\n";
	}
}

void dane() {
	cin>>s;

	char last = 'X';
	F(i,0,s.length()) {
		if(last == 'R' && s[i] == 'L') {
			
			//mamy
			licz(i-1);
		}
		last = s[i];
	}
	//mamy wyliczone
	F(i,0,s.length()) {
		cout<<c[i]<<" ";
	}
	cout<<endl;
}

int main() {
	IOS
	// int t;
	// cin>>t;
	// F(i,0,t)
	    dane();
    return 0;
}

Measured memory_bytes: 1104
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 1000000007
#define int long long
#define ll long long
#define EPS 0.00000000000001
#define ld long double
#define inf 1e16
#define N 1004

int32_t main()
{
    IOS;
 
    char c;
    cin >> c;
    cout << (char)(c + 1);
    

    return 0;

}
 


Measured memory_bytes: 256
n = int(input())
S, H, C, D= [], [], [], []
for i in range(n):
  x = input().split()
  if "S" in x:
    S.append(int(x[1]))
  elif "H" in x:
    H.append(int(x[1]))
  elif "C" in x:
    C.append(int(x[1]))
  elif "D" in x:
    D.append(int(x[1]))
    
for j in range(1,14):
  if j not in S:
    print("S",j)
for j in range(1,14):
  if j not in H:
    print("H",j)
for j in range(1,14):
  if j not in C:
    print("C",j)
for j in range(1,14):
  if j not in D:
    print("D",j)


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

void A()
{
    string N;
    cin >> N;
    
    if( N.find("7") != string::npos )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void B()
{
    int N;
    cin >> N;
    
    long long int ans = 0;
    
    for( int i = 1; i < N+1; ++i )
        if( (i % 3 != 0) && (i % 5 != 0) )
            ans += i;
    
    cout << ans << endl;
}

long long int gcd(long long int a, long long int b)
{
    long long int ret;
     
    if( a < b ){
        long long int tmp = a;
        a = b;
        b = tmp;
    }
     
    if( b == 0 ) return a;
     
    ret = a % b;
    ret = gcd(b, ret);
     
    return ret;
}

void C()
{
    int K;
    cin >> K;
    
    int ans = 0;
    
    for( int a = 1; a < K+1; ++a )
        for( int b = 1; b < K+1; ++b )
            for( int c = 1; c < K+1; ++c )
                ans += gcd(gcd(a, b), c);
    
    cout << ans << endl;
}

int main()
{
    //A();
    //B();
    C();
    
    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int h1 = sc.nextInt();
		int m1 = sc.nextInt();
		int h2 = sc.nextInt();
		int m2 = sc.nextInt();
		int	k = sc.nextInt();
		
		int calc = (h2*60 + m2) - (h1*60 + m1) ;
		System.out.println(calc-k);
		
	}

}


Measured memory_bytes: 35772
#pragma warning(disable: 4996)
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<string.h>
#include<vector>
#include<queue>


using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const int INF=1001001001;

const int mod=100000;

struct road{
	int start;
	int end;
	int length;
};

vector<road> einfo;
vector< pair<int,int> > edge[3003];//a?????????b????????????????????????l???->???edge[a]=(b,l)
int dist[3000];

int main(){
	int N,M,K;
	memset(dist,INF,sizeof(dist));
	scanf("%d %d %d",&N,&M,&K);
	rep(i,M){
		int a,b,l;
		scanf("%d %d %d",&a,&b,&l);
		edge[a-1].push_back( make_pair(b-1,l) );
		edge[b-1].push_back( make_pair(a-1,l) );
		road k;k.start=a-1;k.end=b-1;k.length=l;
		einfo.push_back( k);
	}
	priority_queue< vector<pair<int,int> >, vector< pair<int,int> > , greater< pair<int,int> > > q;
	rep(i,K){
		int s;
		scanf("%d",&s);
		q.push( make_pair(0,s-1) );
	}
	while(!q.empty()){
		pair<int,int> n=q.top();q.pop();
		if(dist[n.second]<=n.first)continue;
		dist[n.second]=n.first;
		rep(i,edge[n.second].size()){
			q.push(make_pair(n.first+edge[n.second][i].second, edge[n.second][i].first) );
		}
	}
	double ans=0;
	rep(i,einfo.size()){
		road r=einfo[i];
		ans=max( ans, (double)(dist[r.start]+dist[r.end]+r.length)/2.0);
	}

	printf( "%d\n", (int)(ans)+(bool)((int)(ans)<=(double)(ans)-0.5));
}

Measured memory_bytes: 8020
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const int EPS = 1e-9;
const int MOD = 1e9 + 7;
const ll INF = 1LL << 50;
const double PI = acos(-1);

struct Edge {
	ll from, to, cost;
	Edge(){}
	Edge(ll _from, ll _to, ll _cost) {
		from = _from;
		to = _to;
		cost = _cost;
	}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
Edges EG;
int V, E;//V=>頂点数 E=>辺数

//頂点sから各頂点への最短距離を求める
// => return true:グラフに負の閉路が存在する。　
bool shortest_path(int s, vll &D) {
	D[s] = 0;
	int cnt = 0;
	while (true) {
		bool update = false; //このループで更新が起こったか
		REP(i, E) {//Edge1本づつに関して
			Edge e = EG[i];
			if (D[e.from] == INF)continue;
			if (D[e.to] > D[e.from] + e.cost) {
				//このEdgeを通ると暫定より低コストでe.toに行ける場合
				D[e.to] = D[e.from] + e.cost;//値を更新
				update = true;
			}
		}
		if (!update) return false;//最短距離の更新が終了
		cnt++;
		if (cnt == V-1)return true; //負の閉路が存在しない場合たかだか|V|-1回しかループしない
	}
}

vector<bool> Negative;
void negative(vll &D) {
	REP(i, V) {
		REP(j, E) {
			if (D[EG[j].from] == INF)continue;
			if (D[EG[j].to] > D[EG[j].from] + EG[j].cost) {
				D[EG[j].to] = D[EG[j].from] + EG[j].cost;
				Negative[EG[j].to] = true;
			}
			if (Negative[EG[j].from])Negative[EG[j].to] = true;
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> V >> E;
	EG = Edges(E);
	vll D(V,INF);
	Negative = vb(V, false);
	REP(i, E) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		EG[i] = Edge(a, b, -c);
	}
	shortest_path(0, D);
	negative(D);
	if (Negative[V-1])cout << "inf" << endl;
	else cout << -D[V - 1] << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 512