akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main(){
    int n; cin >> n;
    vector<ll> l(n);
    rep(i, n){
        cin >> l[i];
    }
    sort(l.begin(), l.end());

    int cnt=0;
    rep(i, n){
        for(int j=i+1; j<n; j++){
            for(int k=j+1; k<n; k++){
                if(l[i]+l[j]>l[k]&&l[i]!=l[j]&&l[j]!=l[k]&&l[k]!=l[i]){
                    cnt++;
                }
            }
        }
    }

    out(cnt);
}

Measured memory_bytes: 3636
import java.util.*;
import java.io.*;
import java.util.function.*;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        long n = in.nextLong();
        long a = in.nextLong();
        long b = in.nextLong();
        if (a > b) {
            long t = b;
            b = a;
            a = t;
        }
        if ((b - a) % 2 == 1) {
            long ans1 = a - 1 + (b - a + 1) / 2;
            a = n - a + 1;
            b = n - b + 1;
            if (a > b) {
                long t = b;
                b = a;
                a = t;
            }
            long ans2 = a - 1 + (b - a + 1) / 2;
            out.println(Math.min(ans1, ans2));
        } else {
            out.println((b - a) / 2);
        }
    }

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

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}


Measured memory_bytes: 23380
import java.util.*;

public class Main {

  static Scanner sc = new Scanner(System.in);

  static long[] size;
  static long[] patty;

  public static void main(String[] args) {

    int N = sc.nextInt();
    long X = sc.nextLong();

    size = new long[N+1];
    patty = new long[N+1];

    size[0] = 1;
    patty[0] = 1;
    for (int i=1; i<=N; i++) {
      size[i] = size[i-1] * 2 + 3;
      patty[i] = patty[i-1] * 2 + 1;
    }

    System.out.println(f(N, X));
  }

  static long f(int n, long x) {
    if (n == 0) return 1;
    if (x == 1) return 0;
    if (x <= (size[n]-1)/2) {
      return f(n-1, x-1);
    } else if (x == (size[n]-1)/2 + 1) {
      return patty[n-1] + 1;
    } else {
      return patty[n-1] + 1 + f(n-1, x-(size[n]-1)/2-1);
    }
  }
  
}

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

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

string s[12];

const int di[4] = {-1, 1, 0, 0}, dj[4] = {0, 0, -1, 1};
void dfs(int i, int j) {
  if (s[i][j] == '0') return;
  s[i][j] = '0';
  rep(z,4) {
    int ti = i + di[z], tj = j + dj[z];
    if (ti < 0 || tj < 0 || ti >= 12 || tj >= 12) continue;
    if (s[ti][tj] == '1') dfs(ti, tj);
  }
}

void solve() {
  REP(i,1,12) cin>>s[i];
  
  int res = 0;
  rep(i,12) rep(j,12) if (s[i][j] == '1') {
    res++; dfs(i,j);
  }
  cout<<res<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>s[0]) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 0
#ifdef __GNUC__
#include <bits/stdc++.h>
#endif // __GNUC_

int main() {

    int A, B;
    std::cin >> A >> B;
    int ans = (A >= 13) ? B : (A >= 6) ? B / 2 : 0;
    std::cout << ans << std::endl;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)



ll N,T,A[3030],B[3030];
pll AB[3030];
ll i, j, k;
ll dp[3030][9090];

int main(){
    scanf("%lld%lld", &N,&T);
    fornum(i,0,N){
        scanf("%lld%lld", &A[i], &B[i]);
        AB[i] = {A[i], B[i]};
    }
    sort(AB, AB + N);

    fornum(i,0,N){
        fornum(j,0,T+3030){
            dp[i + 1][j] = dp[i][j];
        }
        fornum(j,0,T){
            if(dp[i + 1][j + AB[i].first]<dp[i][j]+AB[i].second){
                dp[i + 1][j + AB[i].first] = dp[i][j] + AB[i].second;
            }
        }
    }
    ll ans = 0;
    fornum(i,0,T+3030){
        ans = max(dp[N][i], ans);
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 214784
#include <cstdio>
#include <iostream>
double sol[10000][2];
int main()
{
    double a, b, e, c, d, f;
    int i = 0;
    while (std::cin >> a >> b >> e >> c >> d >> f)
    {
        double det = a * d - b * c;

        double aa = d / det, bb = -b / det, cc = -c / det, dd = a / det;
        sol[i][0] = aa * e + bb * f;
        sol[i][1] = cc * e + dd * f;

        i++;
    }
    for (int j = 0; j < i; j++)
        printf("%.3f %.3f\n", sol[j][0], sol[j][1]);
    return 0;
}

Measured memory_bytes: 3152
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
const int N=55;
ll f[N][N][N*N];
int main() {
    int n,A;
    ll ans=0;
    cin>>n>>A;
    f[0][0][0]=1;
    for(int i=0,x;i<n;i++) {
	cin>>x;
	for(int j=0;j<=i;j++)
	    for(int k=0;k<2500;k++)
		if(f[i][j][k]) {
		    f[i+1][j][k]+=f[i][j][k];
		    f[i+1][j+1][k+x]+=f[i][j][k];
		}
    }
    for(int i=1;i<=n;i++) ans+=f[n][i][i*A];
    cout<<ans;
    return 0;
}

Measured memory_bytes: 65792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define  inf 0x3fffffff 
int main()
{
	long long n,sum,i;
	while (~scanf("%lld", &n))
	{
		sum = 1;
		for (i = 1; i <= n; i++)
		{
			sum *= i;
			if (sum > 1000000007)
				sum %= 1000000007;
		}
		printf("%lld\n", sum);
	}
	return 0;
}

Measured memory_bytes: 128
def main():
    MOD = 10 ** 9 + 7

    S = int(input())
    dp = [0] * (S + 1)
    dp[0] = 1

    acc = 0
    for x in range(3, S + 1):
        dp[x] = (acc := (acc + dp[x - 3]) % MOD)

    print(dp[S])


if __name__ == '__main__':
    main()


Measured memory_bytes: 9108
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>

#define A_P(n,a,d) (n/2)*(2*a + (n-1)*d)
using namespace std;


int main(void){
    int N,K;
    int by4 = 0;
    int even = 0;
    int odd = 0;

    cin >> N;
    for(int i =0; i < N; i++){
        int tmp;
        cin >> tmp;
        if(tmp % 4 == 0){
            by4++;
        }else if(tmp % 2 == 0){
            even++;
        }else{
            odd++;
        }
    }


    if(by4 >= odd){
        cout << "Yes" << endl;
    }else if(by4+1 == odd && even == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
	int A, B;
	cin >> A >> B;
	
	int tasu = A + B;
	int hiku = A - B;
	int kakeru = A * B;
	
	if(tasu > hiku){
		if(kakeru > tasu){
			cout << kakeru << endl;
		}else{
			cout << tasu << endl;
		}
	}else{
		if(kakeru > hiku){
			cout << kakeru << endl;
		}else{
			cout << hiku << endl;
		}
	}
	
	return 0;
}

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

typedef long long ll;
ll MOD = 1e9+7;

map<ll,int> mp;
int main()
{
	int n;
	int ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		ll a;
		cin>>a;
		mp[a]++;
	}

	for(auto itr=mp.begin();itr!=mp.end();itr++)
	{
		if((*itr).second%2==1)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

#define INPUT_FROM_FILE (0)
#if INPUT_FROM_FILE
#include <fstream>
#endif

void counting_sort(const std::vector<int> &A, std::vector<int> &B, int k){
	std::vector<int> C(k + 1, 0);
	
	for(unsigned int i = 0; i < A.size(); i++){
		C[A[i]]++;
	}

	for(unsigned int i = 1; i < C.size(); i++){
		C[i] += C[i - 1];
	}

	for(int i = B.size() - 1; i >= 0; i--){
		B[C[A[i]] - 1] = A[i];
		C[A[i]]--;
	}
	return;
}

int main(int argc, char **argv){
#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif
	int n = 0;
	std::vector<int> A;
	std::vector<int> B;
	int k = 0;

#if INPUT_FROM_FILE
	ifs >> n;
#else
	std::cin >> n;
#endif

	A.resize(n, -1);
	B.resize(n, -1);
	for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
		ifs >> A[i];
#else
		std::cin >> A[i];
#endif
		k = std::max(k, A[i]);
	}

	counting_sort(A, B, k);

	std::cout << B[0];
	for(int i = 1; i < n; i++){
		std::cout << " " << B[i];
	}
	std::cout << std::endl;

	return 0;
}


Measured memory_bytes: 18408
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int main()
{
	string s;
	cin >> s;
	int a = (int)(s[0] - '0');
	int b = (int)(s[1] - '0');
	int c = (int)(s[2] - '0');
	int d = (int)(s[3] - '0');
	if (a == b&&b == c)cout << "Yes" << endl;
	else if (b == c&&c == d)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
def main():

    N = int(input())
    a = []
    for _ in range(N):
        s, t = input().split()
        t = int(t)
        a.append([s, t])
    X = input()

    ans = 0
    flag = False
    for s, t in a:
        if flag == True:
            ans += t
        if s == X:
            flag = True
    return ans

if __name__ == '__main__':
    print(main())


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

int main(){
  while(true){
    int n;
    cin >> n;

    if(n==0)
     break;

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

    int cnt[26] = {0};

    for(int i=0; i<n; i++){
      cnt[(int)(c[i]-'A')]++;

      int max1 = -1;
      int max2 = -1;

      for(int j=0; j<26; j++){
        if(cnt[j]>max1){
          max2 = max1;
          max1 = cnt[j];
        }
        else if(cnt[j]>max2){
          max2 = cnt[j];
        }
      }

      if(max1-max2>n-(i+1)){
        for(int j=0; j<26; j++){
          if(cnt[j]==max1){
            cout << (char)(j+'A') << ' ';
            break;
          }
        }
        cout << (i+1) << endl;
        break;
      }

      if(i==n-1){
            cout << "TIE" << endl;
            break;
      }
    }
  }
  return 0;
}



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

int main() {
  int H, W;
  cin >> H >> W;
  
  for (int i = 0; i < W + 2;i++)
    cout << "#";
  cout << endl;
  for(int i = 0; i < H; i++){
    vector<string> vec(H);
    cin >> vec.at(i);
    cout << "#" + vec.at(i) + "#" << endl;
  }
  for (int i = 0; i < W + 2;i++)
    cout << "#";
  cout << endl;
}

Measured memory_bytes: 256
/*
 *  AUTHOR : MANAV PATEl
*/
#include<bits/stdc++.h>
#include<functional>
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

namespace fastio {

	template <class T> istream &operator>>(istream &os, vector<T> & vec) {
		for (auto &u : vec)os >> u;
		return os;
	}
	template <class T> ostream &operator<<(ostream &os, const vector<T> & vec) {
		for (auto &u : vec)os << u << " ";
		return os;
	}
	template<class T1, class T2> inline istream& operator>>(istream& os, pair<T1, T2>& p) {
		return os >> p.first >> p.second;
	}
	template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
		return os << p.first << " " << p.second;
	}
	template <class T> ostream &operator<<(ostream &os, set<T> & con) {
		for (auto &u : con) os << u << " ";
		return os;
	}
	void re() {}
	template <typename T, typename... args> void re(T& x, args&... tail) {
		cin >> x;
		re(tail...);
	}
	void pr() {}
	template <typename T> void pr(const T& x) {
		cout << x;
	}
	template <typename T, typename... args> void pr(const T& x, const args&... tail) {
		cout << x << " ";
		pr(tail...);
	}
	template <typename... args> void prln(const args&... tail) {
		pr(tail...);
		cout << "\n";
	}
}
using namespace fastio;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9+7;
const ll mod1 = 998244353;

#define fill(a)  memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back

int main()
{
	cin.sync_with_stdio(false);
	cin.exceptions(cin.failbit);
	cin.tie(0);
	ll a, b;
	re(a,b);
	if((a+b)% 2==  0)
	{
		cout << (a+b)/2 <<"\n";
	}
	else cout << "IMPOSSIBLE\n";
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_042_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int L = int.Parse(input[1]);
            string[] strArr = new string[N];

            for (int i = 0; i < N; i++)
            {
                strArr[i] = Console.ReadLine();
            }
            Array.Sort(strArr);

            var ans = strArr[0];

            for (int i = 1; i < N; i++)
            {
                ans += strArr[i];
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13404
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		String code = "Good";
		for (int i = 0; i < 3; i++) {
			if (S.charAt(i) == S.charAt(i + 1)) {
				code = "Bad";
			}
		}
		System.out.println(code);
	}

}

Measured memory_bytes: 35628
for _ in [0]*int(input()):
    s=input()
    cur=0
    for _ in [0]*int(input()):
        c=input()
        if c[0]=='i':
            c=c.split('"')[1]
            s=s[:cur]+c+s[cur:]
            cur+=len(c)
        elif c[8]=='w':
            while cur<len(s) and s[cur]==' ':cur+=1
            while cur<len(s) and s[cur]!=' ':cur+=1
        elif c[7]=='c':s=s[:cur]+s[cur+1:]
        elif c[9]=='w':
            while cur>0 and s[cur-1]==' ':cur-=1
            while cur>0 and s[cur-1]!=' ':cur-=1
        elif c[8]=='c':cur=min(len(s),cur+1)
        elif c[7]=='w':
            if s[cur:].count(' ') == len(s[cur:]): continue
            while cur<len(s) and s[cur]==' ':s=s[:cur]+s[cur+1:]
            while cur<len(s) and s[cur]!=' ':s=s[:cur]+s[cur+1:]
        else:cur=max(0,cur-1)
    print(s[:cur]+'^'+s[cur:])

Measured memory_bytes: 7624
#include<stdio.h>

int GCD(int a, int b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
int main() {
	int i, j, k, f = 0, n, t, m, b, h, w, r, g;
	int r1, g1, b1;


	scanf("%d %d %d %d", &r, &g, &b, &n);

	r1 = n / r +1;
	g1 = n / g +1;
	b1 = n / b +1;

	
	for (i = 0;i < r1;i++) {
		for (j = 0;j < g1;j++) {	
			m = r * i + g * j;
			t = n - m;
			if (t%b == 0&&t>=0) {
				f = f + 1;
			
			}
		}
	}




	printf("%d",f);


	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl;
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0);

const ll INF = 1e9+7;

// 各桁の和
template<typename T>
T digit(T num){
  T sum = 0;
  while(num){
    sum += num % 10;
    num /= 10;
  }
  return sum;
}

template<typename T>T gcd(T a,T b){
  if(b == 0)
    return a;
  return gcd(b,a%b);
}
template<typename T>T lcm(T a, T b){
  T g = gcd(a,b);
  return a/g*b; 
}
template<typename T>T power(T a,T b){
  T tmp = 1;
  rep(i,b){
    tmp *= a;
  }
  return tmp;
}
int main(){
  string s;
  cin>>s;
  ll n;
  cin>>n;
  rep(i,n){
  	if(s[i] != '1'){
      print(s[i])
      return 0;
    }
  }
  
  print(1)
  
  return 0;
}


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

bool is_prime(int x)
{
    if (x == 1)
    {
        return false;
    }
    for (int i = 2; i < x; i++)
    {
        if (x % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    int N;
    cin >> N;
    int a = 11;
    for (int i = 0; i < N; i++)
    {
        while (!is_prime(a))
        {
            a += 10;
        }
        cout << a << " ";
        a += 10;
    }
    cout << endl;
}


Measured memory_bytes: 256
package main

import (
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	const mod = 998244353
	const mx int = 2e5
	F := [mx + 1]int{1}
	for i := 1; i <= mx; i++ {
		F[i] = F[i-1] * i % mod
	}
	pow := func(x, n int) int {
		res := 1
		for ; n > 0; n >>= 1 {
			if n&1 == 1 {
				res = res * x % mod
			}
			x = x * x % mod
		}
		return res
	}
	invF := [...]int{mx: pow(F[mx], mod-2)}
	for i := mx; i > 0; i-- {
		invF[i-1] = invF[i] * i % mod
	}
	c := func(n, k int) int { return F[n] * invF[k] % mod * invF[n-k] % mod }

	var n, m, k, ans int
	Fscan(_r, &n, &m, &k)
	for i := 0; i <= k; i++ {
		ans = (ans + c(n-1, i)*pow(m-1, n-1-i)) % mod
	}
	Fprint(_w, ans*m%mod)
}

func main() { run(os.Stdin, os.Stdout) }


Measured memory_bytes: 4968
from collections import deque
 
n=int(input())
command=[0 for i in range(n)]
k=[0 for i in range(n)]
k_queue= deque([])
 
for i in range(n):
    s=input()
    if s=="deleteFirst" or s=="deleteLast":
        command[i],k[i]=s,0
    else:
        command[i],k[i]=s.split()
     
for i in range(n):
    if command[i]=="insert":
        k_queue.appendleft(k[i])
    elif command[i]=="deleteFirst":
        k_queue.popleft()
    elif command[i]=="deleteLast":
        k_queue.pop()
    else:
        try: k_queue.remove(k[i])
        except ValueError: y=0
print( " ".join(map(str, k_queue)))


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

ll n,m;
vl a;
ll ans = 0;
int main() {
    cin>>n>>m;

    a.resize(n);
    REP(i,n) cin>>a[i];

    vl csum(n+1);
    csum[0] = 0;
    FOR(i,0,n)
        csum[i+1] = (csum[i] + a[i]) % m;

    map<ll,ll> mm;

    REP(i,n+1){
        ans += mm[csum[i]];
        mm[csum[i]]++;
    }

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

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i, N) {
    cin >> a[i];
    a[i]--;
  }
  int now = 0;
  int cnt = 0;
  while (cnt < N) {
    now = a[now];
    cnt++;
    if (now == 1) {
      cout << cnt << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int dp[110][100010];

int main() {
    int N; cin >> N;
    int c = 1000 - N % 1000;
    if(c == 1000) c = 0;
    cout << c << endl;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int d=max(a,max(b,c));
  int e=min(a,min(b,c));
  int f=a+b+c-d-e;
  cout << d*10+e+f << endl;
}
 
            
            
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using namespace std;
using P = pair<int, int>;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    rep(i,n){
        if(a[i] == 0){
            cout << '0' << endl;
            return 0;
        }
    }
    ll ans = 1;
    ll mx = 1000000000000000000;
    rep(i,n){
        if(mx/ans < a[i]){
            cout << "-1" << endl;
            return 0;
        }
        ans *= a[i];
    }

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

Measured memory_bytes: 4052
Imports System.Text

Module D
    Sub Main(ByVal args() As String)
        Dim sb1 As StringBuilder = New StringBuilder
        Dim sb2 As StringBuilder = New StringBuilder
        sb1.Append(Console.ReadLine())
        Dim n As Integer = Integer.Parse(Console.ReadLine())
        Dim q As String
        Dim rv As Boolean = False
        For i As Integer = 1 To n
            q = Console.ReadLine()
            If q(0) = "1" Then
                rv = Not rv
            Else
                If Not rv Then
                    If q(2) = "1" Then
                        sb2.Append(q(4))
                    Else
                        sb1.Append(q(4))
                    End If
                Else
                    If q(2) = "1" Then
                        sb1.Append(q(4))
                    Else
                        sb2.Append(q(4))
                    End If
                End If
            End If
        Next
        Console.WriteLine(If(rv, StrReverse(sb1.ToString()) & sb2.ToString(), StrReverse(sb2.ToString()) & sb1.ToString))
    End Sub
End Module

Measured memory_bytes: 26064
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int):
    if N % 10 == 7 or (N // 10) % 10 == 7 or (N // 100) == 7:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9136
from collections import deque
N, M = map(int, input().split())
A = [[] for i in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  A[a-1].append(b - 1)
  A[b-1].append(a - 1)
B = [0 for i in range(N)]
cnt = 0
for i in range(N):
  if B[i] == 0:
    cnt += 1
    B[i] = cnt
    D = deque([i])
    while len(D) > 0:
      d = D.pop()
      for j in A[d]:
        if B[j] == 0:
          B[j] = cnt
          D.append(j)
print(cnt - 1)

Measured memory_bytes: 86900
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
typedef pair<ll, ll> p;

int n;
vector<vector<long double>> dp;
vector<long double> v;

void dfs(){
  for (int i = 1; i <= n; ++i) {
    for(int count = 0; count < i; count++){
      // cout << i << ' ' << count << endl;
      dp[i][count+1] += dp[i-1][count] * v[i-1];
      dp[i][count] += dp[i-1][count] * (1-v[i-1]);
      // print(dp);
    }
  }
}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  v = vector<long double>(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  dp = vector<vector<long double>> (n+3, vector<long double>(n+3, 0));
  dp[0][0] = 1;
  dp[0][1] = 0;
  dfs();
  long double res = 0;
  for(int count = n/2+1; count <= n; count++){
    res += dp[n][count];
  }
  cout << setprecision(15);
  cout << res << endl;

}


Measured memory_bytes: 141312
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

int
main(int argc, char** argv)
{
	while (true)
	{
		int x, y;

		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0)
			break;

		if (x > y)
		{
			int t = x;
			x = y;
			y = t;
		}

		printf("%d %d\n", x, y);
	}

	return 0;
}

Measured memory_bytes: 600
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<3;i++){
        if(s[i]=='1') ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int a,b;
   cin >> a >> b;
   if(a<=9 and b<=9){
      cout << a*b << '\n';
   }else{
      cout << "-1\n";
   }
   return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	string A, B, C;
	cin >> A >> B >> C;

	if (A[A.size() - 1] == B[0] && B[B.size() - 1] == C[0]) co("YES");
	else co("NO");
	Would you please return 0;
}

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

#define int long long
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()

#define fast ios::sync_with_stdio(0); cin.tie(0)

int32_t main(){
  
    fast;
    int a,b,c; cin >> a >> b >> c;
  	int ar[11]={0}; ar[a]++; ar[b]++; ar[c]++;
  	if(ar[5]==2&&ar[7]==1) cout << "YES";
  	else cout << "NO";
  
    return 0;
} 


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<tuple>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define tii tuple<int,int>
#define tiii tuple<int,int,int>
#define mt make_tuple
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
class FermatCombination{
public:
  vector<ll> factrial; // 階乗
  vector<ll> inverse; // 逆元
  FermatCombination(int size){
    factrial.resize(size+1);
    inverse.resize(size+1);
    factrial[0] = 1;
    inverse[0] = 1;
    for(int i = 1; i < size+1; i++){
      factrial[i] = factrial[i-1] * i % DIV;
      inverse[i] = pow(factrial[i],DIV-2,DIV);
    }
  }
  ll combination(int n, int k){
    if(n < k) return 0;
    return factrial[n]* inverse[k] % DIV * inverse[n - k] % DIV;
  }
  ll permutation(int n, int k){
    if(n < k) return 0; 
    return factrial[n] * inverse[n-k] % DIV;
  }
  // 1-nまでの整数から重複を許しn個選ぶパターンの数
  ll multi_choose(int n, int k){
    if(n == 0 && k == 0) return 1;
    else return combination(n+k-1,k);
  }
};

int main(){
  FermatCombination fc(1000000);
  int n; cin >> n;
  int l = 0,r = 0;
  map<int,int>  m;
  rep(i,n+1){
    int in; cin >> in;
    if(!r && m[in] != 0){
      r = i+1;
      l = m[in];
      continue;
    }else{
      m[in] = i+1;
    }
  }
  for(int k = 1; k <= n+1; k++){
    ll ans = fc.combination(n+1,k);
    int c = n-r+l;
    ans -= fc.combination(c,k-1);
    ans += DIV;
    cout << ans%DIV << endl;
  }
  
  return 0;
}

Measured memory_bytes: 21504
#include<iostream>
#include<string>
using namespace std;
using ll = long long;

int main() {
    string S, T;
    cin >> S >> T;

    int lengthOfSubstring = T.length();
    int minCharToChange = S.length();

    for (int i=0; i<(S.length()-lengthOfSubstring+1); ++i) {
        int charToChange = 0;
        for (int j=0; j<lengthOfSubstring; ++j) {
            if (S[i+j] != T[j]) {
                ++charToChange;
            }
        }
        minCharToChange = (charToChange < minCharToChange) ? charToChange : minCharToChange;
    }

    cout << minCharToChange << endl;
    return 0;
}

Measured memory_bytes: 3628
n,a,b= map(int,input().split())

ans = 0
for i in range(1,n+1):
    s = 0
    q = i
    for j in range(5):
        r = q % 10
        s += r
        q //= 10
    
    if a <= s and s <= b:
        ans += i
        
print(ans)

Measured memory_bytes: 40176
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#define inf 1e9

using namespace std;
typedef pair<int, int> P;

struct edge{
	int to, cost;
	edge(int a, int b){
		to = a, cost = b;
	}
};

int n, m;
vector<edge> g[105], G[305];
int dist[305];

void dijkstra()
{
	for(int i = 1; i <= 3*n; i++) dist[i] = inf;
	dist[1] = 0;

	priority_queue< P, vector<P>, greater<P> > Q;
	Q.push( make_pair(0, 1) );

	int v, d;
	while(Q.size()){
		d = Q.top().first;
		v = Q.top().second;
		Q.pop();
		if(dist[v] < d) continue;
		for(int i = 0; i < G[v].size(); i++){
			if(dist[G[v][i].to] > d + G[v][i].cost){
				dist[G[v][i].to] = d + G[v][i].cost;
				Q.push( make_pair(dist[G[v][i].to], G[v][i].to) );
			}
		}
	}
}

int main(void)
{
  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0) break;
    int u, v, w;
    for(int i = 1; i <= n; i++) g[i].clear();
    for(int i = 1; i <= m; i++){
      cin >> u >> v >> w;
      g[u].push_back(edge(v, w));
      g[v].push_back(edge(u, w));
    }

    for(int i = 1; i <= 3*n; i++) G[i].clear();
    for(int i = 1; i <= n; i++){
      for(int j = 0; j < g[i].size(); j++){
        int u = g[i][j].to, w = g[i][j].cost;
        G[i].push_back(edge(n+u, 0));
        G[n+i].push_back(edge(2*n+u, 0));
        G[i].push_back(edge(u, w));
        G[2*n+i].push_back(edge(2*n+u, w));
      }
    }

    dijkstra();

    int ans = min(dist[n], dist[3*n]);
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3148
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007;




int main(){
	int n;
	vi v;
	while(cin>>n){
		if(n==0)break;
		v.clear();
		rep(i,n){
			int a;
			cin>>a;
			v.pb(a);
		}
		sort(all(v));
		int sum=0;
		repc(i,1,n-1){
			sum+=v[i];
		}
		//cout<<sum<<" "<<n-2<<endl;
		cout<<(int)sum/(n-2)<<endl;
	}
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=500010;

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

    ll n,m,k;
    cin>>n>>m>>k;
    ll ar[n];
    ll br[m];

    ll pre[m];
    for(ll i=0;i<n;++i){cin>>ar[i];}
    for(ll j=0;j<m;++j){
        cin>>br[j];
        if(j==0){
            pre[j]=br[j];
        }
        else{
            pre[j]=pre[j-1]+br[j];
        }
    }

    ll ans=upper_bound(pre,pre+m,k)-pre;
    ll sum=0;
    for(ll i=0;i<n;++i){
        sum+=ar[i];
        if(k-sum>=0){
            ll count=upper_bound(pre,pre+m,k-sum)-pre;
            ans=max(ans,count+i+1);
        }
    }

    cout<<ans<<endl;

    return (0);
}


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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N,S;
ll dp [10] [1001];

int main()
{
	while(scanf("%d%d",&N,&S),N){
		memset(dp,0,sizeof(dp));
		dp [0] [0] = 1;
		FOR(i,0,101){
			for(int j = N - 1;j >= 0;j--){
				for(int k = 0;k + i <= S;k++){
					dp [j + 1] [k + i] += dp [j] [k];
				}
			}
		}
		printf("%lld\n",dp [N] [S]);
	}

	return 0;
}

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

using namespace std;

// #define int long long

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

#define rep(i,a,b) for (int i = a; i <= (int)b; ++i)
#define f first
#define s second

#define single_test

const int max_nodes = 2e5;
using edge = int32_t;
vector<edge> g[max_nodes];
bool vis[max_nodes];
struct digraph {
    int N;
    vector<int> topo;
    static void reset(int n) {
        for (int i = 0; i <= n; ++i) {
            g[i].clear();
            vis[i] = 0;
        }
    }
    digraph(int n) : N(n) { reset(n); }
    // return true if graph is DAG i.e. topo sort exists

    void add_edge(int u, int v) {
        g[u].emplace_back(v);
    }
};

const int maxn = 1e5 + 4;
int dp[maxn];

void dfs(int u, int par = -1) {
    vis[u] = 1;
    for (auto v: g[u]) {
        if (!vis[v]) {
            dfs(v, u);
        }
        dp[u] = max(dp[u], 1 + dp[v]);
    }
}

void solve() {
    int n, m;
    cin >> n >> m;
    digraph ins(n);
    while (m--) {
        int u, v;
        cin >> u >> v;
        ins.add_edge(u, v);
    }
    for (int i = 1; i <= n; ++i) {
        if (!vis[i]) {
            dfs(i);
        }
    }
    cout << *max_element(dp + 1, dp + 1 + n) << '\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: 15300
#include <iostream>
#include <unordered_map>

using namespace std;

int main()
{
  uint64_t n, m;
  cin >> n >> m;
  uint64_t a[n];
  for (auto i = 0; i < n; i++) {
    uint64_t v;
    cin >> v;
    a[i] = v;
  }
  uint64_t b[n + 1];
  b[0] = 0;
  uint64_t sum = 0;
  for (auto i = 0; i < n; i++) {
    sum += a[i];
    b[i + 1] = sum;
  }

  unordered_map<uint64_t, uint64_t> um;
  for (auto i = 0; i < n + 1; i++) {
    auto it = um.find(b[i] % m);
    if (it == end(um)) {
      um.emplace(b[i] % m, 1);
    } else {
      uint64_t v = it->second;
      um.erase(it);
      um.emplace(b[i] % m, v + 1);
    }
  }

  uint64_t ans = 0;
  for (auto&& e : um) {
    uint64_t v = e.second;
    ans += (v * v - v) / 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 5260
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    int n;
    vector<string> w;
    string tmp_w;
    bool ans=true;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> tmp_w;
        w.push_back(tmp_w);
    }

    for(int i=1; i<n; i++){
        if(w[i-1][w[i-1].size()-1]!=w[i][0]){
            ans=false;
            break;
        }
        for(int j=0; j<n; j++){
            if(w[i]==w[j] && i!=j){
                ans=false;
                break;
            }
        }
    }

    if(ans==true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

struct dice {
    int top, bottom, west, east, north, south;

    // no need naming these... just for clarity

    void roll_east() {
        int t = top;
        top = west;
        west = bottom;
        bottom = east;
        east = t;
    };

    void roll_west() {
        int t = top;
        top = east;
        east = bottom;
        bottom = west;
        west = t;
    };

    void roll_north() {
        int t = top;
        top = south;
        south = bottom;
        bottom = north;
        north = t;
    };

    void roll_south() {
        int t = top;
        top = north;
        north = bottom;
        bottom = south;
        south = t;
    };

    void show_dice() {
        std::cout << " " << north << std::endl;
        std::cout << west << bottom << east << top << std::endl;
        std::cout << " " << south << std::endl;
        std::cout << std::endl;
    };
};

int main() {
    dice d;
    std::cin >> d.top >> d.south >> d.east >> d.west >> d.north >> d.bottom;
    
    int n;
    std::cin >> n;
    
    for (int i = 0; i < n; i++) {
        int top, south;
        std::cin >> top >> south;
        while(d.south != south){
            for(int j = 0; j < 4; j++){
                if(d.south == south)
                    break;
                d.roll_north();
                //std::cout << "rolling north" << std::endl;
                //d.show_dice();
            }
            if(d.south != south){
                d.roll_east();
                //std::cout << "rolling east" << std::endl;
                //d.show_dice();
            }
        }
        while(d.top != top){
            d.roll_east();
            //std::cout << "rolling east" << std::endl;
            //d.show_dice();
        }

        std::cout << d.east << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3076
inputs = input().split(" ")
n = int(inputs[0])
k = int(inputs[1])
inputs = input().split(" ")
r = int(inputs[0])
s = int(inputs[1])
p = int(inputs[2])
t = input()
out = ""

result = 0

for i in range(0, k):
    if t[i] == 's':
        result += r
        out += 'r'
    elif t[i] == 'p':
        result += s
        out += 's'
    else:
        result += p
        out += 'p'

for i in range(k, n):
    tmp = 0
    tmp_hand = None
    if t[i] == 's':
        tmp += r
        tmp_hand = 'r'
    elif t[i] == 'p':
        tmp += s
        tmp_hand = 's'
    else:
        tmp += p
        tmp_hand = 'p'
    if tmp_hand != out[i-k]:
        result += tmp
        out += tmp_hand
    else:
        out += 'n'

print(result)


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

int main()
{
    string S;
    cin >> S;
//    cout << S << endl;
    
    int count = 0;
    int N;
    N = S.length();
    
    if(N == 1){
        cout << 1 << endl;
        return 0;
    }
    
    vector<int> dp(N+1, 0);
    
    dp[0] = 0;
    dp[1] = 1;
    if(S[0] == S[1]) dp[2] = 1;
    else dp[2] = 2;
    
    for(int i = 3; i<N+1; i++){
        if(S[i-2] != S[i-1]){
            dp[i] = dp[i-1]+1;
        }
        else{
            dp[i] = dp[i-3]+2;
        }
    }
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 1412
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		int H1, M1, H2, M2, K;
		cin >> H1 >> M1 >> H2 >> M2 >> K;

		int x = 60*H1 + M1;
		int y = 60*H2 + M2;
		cout << y-x-K << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; i++)
    {
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());
    cout << v.at(N - 1) - v.at(0) << endl;
}

Measured memory_bytes: 3636
import std.stdio, std.algorithm, std.range, std.format, std.numeric, std.string, std.conv, std.array, std.math;

auto readLine(T=int)() {
    return readln().split.map!(to!T).array;
}

void main() {
    int n;
    readf("%d\n", &n);
    auto a = readLine();
    auto fee = new int[n + 1];
    auto diff = new int[n + 1];

    fee[0] = abs(a[0]);
    foreach (i; 1 .. n) {
        fee[i] = abs(a[i-1] - a[i]);
    }
    fee[n] = abs(a[n-1]);

    auto total = fee.sum;

    /*
      before: 0 == fee[0] ==> a[0] == fee[1] ==> a[1]
      after:  0                              ==> a[1]
    */
    writeln(total - fee[0] - fee[1] + abs(a[1]));
    foreach (i; 1 .. n - 1) {
        /*
          before: a[i-1] == fee[i] ==> a[i] == fee[i+1] ==> a[i+1]
          after:  a[i-1]                                ==> a[i+1]
        */
        writeln(total - fee[i] - fee[i+1] + abs(a[i-1] - a[i+1]));
    }
    /*
      before: a[n-2] == fee[n-1] ==> a[n-1] == fee[n] ==> 0
      after: a[n-2]                         ==> 0
    */
    writeln(total - fee[n-1] - fee[n] + abs(a[n-2]));
}


Measured memory_bytes: 5128
#include <iostream>
using namespace std;
 
int main(){
    int n;
    cin >> n;
     
    for(int i=1; i<=n; i++){
        if(i%3==0){
            cout << " " << i;
            continue;
        }
        int x=i;
        while(x!=0){
            if(x%10 == 3){
                cout << " " << i;
                break;
            }
            x/=10;
        }
    }
    cout << endl;
    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int D,G;
int P[101],C[101];
int dp[1110];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>D>>G;
	
	FOR(i,1101) dp[i]=-1<<30;
	dp[0]=0;
	for(i=1;i<=D;i++) {
		cin>>x>>y;
		for(j=1000;j>=0;j--) {
			for(k=1;k<x;k++) dp[j+k]=max(dp[j+k],dp[j]+k*i*100);
			dp[j+x]=max(dp[j+x],dp[j]+x*i*100+y);
		}
		
	}
	
	FOR(j,1001) {
		if(dp[j]>=G) return _P("%d\n",j);
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int i, j;
	int hit = 0, blow = 0;
	int a[4], b[4];
	int count = 0;
	
	while (scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF){
		scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]);
		count++;
		
		for (i = 0; i < 4; i++){
if (a[i] == b[i]){
hit++;
}
			for (j = 0; j < 4; j++){
				if (i != j && a[i] == b[j]){
					blow++;
				}
			}
		}
		printf("%d %d\n", hit, blow);
hit = 0;blow = 0;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
//#define int long long 
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
 
 
	ll n,a,b;
	cin>>n>>a>>b;
	ll val=2;
	ll ans=pw(val,n);
	ans = (ans-1+mod)%mod;
	ll x=1;
	for(ll i=0;i<b;i++){
		x = x*(n-i)%mod;
		x = x*mi(i+1,mod)%mod;
		x%=mod;
		if(i==a-1){
			ans=(ans-x+mod)%mod;
		}
	}
	ans=(ans-x+mod)%mod;
	cout<<ans;
 
 
}
int32_t main(){
int t=1;
//cin>>t;
while(t--){
	solve();
}
}

Measured memory_bytes: 256