akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
class UnionFind {
public:
    // 親の番号を格納する。親だった場合-size
    vector<int> parents;

    UnionFind(int n) {
        parents = vector<int>(n, -1);
    }

    // aがどのグループに属しているか
    int root(int a) {
        if (parents[a] < 0) {
            return a;
        }
        return parents[a] = root(parents[a]);
    }

    int size(int a) {
        return -parents[root(a)];
    }

    // aとbをくっつける
    bool connect(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        if (ra == rb) {
            return false;
        }
        // 大きいほうにA
        if (size(ra) < size(rb)) {
            swap(ra, rb);
        }
        parents[ra] += parents[rb];
        parents[rb] = ra;
        return true;
    }

};


int main() {

    int n, m;
    cin >> n >> m;

    vector<ll> ns(n);

    rep(i, n) {
        int p;
        cin >> p;
        p--;
        ns[i] = p;
    }

    UnionFind uf(n);

    rep(i, m) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        uf.connect(x, y);
    }

    ll ans = 0;

    for (int i = 0; i < n; i++) {
        int nsi = ns[i];
        int ufnsi = uf.root(nsi);
        int ufi = uf.root(i);
        if (ufi == ufnsi) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>

using namespace std;
typedef long long int ll;

//最大の中央値に近いものを選ぶと最大になるぞいというお気持ち
int main(){

    ll N = 0;
    cin >> N;
    vector<double > A(N);

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

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

    double max =  A[A.size()-1];
    double center = max / 2;
    double sa = 1145141919;
    ll ans = A[0];
    //cout << center << endl;
    for(ll i = 0; i < N - 1; i++){
        if(abs(A[i] - center)  < sa){
            sa = abs(A[i] - center);
            ans = A[i];
        }
    }    

    cout << (ll)max << " " << (ll)ans << endl;

} 

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))
 
 // ^^^ Template ^^^ //

int main() {
	in(ll, N, M);
	cout << (1<<M)*(1900*M+100*(N-M)) << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int w[200001];
int b[200001];

int main()
{
  int n;
  char s[200001];
  scanf("%d%s", &n, s);
  for (int i = 0; i < n; ++i)
  {
    w[i + 1] = w[i] + (s[i] == '.' ? 1 : 0);
    b[i + 1] = b[i] + (s[i] == '#' ? 1 : 0);
  }
  int ans = 1e8;
  for (int i = 0; i <= n; ++i)
  {
    ans = std::min(ans, b[i] + w[n] - w[i]);
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1920
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
using ll = long long;
constexpr ll linf=2*1e18;

int main(){
    ll n,d,a;
    cin>>n>>d>>a;
    vector<pair<ll,ll>> p(n);
    for(int i=0;i<n;i++){
        ll x,h;
        cin>>x>>h;
        p[i]=make_pair(x,h);
    }
    sort(p.begin(),p.end());
    vector<ll> x(n);
    vector<ll> h(n);
    for(int i=0;i<n;i++){
        x[i]=p[i].first;
        h[i]=(p[i].second+a-1)/a;
    }
    vector<ll> e(n);
    for(int i=0;i<n;i++){
        e[i] = (upper_bound(x.begin(),x.end(),x[i]+2*d)- x.begin());
    }
    vector<ll> damage(n+2,0);
    ll ans=0;
    for(int i=0;i<n;i++){
        if(i==0){
            damage[i]=h[i];
            ans+=h[i];
            damage[e[i]]-=damage[i];
        }
        else{
            damage[i]+=damage[i-1];
            if(damage[i]>h[i]){
                continue;
            }
            else{
                ll res=h[i]-damage[i];
                damage[i]+=res;
                ans+=res;
                damage[e[i]]-=res;
            }
        }
    }
    /*for(int i=0;i<n;i++){
        cout<<e[i]<<endl;
    }*/
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

////typedef
////------------------------------------------
//typedef vector<int> vi;
//typedef vector<vi> vii;
//typedef vector<string> vs;
//typedef vector<bool> vb;
//typedef vector<vb> vbb;
//typedef pair<int, int> pii;
//typedef long long ll;
//typedef unsigned long long ull;
//
////container util
////------------------------------------------
//#define all(a)  (a).begin(),(a).end()
//#define rall(a) (a).rbegin(), (a).rend()
//#define pb push_back
//#define mp make_pair
//#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
//
////repetition
////------------------------------------------
//#define loop(i,a,b) for(int i=(a);i<(b);++i)
//#define rep(i,n)  loop(i,0,n)
//
////constant
////--------------------------------------------
//const double eps = 1e-10;
//const double pi  = acos(-1.0);
//const double inf = (int)1e8;
//
//// output vector
//// ------------------------------------------
//namespace std {
//    template<typename T> ostream & operator<<(ostream& os, vector<T> const& v){
//        for(auto it=v.begin(); it!=v.end(); ++it){
//            os << *it << (it+1==v.end() ? "" : ",");
//        }
//        return os;
//    }
//}
//
////clear memory
//#define clr(a) memset((a), 0 ,sizeof(a))

int getDay(int y, int m){
    if(y % 3 == 0) return 20;
    else {
        if(m % 2 == 0) return 19;
        else return 20;
    }
}

int main(){
    int n;
    cin >> n;
    for(int p=0; p < n; p++){
        int y, m ,d;
        int ans = 0;
        cin >> y >> m >> d;

        ans += getDay(y, m)-d+1;
        m++;
        if(10 < m){y++; m=1;}
        if(m != 1){
            for(int i=m; i <= 10; i++){
                ans += getDay(y, i);
            }
            y++;
        }

        while(y != 1000){
            for(int i=1; i <= 10; i++){
                ans += getDay(y, i);
            }
            y++;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1160
#include <cstdio>
#include <algorithm>

struct problem
{
  long long num;
  long long bonus;
};

int main()
{
  long long d, g;
  scanf("%lld%lld", &d, &g);
  problem ps[10];
  for (long long i = 0; i < d; ++i)
  {
    scanf("%lld%lld", &ps[i].num, &ps[i].bonus);
  }
  
  long long ans = 1e8;
  for (long long i = 0; i < (1 << d); ++i)
  {
    long long score = 0;
    long long count = 0;
    for (long long j = 0; j < d; ++j)
    {
      if (i & (1 << j))
      {
        score += (j + 1) * 100 * ps[j].num + ps[j].bonus;
        count += ps[j].num;
      }
    }
    if (score >= g)
    {
      if (ans > count) ans = count;
      continue;
    }
    for (long long j = d - 1; j >= 0; --j)
    {
      if ((i & (1 << j)) == 0)
      {
        long long num = std::min(((g - score) + (j + 1) * 100 - 1) / ((j + 1) * 100), ps[j].num - 1);
        score += num * (j + 1) * 100;
        count += num;
        if (score >= g)
        {
          if (ans > count) ans = count;
          break;
        }
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void);

int main(void)
{
    int a, b;
    int d, r;
    double f;
    scanf("%d %d", &a, &b);

    d = a / b;
    r = a % b;
    f = a / (double)b;
    /* 変数aを小数点以下8桁まで表示するには…
    printf("%.8lf\n", a);と記述する。 */
    printf("%d %d %.5lf\n", d, r, f);
    return(0);
}


Measured memory_bytes: 2072
from sys import stdin
input = stdin.readline
 
a,b,n = map(int,input().split())
maxpoint = 0
 
if b > n  :
    tmp = int((a * n) / b)  - a * int(n/b) 
    maxpoint = max(tmp,maxpoint)
else:
    k = int(n/b)*b -1
    maxpoint =  int((a * k) / b)  - a * int(k/b) 
    if b == 1:
        maxpoint = 0
 
print(maxpoint)

Measured memory_bytes: 9188
#include<stdio.h>
int main(){
    int n,v[20],c[20],i,r=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&v[i]);
    for(i=0;i<n;i++)scanf("%d",&c[i]);
    for(i=0;i<n;i++)if(v[i]-c[i]>0)r+=v[i]-c[i];
    printf("%d\n",r);
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using static System.Console;

class Program {
    static void Main() {
        var n = (long)NextInt();
        var a = NextInt();
        var b = NextInt();
        WriteLine(Math.Max(0, (b - a) * (n - 2) + 1));
    }

    static int NextInt() {
        return int.Parse(NextString());
    }

    static string NextString() {
        var result = new List<char>();
        while (true) {
            int next = Read();
            if (next < 0)
                break;
            var nextChar = (char)next;
            if (!char.IsWhiteSpace(nextChar))
                result.Add(nextChar);
            else if (nextChar != '\r')
                break;
        }
        return string.Join("", result);
    }
}

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

int main() {
	int result_ac = 0, result_wa = 0;
	int N = 0, M = 0;
	cin >> N >> M;
	vector<bool> ResultState(105000, false);
	vector<int> WrongAnswerCount(105000, 0);

	for (int i = 0; i < M; i++) {
		int question = 0;
		string state;
		cin >> question >> state;
		if (ResultState[question]) continue;

		if (state == "AC") {
			result_ac += 1;
			ResultState[question] = true;
			result_wa += WrongAnswerCount[question];
		}
		if (state == "WA") {
			WrongAnswerCount[question] += 1;
		}
	}

  cout << result_ac << " " << result_wa << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

using namespace std;

int xdir[4] = {0, 1, 0, -1}, ydir[4] = {1, 0, -1, 0};
void change(int b[8][8], bool vis[8][8], int h, int w, int s, int t, int c)
{
  for(int i = 0; i < 4; i++){
    int dx = t+xdir[i], dy = s+ydir[i];
    if(0 <= dx && dx < w && 0 <= dy && dy < h && vis[dy][dx] && b[s][t] == b[dy][dx]){
      vis[dy][dx] = false;
      change(b, vis, h, w, dy, dx, c);
    }
  }
  b[s][t] = c;

  return ;
}

void cp_ary(int p[8][8], int b[8][8], int h, int w, int c)
{
  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++)
      b[i][j] = p[i][j];

  bool vis[8][8];
  fill(&vis[0][0], &vis[8][0], true);
  vis[0][0] = false;
  change(b, vis, h, w, 0, 0, c);

  return ;
}

int check(int p[8][8], bool vis[8][8], int h, int w, int s, int t, int c)
{
  int cnt = 1;

  for(int i = 0; i < 4; i++){
    int dx = t+xdir[i], dy = s+ydir[i];
    if(0 <= dx && dx < w && 0 <= dy && dy < h && vis[dy][dx] && p[dy][dx] == c){
      vis[dy][dx] = false;
      cnt += check(p, vis, h, w, dy, dx, c);
    }
  }

  return cnt;
}

int cfunc(int p[8][8], int h, int w, int c)
{
  int cnt = 0;
  bool vis[8][8];
  fill(&vis[0][0], &vis[8][0], true);

  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++)
      if(vis[i][j]){
	vis[i][j] = false;
	cnt = max(cnt, check(p, vis, h, w, i, j, c));
      }

  return cnt;
}

int dfs(int p[8][8], int h, int w, int c, int cnt)
{
  if(cnt == 5) return cfunc(p, h, w, c);

  int mx = 0, b[8][8];
  for(int i = 1; i <= 6; i++){
    cp_ary(p, b, h, w, i);
    mx = max(mx, dfs(b, h, w, c, cnt+1));
  }

  return mx;
}

int main()
{
  int h, w, c, p[8][8];

  while(cin>>h>>w>>c && (h+c+w)){
    for(int i = 0; i < h; i++)
      for(int j = 0; j < w; j++)
	cin >> p[i][j];

    cout << dfs(p, h, w, c, 0) << endl;
  }

  return 0;
}

Measured memory_bytes: 868
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const long long MOD = 1000000007;

ll N, D1[200], D2[200];

signed main(){
    cin >> N;
    REP(i, N) cin >> D1[i] >> D2[i];
    bool ok = false;
    REP(i, N - 2){
        if(D1[i] == D2[i] && D1[i + 1] == D2[i + 1] && D1[i + 2] == D2[i + 2]) ok = true;
    }
    if(ok) PRINT("Yes");
    else PRINT("No");
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(){
  int i;
  double b[101],sum=0,n,a[101];
  scanf("%lf",&n);
  for(i=0; i<n; i++){
    scanf("%lf",&a[i]);
    b[i]=1/a[i];
    sum=sum+b[i];
  }
  printf("%lf\n",1/sum);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    int n,i,k;
    cin >> n;
    int day[n];
    for(i=0;i<n;i++){
    cin >> day[i+1];
    }cout << day [n]; 
    for(k=1;k<n;k++){
        cout << " ";
        cout << day[n-k];
    }
    cout << endl;
}



Measured memory_bytes: 3092
import java.io.*;
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        Map<Long, Long> mp = new HashMap<>();
        for(int i = 0; i < n; ++i){
            a[i] = sc.nextLong();
            long v = mp.getOrDefault(a[i], 0L);
            mp.put(a[i], v+1);
        }
      
        long sum = 0;
        for(long v : mp.values()){
            sum += v * (v-1) / 2L;
        }

      for(int i = 0; i < n; ++i){
            long v = mp.get(a[i]);
            long ans = sum;
            ans -= v*(v-1)/2L;
            ans += (v-1)*(v-2)/2L;
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 110116
#include<stdio.h>
int main(void){
  int a,b,sum,subt;
  scanf("%d %d",&a,&b);
  if(b%a==0){
    sum=a+b;
    printf("%d",sum);
  }
  else{
    subt=b-a;
    printf("%d",subt);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
bool prime(long long num);
int main(){
    string S;
    cin >> S;
    if(S.size()%2==1){
        cout << "No" << endl;
        return 0;
    }
    for(int i=0;i<S.size();i+=2){
        bool flag=S.substr(i,2)=="hi";
        if(!flag){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;

int main(){

  string S;
  cin >> S;
  int sum = 0, ans = 0;
  vector<int> vec = {'A', 'C', 'G', 'T'};

  bool flag = false;

  for (int i = 0; i < S.size(); i++) {
    for (int j = 0; j < 4; j++) {
      if(S[i] == vec.at(j)){
        sum++;
        break;
      } else if(j == 3 && S[i] != vec.at(j)){
        sum = 0;
      }
    }
    ans = max(ans, sum);
  }

  cout << ans << endl;

  return 0;
}

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

int main()
{
    int n, m, d, v, a[101];

    while( cin >> n >> m )
    {
        if( n + m == 0 )
            break;

        for( int i = 0; i < 101; i++ )
            a[i] = 0;

        for( int i = 0; i < n; i++ )
        {
            cin >> d >> v;
            if( a[d] < v )
                a[d] = v;
        }
        
        int sum = 0;
        for( int i = 1; i <= m; i++ )
            sum += a[i];

        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>


using namespace std;

int count_s(string s) 
{
	int cnt = 0;
	for (int si = 0; si < s.length(); si++) {
		if (s[si] == '#') cnt++;
	}
	return cnt;
}

int main()
{

	int H, W;

	cin >> H >> W;

	vector<string> data;

	string line;
	for (int hi = 0; hi < H; hi++) {
		cin >> line;
		if (count_s(line) > 0) data.push_back(line);
	}

	vector<int> cnts = vector<int>(W, 0);
	for (int wi = W - 1; wi >= 0; wi--) {
		for (int hi = 0; hi < data.size(); hi++) {
			if (data[hi][wi] == '#') cnts[wi]++;
		}
	}

	vector<string> ans;
	for (int hi = 0; hi < data.size(); hi++) {
		string buf = "";
		for (int wi = 0; wi < cnts.size(); wi++) {
			if (cnts[wi] > 0) buf += data[hi][wi];
		}
		ans.push_back(buf);
	}

	for (int hi = 0; hi < ans.size(); hi++) {
		printf("%s\n", ans[hi].c_str());
	}


	//printf("%d", ans);

    return 0;
}



Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

x,y=get_i
ans=0
while x<=y
  ans+=1
  x*=2
end
puts ans

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

int main() {
    int h, w; cin>>h>>w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a.at(i);
	}

	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int a,b,c;

  a=1;
  b=1;

  for(;a<10;a++){
    b=1;
    for(;b<10;b++){
      c=a*b;
      printf("%dx%d=%d\n",a,b,c);
    }
  }
return 0;
}

Measured memory_bytes: 520
#include <iostream>
using namespace std;
int main(void){
  int cnt=0,m=0,n,a[1000000],g[100]={0};
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i];
  g[0]=1;
  while(g[m]<n){
    g[m+1]=3*g[m]+1;
    m++;
  }
  if(n==1)
    m=1;
  for(int i=m-1;i>=0;i--){
    for(int k=g[i];k<n;k++){
      int v=a[k];
      int j=k-g[i];
      while(j>=0&&a[j]>v){
	a[j+g[i]]=a[j];
	j=j-g[i];
	cnt++;
      }
      a[j+g[i]]=v;
    }
  }
  cout<<m<<endl;
  for(int i=m-1;i>0;i--)
    cout<<g[i]<<" ";
  cout<<g[0]<<endl;
  cout<<cnt<<endl;
  for(int i=0;i<n;i++)
    cout<<a[i]<<endl;
  return 0;
}

Measured memory_bytes: 6976
def main():
    n,T = map(int, input().split())

    array = []
    for i in range(n):
        c,t = map(int, input().split())
        if t <= T:
            array.append(c)
    if not array:
        print('TLE')
        return
    print(min(array))


if __name__ == '__main__':
    main()


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

int main() {
  long a, b, c, k;
  cin >> a >> b >> c >> k;
  long ans = 0;
  if(a >= k){
    ans += k;
  } else {
    ans += a;
    k -= a;
    
    if(b < k){
      k -= b;

      if(k > 0){
        ans -= k;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3600
/*An anomaly, I'm Muhammad Ali
  'Cause I know one day I'm gonna be the*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define llpow(a,b) (ll)(pow(a,b)+0.5)
#define f first
#define s second
const  int mod = 1000000007;
void add(ll& a, ll b){a+=b;while(a>=mod)a-=mod;while(a<0)a+=mod;}
void mul(ll& a, ll b){a*=b;while(a>=mod)a-=mod;while(a<0)a+=mod;}
ll binexpomodulo(ll x, ll y){ll res =1;x%=mod;if(!x)return 0;while(y){if(y&1){mul(res, x);}mul(x,x);y>>=1;}return res;}
ll nCrInOr(ll n, ll r){ll res = 1;if(r>n-r)r = n-r;ll rin = 1;for(ll i = 1; i <=r ; i++)rin = (rin*i)%mod;rin = binexpomodulo(rin,mod-2);for(ll i = 1; i <= r; i++)res = (res*(n-i+1))%mod;res = (res*rin)%mod;return res;}
int main()
{
	int n; cin>>n;
	while(n)
	{
		int k = n%10;
		if(k==7)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
		n/=10;
	}
	cout<<"No"<<endl;
  	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin>>s;
  int n=s.length();
  map<int ,int > comp;
 for(int i=0;i<n;i++)
  {
    comp[s[i]-'a']++;
  }   
  if(n<26)
  {
  
    for(int i=0;i<26;i++)
  {
    if(comp[i]==0){cout<<s<<(char)('a'+i);return 0;}
  }  
  }

int now=n-1;int i;
 for( i=n-1;i>0 && s[i-1]>s[i];i--)
;
  if(i==0) cout<<-1<<'\n';
  else {
    
      now=i-1;
      for(int j=now+1;j<n;j++)
      comp[s[j]-'a']=0;
      s.resize(now+1);
      for(int j=s[now]-'a'+1;j<26;j++)
      
      if(comp[j]==0) {char c=('a'+j);s.back()=c;cout<<s;break;}
  }
	return 0;
}



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;
const int INF = 1e9;

int main() {
  ll n, k, ans = 0;
  cin >> n >> k;
  vector<ll> p(n);
  rep(i, n) cin >> p[i];
  sort(p.begin(), p.end());
  rep(i, k) ans += p[i];

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


Measured memory_bytes: 3596
// 2015/03/05 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int c1, c5, c10, c50, c100, c500;
	cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;

	int t = 1*c1+5*c5+10*c10+50*c50+100*c100+500*c500;

	if(t>=1000){
		cout << 1 << endl;
	}
	else{
		cout << 0 << endl;
	}

	return 0;
}

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

int main() {
	int c1, c2, c3;
	while (cin >> c1) {
		cin >> c2 >> c3;

		int c[10] = { 0 }, sum = c1 + c2, count = 0;
		c[c1 - 1] = c[c2 - 1] = c[c3 - 1] = 1;
		for (int i = 0; i < 10; i++) {
			if (c[i]) continue;

			if (sum + i + 1 <= 20) count++;
		}

		if (count / 7.0 >= 0.5) cout << "YES";
		else cout << "NO";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
a,b = map(int,input().split())
s = [['.']*99 if i<50 else ['#']*99 for i in range(100)]
print(100,99)
for i in range(b-1):
    row = ((i*2)//99)*2
    col = (i*2)%99
    s[row][col] = '#'
for i in range(a-1):
    row = ((i*2)//99)*2+51
    col = (i*2)%99
    s[row][col] = '.'
for i in s:
    for j in i:
        print(j,end='')
    print()



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

int main(void){
    
    string s;
    cin >> s;
    
    if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) cout << "Yes";
    else if(s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) cout << "Yes";
    else if(s[0] == s[3] && s[1] == s[2] && s[0] != s[1]) cout << "Yes";
    else cout << "No";

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int S[100000]={0},T[50000]={0};
 
int main(){
    int n,q;
    int i,j,counter=0;
    int start,end;
 
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&S[i]);
    }
 
    scanf("%d",&q);
    for(j=0;j<q;j++){
        scanf("%d",&T[j]);
    }
 
 
    for(i=0;i<q;i++){
 
        start=0,end=n;
 
        while(start < end){
            int middle = (start + end) / 2;
 
            if(S[middle] > T[i]){
                end = middle;
            }
            else if(S[middle] < T[i]){
                start = middle + 1;
            }
            else if(S[middle] == T[i]){
                counter++;
                break;
            }
        }
    }
 
    printf("%d\n",counter);
 
    return 0;
}

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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    int n; cin >> n;
    map<string,ll> m;
    rep(i,n){
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        m[s]++;
    } 
    ll ans = 0;
    for(auto i : m){
        ll cnt = i.second;
        ans += (cnt*(cnt-1))/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 11136
#include<iostream>
#include<map>
#define MAX 5001
using namespace std;
int main()
{
	while(true){
		int n;
		int c[MAX] = {0,};
		map<int,int> m;
		map<int,int>::iterator itm;

		cin >> n;
		if( n == 0 )break;

		for(int i = 1; i < n; ++i){
			m[(i*i)%n]=(i*i)%n;
		}

		itm = m.begin();
		while( itm != m.end() ){
			map<int,int>::iterator itm_t = m.begin();
			while( itm_t != m.end() ){
				if( itm_t != itm ){
					int diff = itm_t->second - itm->second;
					diff = diff < 0 ? diff + n : diff;
					diff = diff > (n-1)/2 ? n - diff : diff;
					++c[ diff ];	
				}
				++itm_t;
			}
			++itm;
		}
		for(int i = 1; i <= (n-1)/2; ++i){
			cout << c[i] << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 1076
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int X,Y; cin>>X>>Y;
  if(X<Y) swap(X,Y);
  string ans="Brown";
  if(X-Y>1) ans="Alice";
  cout<<ans<<endl;
  }


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

int main(int argc, char const* argv[]) {
	string S[3];
	for (int i = 0; i < 3; i++) {
		cin >> S[i];
	}
	cout << "A" << S[1][0] << "C" << "\n";
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#define mp make_pair
#define ii pair < ll, ll >
#define F first
#define S second
#define i_ii pair < ll, ii >
#define mpp(AA, BB, CC) mp( AA, mp(BB, CC) )
#define ll long long int

using namespace std;

int main()
{
    string s;
    cin >> s >> s;
    int arr[s.size() + 1], t = 0;
    arr[0] = 0;
    for(int i = 0 ; i < s.size() ; i++){
        arr[i+1] = arr[i];
        if(s[i] == 'E'){
            arr[i+1]++;
            t++;
        }
    }
    int res = s.size()*3;
    for(int i = 1 ; i <= s.size() ; i++){
        int aux = i - 1 - arr[i - 1] + t - arr[i];
        res = min(res, aux);
    }
    cout << res;
    return 0;
}












Measured memory_bytes: 1924
n, m = list(map(int, input().split()))
x = list(map(int, input().split()))
x.sort()
spans = []
for i in range(len(x) - 1):
    spans.append(x[i + 1] - x[i])
spans.sort()

ans = 0
for i in range(m - n):
    ans += spans[i]
print(ans)

Measured memory_bytes: 13968
package main

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

var sc = bufio.NewScanner(os.Stdin)

const initBufSize, maxBufSize = 10000, 1000000

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextInts(n int) []int {
	res := make([]int, n)
	for i := range res {
		res[i] = nextInt()
	}
	return res
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}

func pow(r, n int) int {
	return int(math.Pow(float64(r), float64(n)))
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initBufSize), maxBufSize)
	n := nextInt()
	m := nextInt()
	study := 0
	homework := make([]int, m)
	for i := range homework {
		homework[i] = nextInt()
		study += homework[i]
	}
	if study <= n {
		fmt.Println(n - study)
	} else {
		fmt.Println(-1)
	}
}


Measured memory_bytes: 1884
import java.util.Scanner;

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

       for(int i=0; i<input.length(); i++) {
           letter[i] = input.charAt(i);
           if(Character.isUpperCase(letter[i]))
            letter[i] = Character.toLowerCase(letter[i]);
           else letter[i] = Character.toUpperCase(letter[i]);
       }

        
       for(int i=0; i<input.length(); i++) System.out.print(letter[i]);
       System.out.println("");
    }
}


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

#define ll long long

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n, m; cin >> n >> m;
    vector<int> counting(n);

    for(int i = 0; i < m; i++){
        int a, b; cin >>a >>b;
        if(a != b){
            counting[a -1]++;
            counting[b -1]++;
        }
    }
    for(int i = 0; i < n; i++){
        cout << counting[i] << '\n';
    }
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){

    map<int,int> m;
    rep(i,3){
        int a;
        cin>>a;
        m[a]++;
    }
    if(m.size()==2){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    d, x = map(int, input().split())
    count = x
    tmp = [1] * (d + 1)

    for i in range(1, n + 1):
        ai = int(input())
        count += sum(tmp[1::ai])

    print(count)


if __name__ == '__main__':
    main()


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

int main(){
    int n;
    cin >> n;
    map<string,int> m;
    rep(i,n){
        string s;
        cin >> s;
        m[s]++;
    }
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <queue>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

void read_line_with_space(vector<string> &list) {
  string str;
  getline(cin, str);
  string tmp;
  istringstream istr(str);
  while (getline(istr, tmp, ' ')) {
    list.push_back(tmp);
  }
}

void round_robin(vector<pair<string, int>> processes, int quantum) {
  int time = 0;
  queue<pair<string, int>> q;
  for (auto process : processes) {
    q.push(process);
  }
  while (!q.empty()) {
    auto process = q.front();
    q.pop();
    if (process.second <= quantum) {
      cout << process.first << " " << time + process.second << endl;
      time += process.second;
    } else {
      process.second -= quantum;
      q.push(process);
      time += quantum;
    }
  }
}

int main() {
  vector<string> v;
  read_line_with_space(v);
  int N = stoi(v[0]);
  int quantum = stoi(v[1]);

  vector<pair<string, int>> processes;
  for (int i = 0; i < N; ++i) {
    v.clear();
    read_line_with_space(v);
    pair<string, int> p;
    p.first = v[0];
    p.second = stoi(v[1]);
    processes.push_back(p);
  }
  round_robin(processes, quantum);
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define int long long

typedef pair<int, int> ii;

const int mod = 1e9 + 7;

const int N = 17;

const int inf = 1e15;

int n, a[N][N], dp[(1 << N)], sum[(1 << N)];

bool checkBit(int x, int pos) {
    if((x & (1 << pos)))
        return 1;
    else
        return 0;
}

int setBit(int x, int pos) {
    return (x | (1 << pos));
}

signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++)
            cin >> a[i][j];
    }
    for(int mask = 0; mask < (1 << N); mask++)
        dp[mask] = -inf;
    for(int mask = 0; mask < (1 << n); mask++) {
        int people = 0, total = 0;
        for(int j = 0; j < n; j++) {
            if(checkBit(mask, j) == 0) {
                total = 0;
                for(int k = 0; k < n; k++) {
                    if(checkBit(mask, k))
                        total += a[k][j];
                }
                sum[setBit(mask, j)] = total + sum[mask];
            }
        }
        //cout << sum[mask] << " " << mask << "\n";
    }
    dp[0] = 0;
    for(int mask = 1; mask < (1 << n); mask++) {
        dp[mask] = sum[mask];
        for(int submask = mask; submask; submask = (submask - 1) & mask)
            dp[mask] = max(dp[mask], dp[submask] + sum[mask ^ submask]);
    }
    cout << dp[(1 << n) - 1];
}


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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int n;

int solve(int p[]) {
  int ans = 0;
  int sum = 0;
  rep(i, 0, n) {
    if(i == n - 1) {
      if(p[i] - sum > 0) ans += p[i] - sum;
      break;
    }
    if(p[i] - sum > 0) {
      ans += (p[i] - sum) * 2;
      sum = p[i] - sum;
    }else sum = 0;
  }
  return ans;
}

int main() {
  int p[5000] = {};
  cin >> n;
  rep(i, 0, n) cin >> p[i];
  int ans = INT_MAX;
  int k = p[0] + 1;
  rep(i, 0, k) {
    ans = min(ans, solve(p) + i);
    p[0]--;
  }
  cout << ans << endl;
}

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

int main() {
  int N, A, B;
  int total = 0;

  cin >> N >> A >> B;

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

    while(target > 0) {
      sum += target % 10;
      target /=10;
    }

    if (sum >= A && sum <= B) total += i;
  }

  cout << total << endl;
}

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

#define MAX 24*60*60

int main(){

  int train[MAX];
  int N;

  while(1){

    cin >> N;
    if(N == 0) break;
    int ans = 0;
    for(int i = 0 ; i < MAX ; i++){
      train[i] = 0;
    }    

    int h1,m1,s1,h2,m2,s2;
    char tmp;

    for(int i = 0; i < N ; i++){
    
      cin  >> h1 >> tmp >> m1 >> tmp >> s1 >> h2 >> tmp >> m2 >> tmp >> s2;
      //  cout << h1 << " " << m1 << " " << s1 << " " << h2 << " " << m2 << " " << s2 << endl;
      // cout   << train[3*60*60 +1] << " " << train[3*60*60] << endl;


      //テ・ツ按療ィツサツ甘」ツつ津・ツ「ツ療」ツつ?」ツ?凖」ツ?ィテ」ツ??

      bool OK = true;
      for(int i =  s1 + 60*m1 + 60*60*h1 ; i <= s2+(60*m2)+(60*60*h2)-1 ;i++){
	if(train[i] == 0){
	  OK = false;
	  break;
	}
      }  
      
      if(OK == false){
	ans++;
	for(int i = 0 ; i < s1 + 60*m1 + 60*60*h1 ;i++){
	  train[i]++;
	} 
	for(int i = s2 + 60*m2 + 60*60*h2 ; i < MAX ;i++){
	  train[i]++;
	} 
      } 
      //ティツカツウテ」ツつ甘」ツ?ヲテ」ツ??」ツつ凝」ツ?ィテ」ツ??
      else{
	for(int i =  s1 + 60*m1 + 60*60*h1 ; i <= s2+(60*m2)+(60*60*h2)-1 ;i++){
	  if(train[i] != 0) train[i]--;
	} 
      }
      //   cout << train[0] <<" "<< train[MAX-1] << endl;
    }
    cout << ans << endl;
  }  
  return 0;
}

Measured memory_bytes: 1496
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
int main() {
	int x, y;
	cin >> x >> y;
	if (x == 2 || x == 11 || y == 2 || y == 4) {
		cout << " No" << "\n";
	}
	else if (x == 4 || x == 6 || x == 9) {
		if (y == 6 || y == 9 || y == 11)
			cout << "Yes" << "\n";
		else
			cout << "No" << "\n";
	} else {
		if (y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)
			cout << "Yes" << "\n";
		else
			cout << "No" << "\n";
	}
}

Measured memory_bytes: 3584
#include<stdio.h>

int main( ){

  int a,b,x,y;
  scanf("%d%d",&x,&y);
  if (x<y){printf("a < b\n");
  }else if (x>y){printf("a > b\n");
  }else if (x==y){printf("a == b\n");
 }
    

return 0;
}

Measured memory_bytes: 580
integer = list(map(int, input().split(" ")))
W = integer[0]
H = integer[1]
x = integer[2]
y = integer[3]
r = integer[4]

if x < 0 or y < 0:
    print("No")
       
elif W - x >= r:
    if H - y >= r:
        print("Yes")
    else:
        print("No")
      
else:
    print("No")


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

const int N = 1e5 + 10;

int n, fa[N], sz[N], dep[N];
vector<int> V[N];

void dfs(int x){
    sz[x] = 1;
    for(int i=0; i<V[x].size(); i++){
        int j = V[x][i];
        if(j == fa[x])  continue;
        fa[j] = x;
        dep[j] = dep[x] + 1;
        dfs(j);
        sz[x] += sz[j];
    }
}

int main(){
    int x, y;
    scanf("%d", &n);
    for(int i=1; i<n; i++){
        scanf("%d %d", &x, &y);
        V[x].push_back(y);
        V[y].push_back(x);
    }
    fa[1] = -1;
    dep[1] = 0;
    dfs(1);
    x = (dep[n] - 1) / 2;
    y = n;
    while(x > 0){
        y = fa[y];
        x--;
    }
    x = sz[1] - sz[y];
    y = sz[y];
    if(x > y)   puts("Fennec");
    else    puts("Snuke");
    return 0;
}


Measured memory_bytes: 13184
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;
int t[105];
int p[105];
int x[105]; 
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>t[i];
	}
	int m;
	cin>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>p[i]>>x[i];
	}
	for(int i=1;i<=m;i++)
	{
		long long sum=0;
		for(int j=1;j<=n;j++)
		{
			if(p[i]==j)
			{
				sum+=x[i];
			}			
			else
			{
				sum+=t[j];
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}
 

Measured memory_bytes: 256
S = input()
T = input()
gap1 = 0
gap2 = len(S) - len(T)
x = 0
ans = 0
while gap1<= gap2:
    itti = 0
    for i in range(len(T)):
        if T[i] == S[gap1+i]:
            itti += 1
    gap1 += 1
    ans = max(ans,itti)
print(len(T)-ans)


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, k;
	cin >> n >> k;
	vl a(n);
	FOR(i,0,n) cin >> a[i];
	
	ll sum = accumulate(all(a),0LL);

	auto check = [&](ll d) {
		vl r(n);
		FOR(i,0,n) r[i] = a[i]%d;
		sort(all(r));

		ll i = 0, j = n-1, cnt = 0;
		while (i < j) {
			if (r[i] == 0) i++;
			else if (r[j] == d) j--;
			else {
				ll take = min(r[i],d-r[j]);
				r[i] -= take, r[j] += take, cnt += take;
			}
		}
		return cnt <= k;
	};

	ll res = 0;
	for (ll d = 1; d*d <= sum; d++) if (sum%d == 0) {
		if (check(d)) res = max(res,d);
		if (check(sum/d)) res = max(res,sum/d);
	}
	cout << res << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
const ll MOD=1000000007,INF=1e18;
int dx[]={0,0,1,-1};
int dy[]={-1,1,0,0};
int dyy[]={1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1};
int dxx[]={0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1};

int N;
string s;
int ans=0;

signed main() {
    IOS();
    cin>>s;
    rep(i,0,s.size()){
        if(s[i]=='0')ans++;
        else ans--;
    }
    cout<<(int)s.size()-abs(ans)<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 512
#pragma region Template

#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <bitset>
#include<map>
#include<cmath>
#include <set>
#include<limits.h>
#include<fstream>

#define lli long long int
#define us unsigned short
#define mod 1000000007
#define INF 1e9+5

#define vi vector<int>
#define vus vector<unsigned short>
#define vlli vector<long long int>
#define vs vector<string>
#define mii map<int,int>
#define mlli map<long long int,long long int>

#define w(t) int t; cin>>t;while(t--)

using namespace std;

#pragma endregion

int main()
{
	lli N, W,sum=0;
	cin >> N >> W;
	vlli p(N + 1), v(N+1);
	for (lli i = 1; i <= N; i++) { cin >> v[i] >> p[i]; sum += p[i]; }
	vlli dp(sum+1,INF);
	dp[0] = 0;

	for (int i = 1; i <= N; i++)
	{
		for (int j = sum; j >= p[i]; j--)
		{
			dp[j] = min(dp[j],v[i]+dp[j-p[i]]);
		}
	}

	lli ans = 0;
	for (int i = 1; i <= sum; i++)
	{
		if (dp[i] <= W)
			ans = max((long long)i,ans);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
N,K=map(int,input().split())
L=[]
for i in range(N+1):
    L.append(i)
count=0
Mod=10**9+7
for i in range(K-1,N+1):
    mi=(i)*(i+1)//2
    ma=(N)*(N+1)//2-(N-i)*(N-i-1)//2
    count+=(ma-mi+1)%Mod
print(count%Mod)

Measured memory_bytes: 78956
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, a, ans = 0;
    cin >> N;
    REP(i, N) {
        cin >> a;
        ans += a - 1;
    }
    cout << ans << endl;
    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 pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<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; }



int main(int argc, char const *argv[]) {
  ll n;
  cin >> n;
  cout << n*(n-1)/2 << endl;
  return 0;
}

Measured memory_bytes: 256
S = gets.chomp.split("")
flag = 1

S.size.times do |i|
    if (i + 1) % 2 == 0 && S[i] == "R"
        flag = 0
        break
    elsif (i + 1) % 2 == 1 && S[i] == "L"
        flag = 0
        break
    end
end

if flag == 0
    puts "No"
else
    puts "Yes"
end

Measured memory_bytes: 3836
#https://atcoder.jp/contests/nikkei2019-2-qual/submissions/10913225
MOD = 998244353

n = gets.to_i
h = Array.new(n+1, 0)
d = gets.split.map do |e|
    e = e.to_i
    h[e] += 1
    e
end

if d[0] != 0 || h[0] != 1
    puts 0
else
    ans = 1
    max = d.max

    1.upto(max) {|i| ans = ans * h[i-1] ** h[i] % MOD}
    puts ans
end


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


const int kN = 100000;
void primeNumber(bool prime[kN]){
    rep(i,kN) prime[i] = 1;
    prime[0] = prime[1] = 0;
    rep(i,kN){
        if(prime[i]){
            for(int j = i + i; j < kN; j+=i){
                prime[j] = 0;
            }
        }
    }
}

int main(){
    int m, a, b;
    bool p[kN];
    primeNumber(p);
    while(cin >> m >> a >> b, m||a||b){
        int ans[3] = {0};
        for(int i = 1; i * i < 100000; i++){
            for(int j = i; j * i < 100000; j++){
                if(a * j <= b * i && i * j <= m && ans[0] < i * j && p[i] == 1 && p[j] == 1){
                    ans[0] = i * j;
                    ans[1] = i;
                    ans[2] = j;
                }
            }
        }
        cout << ans[1] << ' ' << ans[2] << endl;
    }
}

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


Measured memory_bytes: 18476