akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < n; i++)
#define frab(i, a, b) for (int i = a; i < b; i++)
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const ll MOD = 998244353;
const ll INF = 2e15 + 10;
const ll MAX = 1e14 + 10;
const ld EPS = 1e-9;
const int N = 1e5 + 10;
const int M = 1e5 + 10;

int a[N][3];
int d[N][3];

void solve() {
    int n;
    cin >> n;
    fr(i, n)
        fr(j, 3)
            cin >> a[i][j];
    frab(i, 1, 1 + n)
        fr(j, 3)
            fr(k, 3)
                if (j != k)
                    d[i][j] = max(d[i][j], d[i - 1][k] + a[i - 1][j]);
    cout << max({d[n][0], d[n][1], d[n][2]});
}



int main() {
    //freopen("a.in", "r", stdin);
    ios_base::sync_with_stdio(false);
    solve();
}


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

int main()
{
  int N, K;
  string S;
  cin >> N >> K >> S;
  S.at(K-1) = tolower(S.at(K-1));
  cout << S << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define all(a) a.begin(),a.end()
typedef pair<int,int> P;
const long long mod=1000000007;
const long long inf=1ll<<61;

signed main(){
    int a,b,c,d,e,f;cin>>a>>b>>c>>d>>e>>f;
    vector<int>water,sugar;
    for(int i=0;i*a<=f;i+=100){
        for(int j=0;j*b<=f;j+=100){
            if(i*a+j*b<=f)water.push_back(i*a+j*b);
            else break;
        }
    }
    for(int i=0;i*c<=f;i++){
        for(int j=0;j*d<=f;j++){
            if(i*c+j*d<=f)sugar.push_back(i*c+j*d);
            else break;
        }
    }
    double per=0;
    int ax=0,ay=0;
    rep(i,water.size()){
        rep(j,sugar.size()){
            int X=water[i],Y=sugar[j];
            if(X/100*e>=Y&&X+Y<=f){
                double nowpar=(double)Y/double(X+Y);
                if(per<=nowpar){
                    per=nowpar;
                    ax=X;ay=Y;
                }
            }
        }
    }
    cout<<ax+ay<<' '<<ay<<endl;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    int n;
    cin>>n;
    vector<int> a(n);
    int sum = 0;
    for (int i=0; i<n; i++) {
	cin>>a[i];
	sum += a[i];
    }

    int idx = 0;
    for (int i=1; i<n; i++) {
	if (abs(n*a[idx]-sum) > abs(n*a[i]-sum)) {
	    idx = i;
	}
    }

    cout<<idx<<endl;    
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>

using namespace std;

class Digit{
    public: 
          int n, k;

          int digit(int n, int k)
          {
              int d = 0;

              while (n)
              {
                  n /= k;
                  d++;
              }

              return d;
              
          }
};

int main()
{
    Digit obj;

    cin >> obj.n >> obj.k;

    cout << obj.digit(obj.n, obj.k) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
vector<ll> factor(105);
ll seventyfour, twentyfour, fourteen, four, two;
int main() {
    //cout.precision(10);
    ll N;
    cin >> N;
    for(ll i = 2; i <= N; i++) {
        ll copy = i;
        for(ll j = 2; j <= 100; j++) {
            while(copy % j == 0) {
                factor[j]++;
                copy /= j;
            }
        }
    }
    for(int i = 2; i <= 100; i++) {
        cerr << i << " " << factor[i] << endl;
    }
    for(int i = 2; i <= 100; i++) {
        if(factor[i] >= 74) seventyfour++;
        if(factor[i] >= 24) twentyfour++;
        if(factor[i] >= 14) fourteen++;
        if(factor[i] >= 4) four++;
        if(factor[i] >= 2) two++;
    }
    cerr << seventyfour << endl;
    cerr << twentyfour << endl;
    cerr << fourteen << endl;
    cerr << four << endl;
    cerr << two << endl;
    ll ans = 0;
    ans += seventyfour;
    cerr << ans << endl;
    ans += twentyfour * (two - 1);
    cerr << ans << endl;
    ans += fourteen * (four - 1);
    cerr << ans << endl;
    ans += four * (four - 1) / 2 * (two - 2);
    cout << ans << endl;
    return 0;
}


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

int main() {
  int n, y;
  cin >> n;
  int a[2][110];
  for (int i = 0; i < n; i++) {
    cin >> a[0][i];
  }
  for (int i = 0; i < n; i++) {
    cin >> a[1][i];
  }

  int res = 0;
  for (int i = 0; i < n; i++) {
    int temp = 0;
    int j = 0;
    
    for (j = 0; j < i; j++) {
      temp += a[0][j];
    }
    temp += a[0][j];
    for (j = i; j < n; j++) {
      temp += a[1][j];
    }

    if (temp > res) {
      res = temp;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFIN
#include<bits/stdc++.h>
using namespace std;  
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const double eps = 1e-14;
const double PI = M_PI;  
#define DEB cout<<"!"<<endl
#define SHOW(a,b) cout<<(a)<<" "<<(b)<<endl  
#define DIV 1000000009  
int main(){
	vector<string> input;
	int N,L;
	cin >> N >> L;
	REP(i,N){
		string temp; cin >> temp;
		input.pb(temp);
	}
	sort(ALL(input));
	string ans ="";
	REP(i,input.size()){
		ans += input[i];
	}
	cout << ans << endl;
	return 0;
} 

Measured memory_bytes: 764
#include <iostream>
#include <map>

using namespace std;

int A[2 * 100000];

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

  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }

  long long count = 0;
  map<int, int> values;
  for (int i = N - 1; i >= 0; --i) {
    count += values[-A[i] - i];
    values[A[i] - i]++;
  }
  cout << count << endl;
}

Measured memory_bytes: 21396
#include <iostream>
using namespace std;
unsigned long long lucas(int n)
{
	unsigned long long l[87];
	l[0]=2;
	l[1]=1;
	for(int i = 2; i <n+1; ++i)
	{
		l[i]= l[i-1] + l[i-2];
	}
	return l[n];
}
int main(void)
{ 
   int n;
  cin >>n;
  cout << lucas(n) << endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

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

	int recangCount = 0;
	int rhomCount = 0;
	while (sc.hasNextLine()) {
	    int a;
	    int b;
	    int c;
	    String[] input = sc.nextLine().split(",");
	    if ("".equals(input[0])) {
		break;
	    }

	    a = Integer.parseInt(input[0]);
	    b = Integer.parseInt(input[1]);
	    c = Integer.parseInt(input[2]);

	    if (isRectangle(a, b, c)) {
		recangCount++;
	    }

	    if (isRhombus(a, b)) {
		rhomCount++;
	    }
	}

	System.out.println(recangCount);
	System.out.println(rhomCount);
    }

    private static boolean isRectangle(int a, int b, int c) {
	if (a == b) {
	    return false;
	}

	if (a * a + b * b != c * c) {
	    return false;
	}

	return true;
    }

    private static boolean isRhombus(int a, int b) {
	if (a != b) {
	    return false;
	}
	return true;
    }
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

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

	vector<long long int> input;

	for(int i = 0; i < n; i++){
		long long int x;
		cin >> x;

		if(x == 0){
			cout << 0;
			return 0;
		}

		input.push_back(x);
	}
	
	long long int ans = input[0];

	for(int i = 1; i < input.size(); i++){
		if(input[i] <= 1000000000000000000 / ans){
			ans *= input[i];
		}
		else{
			cout << -1;
			return 0;
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 4256
//Character Couting 
//?????????????????????

#include<stdio.h>


int main(void){
    
    int a[257] = {0};
    int i;
    char s_ch[] = {'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'};
    char l_ch[] = {'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'};
    
    char c;                      
    while((c = getchar()) != EOF)   a[c] += 1;
    
    for(i = 0; i < 26; i++)
        printf("%c : %d\n", s_ch[i], a[s_ch[i]] + a[l_ch[i]]);
        
    return 0;
}

Measured memory_bytes: 524
#include <iostream>

using namespace std;

int A,B,C;
int ans;
int main() {
  cin >> A >> B >> C;

  if(A == B && B == C && (C % 2 == 0)) {cout << "-1" <<endl; return 0;}

  while((A % 2 == 0) && (B % 2 == 0) && (C % 2 == 0)) {
    int tmp = A / 2;
    int tmp2 = B / 2;
    int tmp3 = C / 2;
    A = tmp2 + tmp3;
    B = tmp + tmp3;
    C = tmp + tmp2;
    ans++;
  }

  cout << ans << endl;
}
  
  


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
ll test[12345678], res[12345678];
ll aa[1234][1234];
signed main() {
	vector<ll> v; map<ll, ll> cost;
	ll n, m, a, b, c, k, l, x, cnt = 0, ans = 0; string s, t;
	cin >> n >> m >> a >> b >> k;
	m += n * 60; b += a * 60;
	cout << b - m - k << endl;
	return 0;
}

Measured memory_bytes: 3624
import std.stdio : readln, writeln, writefln;
import std.array : array, split;
import std.conv  : to;
import std.range.primitives;
import std.range : enumerate, iota, repeat, retro, assumeSorted;
import std.algorithm.searching  : all, any, canFind, count, countUntil;
import std.algorithm.comparison : max, min, clamp;
import std.algorithm.iteration  : each, group, filter, map, reduce, permutations, sum, uniq;
import std.algorithm.sorting    : sort;
import std.algorithm.mutation   : reverse, swap;

void main() {
    int n,h;
    scan(n,h);

    auto b = new int[](n);
    int am = 0;

    foreach (i ; 0 .. n) {
        int ai, bi;
        scan(ai,bi);
        am = max(am, ai);
        b[i] = bi;
    }

    b.sort!"a > b"();

    long[] bs = new long[](n + 1);
    foreach (i ; 1 .. n + 1) {
        bs[i] = bs[i-1] + b[i-1];
    }

    long ans = 10^^9 + 1;

    foreach (i ; 0 .. n + 1) {
        long d;
        long z = h - bs[i];
        if (z > 0) {
            d = (h - bs[i] + am - 1) / am;
        }
        ans = min(ans, i + d);
    }

    writeln(ans);
}




void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.array : split;
    import std.conv  : to;
    import std.range.primitives;

    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 4348
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    if (n<=111) cout << 111 << endl;
    else if (111<n && n <= 222) cout << 222 << endl;
    else if (222<n && n <= 333) cout << 333 << endl;
    else if (333<n && n <= 444) cout << 444 << endl;
    else if (444<n && n <= 555) cout << 555 << endl;
    else if (555<n && n <= 666) cout << 666 << endl;
    else if (666<n && n <= 777) cout << 777 << endl;
    else if (777<n && n <= 888) cout << 888 << endl;
    else if (888<n && n <= 999) cout << 999 << 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<int> s(m), c(m);
    rep(i, m) {
        cin >> s[i] >> c[i];
        if (n > 1 && s[i]==1 && c[i] == 0) {
            cout << -1 << endl;
            return 0;
        }
    }
    int snum=0;
    int cnum=0;
    rep(i, m-1) {
        for (int j=i+1; j<m; j++) {
            if (s[i] > s[j]) {
                snum = s[i];
                s[i] = s[j];
                s[j] = snum;
                cnum = c[i];
                c[i] = c[j];
                c[j] = cnum;
            }
        }
    }
    rep(i, m-1) if (s[i] == s[i+1]) {
        if (c[i] != c[i+1]) {
            cout << -1 << endl;
            return 0;
        }
    }
    vector<int> a(n);
    rep(i, m) a[s[i]-1] = c[i];
    if (n > 1 && a[0] == 0) a[0] = 1;
    rep(i, n) cout << a[i];
    cout << endl;
    
    return 0;
}

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

int main() {
	int N,M,C,ans = 0; cin >>N>>M>>C;
	vector<int> B(M);
	for(int &x : B) cin >> x;
	for(int i = 0 ; i < N ; i++){
		vector<int> A(M);
		for(int &x : A) cin >> x;
		int judge = C;
		for(int j = 0 ; j < M ; j++){
			judge += A[j]*B[j];
		}
		if(judge > 0) ans++;
	}
	cout << ans << endl;
}

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

public class GFG
{
    static public void Main()
    {
        try
        {

            var n = int.Parse(Console.ReadLine());

            var aar = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
            Dam(aar, n);
        }
        catch (Exception ex)
        {
            Console.Write(ex);
        }
    }

    static void Dam(Int64[] arr, int n)
    {

        long sum = 0;
        long AltSum = 0;

        for (int i = 0; i < n; i++)
        {
            sum = sum + arr[i];
        }

        for (int i = 2; i <= n - 1; i+=2)
        {
            AltSum = AltSum + arr[i];
        }

        long x1 = sum - 2 * (AltSum);

        long[] dp = new long[n];

        dp[1] = x1;

        for (int i = 2; i < n; i++)
        {
            dp[i] = 2 * arr[i-1] - dp[i - 1];
        }
        dp[0] = 2 * arr[n - 1] - dp[n - 1];
        for (int i = 0; i < n; i++)
        {
            Console.Write(dp[i] + " ");
        }
    }


}

Measured memory_bytes: 32092
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int n,all=0,wa=0;
  cin >> n;
  int w[n],ans[n];
  for(int i=0;i<n;++i) {
    cin >> w[i];
    all+=w[i];
  }
  for(int i=0;i<n;++i) {
    for(int t=0;t<i+1;++t) {
      wa += w[t];
    }
    ans[i]=abs(wa-(all-wa));
    wa=0;
  }
  sort(ans,ans+n);
  cout << ans[0] << endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    d = set()
    mini = a[0]
    for i in range(n):
        if mini >= a[i]:
            mini = a[i]
        d.add(mini)
    print(len(d))

if __name__ == '__main__':
    main()

Measured memory_bytes: 24744
#include <iostream>
#include <string>
using namespace std;
typedef unsigned long long ull;

ull gcd( ull m, ull n ){
    if ( ( 0 == m ) || ( 0 == n ) ) return 0;

    while( m != n ){
        if ( m > n ) m = m - n;
        else         n = n - m;
    }
    return m;
}

ull lcm( ull m, ull n ){
    if ( ( 0 == m ) || ( 0 == n ) ) return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

int main()
{
    ull N, M;
    string S,T;
    cin >> N >> M;
    cin >> S;
    cin >> T;
    auto ngcd = gcd(N,M);
    auto nlcm = lcm(N,M);
    for(ull i=0; i<ngcd; i++){
        if(S[(i*N/ngcd)%N] != T[(i*M/ngcd)%M]){
            cout<<"-1"<<endl;
            return 0;
        }
    }
    cout<< nlcm <<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n,k; cin >> n >> k;
	ll ans = 0;
	for(int b=k+1; b<=n; b++){
		ans += n/b*max(0,b-k)+max(0,n%b-k+1);
//		cout << n/b*max(0,b-k)+max(0,n%b-k+1) << endl;
	}
	if(k>0)cout << ans << endl;
	else cout << ll(n)*n << endl;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    ll n, k; std::cin >> n >> k;
    vi a(n), b(n); rep(i, n) std::cin >> a[i] >> b[i];
    map<int, ll> cnt;
    rep(i, n) cnt[a[i]] += b[i];
    ll kk = 0;
    int ans = 0;
    for (auto &p : cnt) {
        if (kk < k) chmax(ans, p.fi);
        kk += p.se;
    }
    std::cout << ans << "\n";
}


Measured memory_bytes: 4992
import numpy as np

N, M = list(map(int, input().split()))
num_array = np.cumsum(list(map(lambda x: (x+1)/2, list(map(int, input().split())))))

max_exp = num_array[M-1]
for i in range(len(num_array)-M):
    tmp = num_array[i+M] - num_array[i]
    if max_exp < tmp:
        max_exp = tmp

print(max_exp) 

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

const int inf = 1e9 + 7;

template<typename T>
void mini(T& a, T b) { a = min(a, b); }

// This is the same knapsack problem with very large valus of W.
// lets try to reverse the dp intuition.
// let's say dp(i) <-- is the minimum sum we can have for exactly i value.
// by keeping the minimum sum we can extend all j greater than i and still go
// further right.. going further right in the array means we can have more
// value. maximum value we can get is theoratically sum of all values givin in
// the question.
int main() {
  int n, W;
  scanf("%d %d", &n, &W);
  std::vector<int> w(n);
  std::vector<int> v(n);
  for (int i = 0; i < n; ++i) scanf("%d %d", &w[i], &v[i]);

  // calculate the sum of values so that we can construct the dp table.
  // s = maximum value we can have.
  int s = 0;
  for (int val : v) s += val;

  std::vector<int> dp(s + 1, inf);
  dp[0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = s; j >= v[i]; --j) {
      mini(dp[j], dp[j - v[i]] + w[i]);
    }
  }

  // Now we can extract the max value.
  // values are actually the index. iterating from right to left.
  // means as soon as we can get w <= W it means the index is correct.
  int ans = 0;
  for (int p = s; p >= 0; --p)
    if (dp[p] <= W) {
      ans = p;
      break;
    }
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a, b) for (int i = (a); i < (b); i++ )

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

const int INF = 100000000;
const double PI=3.14159265358979323846;

int main () {
    int N, M;
    cin >> N >> M;

    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    vector<int> sign(N,-1);
    queue<int> que;
    queue<int> sq;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    sign[0] = 0;
    que.push(0); // 0 を橙色頂点にする
    sq.push(0);

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        int s = sq.front();
        que.pop();
        sq.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            sign[nv] = s;
            que.push(nv);
            sq.push(nv);
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    //for (int v = 0; v < N; ++v) cout << v << ": " << dist[v] << endl;
    for (int v = 0; v < N; ++v) sign[v]++;
    cout << "Yes" << endl; 
    for (int v = 1; v < N; ++v) cout << sign[v] << endl;


}

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

int main()
{
	int num;
	cin>>num;
	int dp[num][3];
	int arr[num][3];

	for(int i=0; i<num; i++)
	{
		for(int j=0; j<3; j++)
		{
			int temp;
			cin>>temp;
			arr[i][j] = temp;
			if(i==0)
				dp[i][j]=temp;
		}

	}

	for(int i=1; i<num; i++)
	{
		dp[i][0] = arr[i][0] + max(dp[i-1][1],dp[i-1][2]);
		dp[i][1] = arr[i][1] + max(dp[i-1][0],dp[i-1][2]);
		dp[i][2] = arr[i][2] + max(dp[i-1][0],dp[i-1][1]);
	}

	int t;
	t=max(max(dp[num-1][0],dp[num-1][1]),dp[num-1][2]);
	cout<<t;
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;

const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555;
const double PI = acos(-1.0);
void solve()
{
	ll n;
	cin >> n;
	cout << n * (n - 1) / 2;


}	
int main()
{
	Red;
	solve();
	return 0;
}


Measured memory_bytes: 256
n = int(input())
f = []
for i in range(n):
    line = list(map(int, input().split()))
    f.append(line)

p = []
for i in range(n):
    line = [int(j) for j in input().split()]
    p.append(line)

res = - 10 ** 11
for i in range(1, 1 << 10):
    tmp_res = 0
    for j in range(n):
        counter = 0
        for k in range(10):
            if i >> k & f[j][k]:
                counter += 1
        tmp_res += p[j][counter]
    res = max(res, tmp_res)

print(res)


Measured memory_bytes: 9228
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int main(){
    ll k; cin>>k;
    cout << 50 << endl;
    for(int i=0; i<50; i++){
        if(i<k%50) cout << 100+k/50*50+k/50-k;
        else cout << k/50+49-k%50;
        cout << " \n"[i==49];
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define digit(x) floor(log10(x))+1
#define mod 1000000007
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef vector<vector<ll> > matrix;
typedef vector<ll> arr;
typedef vector<string> vs;
typedef vector<pair<ll,ll> > pv;
#define FOR(i,a,b) for(int i=a;i<=b;--i)
#define ROF(i,a,b) for(int i=a;i>=b;--i)
#define all(x) x.begin(),x.end()
#define debug(x) cerr << #x << " is " << x << endl;
int bx[]={0,0,1,-1,1,-1,-1,1};
int by[]={1,-1,0,0,1,-1,1,-1};

//=================================================================//

int main(){
    fast;
    ll n;
    cin>>n;
    unordered_map<ll,ll>mp;
    for(int i=0;i<n;i++) {
        int t;
        cin>>t;
        mp[t]++;
    }
    ll ans = 0;
    for(auto it:mp) {
        if(it.first!=it.second) {
            if(it.second>it.first) {
                ans += it.second-it.first;
            } else {
                ans += it.second;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4260
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Main tr = new Main();
		tr.test(sc);
		sc.close();
	}

	void test(Scanner sc){
		int R = sc.nextInt();
		int C = sc.nextInt();
		sc.nextLine();
		char[][]a= new char[R][C];
		for (int r = 0; r < R; r++) {
			String n = sc.nextLine();
			a[r] = n.toCharArray();
		}

		int[] RC = new int[R];
		int rows=R;
		for (int r = 0; r < R; r++) {
			int dot = 0;
			for (int c = 0; c < C; c++) {
				if(a[r][c] == '.'){
					dot++;
				}else{
					break;
				}
			}
			if(dot==C){
				RC[r]=1;
				rows--;
			}
		}

		int[] CC = new int[C];
		int cols = C;
		for (int c = 0; c < C; c++) {
			int dot = 0;
			for (int r = 0; r < R; r++) {
				if(a[r][c] == '.'){
					dot++;
				}else{
					break;
				}
			}
			if(dot==R){
				CC[c]=1;
				cols--;
			}
		}


		char[][]out = new char[rows][cols];
		int rn=0;
		for (int r = 0; r < R; r++) {
			if(RC[r]!=1){
				int cn=0;
				for (int c = 0; c < C; c++) {
					if(CC[c]!=1){
						out[rn][cn] = a[r][c];
						cn++;
					}
				}
				rn++;
			}
		}

		// show
		for (int r = 0; r < rows; r++) {
			for (int c = 0; c < cols; c++) {
				System.out.print(out[r][c]);
			}
			System.out.println();
		}

	}
}


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

using namespace std;

#define lli long long
#define ld long double
#define mod 1000000007 
#define set(n) cout << fixed << setprecision(n)    
#define fi first
#define se second
#define mp make_pair
#define pll pair<lli, lli>
#define endl '\n'

const double PI = acos(-1);
const double epsilon = 1e-7;  // floating point precision

signed main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    int d;
    cin >> n >> d;
    vector<pll> v(n);
    int ans = 0;
    for(int i = 0; i < n; i++) {
        cin >> v[i].fi >> v[i].se;
        ld dist = sqrt(v[i].fi * v[i].fi + v[i].se * v[i].se);
        if(ceil(dist) <= d) {
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6372
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>
#include <functional>
#include <stack>

int main (){
	int a;

	std::cin >> a;

	int count = 0;
	for (size_t i = 1; i <= a / 2; i++)
	{
		if (a - i != i) {
			count++;
		}
	}

	std::cout << count << std::endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
xor = 0
rank = [0] * 35 
for i in range(n):
    a = int(input())
    LSB = (a & -a).bit_length()
    rank[LSB] += 1
    xor ^= a 

prev = False 
ans = 0
for i in range(33, -1, -1):
    bit = xor & (1 << i)
    if (bit > 0 and prev == 0) or (bit == 0 and prev > 0):
        if rank[i+1] == 0:
            print(-1)
            exit()
        else:
            ans += 1
    prev = bit
print(ans)

Measured memory_bytes: 3188
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

typedef map<string, int> Mp;

int main(void){
    int N, max;
    cin >> N;
    max = 0;
    string name;
    Mp vote;
    for(int i = 0; i < N; i++){
        cin >> name;
        vote[name]++;
    }
    for(Mp::iterator it = vote.begin(); it != vote.end(); it++){
        if(it->second > max){
            max = it->second;
        }
    }
    for(Mp::iterator it = vote.begin(); it != vote.end(); it++){
        if(it->second == max){
            cout << it->first << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 25216
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define MAX 1000000001
using ll=long long;

int main(){
    int w,h,x,y;
    cin>>w>>h>>x>>y;
    double s=double(h)*double(w)/2.0;
    printf("%.10f ",s);
    cout<<(x*2==w&&y*2==h)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 50;
int n, m, s;
int C[N], D[N];
V<P<int, P<int, int>>> e[N];
ll d[N][N*50];
typedef P<ll, P<int, int>> T;
priority_queue<T, V<T>, greater<T>> q;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m >> s;
  FOR(_, 0, m){
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--; v--;
    e[u].pb(mp(v, mp(a, b)));
    e[v].pb(mp(u, mp(a, b)));
  }
  FOR(i, 0, n) cin >> C[i] >> D[i];
  int nn = n*50-1;
  FOR(i, 0, n)FOR(j, 0, nn+1) d[i][j] = LINF;
  mins(s, nn);
  d[0][s] = 0;
  q.push(mp(0ll, mp(0, s)));
  while(!q.empty()){
    auto p = q.top();
    q.pop();
    ll _d = p.fi;
    int x=p.se.fi, y=p.se.se;
    if(d[x][y] < _d) continue;
    for(auto t:e[x]){
      ll __d = _d + t.se.se;
      if(t.se.fi<=y && __d<d[t.fi][y-t.se.fi]){
        d[t.fi][y-t.se.fi] = __d;
        q.push(mp(__d, mp(t.fi, y-t.se.fi)));
      }
    }
    _d += D[x];
    y = min(nn, y+C[x]);
    if(_d < d[x][y]){
      d[x][y] = _d;
      q.push(mp(_d, mp(x, y)));
    }
  }
  V<ll> ans(n, LINF);
  FOR(i, 0, n)FOR(j, 0, nn+1) mins(ans[i], d[i][j]);
  FOR(i, 1, n)cout << ans[i] << endl;
}

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

int main(){
  int N;
  cin >> N;
  int A[N];
  int ans = 0;
  for(int i=0;i<N;i++){
    cin >> A[i];
    ans += A[i];
  }
  sort(A, A+N);
  cout << ans-A[N-1]/2 << endl;
}
  

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
typedef long long lint;
using namespace std;

int main()
{
	int N;
	int a[100010]={};
	int tmp,Min=1e5+7,Max=0;
	int ans=0;
	
	cin >> N;
	for(int i=0;i<N;i++)
	{
		cin >> tmp;
		tmp++;
		Min=min(Min,tmp);
		Max=max(Max,tmp);
		a[tmp]++;
	}
	
	for(int i=max(1,Min);i<=Max+3;i++)
		a[i]+=a[i-1];
	
	for(int i=Min-1;i<=Max;i++)
		ans=max(ans,a[i+3]-a[i]);
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,ans=0;
  cin>>N;
  int M=9999999;
  while(N--)
  {
    int X;
    cin>>X;
    if(X<M)
    {
      ans++;
      M=X;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> s(n);
    for (int i = 0; i < n; ++i) cin >> s[i];
    
    mcf_graph<int, int> g(n * m + 2);
    int a = n * m, b = a + 1;

    int pre_sum = 0;
    int cost_max = 10000;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (s[i][j] == 'o') {
                g.add_edge(a, m * i + j, 1, 0);
                pre_sum += i + j;
            }
            if (s[i][j] != '#') {
                g.add_edge(m * i + j, b, 1, cost_max - (i + j));
                for (int k = 0; k < 2; ++k) {
                    int ni = i + k, nj = j + (1 - k);
                    if (ni >= n || nj >= m) continue;
                    if (s[ni][nj] == '#') continue;
                    g.add_edge(m * i + j, m * ni + nj, INT_MAX, 0);
                }
            }
        }
    }

    auto [flow, cost] = g.flow(a, b);
    int ans = -(cost - flow * cost_max) - pre_sum;
    cout << ans << '\n';
}

Measured memory_bytes: 4092
n,k=map(int,input().split())
heights=[int(i) for i in input().split()]

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

for i in range(2,n):
  step=[]
  for j in range(1,min(k+1,i+1)):
      step.append(dp[i-j]+abs(heights[i]-heights[i-j]))
    
  dp[i]=min(step)
print(dp[n-1])


Measured memory_bytes: 52448
#include<iostream>
#include<cstdio>

using namespace std;
 
int main()
{
    long long k,a,b,c=1;
    cin>>k>>a>>b;
    if(a<k)
    {
        if(a-b<=0)c=-1;
        else c+=2*((k-b-1)/(a-b));
    }
    cout<<c<<endl;
}

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

int main()
{
    double x1, y1, x2, y2, xq, yq;
    char p;

    while( cin >> x1 >> p >> y1 >> p >> x2 >> p >> y2 >> p >> xq >> p >> yq )
    {
        if( y1 == y2 )
            cout << fixed << setprecision(6) << xq << " " << yq-(yq-y1)*2 << endl;
        else if( x1 == x2 )
            cout << fixed << setprecision(6) << xq-(xq-x1)*2 << " " << yq << endl;
        else
        {   
            //2本の直線の交点を求めて、交点を原点に合わせるようにqを調節して、符号を反転して、調整し直して戻す。
            double a = x2 - x1, b = y2 - y1;
            double crossx = ( yq - y1 + a * xq / b + b * x1 / a ) / ( a / b + b / a );
            double crossy = b * crossx / a + y1 + -1 * x1 * b / a; 
            double mx = xq - crossx;
            double my = yq - crossy;

            cout << fixed << setprecision(6) << -1* mx + crossx << " " << -1 * my + crossy << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3184
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <type_traits>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using intl32 = std::int_least32_t;
using intl64 = std::int_least64_t;
using uintl32 = std::uint_least32_t;
using uintl64 = std::uint_least64_t;



int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int64 n;
	std::cin >> n;
	std::vector<int64> a(n);
	int64 sum = 0;
	for (uint32 i = 0;i < n;++i) {
		std::cin >> a[i];
		sum += a[i];
	}
	if (sum % (n*(n + 1) / 2) != 0) {
		std::cout << "NO\n";
		return 0;
	}
	sum /= (n*(n + 1) / 2);
	int64 temp = a[0];
	for (uint32 i = 1;i < n;++i) {
		a[i - 1] -= a[i];
	}
	a[n - 1] -= temp;
	for (uint32 i = 0;i < n;++i) {
		a[i] += sum;
		if (a[i] % n != 0) {
			std::cout << "NO\n";
			return 0;
		}
		if (a[i] < 0) {
			std::cout << "NO\n";
			return 0;
		}
	}
	std::cout << "YES\n";
	return 0;
}

Measured memory_bytes: 1024
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
using ll = long long;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a/g*b;
}

vector<vector<long long> > comb(int n) {
  vector<vector<long long> > v(n + 1,vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

string change(string S)
{
    char f = S.back();
    S.erase(S.end()-1);
    S.insert(S.begin(), f);
    return S;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    string S, T; cin >> S >> T;
    
    bool is_ok=false;
    
    REP(i, S.size())
    {
        S = change(S);
        if (S==T)
        {
            is_ok=true;
            cout << "Yes" << endl;
            break;
        }
    }
    
    if (!is_ok)
    {
        cout << "No" << endl;
    }

    return 0;
}



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

class Program
{
    static string InputPattern = "InputX";

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

        if (InputPattern == "Input1") {
            WillReturn.Add("5 5 7");
            //YES
            //与えられる文節の長さはそれぞれ5,5,7であり、
            //5,7,5 となるように文節を並び替えることができます。
            //したがって、文節の並びを五七五にすることは可能といえます。
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("7 7 5");
            //NO
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        Array.Sort(wkArr);

        bool IsOK = true;
        if (wkArr[0] != 5) IsOK = false;
        if (wkArr[1] != 5) IsOK = false;
        if (wkArr[2] != 7) IsOK = false;
        Console.WriteLine(IsOK ? "YES" : "NO");
    }
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+34;

priority_queue<int> pq;

void solve() {
  int n, m; scanf("%d%d", &n, &m);
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    int a; scanf("%d", &a);
    pq.push(a);
    ans += a;
  }
  for (int i = 0; i < m; ++i) {
    int value = pq.top(); pq.pop();
    ans -= value;
    ans += value/2;
    pq.push(value/2);
  }
  printf("%lld", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int H, W, n; cin >> H >> W >> n;
  int si, sj; cin >> si >> sj;
  si--; sj--;
  string T, A; cin >> T >> A;
  int L = sj, R = (W - 1) - sj;
  int U = si, D = (H - 1) - si;
  REP (i, n) {
    dump(i, L, R, U, D);
    if (T[i] == 'L') L--;
    if (T[i] == 'R') R--;
    if (T[i] == 'U') U--;
    if (T[i] == 'D') D--;
    if (L < 0 || R < 0 || U < 0 || D < 0) {
      cout << "NO" << endl; return 0;
    }
    if (A[i] == 'L') R = min(W - 1, R + 1);
    if (A[i] == 'R') L = min(W - 1, L + 1);
    if (A[i] == 'U') D = min(H - 1, D + 1);
    if (A[i] == 'D') U = min(H - 1, U + 1);
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 920
#include<stdio.h>
int main()
{
    int i;
    char ara[20];
    scanf("%s",ara);
    for(i=0;i<19;i++)
    {
        if(ara[i]==',')
        {
            printf(" ");
        }
        else
            printf("%c",ara[i]);
    }
    return 0;

}


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

int main(){
	double a,b,c,d,e,f,x,y;
	cout<<setprecision(3);
	cout<<fixed;
	while(cin>>a>>b>>c>>d>>e>>f){
		x=1.0/(a*e-b*d)*(e*c-b*f);
		y=1.0/(a*e-b*d)*(a*f-d*c);
		if(-0.0005<=x && x<=0)x=0;
		if(-0.0005<=y && y<=0)y=0;
		cout<<x<<" "<<y<<endl;
	}
	return 0;
}

Measured memory_bytes: 1280
package main

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

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func dfs(a int, ans []int, t,co [][]int) {
	for i, e := range t[a] {
		if ans[e] != -1 {
			continue
		}
		
		if co[a][i]%2 == 0 {
			ans[e] = ans[a]
		} else {
			if ans[a] == 0 {
				ans[e] = 1
			} else {
				ans[e] = 0
			}
		}
		dfs(e, ans,t,co)
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	n := scanInt()

	t := make([][]int,n)
	co := make([][]int,n)

	for i := 1; i < n; i++ {
		u := scanInt() - 1
		v := scanInt() - 1
		w := scanInt()
		t[u] = append(t[u], v)
		t[v] = append(t[v], u)
		co[u] = append(co[u], w)
		co[v] = append(co[v], w)
	}

	ans := make([]int,n)
	for i := 0; i < n; i++ {
		ans[i] = -1
	}
	ans[0] = 0

	dfs(0,ans,t,co)

	for i := 0; i < n; i++ {
		fmt.Println(ans[i])
	}

}


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

int main(){
 
  int n,a,b,ans=0;
  cin>>n; 
  vector<int> mochi(n);
  REP(i,n) cin>>mochi.at(i);
  sort(mochi.begin(),mochi.end());
  reverse(mochi.begin(),mochi.end());
  
  int top=INT_MAX;
  REP(i,n){
   if(mochi.at(i)<top){
     top=mochi.at(i);
     ans++;
   }
  }
  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  int a, b, c, d; readV(a, b, c, d);
  if (a+b > c+d)
    writeln("Left");
  else if (a+b < c+d)
    writeln("Right");
  else
    writeln("Balanced");
}


Measured memory_bytes: 256