akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import sys
import itertools
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    S = lines.pop(0)
    K = int(lines.pop(0))
    n = 0
    skip = []
    res = []
    while K > 0:
        min_idx = 0
        min_str = "z"
        for i,x in enumerate(S):
            if i in skip:
                continue
            if min_str > x:
                min_str = x
                min_idx = i
            elif min_str == x:
                l = len(S[i:])
                if S[min_idx:min_idx+l] > S[i:]:
                    min_str = x
                    min_idx = i
                elif S[min_idx:min_idx+l] == S[i:]:
                    skip.append(i)
        skip.append(min_idx)
        res = S[min_idx:]
        if len(res) >= K:
            print(res[:K])
            sys.exit(0)
        else:
            K -= len(res)
    sys.exit(1)



#
# main
#
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Measured memory_bytes: 3188
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var K = cin.ReadInt;
            var LunLunNumber = new Queue<long>();
            var count = 0;
            long ans = 0;

            for (int i = 1; i < 10; i++)
            {
                LunLunNumber.Enqueue(i);
            }

            while (true) 
            {
                count++;
                if (count >= K)
                {
                    ans = LunLunNumber.Dequeue();
                    break;
                }
                var num = LunLunNumber.Dequeue();
                var d = num % 10;
                if (d != 0) LunLunNumber.Enqueue(num * 10 + d - 1);
                LunLunNumber.Enqueue(num * 10 + d);
                if (d % 10 != 9) LunLunNumber.Enqueue(num * 10 + d + 1);
                //WriteLine(num);
            }

            WriteLine(ans);
        }

    }


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }


        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 15200
#include <bits/stdc++.h>
    using namespace std;
    #define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
     
    typedef long long ll;
     
    int main(){FIN
    	
      ll w, h, sq;
        cin >> w >> h;
               if (w == 1 or h == 1) {
                 cout << 1 << "\n";
               } else {
                sq = w * h;
                cout << (sq / 2) + (sq % 2) << "\n";
               }
    	return 0;
    }

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

int x;
int gcd(const int &a, const int &b);

int main() {
	scanf("%d", &x);
	printf("%d\n", 360 / gcd(360, x));
	return 0;
}

int gcd(const int &a, const int &b) {
	return b == 0 ? a : gcd(b, a % b);
}



Measured memory_bytes: 3708
n, p = map( int, input().split())
lis = list( map( int, input().split()))

def nCk( n, k):
  ans = 1
  for i in range(k):
    ans *= (n-i)
  for i in range(k):
    ans /= (k-i)
  return ans

e = 0
o = 0
for i in lis:
  if i % 2 == 0:
    e += 1
  else:
    o += 1

if p == 0:
  ans = 1
  for i in range( o//2):
    ans += nCk( o, (i+1)*2)
  print( int( ans * 2**e))
else:
  ans = 0
  for i in range( o//2):
    ans += nCk( o, i*2+1)
  print( int( ans * 2**e))

Measured memory_bytes: 3064
n = int(input())
h = list(map(int, input().split()))

dp = [0]*n
dp[1] = abs(h[0]-h[1])

for i in range(2,n):
    dp[i] = min(abs(h[i-1]-h[i])+dp[i-1], abs(h[i-2]-h[i])+dp[i-2])
print(dp[-1])

Measured memory_bytes: 13980
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long ll;

ll n, k, t;
string str;

void read_input()
{
    scanf("%lld %lld", &n, &k);

    cin >> str;
}

string answer = "";

void test(string temp)
{
    ll z = n - 1;
    while(z > 0 && temp[z - 1] == temp[n - 1]) z--;
    ll curr = min(n, (1 << (k - 1)) * (n - z));
    string fin = "";
    for(ll i = 0; i < curr; i++)
    {
        fin += temp[n - 1];
    }
    ll left = n - curr;
    for(ll i = z - 1; left && i >= 0; i--, left--)
    {
        fin += temp[i];
    }
    if(answer == "") answer = fin;
    else
    answer = min(answer, fin);
    //cout << fin << " " << temp << "\n";
}

void solve()
{
    ll biggest = 'z';
    for(ll i = 0; i < n; i++)
    {
        biggest = min(biggest, 1LL * str[i] - 'a');
    }
    if(k >= 14)
    {
        for(ll i = 0; i < n; i++)
        {
            answer += biggest + 'a';
        }
    }
    else
    {

        string d = str;
        reverse(d.begin(), d.end());
        str += d;
        ll p = n * 2;
        for(ll i = n - 1; i < p; i++)
        {
            //printf("%c\n", str[i]);
            if(str[i] - 'a' == biggest)
            {
                //printf("%d %d\n", i - n + 1, i);
                test(str.substr(i - n + 1, n));
            }
        }
    }

    cout << answer;
}

int main()
{
    read_input();
    solve();

    return 0;
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
            int n = line[0], t = line[1];

            var min = int.MaxValue;

            for (var i = 0; i < n; i ++)
            {
                var ct = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
                if (ct[1] <= t) min = Math.Min(ct[0], min);
            }
            Console.WriteLine(min == int.MaxValue ? "TLE" : min.ToString());
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
const int inf=1e5;
int main(){
	int n,T,c[100],t[100],cost=inf;
	cin>>n>>T;
	for(int i=0;i<n;i++){
		cin>>c[i]>>t[i];
		if(t[i]<=T) cost=min(cost,c[i]);
	}
	if(cost==inf) cout<<"TLE"<<endl;
	else cout<<cost<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=5e5+10,mod=998244353;
int Pow(int x,int y) {                                                                                                                                                   
	int res=1;
	while(y) {
		if(y&1) res=res*(ll)x%mod;
		x=x*(ll)x%mod,y>>=1;
	}
	return res;
}
int fac[N],inv[N];
void getfac(int n) {
	fac[0]=1; for(int i=1;i<=n;++i) fac[i]=fac[i-1]*(ll)i%mod;
	inv[n]=Pow(fac[n],mod-2); for(int i=n;i>=1;--i) inv[i-1]=inv[i]*(ll)i%mod;
}
int C(int n,int m) { if(m>n) return 0;return fac[n]*(ll)inv[m]%mod*inv[n-m]%mod; }
int n,m;
int main() {
	rd(n),rd(m); getfac(m);
	if(m<n) {
		printf("0");
		return 0;
	}
	int ans=0;
	for(int R=0;R<=m;++R) {
		int B=m-R; if(R==B) B--;
		int tot=R+B;
		int L=R-B;
		if(L<0) continue;
		int T=B-(n-L);
		if(T<0) continue;
		ans=(ans+C(tot,R))%mod;
		if(L<n) ans=(ans-C(tot,R+T+1))%mod;
	}	
	printf("%d",(ans+mod)%mod);
	return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,x,y,z=0;
    cin>>a>>b>>c;
    for(int i=1;i<=a;i++){
        x=i;
        y=0;
        while(x){
            y+=x%10;
            x/=10;
        }
        if(y>=b&&y<=c) z+=i;
    }
    cout<<z<<endl;
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  vi a(5);
  int k;
  rep(i,5) cin >> a[i];
  cin >> k;
  bool ok = true;
  rep(i,5){
    for(int j=i+1; j<5; j++){
      if(a[j] - a[i] > k) ok = false;
    }
  }
  if(ok) cout << "Yay!" << endl;
  else cout << ":(" << endl;
}

Measured memory_bytes: 3588
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        Integer[] a = new Integer[m];
        Arrays.setAll(a, i -> Integer.parseInt(sc.next()));
        sc.close();

        // 主処理
        List<Integer> list = new ArrayList<>(); // 壊れていない連続する階段の段数のリスト
        int index = 0;
        for (int i = 0; i < a.length; i++) {
            int num = a[i] - index;
            index = a[i] + 1;
            list.add(num);
        }
        list.add(n - index + 1);

        // 連続した階段の段数の上り方はフィボナッチ数列で求められる
        long[] fibonacci = new long[100001];
        final long MOD = 1000000007;
        fibonacci[0] = 1;
        fibonacci[1] = 1;
        for (int i = 2; i < 100001; i++) {
            fibonacci[i] = (fibonacci[i - 1] + fibonacci[i - 2]) % MOD; // オーバーフローするためMODで除算
        }

        // 連続した階段の段数に上り方を求めて乗算する
        long result = 1;
        if (list.contains(0)) {
            result = 0;
        } else {
            for (int num : list) {
                result *= fibonacci[num - 1];
                result %= MOD;
            }
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 46652
// https://atcoder.jp/contests/abc072/tasks/arc082_a
// 5min ~ 10min
#include <stdio.h>

int main(void) {
    int N;
    scanf("%d", &N);

    int counts[100000];
    for (int i=0; i<100000; i++) {
        counts[i] = 0;
    }

    int ai;
    for (int i=0; i<N; i++) {
        scanf("%d", &ai);

        for (int d=-1; d<=1; d++) {
            if (ai+d < 0 || ai+d >= 100000) {
                continue;
            }
            counts[ai+d]++;
        }
    }

    int max = 0;
    for (int i=0; i<100000; i++) {
        if (max < counts[i]) {
            max = counts[i];
        }
    }

    printf("%d\n", max);
}


Measured memory_bytes: 512
n = gets.to_i

ans = [1,1]
n.times do
    t,a = gets.split.map(&:to_i)
    m = (ans[0].to_r / t).ceil
    if m * a < ans[1] then
        m = (ans[1].to_r / a).ceil
    end
    ans = [m * t, m * a]
    #p ans
end

puts ans.inject(:+).to_i

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;
typedef std::vector<std::vector<int>> graph;

void dfs(int c, int par, const graph &g, vi &d) {
  for (auto v : g[c]) {
    if (v == par)
      continue;
    d[v] = d[c] + 1;
    dfs(v, c, g, d);
  }
}

int main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--;
  v--;
  graph g(n);
  vi du(n), dv(n);
  REP(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  du[u] = 0;
  dfs(u, -1, g, du);
  dv[v] = 0;
  dfs(v, -1, g, dv);

  int ans = 0;
  REP(i, n) {
    if (du[i] <= dv[i] && g[i].size() > 1) {
      ans = max(ans, dv[i]);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 12928
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

const ll M = 1e9+7;
const ll INF = 1e9+7;

ll n, t, ans;
P p[3100];
ll dp[3100];

int main() {
  cin >> n >> t;

  for (ll i = 0; i < n; i++) {
    cin >> p[i].first >> p[i].second;
  }
  
  sort(p, p+n);
  
  for (ll i = 0; i < n; i++) {
    ll a = p[i].first, b = p[i].second;
    for (ll j = 3000; j >= 0; j--) {
      if (j + a >= t) {
        ans = max(ans, dp[j]+b);
      } else {
        dp[j+a] = max(dp[j+a], dp[j]+b);
      }
    }
  }
  
  for (ll i = 0; i < t; i++) {
    ans = max(ans, dp[i]);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
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; }
 
const int MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> pi(n+1,-1);//最後に出てきた場所
  vector<vector<int>> ps(n);
  rep(i,n){
    int l = pi[a[i]];
    if(l != -1) ps[l].emplace_back(i);
    pi[a[i]] = i;
  }
  
  vector<vector<P>>qs(n);
  rep(i,q){
    int l, r;
    cin >> l >> r;
    --l;
    --r;
    qs[l].emplace_back(r,i);
  }
  
  vector<int> ans(q);
  BIT<int> d(n);
  for(int x=n-1; x>=0; --x){
    for(int y:ps[x]) d.add(y,1);
    for(P query:qs[x]){
      int r = query.first, i = query.second;
      ans[i] = (r-x+1)-d.sum(r);
    }
  }
  
  rep(i,q) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 63108
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define alpha_size 26



int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);    
    
    set<char> s;
    for (int i = 0; i < 3; i++){
      char c;
      cin >> c;
      s.insert(c);
    }
    if (s.size() == 2)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int a, b;
  int d, r;
  double f;

  scanf("%d %d", &a, &b);

  d = a / b; //  printf("%d\n", d);
  r = a % b; // printf("%d\n", r);
  f = 1.0 * a / b; // printf("%.5lf\n", f);

    printf("%d %d %.5lf\n", d, r, f);

  return 0;
}

Measured memory_bytes: 636
def main():
    N = int(input())
    ans = 0
    from itertools import permutations
    from math import hypot
    XY = [[int(i) for i in input().split()] for j in range(N)]
    for p in permutations(range(N)):
        cur = 0
        for i in range(N-1):
            cur += hypot(XY[p[i]][0] - XY[p[i+1]][0],
                         XY[p[i]][1] - XY[p[i+1]][1])
        ans += cur
    fact = 1
    for i in range(1, N+1):
        fact *= i
    print(ans / fact)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39280
import java.io.*;
import java.util.StringTokenizer;


public class Main {


  private void solve(InputReader in, PrintWriter out) {
    int n = in.nextInt();
    int t = in.nextInt();
    int a = in.nextInt();
    int index = 1;
    double val = 0;
    int[] arr = new int[n];
    for (int i = 0; i < n; i++) {
      arr[i] = in.nextInt();
    }

    double[] res = new double[n];
    for (int i = 0; i < n; i++) {
      res[i] = (t - arr[i] * 0.006);
    }
    val = Math.abs(res[0] - a);
    for (int i = 1; i < n; i++) {
      if (val > Math.abs(res[i] - a)) {
        val = Math.abs(res[i] - a);
        index = i + 1;
      }
    }
    out.println(index);

  }


  public static void main(String[] args) throws FileNotFoundException {
    new Main().run();
  }

  private void run() throws FileNotFoundException {

    //new FileInputStream(new File("input.txt"))
    //
    try (InputReader in = new InputReader(System.in);
         PrintWriter out = new PrintWriter(System.out)) {
      solve(in, out);
    }
  }


  static class InputReader implements AutoCloseable {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      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();
    }

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

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

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    @Override
    public void close() {
    }
  }

}


Measured memory_bytes: 23124
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    int n;
    cin >> n;
    for(int i=1;i<=9;i++){
        if(n<=i*111){
            cout << i*111;
            break;
        }
    }
}

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

int main () {
  int N, K;
  cin >> N >> K;
  vector <int> h(N);
  int ans = 0;
  for (int i = 0; i< N; i++) {
    cin >> h.at(i);
    if (h.at(i) >= K) ans ++;
  }
  cout << ans << endl;
}

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

int main(){
  int N;
  cin>>N;
  vector<double> v(N);
  for(int i=0; i<N; i++){
    cin>>v[i];
  }

  sort(v.begin(), v.end(), greater<double>());

  while(v.size()>1){
    double y = v.back();
    v.pop_back();
    double z = v.back();
    v.pop_back();

    v.push_back((y+z)/2);
  }

  cout<<v.front()<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y) {
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int main(){
  ll n,q;
  string s;
  char c;
  cin >> n;
  cin >> s;
  cin >> q;
  set<ll> se[26];
  rep(i,n){
    se[s[i] - 'a'].insert(i);
  }
  rep(i,q){
    cin >> t1;
    if(t1 == 1){
      cin >> t1 >> c;
      t1--;
      rep(i,26){
        se[i].erase(t1);
      }
      se[c - 'a'].insert(t1);
    }else{
      cin >> t1 >> t2;
      t1--,t2--;
      ll sum = 0;
      rep(i,26){
        auto itr1 = se[i].lower_bound(t1);
        auto itr2 = se[i].lower_bound(t2+1);
        if(itr1 != itr2){
          sum++;
        }
      }
      cout << sum << endl;
    }
  }
}

Measured memory_bytes: 24324
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: u32,
        x: u32,
        t: u32,
    }
    let mut ans = (n / x) * t;
    if n % x != 0 {
        ans += t;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2108
n=int(input())
l=[int(x) for x in input().rstrip().split() if int(x)%2==0]

cnt = 0
for i in l:
    if i%3 == 0 or i%5==0:
        cnt += 1
    else:
        break

if cnt == len(l):
    print("APPROVED")
else:
    print("DENIED")

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair


typedef long long int ll;
#define int ll
typedef vector<int> vi;
typedef pair<int,int> pii;

const int N = 2e5 + 10;

int n,r,c;
vector<pii> adj[2][N];
bool vis[2][N];
ll val[2][N];

vector<pii> path;
void dfs(int t, int u, ll va) {
    if (vis[t][u]) return;
    vis[t][u] = true;
    val[t][u] = va;
    path.eb(t,u);
    for (auto xy : adj[t][u]) dfs(1-t, xy.first, xy.second-val[t][u]);
}

vector<tuple<int,int,int>> check;

#undef int
int main() {
#define int ll
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    memset(vis, 0, sizeof vis);
    cin >> r >> c >> n;
    forn(i,n) {
        int x,y,z; cin >> x >> y >> z;
        x--; y--;
        adj[0][x].eb(y,z);
        adj[1][y].eb(x,z);
        check.eb(x,y,z);
    }

    forn(i,r) if (!vis[0][i]) {
        path.clear();
        dfs(0,i,0);

        int mn = 0;
        for (auto xy : path) if (xy.first == 0) mn = min(mn, val[0][xy.second]);
        for (auto xy : path) {
            if (xy.first == 0) val[0][xy.second] -= mn;
            else val[1][xy.second] += mn;
        }
    }
    forn(j,c) if (!vis[1][j])  {
        path.clear();
        dfs(1,j,0);

        int mn = 0;
        for (auto xy : path) if (xy.first == 0) mn = min(mn, val[0][xy.second]);
        for (auto xy : path) {
            if (xy.first == 0) val[0][xy.second] -= mn;
            else val[1][xy.second] += mn;
        }
    }

    int mni = 0, mnj = 0;
    forn(i,r) if (val[0][i] < val[0][mni]) mni = i;
    forn(j,c) if (val[1][j] < val[1][mnj]) mnj = j;

    bool ok = val[0][mni] + val[1][mnj] >= 0;
    for (auto xyz : check) {
        int x,y,z; tie(x,y,z) = xyz;
        ok &= (val[0][x] + val[1][y] == z);
    }
    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 27440
#include<stdio.h>

#define N 103
#define INF 10000000
#define NIL -1
#define BLACK 1

int G[N][N];

int d[N],pi[N],color[N];
int ci[N];
int v[N];

int num;

void initialize(int);
void dij(int);

int main(){
  int i,j;
  int k,u;
  int start=0;

  scanf("%d",&num);

  for(i=0;i<num;i++){
    for(j=0;j<num;j++){
      G[i][j] = NIL;
    }
  }
  

  for(i=0;i<num;i++){
    scanf("%d%d",&u,&k);
      for(j=0;j<k;j++){
	scanf("%d%d",&v[j],&ci[j]);
	G[u][v[j]] = ci[j]; 
      }
  }

  dij(start);

  /*for(i=0;i<num;i++){
    for(j=0;j<num;j++){
      printf("%d ",G[i][j]);
    }
    printf("\n");
  }
  */

  for(i=0;i<num;i++){
    printf("%d %d\n",i,d[i]);
  }
  
  return 0;

}

void initialize(int s){
  int v;
  for(v=0;v<num;v++){
    d[v] = INF;
    pi[v] = NIL;
  }

  d[s] = 0;
}

void dij(int s){
  int mincost;
  int i,v,u;
  
  initialize(s);

  while(1){
    
    mincost = INF;

    for(i=0;i<num;i++){
      
      if(color[i] != BLACK && d[i] < mincost){
	mincost = d[i];
	u = i;

      }
    }

    //printf("u=%d\n", u);
    if(mincost == INF) break;

    color[u] = BLACK;
    
    for(v=0;v<num;v++){
      
      if(G[u][v] == -1) continue;
      if(color[v] != BLACK && d[u] + G[u][v] < d[v]){
	pi[v]= u;
	d[v] = d[u] + G[u][v];
      }
    }
  }
}
	



Measured memory_bytes: 2108
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

typedef long long ll;

int MOD=1000000007;

int main()
{
  ll D,G,ans=MOD,count=0;
  cin >> D >> G;
  ll p[D+10],c[D+10];
  for(int i=0; i<D; i++) cin >> p[i] >> c[i];
  for(int i=0; i<(1<<D); i++){
      ll sum=0, count=0;
        for(ll j=0; j<D; j++) if(i&(1<<j)){
            sum+=(j+1)*p[j]*100+c[j];
            count+=p[j]*100;
        }
        for(ll j=D-1; j>=0; j--) if(!(i&(1<<j))){
            if(sum>=G) break;
            for(ll k=0; k<p[j]; k++){
                if(sum>=G) break;
                sum+=(j+1)*100;
                count+=1*100;
            }
        }
        if(sum>=G){
            ans=min(ans,count);
        }
    }
    cout << ans/100 << endl;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if(a >= b){
        for(int i = 0; i < a; i++){
            cout << b;
        }
    } else {
        for(int i = 0; i < b; i++){
            cout << a;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int h,w;
struct postion
{
    int x,y;
};
postion pos[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
int main()
{
    int i,j,cnt,k,q,p;
    cin>>h>>w;
    char a[h][w];
    for(i=0;i<h;i++)
        cin>>a[i];
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        {
            if(a[i][j]=='#')
                cout<<'#';
            else
            {
                cnt=0;
                for(k=0;k<8;k++)
                {
                    q=pos[k].x+i;
                    p=pos[k].y+j;
                    if(q>=0&&q<h&&p>=0&&p<w)
                    {
                        if(a[q][p]=='#')
                            cnt++;
                    }
                }
                cout<<cnt;
            }
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {

		int N = sc.nextInt();

		int[] A = new int[N];
		for(int i=0; i<N; i++) {
			A[i] = sc.nextInt();
		}

		for(int i=0; i<N; i++) {

			int temp = A[i];

			int j;
			for(j=i-1; j>=0; j--){
				A[j+1] = A[j];

				if(A[j] < temp){
					break;
				}
			}

			A[j+1] = temp;


			for(int k=0; k<N; k++) {
				System.out.print(A[k]);
				if(k != N-1){
					System.out.print(" ");
				}
			}
			System.out.println();

		}
	}

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }


}

Measured memory_bytes: 30388
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Sat Aug 31 20:28:11 2019
//
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	sc = bufio.NewScanner(os.Stdin)
	bw = bufio.NewWriter(os.Stdout)
)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	var n, q int
	fmt.Sscan(nextLine(), &n, &q)

	graph := make([][]int, n+1)
	for i := range graph {
		graph[i] = make([]int, 0)
	}
	for i := 0; i < n-1; i++ {
		var a, b int
		fmt.Sscan(nextLine(), &a, &b)
		graph[a] = append(graph[a], b)
		graph[b] = append(graph[b], a)
	}

	vals := make([]int, n+1)
	for i := 0; i < q; i++ {
		var p, x int
		fmt.Sscan(nextLine(), &p, &x)
		vals[p] += x
	}

	visited, points := make([]bool, n+1), make([]int, n+1)
	dfs(graph, 1, 0, visited, vals, points)

	for i, p := range points[1:] {
		if i != 0 {
			fmt.Fprint(bw, " ")
		}
		fmt.Fprint(bw, p)
	}
	fmt.Fprint(bw, "\n")
	bw.Flush()
}

func dfs(graph [][]int, cur int, parent int, visited []bool, vals []int, points []int) {
	points[cur] = points[parent] + vals[cur]
	visited[cur] = true
	for _, child := range graph[cur] {
		if !visited[child] {
			dfs(graph, child, cur, visited, vals, points)
		}
	}
}


Measured memory_bytes: 123392
#include <iostream>
#include <set>
#include <math.h>
#include <list>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MAX_N 100005
#define MAX_M 100

int N;
int A[MAX_N];

int main()
{
    int x;
    cin >> N >> x;
    rep(i, N) cin >> A[i];
    //rep(i, N) cout << A[i] << endl;
    long long ans = 0;

    for (int i = 1; i < N; i++)
    {
        if (A[i - 1] + A[i] <= x)
            continue;

        int tmp = A[i] + A[i - 1] - x;
        ans += tmp;
        A[i] = max(0, A[i] - tmp);
        //cout << i << " " << A[i] << " " << A[i - 1] << " " << tmp << ans << endl;
    }
    cout << ans << endl;

    return 0;
}


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


def solve(N: int, a: "List[int]", b: "List[int]", c: "List[int]"):
    hs = [(a1, b1, c1) for a1, b1, c1 in zip(a, b, c)]
    dp = [[0]*3 for _ in range(N)]
    dp[0][0] = hs[0][0]
    dp[0][1] = hs[0][1]
    dp[0][2] = hs[0][2]

    for i in range(1, N):
        for j in range(3):
            for k in range(3):
                if j!=k:
                    dp[i][j] = max(dp[i][j], dp[i-1][k]+hs[i][j])
    return max(dp[-1])


# Generated by 1.1.4 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
    a = [int()] * (N)  # type: "List[int]" 
    b = [int()] * (N)  # type: "List[int]" 
    c = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
    print(solve(N, a, b, c))

if __name__ == '__main__':
    main()


Measured memory_bytes: 42592
#include<iostream>
using namespace std;
int main(){
    int a[3],sum=0;
    for(int i=0;i<3;i++)
        cin>>a[i];
    for(int i=0;i<3;i++)
        sum+=a[i];
    if(sum>=22)
        cout<<"bust \n";    
    else
        cout<<"win \n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n, j, i, k, x=1, c, m=100;
int main(){
	scanf("%lld", &n);
	for(i=1; ;i++){
		m*=1.0*1.01;
		m=abs(m);
		if(m>=n){
			printf("%d", i);
			return 0;	
		}
	}
}

Measured memory_bytes: 3844
module M = Map.Make (struct type t = string let compare = compare end)

let () =
    let n = read_int () in
    let rec loop i map =
        if i = n then map else
            let s = read_line () in
            let map = M.add s (1 + try M.find s map with _ -> 0) map in
            loop (i + 1) map
    in
    let map = loop 0 M.empty in
    let (_, l) = M.fold (fun key v (mx, mxl) ->
        if v > mx then (v, [ key ]) else
            if v = mx then (v, key :: mxl) else (mx, mxl)) map (0, [])
    in
    List.sort compare l |> List.iter print_endline

Measured memory_bytes: 30848
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
for i in range(n):
    if a[i] < b[i]:
       
        s = b[i] - a[i] if a[i+1] - (b[i] - a[i]) >= 0 else a[i+1]
        ans += a[i] + s

        a[i+1] = max(a[i+1] - (b[i] - a[i]),0)
        a[i] = 0

        #print(a[i] + s)

    else:
        a[i] -= b[i]
        ans += b[i]
        #print(b[i])
#print(a)
print(ans)

Measured memory_bytes: 82020
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;
vector<int> vec;
ll n;
int ans;

bool check(ll m){
    int a=0,b=0,c=0;
    while(m>0){
        if(m%10==3)a=1;
        if(m%10==5)b=1;
        if(m%10==7)c=1;
        m/=10;
    }
    if(a+b+c==3)return true;
    else return false;
}

void dfs(ll m){
    if(m>n)return;
    if(check(m))ans++;
    dfs(10*m+3);
    dfs(10*m+5);
    dfs(10*m+7);        
}

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

Measured memory_bytes: 256
n=io.read("*n","*l")
p={}
for i=1,n do
    p[i]=io.read("*n")
end

counter=0
for i=1,n-1 do
    if p[i]==i then
        p[i],p[i+1]=p[i+1],p[i]
        counter=counter+1
    end
end
if p[n]==n then
    counter=counter+1
end
print(counter)

Measured memory_bytes: 2424
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 200'000;
const int LOGN = 18;

int n, m, k;

int64 gcd(int64 a, int64 b)
{
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}

int64 lcm(int64 a, int64 b)
{
  return a / gcd(a, b) * b;
}

void solve(int test)
{
  int64 a, b, c, d;
  cin >> a >> b >> c >> d;
  int64 l = lcm(c, d);
  auto f = [](int64 x, int64 y, int64 val) {
    int64 first = (x + val - 1) / val * val;
    int64 last = y / val * val;
    return max(0ll, (last - first) / val + 1);
  };
  cout << b - a + 1 - f(a, b, c) - f(a, b, d) + f(a, b, l) << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


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

int main(){
	int n = 0;
	int math[1000]; 
	cin >> n;
for (int i = 1; i < n+1; i++) {
	cin >> math[i];
}
for (int a = n; a > 0; a--) {
	if(a>1) {
		cout << math[a] << ' ';
	}
	else {
		cout << math[1];
	}
}
cout << endl;
return 0;
}

Measured memory_bytes: 3076
# -*- coding: utf-8 -*-
from pprint import pprint
import random
from collections import deque, defaultdict
N, M = map(int, input().split())

if M == 0:
    print("Yes")
    exit()

LRD = [list(map(int, input().split())) for _ in range(M)]

# N,M = 100000,200000
# LRD = [[i+10+random.randint(-9,100),i+20+random.randint(-18,200),random.randint(1,300)] for i in range(M)]
# print("run")

# 速めのdfs（非再帰）
graph = defaultdict(lambda: defaultdict(int))
# graph = [[0 for _ in range(N+1)] for _ in range(N+1)]
# graph = [defaultdict(int) for _ in range(N+1)]
visited = defaultdict()

for L,R,D in LRD:
    graph[L][R] = D
    graph[R][L] = -D
    visited[L] = None
    visited[R] = None

# print("step1")
# pprint(graph)

def xfs(v):
    que = deque()
    que.append((v,0))
    while len(que) > 0:
        i,cnt = que.pop()  # 深さ優先探索
        visited[i] = cnt
        # print("step3:i",i)
        for n,val in graph[i].items():
            if visited[n] == None:
                # print("if:v,i,n,cnt,val", v,i,n, cnt, val)
                que.append((n, cnt+val))
            else:
                # print("el:v,i,n,cnt,val,visited[n]",
                #       v, i, n, cnt, val, visited[n])
                if cnt + val != visited[n]:
                    return False

    return True


que2 = deque()
L, _, _ = LRD[0]
que2.append(L)
while len(que2) > 0:
    L = que2.pop()
    # print("step2:L",L)
    if xfs(L):
        for k,v in [(k,v) for k,v in visited.items() if v==None]:
            # print("step4:k", k)
            que2.append(k)
            break
    else:
        # pprint(visited)
        # print("L=",L)
        print("No")
        exit()

# pprint(visited)
print("Yes")


Measured memory_bytes: 140240
#include<bits/stdc++.h>
#include<unordered_map>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define endl                         '\n'	
#define Ceil(x,y)             ((x+y-1)/y)
#define sz(s)               (int)s.size()
#define RT(x)           return cout<<x,0;
#define mem(x,y)    memset(x,y,sizeof(x))
#define all(v) ((v).begin()), ((v).end())
#define vi                    vector<int>
#define pii                 pair<int,int>
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define forr(i, n) for (int i = 0; i < int(n); i++)
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
const double PI = acos(-1), EPS = 1e-7;
const int OO = 0x3f3f3f3f, N = 1e7 + 5, mod = 1e9 + 7;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll x, ll y) { return (!y) ? x : gcd(y, x%y); }
ll lcm(ll x, ll y) { return ((x / gcd(x, y))*y); }
void mansour()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin) ;
    freopen("output.txt" , "w" , stdout) ;
#endif
}

int main()
{
	mansour();
	//file();
	/*The First*/
	int a,b,c;
	cin>>a>>b>>c;
	cout <<c<<" "<<a<<" "<<b<<"\n";
}

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

int main()
{
  int N, T; cin >> N >> T;
  vector<int> t(N);
  for (int i = 0; i < N; i++) cin >> t[i];

  long long ans = 0;

  for (int i = 1; i < N; i++)
  {
    if (t[i]-t[i-1] >= T) {
      ans += T;
    }
    else ans += t[i]-t[i-1];
  }
  ans += T;
  cout << ans << endl;
}

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

int main()
{
	long long a, b, c = 0, k;
	scanf("%lld%lld%lld", &a, &b, &k);
	printf("%lld %lld", max(c, a - k), max(c, b - max(c, k - a)));
	return 0;
}



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

typedef long long ll;
static const ll INF = 100000000000000;
struct Node {
  int id;
  ll cost;
  Node() {}
  Node(int id, ll cost) : id(id), cost(cost){}
  bool operator< (const Node& node) const {
    return node.cost < cost;
  } 
};

// N: 頂点数, E: 辺の数, d: 距離 を格納する配列, 
// t: 始点, flag: true なら　無向辺, false なら 有向辺
void dijkstra(int N, int E, ll d[], int t, int from[], int to[], ll cost[], bool flag) {
  static const int WHITE = 0;
  static const int GRAY = 1;
  static const int BLACK = 2;
  
  int color[N];
  vector<Node> adj[N];
  for (int i = 0; i < N; i++) {
    d[i] = INF;
    color[i] = WHITE;
  }
  // 隣接リストの作成
  for (int i = 0; i < E; i++) {
    adj[from[i]].push_back(Node(to[i], cost[i]));
    if (flag) adj[to[i]].push_back(Node(from[i], cost[i]));
  }
  priority_queue<Node> pq;
  d[t] = 0;
  pq.push(Node(t, 0));
  while (!pq.empty()) {
    Node f = pq.top();
    pq.pop();
    int u = f.id;
    color[u] = BLACK;
    if (d[u] < f.cost) continue;
    for (int j = 0; j < adj[u].size(); j++) {
      int v = adj[u][j].id;
      if (color[v] == BLACK) continue;
      if (d[v] > d[u] + adj[u][j].cost) {
        d[v] = d[u] + adj[u][j].cost;
        pq.push(Node(v, d[v]));
        color[v] = GRAY;
      }
    }
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int V, E, r;
  cin >> V >> E >> r;
  int s[E], t[E];
  ll d[E];
  for (int i = 0; i < E; i++) {
    cin >> s[i] >> t[i] >> d[i];
  }
  ll ans[V];
  dijkstra(V, E, ans, r, s, t, d, false);
  for (ll i : ans) {
    if (i == INF) {
      cout << "INF\n";
    } else {
      cout << i << "\n";
    }
  }
  return 0;
}


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

namespace ABC151
{
    class Program
    {
        static void Main(string[] args)
        {
            c();
        }

        public static void c()
        {
            long[] nm = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
            long n = nm[0], m = nm[1];
            if (m == 0)
            {
                Console.WriteLine("0 0");
                return;
            }
            bool[] acwa = new bool[n + 1];
            long[] wa1 = new long[n + 1];
            for(long i = 0; i < n + 1; i++)
            {
                acwa[i] = false;
                wa1[i] = 0;
            }
            long ac = 0, wa = 0;
            for(long i = 0; i < m; i++)
            {

                string[] ps = Console.ReadLine().Split(' ');
                long p = long.Parse(ps[0]);
                string s = ps[1];
                if (acwa[p] == true)
                { continue; }
                else if(s == "AC")
                {
                    ac++;
                    wa += wa1[p];
                    wa1[p] = 0;
                    acwa[p] = true;
                }
                else if(s == "WA")
                {
                    wa1[p]++;
                }
            }
            Console.WriteLine("{0} {1}",ac,wa);
        }
    }
}


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

using namespace std;

template<typename T>
class BIT {
public:
    explicit BIT(int n) : N(calcN_(n)), mVal(calcN_(n)+1, 0) {}
    void add(int idx, T val){
        for(int x=idx;x<=N;x+=x&-x) mVal[x] += val;
    }
    T sum(int idx){
        T res = 0;
        for(int x=idx;x>0;x-=x&-x) res += mVal[x];
        return res;
    }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    const int N;
    vector<T> mVal;
};

int main(){
    int N, Q; cin >> N >> Q;
    BIT<long long> bit(N);
    for(int i=1;i<=N;i++){
        int a; cin >> a;
        bit.add(i, a);
    }
    for(int i=0;i<Q;i++){
        int t, l, r; cin >> t >> l >> r;
        if(t == 0){
            bit.add(l+1, r);
        } else {
            cout << bit.sum(r) - bit.sum(l) << endl;
        }
    }
}

Measured memory_bytes: 8412
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <stack>

using namespace std;

int main() {
    int n, l;
    string s[105];
    int a[105]; for (int i = 0; i < 105; i++)a[i] = -1;
    cin >> n >> l;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < n; i++) {
        int cou = 0;
        for (int j = 0; j < n; j++) {
            
            if (s[i] > s[j]) {
                cou++;
            }
            
        }
        a[cou] = i;
    }
    for (int i = 0; i < n; i++) {
        if (a[i] > -1) {
            cout << s[a[i]]; 
        }
        if (a[i] == -1) {
            int j = i;
            while (a[j] == -1) {
                j--;
            }
            cout << s[a[j]];
        }
    }
}

Measured memory_bytes: 256
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long R, G, B, N;
    scan(R, G, B, N);
    long ans;
    foreach (r; 0 .. N / R + 1)
    {
        long M = N - r * R;
        foreach (g; 0 .. M / G + 1)
        {
            if ((M - g * G) % B == 0)
                ans++;
        }
    }
    writeln(ans);
}


Measured memory_bytes: 3640
S = raw_input()
T = raw_input()
ans = "z"*100
for i in range(len(S)-len(T)+1)[::-1]:
    ok = True
    for j in range(len(T)):
        if S[i+j]!="?" and S[i+j]!=T[j]:
            ok = False
    if ok:
        s = S[:i]+T+S[i+len(T):]
        ans = min(ans, s.replace("?", "a"))
        break
if ans=="z"*100:
    print "UNRESTORABLE"
else:
    print ans


Measured memory_bytes: 2568
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<utility>//swap(数値交換)
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define rt "\n"
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())

int main(){
	int a, b;
	cin >> a >> b;
	for (int i = b - a + 1; i <= a + b - 1; i++) {
		cout << i<<" ";
	}
	rt;
	return 0;
}

// abc : 141 , aoj : ITP1_6_D
//sort, abs, swap, reverse, max, min
//__gcd, substring, erase, push_back,stoll、stoi

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

std::string S;

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

    std::cin >> S;

    int k = S.size(), l = 15 - k;
    int a = std::count(S.begin(), S.end(), 'o') + l;

    if(a >= 8){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }
}


Measured memory_bytes: 256
import java.io.*;

class Main {
    public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String s = in.readLine();
    int x = Integer.parseInt(s);
    int res = x * x * x;
    System.out.println(res);
    }
}

Measured memory_bytes: 24056