akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
typedef long long ll;
const int inf=1e9+7;
inline int poww(int a,int b)
{
  	int base=a,ans=1;
  	while(b)
       	 {
        	if(b&1)
		    ans=(ans*base)%inf;
        	base=(base*base)%inf;
        	b>>=1;
    	 }
  	return ans;
}
inline int fast_multiply(int a,int b)
{
	int ans=0,s=a;
	for(;b;b>>=1,s=(s+s)%inf)
	   	if(b&1)
		   	ans=(ans+s)%inf;
	return ans;
}
inline int read()
{
  	int p=0,f=1;char c=getchar();
  	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
  	while(c>='0'&&c<='9'){p=p*10+c-'0';c=getchar();}
  	return f*p;}
char s[109];
bool f1,f2;
int main()
{
    cin>>s;
    for(int i=0;i<strlen(s);i++)
        {
        	if(s[i]=='C')
        	   f1=1;
        	if(f1&&s[i]=='F')
        	   {
        	   	f2=1;break;
			   }
		}
    if(f2)printf("Yes");
    else printf("No");
    printf("\n");
  	return 0;
}

Measured memory_bytes: 256
def az18():
    n,m = map(int,raw_input().split())
    a = [[0 for i in range(m)] for j in range(n)]
    b = [0 for i in range(m)]
    for i in range(n):
        a[i] = map(int,raw_input().split())
    for i in range(m):
        b[i] = input()
    for i in range(n):
        t = map(lambda (x,y): x*y, zip(a[i],b))
        print sum(t)
        
    
    
az18()

Measured memory_bytes: 4568
import sys
N = input()
A = int(N[0])
B = int(N[1])
C = int(N[2])
D = int(N[3])

def ops (i):
    ans = "+" if i == 0 else "-"
    return ans

for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = A + ((-1)**i)*B + ((-1)**j)*C + ((-1)**k)*D

            if ans == 7:
                print("{0}{1}{2}{3}{4}{5}{6}=7" .format(A,ops(i),B,ops(j),C,ops(k),D))
                sys.exit()

Measured memory_bytes: 9212
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N, K;
    cin >> N >> K;
    lli a[N];
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    for (int i = K; i < N; i++)
    {
        if (a[i] > a[i - K])
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    return 0;
}


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

int main()
{
    int N, M, input, tmp;
    long long account = 0;

    cin >> N >> M;
    priority_queue<double> A;
    for (int i = 0; i < N; i++)
    {
        cin >> input;
        A.push(input);
    }
    for (int i = 0; i < M; i++)
    {
        tmp = A.top() / 2;
        A.pop();
        A.push(tmp);
    }
    while (!A.empty())
    {
        account += (long long)A.top();
        A.pop();
    }
    cout << account << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

#define YesNo(b) ((b) ? "Yes" : "No")
#define YESNO(b) ((b) ? "YES" : "NO")

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;



int main()
{
    int S, W;
    cin >> S >> W;

    bool ans = (W >= S);
    cout << ((ans) ? "unsafe" : "safe") << endl;
}

Measured memory_bytes: 3636
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(n,x);
  OUT(x*(int)(pow(x-1,n-1)));
}

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right

from sys import setrecursionlimit
setrecursionlimit(10 ** 6)

class UnionFind:
    def __init__(self, size):
        self.data = [-1] * size
    def find(self, x):
        if self.data[x] < 0:
            return x
        else:
            self.data[x] = self.find(self.data[x])
            return self.data[x]
    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x != y:
            if self.data[y] < self.data[x]:
                x, y = y, x
            self.data[x] += self.data[y]
            self.data[y] = x
        return (x != y)
    def same(self, x, y):
        return (self.find(x) == self.find(y))
    def size(self, x):
        return -self.data[self.find(x)]



N, M, *I = map(int, open(0).read().split())
AB, LR = I[:2 * N], I[2 * N:]

A, B = map(list, zip(*sorted(zip(*[iter(AB)] * 2))))
D = [l ^ r for l, r in zip([0] + B, B + [0])]
E = [set() for _ in range(N + 1)]

uf = UnionFind(N + 1)
for i, (l, r) in enumerate(zip(*[iter(LR)] * 2), 1):
    li = bisect_left(A, l)
    ri = bisect_right(A, r)
    if li == ri or uf.same(li, ri):
        continue

    uf.union(li, ri)
    E[li].add((ri, i))
    E[ri].add((li, i))


used = set()
def dfs(v, p):
    res = D[v]
    for u, c in E[v]:
        if u == p:
            continue
        ret = dfs(u, v)
        if ret == 1:
            used.add(c)
        D[u] = 0
        res ^= ret
    return res

for v in range(N + 1):
    if D[v]:
        D[v] = dfs(v, -1)

if all(d == 0 for d in D):
    print(len(used))
    print(*sorted(used))
else:
    print(-1)

Measured memory_bytes: 81532
#include <bits/stdc++.h>
#include<algorithm>//next_permutation
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
 
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
const int ddx[]={-1,-1,-1,0,0,1,1,1};
const int ddy[]={-1, 0, 1,-1,1,-1,0,1};

int main (){    
    int n;
    cin >> n;
    vector<int>a(n+2);
    a[0]=0;
    a[n+1]=0;
    for(int i = 1;i<=n;++i) cin>>a[i];
    int s = 0;
    for(int i = 1;i<=n+1;++i){
        s+=abs(a[i]-a[i-1]);
    }
    for(int i = 1;i<=n;++i){
        cout << s-abs(a[i+1]-a[i])-abs(a[i]-a[i-1])+abs(a[i+1]-a[i-1])<<endl;
    }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> height(n);
    for(int i = 0; i < n; ++i){
        cin >> height[i];
    }
    if(n == 2){
        cout << abs(height[1] - height[0]);
        return 0;
    }
    int min_cost = 0, prev2 = 0, prev1 = abs(height[1] - height[0]);
    for(int i = 2; i < n; ++i){
       min_cost = min(prev1 + abs(height[i] - height[i - 1]), prev2 + abs(height[i] - height[i - 2]));
        prev2 = prev1;
        prev1 = min_cost;
    }
    cout << min_cost << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
long long int inf = 1e18;

int main() {
  int n; cin >> n;
  int now = 0;
  int x = 0;
  int y = 0;
  bool f = true;
  for(int i=0; i<n; i++){
    int t, nx, ny;
    cin >> t >> nx >> ny;
    int dist = abs(x-nx) + abs(y-ny);
    if( dist > t || (t-now)%2 != dist%2 ){
      f = false;
    }
    now = t;
    x = nx;
    y = ny;
  }

  cout << ( f ? "Yes" : "No") << endl;


  return 0;
}




//


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var ss = ReadLine().Split();
            if (ss[0].Last() == ss[1].First() && ss[1].Last() == ss[2].First())
                WriteLine("YES");
            else
                WriteLine("NO");
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 26232
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll n,k;
 sc(n);sc(k);
 ll m;
 ll a;
 rep(i,0,n){
  sc(a);
  if(a==1)m=i;
 }
 ans=cei(n-1,k-1);
 pr(ans);
 return 0;}

Measured memory_bytes: 3620
#include<iostream>
#include<functional>
#include<vector>
#include<cstring>
#include<string.h>
#include<algorithm>
#include<stack>
using namespace std;
int main()
{
  string s;
  cin>>s;
  string res="";
  auto it=s.rbegin();
  if(*it=='s')
  {
    res=s+"es";
  }
  else
  {
    res=s+"s";
  }
  cout<<res<<endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
ll B=1000000007;
int main(){
  ll n,m;
  string s;
  cin>>n>>m>>s;
  int l=0,r=0;
  set<ll> sl;
  ll hash[n+1],p[n+1];
  hash[0]=0;p[0]=1;
  for(ll i=0;i<n;i++){
    hash[i+1]=hash[i]*B+s[i];
    p[i+1]=p[i]*B;
  }
  for(ll i=0;i<m;i++){
    string q;
    cin>>q;
    if(q=="R++") r++;
    if(q=="R--") r--;
    if(q=="L++") l++;
    if(q=="L--") l--;
    sl.insert(hash[r+1]-hash[l]*p[r-l+1]);
  }
  cout<<sl.size()<<endl;
  return 0;
}

Measured memory_bytes: 21740
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        int N;
        String S;

        void solve(InputReader in, PrintWriter out) {
            N = in.nextInt();
            S = in.next();
            out.println(N < 3200 ? "red" : S);
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

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

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

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

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

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

Measured memory_bytes: 22740
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.EducationalDP
{
    class G
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            int n = nm[0];
            int m = nm[1];
            List<int>[] graph = new List<int>[n];
            for(int i = 0; i < n; i++)
            {
                graph[i] = new List<int>();
            }
            for(int i = 0; i < m; i++)
            {
                int[] xy = ReadInts();
                graph[xy[0] - 1].Add(xy[1] - 1);
            }
            bool[] visit = new bool[n];
            int[] dist = new int[n];
            int res = 0;
            for (int i = 0; i < n; i++)
            {
                if (visit[i]) continue;

                res = Math.Max(res, DFS(graph, ref visit, ref dist, i));
            }
            Console.WriteLine(res);
        }

        static int DFS(List<int>[] graph, ref bool[] visit,
            ref int[] dist, int now)
        {
            if (visit[now]) return dist[now];

            visit[now] = true;
            int distance = 0;
            for(int i = 0; i < graph[now].Count; i++)
            {
                distance = Math.Max(distance, 1 + DFS(
                        graph, ref visit, ref dist, graph[now][i]));
            }
            dist[now] = distance;
            return dist[now];
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 29452
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
vector<vector<int> > v(100000);
int dfs(int now,int p){
	int ret = 0;
	for(auto& to:v[now]){
		if(to == p) continue;
		ret ^= (dfs(to,now)+1);
	}
	return ret;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b;
    cin >> n;
    for(int i=1;i<n;i++){
    	cin >> a >> b;
    	a--;b--;
    	v[a].pb(b);
    	v[b].pb(a);
    }
    if(dfs(0,-1))cout << "Alice" << endl;
    else cout << "Bob" << endl;
    return 0;
}


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

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using ll = long long;
using PAIR = pair<int, int>;
using Graph = vector<vector<int>>;
//const ll INF = (1LL << 60);
//const double pi=acos(-1.0);
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
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; }
/**************************************/

/******** User-defined Function *******/




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

/********** Main()  function **********/
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    n--;
    string s;
    while(n>=0){
        s+=char('a'+ n%26);
        n /= 26;
        n--;
    }

    reverse(all(s));
    if(s.size()==0) s='a';
    cout << s << endl;

    return 0;
}
/********  Main() Ends Here *************/


Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <iomanip>
#include <cmath>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

int main()
{
    // 整数の入力
    ll N;
    cin >> N;

    cout << fixed <<  setprecision(8) << (1.0 * (N/2 + (N % 2)))/N <<endl;
    return 0;
}

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

int main(){
    ll k,a=7,ans=1,t,p[1000001];
    rep(i,1000001){
        p[i]=0;
    }
    cin>>k;
    while(1){
        t=a%k;
        if(t==0){
            break;
        }
        if(p[t]==1){
            cout<<-1;
            return 0;
        }
        a=t*10+7;
        ans++;
        p[t]=1;
    }
    cout<<ans;
}

Measured memory_bytes: 11388
#include <algorithm>
#include <iterator>
#include <vector>
#include <iomanip>
#include <iostream>
#include <stack>
#include <queue>
#include <list>
#include <utility>
#include <typeinfo>
 
#include <string>
#include <cstring>
 
#include <cstdio>
#include <cassert>
 
// M_PI for pi
#define _USE_MATH_DEFINES
#include <cmath>
 
using namespace std;
 
static const int MAX = 10;

int N;
string s;
long long x[MAX];
long long y[MAX];
long long z[MAX];


long long f(int i, long long t, long long s) {
    //cout << "i: " << i << ", " << t << " " << s << endl;

    if (i < N) {
        if (t > 0) {
            return f(i + 1, t * 10 + x[i], s) + f(i + 1, x[i], s + t);
        } else {
            return f(i + 1, x[i], s);
        }
    } else {
        return s + t;
    }
}

void slove() {
}
 
int main(int argc, char* argv[]) {

    cin >> s;

    N = (int) s.size();

    for (int i = 0; i < N; ++i) {
        x[i] = atoi(s.substr(i, 1).c_str());
        //y[i] = atoi(s.substr(i, N).c_str());
        //z[i] = atoi(s.substr(0, i+1).c_str());

        //cout << "i: " << i << " " << y[i] << " " << z[i] << endl;
        //cout << "i: " << i << " " << x[i] << endl;
    }

    //cout << endl;
    cout << f(0, 0, 0) << endl;

    return 0;
}


Measured memory_bytes: 256
from operator import itemgetter
N = int(input())
AB = [list(map(int, input().split(" "))) for i in range(N)]

ABC = [[a, b, a+b] for a, b in AB]
ABC = sorted(ABC, key=itemgetter(2), reverse=True)
ans = 0
flag = True
for a, b, c in ABC:
    if flag:
        ans += a
    else:
        ans -= b
    flag = not flag
print(ans)


Measured memory_bytes: 40204
//Volume5 -> 0501

#include <iostream>
#include <vector>
//#include <math.h>
//#include <string>
#include <cmath>
#include <iomanip>

int main();

int main(){
	std::vector<int> totalAPoint;		//Aの得点
	std::vector<int> totalBPoint;		//Bの得点
	int dataSetCount = 0;				//ゲーム数

	while (1){
		int n = 0;		//1ゲームの入力数

		std::cin >> n;
		//n=0で終了
		if (n == 0){
			break;
		}

		dataSetCount++;

		int aPoint = 0;		//1ゲームにおけるAの得点
		int bPoint = 0;		//1ゲームにおけるBの得点

		for (int i = 0; i < n; i++){
			int tempA;
			int tempB;

			std::cin >> tempA >> tempB;
			if (tempA > tempB){
				aPoint += (tempA + tempB);
			}
			else if (tempA < tempB){
				bPoint += (tempA + tempB);
			}
			//引き分け
			else{
				aPoint += tempA;
				bPoint += tempB;
			}
		}

		totalAPoint.push_back(aPoint);
		totalBPoint.push_back(bPoint);
	}

	//結果出力
	for (int i = 0; i < dataSetCount; i++){
		std::cout << totalAPoint[i] << " " << totalBPoint[i] << std::endl;
	}

	//while (1);
	return 0;
}


Measured memory_bytes: 3108
# 整数の入力
# スペース区切りの整数の入力
N,W,H=gets.chomp.split(" ").map(&:to_i);
ans = 0
for i in 1..N do
    a,b = gets.chomp.split(" ").map(&:to_i)
    if W<=a && H<=b
        ans+=1
    end
end
p ans

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

// #define ANS  //for answer
#define CMP  //for compe

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define nv(x) #x,(x)
#define ncv(x) #x,":",(x)
#define ncvc(x) #x,":",(x),","
using ll = long long;
void pPRINT(std::ostream& ost) {}
template <class T, class... U>void pPRINT(std::ostream& ost,const T t,const U... u) {ost<<t<<" ";pPRINT(ost, u...);}
template <class... T>void PRINT(const T... t) {pPRINT(std::cout, t...);}
template <class... T>void PRINTl(const T... t){pPRINT(std::cout,t...);std::cout<<"\n";}
template <class T>void PRINTa(const T* const t,const ll size){REP(i,size)PRINT(t[i]);PRINTl();}
template <class T>void PRINTal(const T* const t,const ll size){REP(i,size)PRINTl(i,":",t[i]);}
#ifdef ANS
#define DEBUG(...)
#else
#define DEBUG(...) PRINTl("##DEBUG##","file :",__FILE__,", line :",__LINE__,"\n##DEBUG##",__VA_ARGS__)
#endif
#ifdef CMP
using namespace std;
#else
#endif

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

  ll n;cin>>n;
  ll m = n%100;
  if(n>1200||n<100){
    if(m>12||m<1)PRINT("NA");
    else PRINT("YYMM");
  }
  else{
    if(m>12||m<1)PRINT("MMYY");
    else PRINT("AMBIGUOUS");
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
    
    int n,temp,s,w;
    long long int ans=0;
    vector<int> all;
    cin>>s>>w;
    if(s>w)
        cout<<"safe"<<endl;
    else
        cout<<"unsafe"<<endl;
    //cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e14;
using Graph = vector<vector<int>>;

signed main(){
  string S;
  cin >> S;
  if( S == "RRR" ) cout << 3 << endl;
  else if( S == "RRS" || S == "SRR" ) cout << 2 << endl;
  else{
    for( int i = 0; i < 3; i++ ){
      if( S[i] == 'R' ){
        cout << 1 << endl;
        return 0;
      }
    }
    cout << 0 << endl;
  }
}


Measured memory_bytes: 3624
//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
#pragma comment(linker,"/STACK:33554432") /*32Mb*/

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <sstream>
#include <fstream>
#include <sstream>
#include <iterator>
#include <math.h>
using namespace std;

typedef  long long LL;
typedef  unsigned long long ULL;
typedef  long double LD;
typedef  pair<int, int> PII;
typedef  pair<long long, long long> PLL;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i)) 
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i)) 
#define MP make_pair
#define MOD 1000000007
#define mod 1000000000
#define INF 1000000007
#define PB push_back
#define eps 1e-8
#define X first
#define Y second



int main()
{
	cout.setf(ios::fixed, ios::floatfield);
	cout.precision(9);

	string s;
	cin >> s;
	int ans = 0;
	For(i, 0, s.length())
		if (s[i] == '1') ans++;

	cout << ans << endl;

	return 0;
}

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3");
            WillReturn.Add("1 2 3");
            //11
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4");
            WillReturn.Add("141421356 17320508 22360679 244949");
            //437235829
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        long ModVal = 1000000000 + 7;

        long[] AArr = InputList[1].Split(' ').Select(X => long.Parse(X)).ToArray();
        long wkSum = 0;
        foreach (long EachInt in AArr) {
            wkSum += EachInt;
            wkSum %= ModVal;
        }

        long Answer = 0;
        for (long I = 0; I <= AArr.GetUpperBound(0) - 1; I++) {
            wkSum -= AArr[I];
            wkSum += ModVal;
            wkSum %= ModVal;

            Answer += AArr[I] * wkSum;
            Answer %= ModVal;
        }
        Console.WriteLine(Answer);
    }
}


Measured memory_bytes: 47660
N = int(input())
l = []
for i in range(N):
    i = input()
    l.append(i)

b = l.count("AC")
c = l.count("WA")
d = l.count("TLE")
e = l.count("RE")

print("AC x",b)
print("WA x",c)
print("TLE x",d)
print("RE x",e)

Measured memory_bytes: 16292
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <unordered_set>

using namespace std;

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

    if(N%2==1){
        cout << "No" << endl;
        return 0;
    }

    string sub_str1 = S.substr(0, N/2);
    string sub_str2 = S.substr(N/2);
    
    if(sub_str1 == sub_str2){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
x = int(input())
if x<600:
    print(8)
elif x<800:
    print(7)
elif x<1000:
    print(6)
elif x<1200:
    print(5)
elif x<1400:
    print(4)
elif x<1600:
    print(3)
elif x<1800:
    print(2)
else:
    print(1)

Measured memory_bytes: 9176
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#define int long long
using namespace std;
int a[114];
signed main() {
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	cout << n - a - b + c << endl;
}


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

void fnInput(vector<int>& rvnBall, int& rnVarie)
{
  int nBallSiz;
  cin >> nBallSiz >> rnVarie;

  rvnBall.resize(nBallSiz);
  for (int& rnBall : rvnBall)
    cin >> rnBall;
}

int fnRewCount(const vector<int>& cnrvnBall, int nVarie)
{
  map<int, int> mpBall;

  for (int nBall : cnrvnBall)
    mpBall[nBall]++;

  vector<int> vnNum;
  for (pair<const int, int> PBall : mpBall)
    vnNum.push_back(PBall.second);

  int nRewCnt = 0;
  sort(begin(vnNum), end(vnNum), greater<int>());
  if (vnNum.size() <= nVarie)
    nRewCnt = 0;
  else
    for (int i = nVarie; i < vnNum.size(); i++)
      nRewCnt += vnNum[i];

  return nRewCnt;
}

int main()
{
  vector<int> vnBall;
  int nVarie;
  fnInput(vnBall, nVarie);
  cout << fnRewCount(vnBall, nVarie) << endl;

  return 0;
}

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	string ans(s.size(),'x');
	cout<<ans<<endl;
	return 0;
}

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

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

use std::collections::VecDeque;

fn main() {
    let n: usize = read();
    let k: i64 = read();
    let mut l: Vec<i64> = vec![];
    for _ in 0..n {
        let li = read();
        l.push(li);
    }

    l.sort();
    l.reverse();
    let mut ans = 0;

    for i in 0..k {
        ans += l[i as usize];
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int k;
int sta[100],tot;
ll dp[100][11];
ll dfs(int now,int x,bool lim){
    if(now==0)return 1;
    if(!lim&&dp[now][x])return dp[now][x];
    int maxx=lim?sta[now]:9;
    ll res=0;
    for(int i=0;i<=maxx;i++){
        if(x==10){
            if(i==0)res+=dfs(now-1,10,lim&&i==maxx);
            else res+=dfs(now-1,i,lim&&i==maxx);
        }
        else{
            if(abs(i-x)<=1)res+=dfs(now-1,i,lim&&i==maxx);
        }
    }
    if(!lim)dp[now][x]=res;
    return res;
}
bool check(ll n){
    tot=0;
    while(n)sta[++tot]=n%10,n/=10;
    for(int i=0;i<=tot;i++){
        for(int j=0;j<=10;j++)dp[i][j]=0;
    }
    ll res=dfs(tot,10,1);
    //cout<<res-1<<endl;
    return res-1>=k;
}
int main(){
    scanf("%d",&k);
    /*
    check(100);
    check(3234566667);
    check(1223433323);
    */
    
    ll l=1,r=1000000000000000000;
    ll mid,ans;
    while(l<=r){
        mid=l+r>>1;
        if(check(mid))ans=mid,r=mid-1;
        else l=mid+1;
    }
    printf("%lld\n",ans);
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;
int factorial(int n){
    if(n <= 1)
        return 1;
    return factorial(n-1) * n;
}
int findPosition(vector<int> &a){
    int n = a.size();
    int index = 0;
    vector<bool> occ(n, false);
    for(int i = 0;  i < n-1;i++){

        int x =  a[i] - 1;
        int cc = 0;
        for(int j =0; j < x; j++){
            if(!occ[j])
                cc++;
        }

        occ[x] = true;

        index += cc*factorial(n-i-1);
    }
    return index;
}
int main() {
    int n;
    cin >> n;

    if(n == 1){
        cout << 0 << endl;
        return 0;
    }

    vector<int> p(n);
    vector<int> q(n);
    for(auto &i: p){
        cin >> i;
    }
    for(auto &i: q){
        cin >> i;
    }
    cout << abs(findPosition(p) -findPosition(q) )<< endl;

    return 0;
}



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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> using V = vector<T>;
using P = pair<int, int>;

/*
 */

signed main() {
  int L;
  cin >> L;

  double tmp = L/3.0;
  double ans = tmp*tmp*tmp;

  printf("%.12f\n", ans);

  return 0;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	var l []int

	fmt.Scanf("%d", &n)
	l = make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &l[i])
	}

	isNg := false
	cnt := 0

	for i := 1; i < n; i++ {
		if l[i-1] > l[i] {
			if l[i-1]-l[i] > 1 {
				isNg = true
				break
			}
			cnt++
			if cnt > 1 {
				break
			}
		} else if l[i-1] < l[i] {
			cnt = 0
		}
	}

	if !isNg && cnt <= 1 {
		fmt.Print("Yes")
	} else {
		fmt.Print("No")
	}
}


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


int main(void) {
	int x, y, z, i, j, k;
	ll a[1003], b[1003], c[1003];
	vector<ll> w;

	cin >> x >> y >> z >> k;
	for (i = 0; i < x; i++) cin >> a[i];
	for (i = 0; i < y; i++) cin >> b[i];
	for (i = 0; i < z; i++) cin >> c[i];

	for (i = 0; i < y; i++) for (j = 0; j < z; j++) {
		w.push_back(b[i] + c[j]);
	}

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

	int sn;
	ll l, r, mid;
	l = 0;
	r = 1e18;
	while (r - l > 1) {
		mid = (l + r) / 2;
		sn = 0;
		for (i = 0; i < x; i++) {
			sn += w.end() - lower_bound(w.begin(), w.end(), mid - a[i]);
		}
		if (sn >= k) l = mid;
		else r = mid;
	}

	ll t = l;

	vector<ll> ans;
	vector<ll>::iterator ite;
	for (i = 0; i < x; i++) {
		ite = lower_bound(w.begin(), w.end(), t - a[i]);
		while (ite != w.end()) {
			ans.push_back(*ite + a[i]);
			ite++;
		}
	}

	sort(ans.begin(), ans.end(), greater<ll>());

	for (i = 0; i < k; i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 140380
/*
	*#*#*#* Author GaryMr *#*#*#*
########################################################################
	是否可以简化问题：
	抓住数据范围哪里小
	dfs or bfs
	是否可以化具体为抽象
	字符串问题是否可以用数学模拟递归过程（取c[i]或不取来算结果）
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	树的直径:随便找一点再走到它最远的点A，再从A最远的点走到最远B的点。AB就是树的直径
	匹配括号 左减右>=0
	字符串赋值字符加单引号
	double> printf("%lf")输出小数点6位，%.16lf输出后十六位
	多组数据清空？
	dp优化用g？
	线段树：大小为n的8倍
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
	1<<int(ceil(log2(double(n))))
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int MAX=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	int n,lo;
	scanf("%d %d",&n,&lo);
	string s;
	cin>>s;
	rb(i,0,n-1){
		if(i!=lo-1){
			cout<<s[i];
		}
		else{
			cout<<char(s[i]+32);
		}
	}
	return 0;
}

Measured memory_bytes: 256
t = (1..gets.to_i).map{gets.chomp.chars}
keys = t.join.chars.uniq
r = {}
keys.each do|i|
  r[i] = []
end
t.each do |l|
  c = l.group_by{|v|v}
  keys.each do |i|
    r[i].push(c[i].nil? ? 0 : c[i].length)
  end
end

r.keys.each{|i| r[i] = r[i].min}

puts r.keys.sort.inject('') {|v, i| v + i * r[i] }


Measured memory_bytes: 2044
from itertools import product
N, A, B, C = map(int, input().split())
L = []
for i in range(N):
  L.append(int(input()))
  
hand = ['n', 'a', 'b', 'c']

ans = 1e12
for h in product(hand, repeat=N):
  if len(set(h) & set(['a', 'b', 'c'])) < 3:
    continue
  cost = 0
  work_k = {'a':0, 'b':0, 'c':0}
  #print(h)
  for i in range(N):
    #print(i, h[i], L[i], work_k['a'])
    if h[i] == 'n':
      continue
    if work_k[h[i]] > 0:
      cost += 10
    work_k[h[i]] = work_k[h[i]] + L[i]
    
  cost += abs(A - work_k['a'])
  cost += abs(B - work_k['b'])
  cost += abs(C - work_k['c'])
  
  ans = min(cost, ans)

print(ans)

Measured memory_bytes: 3064
/*
* @author:  codancer
* @createTime:  2020-04-12, 19:57:58
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
typedef vector<int> VI;
typedef vector<ll> VII;
typedef pair<int,int> pii;
int main(){
	int n;
	cin>>n;
	while(n){
		if(n%10==7){
			cout<<"Yes"<<endl;
			return 0;
		}
		n/=10;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

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

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int N = 52;

string s[N];
int t[N];

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cin >> s[i] >> t[i];
  string x;
  cin >> x;
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    if (s[i] != x)
      ans += t[i];
    else ans = 0;
  cout << ans << '\n';

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int main(){
    int n, s;
    while(cin >> n >> s, n){
        long long dp[10][2005] = {{0}};
        dp[0][0] = 1;
        rep(j,101){
            for(int i = n; i >= 0; i--){
                for(int k = s; k >= 0; k--){
                    dp[i + 1][k + j] += dp[i][k];
                }
            }
        }
        cout << dp[n][s] << endl;
    }
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    string s; cin >> s;
    map<char, int> mp;
    for(int i=0; i<s.size(); i++) mp[s[i]]++;

    pair<char, int> pa = {'a', 0}; 
    for(auto itr=mp.begin(); itr!=mp.end(); itr++){
        if(itr->second > pa.second){
            pa.second = itr->second;
            pa.first = itr->first;
        }
    }

    int must = 2*(pa.second-1);
    int ans = 0;

    for(auto itr=mp.begin(); itr!=mp.end(); itr++){
        if(itr->first == pa.first) continue;
        ans += min(pa.second-1, itr->second);
    }

    if(ans >= must) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
package main

import "fmt"

// import "fmt"
func readline(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	return a
}

func main() {
	v := readline(3)
	a := v[0]
	b := v[1]
	t := v[2]
	res := (t / a) * b
	fmt.Println(res)
}


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

int main() {
  stack<int> S1;
  stack<pair<int, int> > S2;
  char ch;
  int sum = 0;
  for ( int i = 0; cin >> ch; i++ ) {
    if ( ch == '\\' ) S1.push(i);
    else if ( ch == '/' && S1.size() > 0 ) {
      int j = S1.top(); S1.pop();
      sum += i - j;
      int a = i - j;
      while ( S2.size() > 0 && S2.top().first > j ) {
        a += S2.top().second; S2.pop();
      }
      S2.push(make_pair(j, a));
    }
  }

  vector<int> ans;
  int t = 0;
  while ( S2.size() > 0 ) { ans.push_back(S2.top().second); S2.pop(); }
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();
  for ( int i = 0; i < ans.size(); i++ ) {
    cout << " ";
    t += ans[i];
    cout << ans[i];
  }
  cout << endl;

  return 0;
}


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

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	int m;cin >> m;
	UnionFind uni(n+1);
	for(int i = 0; i < m; i++){
		int a;cin >> a;
		int b;cin >> b;
		uni.unite(a,b);
	}

	vector<int> count = vector<int>(n+1,0);
	int maxCount = 0;
	for(int i = 1; i <= n; i++){
		int tmp = uni.root(i);
		count[tmp]++;
		if(count[tmp]>maxCount){
			maxCount = count[tmp];
		}
	}

	cout << maxCount << endl;

	return 0;
}


Measured memory_bytes: 11004
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;


int main() {
  int a,b;
  cin >> a >> b;
  cout << 6 - a - b << endl; 
}


Measured memory_bytes: 256