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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<55)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

string m(lli sx,lli sy,lli tx,lli ty,bool up){
    string rtn="";
    if(up){
        REP(i,0,abs(ty-sy))rtn.push_back('U');
        REP(i,0,abs(tx-sx))rtn.push_back('R');
    }
    else{
        REP(i,0,abs(ty-sy))rtn.push_back('D');
        REP(i,0,abs(sx-tx))rtn.push_back('L');
    }
    return rtn;
}

int main(){

    lli sx,sy;
    lli tx,ty;

    cin>>sx>>sy>>tx>>ty;

    cout<<m(sx,sy,tx,ty,true)<<m(sx,sy,tx,ty,false)<<"L";
    cout<<m(sx-1,sy,tx,ty+1,true)<<"DR";
    cout<<m(sx,sy-1,tx+1,ty,false)<<"U"<<endl;


    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
maxdi = 0
if M-N <= 0:
    print(0)
    exit()
dis = []
for i in range(M-1):
    dis.append(X[i+1]-X[i])
alldi = max(X)-min(X)
dis.sort(reverse=True)
partdi = sum(dis[:N-1])
print(alldi-partdi)

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int n, x;

int main() {

	FAST;

	cin >> n;
	set <int> s;
	while (n -- ) {
		cin >> x;
		s.insert(x);
	}
	cout << s.size() << '\n';
	return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   ll n;cin >>n;
   vector<ll>p(n);
    for (int i = 0; i < n; ++i) {
        cin >>p[i];
    }
    sort(all(p));
    p[n-1]/=2;
    ll ans=0;
    for (int i = 0; i < n; ++i) {
        ans+=p[i];
    }
    cout <<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
public class Main {


  private static void solve() {
    char[] s = ns();
    int w = ni();
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < s.length; i += w) {
      sb.append(s[i]);
    }
    System.out.println(sb);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	FOR(i,0,n)cin >> a[i];
	sort(ALL(a));
	int ans = 0;
	FOR(i,-1,100001)
		ans = max(ans, (int)(upper_bound(ALL(a), i+1) - lower_bound(ALL(a), i-1)));
	ANS(ans);
	return 0;
}


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

int main(){
  int N,M;
  cin>>N>>M;
  vector <int> A(M,0);
  vector <int> B(M,0);
  map<int,int>mp;

  for (int i=0;i<N;i++){
    cin>>A[i]>>B[i];
    mp[A[i]]++;
    mp[B[i]]++; 
  }
  int flag=0;
  for(auto itr=mp.begin();itr != mp.end();itr++){
    if((itr->second)%2 != 0) flag=1;
  }
  if(flag){
    cout<<"NO"<<endl;
    return 0;
  }
  cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 7936
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int n,a[1 << 17],ans;

int32_t main(){_
    //freopen("input","r",stdin);
    cin >> n;
    for(int i = 1;i <= 2 * n;i++) cin >> a[i];
    sort(a + 1,a + 1 + 2 * n);
    for(int i = 1;i <= 2 * n;i+=2) ans += a[i];
    rc(ans);
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int n, k;
ll a[100050];
ll Ideal[100050];
ll sum[100050];
ll ans = 0;
void func(int l, int r){
    ll now = Ideal[l - 1] + (Ideal[n] - Ideal[r]);
    now += max((ll)0, sum[r] - sum[l - 1]);
    ans = max(ans, now);
}

int main() {
    //cout.precision(10);
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
        Ideal[i] = Ideal[i - 1] + max((ll)0, a[i]);
    }
    for(int i = 1; i + k - 1 <= n; i++){
        func(i, i + k - 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

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

int main(){
   int n;
   while (cin >> n){
      if (n == 0) return 0;
      int ans = 0;
      for (int i = n+1; i <= 2*n; i++){
         if (is_prime(i)) ans++;
      }
      cout << ans << endl;
   }
}



Measured memory_bytes: 3016
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);   

    int A; int B; int X;
    cin >> A >> B >> X;
    if (A + B < X || A > X)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
    
}


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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var C = Char.Parse(Console.ReadLine());
            var intC = (int)C;
            var ans = (char)(intC + 1);

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 10101010

int main()
{
    ll N;
    cin >> N;
    vector<char> s(INF);
    int k=0;
    N--;
    if(N==0){
        s[0]='a';
        k++;
    }else{
        while(N>=1){
            int a=(N%26);
            
            s[k++]='a'+(N%26);
            N/=26;
            N-=1;
            if(N==0){
                s[k++]='a';
            }
        }
    }



    for(int i=k-1;i>=0;i--){
        cout << s[i];
    }
    cout << endl;

}

Measured memory_bytes: 13032
#include "bits/stdc++.h"

#pragma warning(disable:4996)
using namespace std;
using ld = long double;

vector<pair<long long int, long long int>>ps;
long long int g(long long int x, long long int place) {
	return ps[x].first + ps[x].second*(place);
}

int main() {
	int N,Q;cin>>N>>Q;
	int k=0;
	for (int i = 0; i < Q;++i) {
		int a,b;cin>>a>>b;
		if (a == 1) {
			k+=b;
			k%=N;
		}
		else {
			if(k+b==N)cout<<N<<endl;

			else cout<<(k+b)%N<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3100
import java.util.Scanner;

public class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		char[] S = sc.next().toCharArray();
		int a = 0;
		int b = 0;

	   for(int i = 0;i<S.length;i++){
		   if(S[i]=='a' && (a+b)<(A+B)){
			   a++;
			   System.out.println("Yes");
		   }else if(S[i]=='b' && b<B && (a+b)<(A+B)){
			   b++;
			   System.out.println("Yes");
		   }else{
			   System.out.println("No");
		   }
	   }
	}
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

// Time: 10:55:17

// まず，A+Bの操作が2Cの操作と等価なのでchminを取っておく(操作の等価性)
// ちょうど作る場合は算数でいいのだが，ちょうどでないので
// 今回は全探索をする必要があった．(本当は二分探索でいけるはず)

// 一番厄介なものを決めうつと嬉しい例(Cのものが厄介なので固定した)

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B,C,X,Y; cin>>A>>B>>C>>X>>Y;
    // C*=2;s
    // chmin(C,A+B);
    // ll ans=(ll)1e15;
    auto f = [&](int n){
        ll ret=0;
        ret+=(ll)n*2*C;
        int x=max(X-n,0),y=max(Y-n,0);
        ret+=(ll)x*A+(ll)y*B;
        return ret;
    };
    int l=-1,r=max(X,Y);
    while(r-l>1){
        int c=(l+r)/2;
        if (f(c+1)-f(c)<=0) l=c;
        else r=c;
    }
    ll ans=f(l+1);
    // FOR(i,min(X,Y),max(X,Y)){
    //     ll cand=0;
    //     cand+=(ll)i*C;
    //     int x=X-i,y=Y-i;
    //     chmax(x,0); chmax(y,0);
    //     cand+=(ll)x*A;
    //     cand+=(ll)y*B;
    //     chmin(ans,cand);
    // }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
program answer
  implicit none

  integer :: A,B,C,i,a0,b0,c0

  read(*,*) A,B,C
  a0=A
  b0=B
  c0=c
  i =0
  if (A==B.and.A==C.and. mod(A,2)==0) then
     i = -1
  else
     do while(mod(A,2)==0 .and. mod(B,2)==0 .and. mod(C,2)==0) 
     a0=b0/2+c0/2
     b0=A/2+c0/2
     c0=A/2+B/2
     a = a0
     b = b0
     c = c0
     
     i = i + 1
     end do
  end if
  write(*,*) i

  stop
 end program answer


Measured memory_bytes: 256
(defn TimeLimitExceeded [N T]
  (loop [i 1 n 10000 t T]
    (if (> i N) (if (= 10000 n) "TLE" n)
      (let[c (int(read)) ts (int(read))]
        (if (and (<= ts T) (< c n)) 
          (recur (inc i) c ts)
          (recur (inc i) n t))))))
(println (TimeLimitExceeded (int (read)) (int (read))))

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

using namespace std;

#define endl '\n'
typedef long long ll;

ll N,X;

ll R(ll n,ll x)
{
    ll k=(n-x)/x;
    ll r=(n-x)%x;
    ll res=n+x*k+x*(k-1);
    if(r==0) return res;
    ll kk=x/r;
    ll rr=x%r;
    if(rr==0) return res+x+r*kk+r*(kk-1);
    return res+x+r*kk+r*(kk-1)+R(rr+r,rr)-rr;
}

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

    cin >> N >> X;

    cout << R(N,X) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define eps 1e-8

int A,B,C,D,E,F;
int dp[3005];

int main()
{
    scanf("%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F);

    memset(dp,0,sizeof(dp));
    dp[0]=1;
    for (int k=C;k<=F;k++)
        if (dp[k-C]) dp[k]=1;
    for (int k=D;k<=F;k++)
        if (dp[k-D]) dp[k]=1;

    int sum=0,sugar=0;
    for (int i=0;i<=100;i++)
    {
        for (int j=0;j<=100;j++)
        {
            if (i==0&&j==0) continue;
            int wat = 100*(i*A+j*B);
            if (wat>=F) break;

            int x = (i*A+j*B)*E;
            x=min(x,3000);

            for (int k=0;k<=F-wat;k++)
            {
                if (k>x) break;
                if (dp[k])
                {
                    if (k*sum>sugar*(wat+k)||sum==0)
                    {
                        sum=(k+wat);
                        sugar=k;
                    }
                }
            }
        }
    }
    printf("%d %d\n",sum,sugar);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.regex.*;
public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    String str = sc.nextLine();
    
    if(Pattern.matches("[A-Z]",str))
      System.out.println('A');
      else
        System.out.println('a');
  }
}


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

const double EPS = 1e-10;
double add(double a, double b) {
    if(abs(a+b) < EPS*(abs(a)+abs(b))) return 0;
    return a+b;
}
struct Vector {
    double x, y;
    Vector() {}
    Vector(double x, double y):x(x), y(y) {}
    Vector operator+(Vector v) {return Vector(add(x, v.x), add(y, v.y));}
    Vector operator-(Vector v) {return Vector(add(x, -v.x), add(y, -v.y));}
    Vector operator*(double d) {return Vector(x*d, y*d);}
    Vector operator/(double d) {return Vector(x/d, y/d);}
    double dot(Vector v) {return add(x*v.x, y*v.y);}
    double cross(Vector v) {return add(x*v.y, -y*v.x);}
};
istream &operator>>(istream &is, Vector &v) {return is >> v.x >> v.y;}
ostream &operator<<(ostream &os, const Vector &v) {return os << v.x << ' ' << v.y;}
double sqdist(Vector v, Vector u) {return (v-u).dot(v-u);}
bool on_seg(Vector v1, Vector v2, Vector p) {
    return (v1-p).cross(v2-p) == 0 && (v1-p).dot(v2-p) <= 0;
}
//v1-v2とu1-u2の交点
Vector intersection(Vector v1, Vector v2, Vector u1, Vector u2) {
    assert((v1-v2).cross(u1-u2)); //2直線が平行だとだめ
    return v1 + (v2-v1)*((u2-u1).cross(u1-v1)/(u2-u1).cross(u2-v1));
}
//p2-p1へのQの投影
Vector projection(Vector p1, Vector p2, Vector Q) {
    return p1+(p2-p1)*(Q-p1).dot(p2-p1)/sqdist(p1, p2);
}
//p1-p2を軸としたQの線対称移動
Vector reflection(Vector p1, Vector p2, Vector Q) {
    return projection(p1, p2, Q)*2-Q;
}
bool cmp_x(const Vector &v, const Vector &u) {
    if(v.x != u.x) return v.x < u.x;
    return v.y < u.y;
}
//頂点数nの頂点集合vv
vector<Vector> convex_hull(vector<Vector> &vv, int n) {
    sort(vv.begin(), vv.end(), cmp_x);
    int k = 0;
    vector<Vector> res(n*2);
    for(int i = 0; i < n; i++) {
        while(k > 1 && (res[k-1]-res[k-2]).cross(vv[i]-res[k-1]) <= 0) k--;
        res[k++] = vv[i];
    }
    for(int i = n-2, t = k; i >= 0; i--) {
        while(k > t && (res[k-1]-res[k-2]).cross(vv[i]-res[k-1]) <= 0) k--;
        res[k++] = vv[i];
    }
    res.resize(k-1);
    return res;
}
signed main() {
    Vector p1, p2, Q;
    int q;
    cin >> p1 >> p2 >> q;
    while(q--) {
        cin >> Q;
        double X = (p2-p1).cross(Q-p1);
        if(add(X, 0) != 0) {
            if(X > 0) {
                cout << "COUNTER_CLOCKWISE" << '\n';
            } else {
                cout << "CLOCKWISE" << '\n';
            }
        } else {
            if((p2-p1).dot(Q-p1) < 0) {
                cout << "ONLINE_BACK" << '\n';
            } else if(sqdist(Q, p1) > sqdist(p2, p1)) {
                cout << "ONLINE_FRONT" << '\n';
            } else {
                cout << "ON_SEGMENT" << '\n';
            }
        }
    }
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
char c[1001][1001];
int K[1001][1001];
int main(){
  int w,h;
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>c[i][j];
      K[i][j]=0;
    }
  }
  int dx[8]={-1,-1,-1,0,0,1,1,1};
  int dy[8]={-1,0,1,-1,1,-1,0,1};
  bool b=0;
  queue<P> que[2];
  queue<P> que2;
   
  for(int i=1;i<h-1;i++){
    for(int j=1;j<w-1;j++){
      for(int k=0;k<8;k++){
    int y=i+dy[k];
    int x=j+dx[k];
    if(c[y][x]=='.'){
      K[i][j]++;
    }
      }
      if(c[i][j]!='.' && K[i][j]>=c[i][j]-'0'){
    que[b].push(P(i,j));
    que2.push(P(i,j));
    //c[i][j]='.';
      }
    }
  }
 
  int ans=0;
  while(!que[b].empty()){
    while(!que[b].empty()){
      while(!que2.empty()){
    P p=que2.front();
    que2.pop();
    c[p.first][p.second]='.';
      }
      //cout<<"ok"<<endl;
      P p=que[b].front();
      int i=p.first;
      int j=p.second;
      que[b].pop();
      c[i][j]='.';
      for(int k=0;k<8;k++){
    int y=i+dy[k];
    int x=j+dx[k];
    K[y][x]++;
    if(c[y][x]!='.' && K[y][x]>=c[y][x]-'0'){
      que[!b].push(P(y,x));
      que2.push(P(y,x));
    }
      }
    }
    ans++;
    b=!b;
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {
  string str;
  cin >> str;
  
  int i =str.size();
  
  int lastword = str.at(i-1);
  
  
  if( lastword== 's' ){
    cout << str << "es" << endl;
  }
  
  else{
    cout << str << "s" << endl;
  }
}

  

Measured memory_bytes: 3624
#include <stdio.h>

int main(void)
{
  double height[50],max,min;
  int n=0,j;
  

  while(scanf("%lf",&height[n]) != EOF){
    n++;
  }

  max = height[0];
  min = height[0];

  for(j=1; j<n; j++){
    if(height[j] > max)
      max = height[j];
    else if(height[j] < min)
      min = height[j];
  }

  printf("%.1lf\n",max-min);

  return 0;
}

Measured memory_bytes: 652
n,k = map(int,input().split())
p = [0] + list(map(int,input().split()))
c = [0] + list(map(int,input().split()))
ans = max(c[1:])
t = 0
for i in range(1,n+1):
    # print(ans)
    j = p[i]
    temp = c[i]
    cnt = 1
    ans = max(ans,temp)
    tempans = 0
    while i!=j:
        
        temp += c[j]
        j = p[j]
        cnt += 1
        # if i==5:
        #     print(j,c[j],temp)
    t = cnt
    tt = ans
    # if i==8:
    #     print(temp,t)
    if t < k:
        if temp > 0:
            # print(k,t,i)
            tempans += temp*(k//t - 1)
            tt = tempans
            j = p[i]
            for l in range(k-(k//t - 1)*t):
                tempans += c[j]
                j = p[j]
                tt = max(tt,tempans)
            ans = max(ans,tt)
            # print(ans)
        else:
            j = p[i]
            for l in range(t):
                tempans += c[j]
                j = p[j]
                tt = max(tt,tempans)
            ans = max(ans,tt)
            # print(ans)
    else:
        j = p[i]
        for l in range(k):
            tempans += c[j]
            j = p[j]
            tt = max(tt,tempans)
        ans = max(ans,tt)
        # print(ans)
    # if ans == 29779631210:
    #     print(i,ans,t,temp)
    #     exit()
print(ans)


Measured memory_bytes: 74204
import sys
N = int(input())

num = sorted([int(input()) for i in range(N)])
MAX = sum(num)

if MAX % 10 != 0:
    print(MAX)
    sys.exit()
else:
    for i in range(N):
        if num[i] % 10 != 0:
            print(MAX - num[i])
            sys.exit()

print(0)


Measured memory_bytes: 9176
import sys
from collections import Counter
input = sys.stdin.readline

n = int(input())
s = [str(input().rstrip()) for _ in range(n)]
c = Counter(s)
d_sorted = sorted(c.items(), key=lambda x:x[1], reverse=True)

m = d_sorted[0][1]
ans = []
for key, v in d_sorted:
    if v == m:
        ans.append(key)
ans.sort()
print("\n".join(ans))


Measured memory_bytes: 50280
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
        int[] list = new int[n];
        
        for(int i = 0; i < n; i++) {
          list[i] = sc.nextInt();
        }
        Arrays.sort(list);
        int ans = 1;
        for(int i = 1; i < list.length; i++) {
          if (list[i - 1] < list[i]) {
            ans++;
          }
        }
    
		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <stdio.h>

int main(void) {
	int a[100][100];
	int n, m, r, i, j, id;

	for (i = 0; i < 100; i++) {
		for (j = 0; j < 100; j++) {
			a[i][j] = 0;
		}
	}

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d %d", &id, &m);
		id = id - 1;
		for (j = 0; j < m; j++) {
			scanf("%d", &r);
			a[id][r - 1] = 1;
		}
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			printf("%d", a[i][j]);
			if (j != n - 1) {
				putchar(' ');
			}
		}
		putchar('\n');
	}

	return 0;
}




Measured memory_bytes: 2100
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

typedef vector<int> perm;
perm pow_perm(perm a,ll k){
	perm ret;
	rep(i,a.size()){
		ret.pb(i);
	}
	for(ll i = 0 ; i < 60 ; i ++){
		if(k%2 == 1){
			perm ret_ = ret;
			rep(i,ret.size()){
				ret[i] = a[ret_[i]];
			}
		}
		perm a_ = a;
		rep(i,a.size()){
			a[i] = a_[a_[i]];
		}
		k /= 2;
	}
	return ret;
}

int main(){
	static ll n;
	static ll x[100010];
	static ll m,k;
	static ll a[100010];
	scanf("%lld",&n);
	rep1(i,n)scanf("%lld",&x[i]);
	scanf("%lld%lld",&m,&k);
	rep1(i,m)scanf("%lld",&a[i]);
	
	perm p;
	rep(i,n-1)p.pb(i);
	rep1(i,m){
		swap(p[a[i]-2],p[a[i]-1]);
	}
	p = pow_perm(p,k);
	ll loc = x[1];
	rep1(i,n){
		printf("%lld\n",loc);
		if(i < n){
			loc += x[p[i-1]+2]-x[p[i-1]+1];
		}
	}
}



Measured memory_bytes: 3552
#include<stdio.h>

int main(){
  int n, m;
  int arr1[100][100];
  int arr2[100];
  int i, j;
  int input;
  int res[100];
  int sum;
  
  // input
  scanf("%d %d", &n, &m);
  for(i = 0; i < n; i++){
    for(j = 0; j < m; j++){
      scanf("%d", &input);
      arr1[i][j] = input;
    }
  }

  for(i = 0; i < m; i++){
    scanf("%d", &input);
    arr2[i] = input;
  }

  // calculation
  for(i = 0; i < n; i++){
    sum = 0;
    for(j = 0; j < m; j++){
      sum += arr1[i][j] * arr2[j];
    }
    res[i] = sum;
  }

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


Measured memory_bytes: 2140
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <math.h>
using namespace std;

int gcd(int x, int y) {
	if (y == 0) {
		return x;
	}
	gcd(y, x % y);
}

int main()
{
	int x, y;
	cin >> x >> y;
	cout << gcd(x, y) << endl;

	return 0;
}



Measured memory_bytes: 3100
#include <iostream>
using namespace std;
int main() {
    string str;
    int n;
    cin >> str >> n;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        string tmp;
        cin >> tmp;
        string hoge = tmp + tmp;
        if (hoge.find(str) != string::npos) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  string S;cin>>S;
  S[3]='8';cout<<S<<endl;
}







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

int main() {
    string a, b, c;
    const char change = 'A'-'a';
    cin >> a >> b >> c;
    a[0]+=change;
    b[0]+=change;
    c[0]+=change;
    cout << a[0] << b[0] << c[0] << endl;
    return 0;
}

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

int main(){
  int X;
  cin >> X;
  if(X == 7){
  	cout << "YES" << endl;
  }else if(X == 5){
  	cout << "YES" << endl;
  }else if(X == 3){
    cout << "YES" << endl;
  }else{
  	cout << "NO" << endl;
  }
}



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

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int> > jobs(m);
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    if ( a > m) continue;
    jobs[m-a].push_back(b);
  }
  priority_queue<int> q;
  ll ans = 0;
  for (int i = m - 1; i >= 0; --i){
    for ( vector<int>::iterator it = jobs[i].begin(); it != jobs[i].end(); it++) {
      q.push(*it);
    }
    if ( !q.empty()){
      ans += q.top();
      q.pop();
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 5504
// dile a la jardinera que traigo flores
// corner cases // int vs ll // cin vs scanf
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int n,W;
ll w[128],v[128],dp[128][100020];

int main(){

	fastio;
	cin >> n >> W;
	FER(i,1,n+1) cin >> w[i] >> v[i];

	fill(dp,0);
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= W; ++j){
			dp[i][j] = dp[i-1][j];
			if(j - w[i] >= 0) dp[i][j] = max(dp[i][j],dp[i-1][j-w[i]] + v[i]);
		}
	}
	cout << dp[n][W] << endl;
	return 0;
}


Measured memory_bytes: 100224
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, k; cin >> n >> k;
    string s; cin >> s;
    if (s[k-1] == 'A') s[k-1] = 'a';
    if (s[k-1] == 'B') s[k-1] = 'b';
    if (s[k-1] == 'C') s[k-1] = 'c';
    cout << s << endl;
}


Measured memory_bytes: 384
let words str =
  let len = String.length str in
  let buf = Buffer.create 128 in
  let rec aux i l =
    if i >= len then List.rev ((int_of_string (Buffer.contents buf))::l)
    else 
      match str.[i] with
      | ' ' ->
        let s = int_of_string (Buffer.contents buf) in
        Buffer.clear buf;
        aux (i+1) (s :: l)
      | c   ->
        Buffer.add_char buf c;
        aux (i+1) l
  in aux 0 []

let transpose matrix =
  List.fold_left
    (fun acc x -> List.map2 (fun a b -> b::a) acc x)
    (Array.make (List.length (List.hd matrix)) [] |> Array.to_list) matrix

let product a b =
  let f m n = List.map
      (fun x -> List.fold_left (+) 0
          (List.map2 (fun a b -> a*b) m x)) n
  in
  List.map (fun x -> f x b) a

  
let () =
  let n,m,l = Scanf.sscanf (read_line ()) "%d %d %d" (fun n m l -> n,m,l) in
  let rec read i =
    let rec iter l = function
      | 0 -> l
      | i ->
        let r = words (read_line ()) in
        iter (r::l) (i-1)
    in iter [] i
  in
  let a = read n |> List.rev in
  let b = read m |> transpose in
  let ab = product a b in
  let sl = List.map (fun x -> String.concat " " (List.map string_of_int x)) ab in
  List.iter print_endline sl

Measured memory_bytes: 5224
N=int(input())
S=input()
counter=0
alpha=list(set(list(S)))
for i in range(1,N):
    st=S[:i]
    gr=S[i:]
    count=0
    for j in range(0,len(alpha)):
        if st.count(alpha[j])!=0 and gr.count(alpha[j])!=0:
            count+=1
    if counter<count:
        counter=count
print(counter)

Measured memory_bytes: 3064
import java.util.Scanner;


public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] b = new int[n-1];
        for(int i=0;i<n-1;i++){
            b[i] = Integer.parseInt(sc.next());
        }
        int sum = 0;
        sum += b[0];
        sum += b[n-2];
        for(int i=1;i<n-1;i++){
            sum += Math.min(b[i-1], b[i]);
        }
        System.out.println(sum);
    }
}

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

int main()
{
ll n;
cin>>n;
ll arr[n][3];
ll temp[3];

ll dp[3];

fr(i,0,n){
	fr(j,0,3){
		cin>>arr[i][j];
	}
}
fr(i,0,3)
{
    dp[i]=arr[0][i];
}
for(ll i=1;i<n;i++){
	for(ll j=0;j<3;j++){


        temp[j]=arr[i][j]+max(dp[(j+1)%3],dp[(j+2)%3]);
	}
	fr(k,0,3)
	dp[k]=temp[k];
}
cout<<max(dp[0],max(dp[1],dp[2]));
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    int l = 0;
    int r = s.size()-1;
    int ans = 0;
    while(l < r) {
        if(s[l] == s[r]) {
            l++;
            r--;
        }
        else {
            if(s[l] == 'x') {
                l++;
                ans++;
            }
            else if(s[r] == 'x') {
                r--;
                ans++;
            }
            else {
                cout << -1 << endl;
                return 0;
            }
        }
    } 

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

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

int main(){
    int n;cin >> n;
    int a[n*2];
    for(int i = 0;i < n*2;i++){
        cin >> a[i];
    }
    sort(a,a + 2*n);
    int result = 0;
    for(int i = 0;i < n*2;i+=2){
        result += min(a[i], a[i + 1]);
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(vector<int>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

//CODE
void solve(void)
{
  string str;
  cin>>str;
  int COUNT = 0;
  for (int i = 0; i < str.size(); i++)
  {
    if(str[i] == 'o')COUNT++;
  }
  cout<< 700 + 100*COUNT <<endl;
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

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

int main() {
   int a, b;
   cin >> a >> b;

   if (a <= b) {
       cout << a << endl;
   } else {
       cout << a - 1 << endl;
   }
}

Measured memory_bytes: 256
inp = input()
n = int(inp)
inp = input()
split_inp = inp.split()
d_list = [int(st) for st in split_inp]
if n % 2 == 1 or n < 2:
    print(0)
    exit()
half = n // 2
d_list = sorted(d_list)
print(d_list[half] - d_list[half-1])

Measured memory_bytes: 15360
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <fstream>
using namespace std;
typedef pair<int, int>p;
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
vector<long long> divisor(long long n) {
	vector< long long> ret;
	for (long long i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return (ret);
}
struct LazySegmentTree {
private:
	int n;
	vector<int> node, lazy;
	vector<bool> lazyFlag;

public:
	LazySegmentTree(vector<int> v) {
		int sz = (int)v.size();
		n = 1; while (n < sz) n *= 2;
		node.resize(2 * n - 1);
		lazy.resize(2 * n - 1, INT_MAX);
		lazyFlag.resize(2 * n - 1, false);

		for (int i = 0; i<sz; i++) node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--) node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
	}

	void lazyEvaluate(int k, int l, int r) {
		if (lazyFlag[k]) {
			node[k] = lazy[k];
			if (r - l > 1) {
				lazy[k * 2 + 1] = lazy[k * 2 + 2] = lazy[k];
				lazyFlag[k * 2 + 1] = lazyFlag[k * 2 + 2] = true;
			}
			lazyFlag[k] = false;
		}
	}

	void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		lazyEvaluate(k, l, r);
		if (b <= l || r <= a) return;
		if (a <= l && r <= b) {
			lazy[k] = x;
			lazyFlag[k] = true;
			lazyEvaluate(k, l, r);
		}
		else {
			update(a, b, x, 2 * k + 1, l, (l + r) / 2);
			update(a, b, x, 2 * k + 2, (l + r) / 2, r);
			node[k] = min(node[2 * k + 1], node[2 * k + 2]);
		}
	}

	int find(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		lazyEvaluate(k, l, r);
		if (b <= l || r <= a) return INT_MAX;
		if (a <= l && r <= b) return node[k];
		int vl = find(a, b, 2 * k + 1, l, (l + r) / 2);
		int vr = find(a, b, 2 * k + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
};
long long mod = 1000000007;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(16);
	long long n, ga, sa, ba, gb, sb, bb;
	cin >> n >> ga >> sa >> ba >> gb >> sb >> bb;
	long long dp[5003] = { 0 };
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		dp[i + 1] = max(dp[i] + 1, dp[i + 1]);
		if (i + ga <= n) {
			dp[i + ga] = max(dp[i + ga], dp[i] + gb);
		}
		if (i + sa <= n) {
			dp[i + sa] = max(dp[i + sa], dp[i] + sb);
		}
		if (i + ba <= n) {
			dp[i + ba] = max(dp[i + ba], dp[i] + bb);
		}
	}
	n = dp[n];
	long long dp2[5003 * 5003] = { 0 };
	dp2[0] = 0;
	for (int i = 0; i < n; i++) {
		dp2[i + 1] = max(dp2[i] + 1, dp2[i + 1]);
		if (i + gb <= n) {
			dp2[i + gb] = max(dp2[i + gb], dp2[i] + ga);
		}
		if (i + sb <= n) {
			dp2[i + sb] = max(dp2[i + sb], dp2[i] + sa);
		}
		if (i + bb <= n) {
			dp2[i + bb] = max(dp2[i + bb], dp2[i] + ba);
		}
	}
	cout << dp2[n];
}

Measured memory_bytes: 195968
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<int> A(N);
  REP(i, N){
    cin >> A[i];
  }
  int ans = 0;
  REP(i, N){
    if((i+1)%2 == 1 && A[i]%2 == 1) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <iomanip>
#include <stdlib.h>
using namespace std;
int main(){
    long long n,a[10001];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n-1;i++){
        for(int j=n-1;j>i;j--){
	       if(a[j]>a[j-1]){
	           int t=a[j];
	           a[j]=a[j-1];
	           a[j-1]=t;
	       }
        }
    }
	long long count=0;
	for(int i=0;i<n;i++)
		count+=a[i];
	cout<<a[n-1]<<" "<<a[0]<<" "<<count<<endl;
	return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int N, M;
void func()
{
    cin >> N;
    vector<pair<int, int>> ba;
    rep(i, 0, N)
    {
        int a, b;
        cin >> a >> b;
        ba.push_back(make_pair(b, a));
    }
    sort(ba.begin(), ba.end());
    ll time = 0;
    rep(i, 0, N)
    {
        time += ba[i].second;
        if (time > ba[i].first)
        {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}
int main()
{
    func();
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

bool dp[200001];

void solve(long long X){
    dp[0] = true;
    REP(i, X) {
        if(dp[i]) {
            REP2(j, 100, 106) {
                dp[i+j] = true;
            }
        }
    }

    cout << (dp[X] ? 1 : 0) << endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 384
# solution

import math
import io

data = int(input())

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

n, m, k = list(filter(lambda n: n[2], array))[0]

for i in range(101):
  for j in range(101):
    kite = k + abs(n-i) + abs(m-j)
    if all(max(kite-abs(t[0]-i)-abs(t[1]-j), 0) == t[2] for t in array):
      print(i,j,kite)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>

using namespace std;

typedef long long ll;

int main(){
    while(true){
        int n;  //n人
        cin>>n;
        if(n==0){
            break;
        }
        
        int s[n];
        double sum=0;
        double a=0;
        
        for(int i=0;i!=n;++i){
            cin>>s[i];
            sum+=s[i];
        }
        
        double m=sum/n;
        
        for(int i=0;i!=n;++i){
            a+=(s[i]-m)*(s[i]-m);
        }
        
        printf("%f\n",sqrt(a/n));
    }
    
    
    
 
}



Measured memory_bytes: 3220
#include <iostream>

using namespace std;

void swap(string *a,string *b){
  string tmp=*a;
  *a=*b;
  *b=tmp;
}
int main(){
  int N,L;
  cin >> N >> L;
  string S[N]={};
  for(int i=0;i<N;i++){
    cin >> S[i];
  }
  
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      if(S[i]>S[j]){
        swap(&S[i],&S[j]);
      }
    }
  }
  for(int i=0;i<N;i++){
    cout << S[i];
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> x(N);
    for (ll i = 0; i < N; i++) {
        cin >> x[i];
    }

    ll ans = INT_MAX;
    for (ll i = 0; i <= N - K; i++) {
        ll left = i;
        ll right = i + K - 1;

        //左を先に行く
        ll ans1 = abs(0 - x[left]) + abs(x[right] - x[left]);
        ll ans2 = abs(0 - x[right]) + abs(x[left] - x[right]);

        ans = min(ans, min(ans1, ans2));
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
    public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		long N = scan.nextInt();
		long ans = 0;
        for (int i = 1; i < N; i++) {
            ans += i;
        }
		System.out.println(ans);
    }
}

Measured memory_bytes: 23636