akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n, d;
    cin >> n >> d;
    int a[n][d];
    int ans = 0;
    REP(i, n)
    {
        REP(j, d)
        {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            int dist = 0;
            for (int k = 0; k < d; k++)
            {
                dist += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
            }
            bool flag = false;
            for (int k = 0; k < 1000; k++)
            {
                if (k * k == dist)
                {
                    flag = true;
                }
                if (k * k > dist)
                    break;
            }
            if (flag)
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def solve(N, A):
    if len(list(filter(lambda x: x < 0, A))) % 2 == 0:
        return sum(map(abs, A))
    else:
        min_abs = min(map(abs, A))
        return sum(map(abs, A)) - 2 * min_abs


def solve_dp(N, A):
    """
    >>> N = 3
    >>> A = [-10, 5, -4]
    >>> solve_dp(N, A)
    19
    >>> N = 5
    >>> A = [10, -4, -8, -11, 3]
    >>> solve_dp(N, A)
    30
    """
    # 複数回同じインデックスを反転する意味はないので、各iについて反転回数は0, 1のいずれか
    # 考えられる結果の集合はN^2なので空間的には余裕
    # すべてのパターンをメモしながら動的計画法で解く

    # dp(i, j) = A_i-1までを確定とし、jによってA_iを反転させた場合のSUM(A_0 ~ A_i)の最大値
    dp = [[None, None] for _ in range(N)]
    for i in range(N - 1):
        if i == 0:
            dp[0][0] = A[0]
            dp[0][1] = -A[0]
            continue
        dp[i][0] = max(dp[i - 1][0] + A[i], dp[i - 1][1] - A[i])
        dp[i][1] = max(dp[i - 1][0] - A[i], dp[i - 1][1] + A[i])
    # i = N - 1の場合は反転操作は許されないので、可能なパターン2つを手作業で計算
    return max(dp[N - 2][0] + A[N - 1], dp[N - 2][1] - A[N - 1])


# import doctest
# doctest.testmod()

N = int(input())
A = list(map(int, input().split()))
print(solve_dp(N, A))


Measured memory_bytes: 25492
#include<bits/stdc++.h>
using namespace std;
int main()

{

    char a[1000];
    int n,k;
    cin>>n>>a>>k;
    char d=a[k-1];
    for(int i=0;i<n;i++)
    {
        if(a[i]!=d)
            a[i]='*';
    }
    cout<<a;
}



Measured memory_bytes: 256
N, M = map(int, input().split())

accepted = [False for _ in range(N)]
wa = [0 for _ in range(N)]

for _ in range(M):
    p, s = input().split()
    p = int(p)
    if not accepted[p - 1]:
        if s == 'AC':
            accepted[p - 1] = True
        else:
            wa[p - 1] += 1

correct = sum(accepted)
penalty = sum([a * w for a, w in zip(accepted, wa)])

print(correct, penalty)




Measured memory_bytes: 11184
#include<bits/stdc++.h>
#define MAXN 99999
#define ll long long 
#define INF 101
using namespace std;
inline int read(){
 char c=getchar();int x=0,f=1;
 while(c>'9'||c<'0'){if(c!='-')f=-1;c=getchar();}
 while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
 return x*f;
}
string n;
int l,ans,tot;
int main()
{
	cin>>n; 
	l=n.size()-1;
	for(int i=1;i<n.size();++i)
	 if(n[i]!='9')
	  tot=1;
	if(l==0)
	 {
	 	cout<<n[0]-'0';
	 	return 0;
	 }
	ans=l*9;
	if(tot==0)
	 ans+=n[0]-'0';
	else
	 ans+=n[0]-'0'-1;
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n;
  scanf("%d",&n);
  char a[101],b[101],c[101];
  scanf("%s",a);
  scanf("%s",b);
  scanf("%s",c);
  int cnt=0;
  for(int i=0;i<n;i++){
    if(a[i]==b[i]){
      cnt+=c[i]==a[i]?0:1;
    } else if(a[i]==c[i]){
      cnt++;
    } else if(b[i]==c[i]){
      cnt++;
    } else {
      cnt+=2;
    }
  }
  printf("%d\n",cnt);
}

int main(void){
  run();
  return 0;
}


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

int main()
{
  // Input
  int h, w, n;
  cin >> h >> w >> n;

  // Main Procedure
  int biggerNum = (h >= w ? h : w);
//   int smallerNum = (h >= w ? w : h);
  int answer = n / biggerNum;
  if (n % biggerNum != 0) {
      answer += 1;
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
   public static void main(String[]args){
    
   Scanner sc = new Scanner(System.in);
  
     //入力
     int N = sc.nextInt();
     //int kuku1 =new int[81];
    
     //九九でだせる数字を求めてNと合えば出力
     //int idx = 0;
     for(int i=1; i<=9; i++){
         for(int j=1; j<=9; j++){
           if((i*j)==N){
              System.out.print("Yes");
             return;
         }
            //int kuku2 = i*j;
            //kuku1[idx] = sc.nextInt();
            //kuku1[idx] = kuku2;
            //idx = idx + 1;
            //String kuku2 = String.valueOf(kuku);
            //System.out.println(int[kuku2]);
            }  
     }
     System.out.println("No");
 
     // 九九の中にNが含まれるか？
     
     //九九で表せる数字かどうか
     //System.out.println(kuku2.contains(N) ? "Yes":"No");
   }
}

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

int main()
{
	string str,p,cmd;
	int a,b,q;
	int i;
	
	cin >> str >> q;
	for( i=0; i<q; i++){
		cin >> cmd;
		
		if( cmd == "print"){
			cin >> a >> b;
			cout << str.substr( a, b-a+1 ) << endl;
		}
		else if( cmd == "reverse"){
			cin >> a >> b;
			p = str.substr(a, b - a + 1);
			reverse(p.begin(), p.end());
			str.replace(a, p.length(),p);
		}
		else if(cmd == "replace"){
			cin >> a >> b >> p;
			str.replace(a, b-a+1 , p);
		}

	}
	return 0;
}

Measured memory_bytes: 1224
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>     // pow
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

// long long gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a;
// }

// int binary_search(int key) {
//     int ng = -1;
//     int ok = (int)a.size();
//     while(abs(ok - ng) > 1) {
//         int mid = (ok + ng) / 2;
//         if(isOK(mid, key))
//             ok = mid;
//         else
//             ng = mid;
//     }
//     return ok;
// }

// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W
// int MOD = 1000000007;

int main() {
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> priceA(A);
    vector<int> priceB(B);
    int minA = 1000000, minB = 1000000;
    for(size_t i = 0; i < A; i++) {
        cin >> priceA[i];
        minA = min(minA, priceA[i]);
    }
    for(size_t i = 0; i < B; i++) {
        cin >> priceB[i];
        minB = min(minB, priceB[i]);
    }

    int ans = minA + minB;
    for(size_t i = 0; i < M; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        ans = min(ans, priceA[x-1]+priceB[y-1]-c);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <ctype.h>

int main(){
  char ch;

  while(1){
	scanf("%c", &ch);
	if(ch == '\n'){break;}

	if(!isalpha(ch)){
	  printf("%c", ch);
	}else if(isupper(ch)){
	  printf("%c", tolower(ch));
	}else{
	  printf("%c", toupper(ch));
	}
  }
  printf("\n");
  return 0;
}


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

#define int long long

#define pii pair<int, int>

#define x1 x1228
#define y1 y1228

#define left left228
#define right right228

#define pb push_back
#define eb emplace_back

#define mp make_pair 

#define ff first
#define ss second   

#define matr vector<vector<int> > 

#define all(x) x.begin(), x.end()


using namespace std;
typedef long long ll; 
typedef long double ld; 

const int maxn = 3e5 + 7, mod = 1e9 + 7, inf = 1e18, MAXN = 1e6 + 7;
const double eps = 1e-9;
mt19937 rnd(time(0));
int n; 
int cnt[maxn]; 
multiset<int> p;
         
void solve() {        
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a; cin >> a;
        p.insert(a); 
    }
    int ans = 0;
    while (p.size()) {
        int d = *(--p.end());
        p.erase(--p.end());
        for (int pt = 1; pt <= 2e9; pt *= 2) {
            int k = pt - d; 
            if (p.find(k) != p.end()) {
                ++ans;
                p.erase(p.find(k)); 
                break; 
            }
        }        
    }
    cout << ans; 
}                               
   
signed main() {
#ifdef LOCAL
    freopen("TASK.in", "r", stdin);
    freopen("TASK.out", "w", stdout);
#else 
    
#endif // LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20); 
    cout << fixed; 
    int t = 1;  
    for (int i = 0; i < t; ++i)              
        solve();
    return 0;
}  

Measured memory_bytes: 9600
/*やったぜ。　投稿者：変態糞土方 (8月16日（水）07時14分22秒)

昨日の8月15日にいつもの浮浪者のおっさん（60歳）と先日メールくれた汚れ好きの土方のにいちゃん

（45歳）とわし（53歳）の3人で県北にある川の土手の下で盛りあったぜ。

今日は明日が休みなんでコンビニで酒とつまみを買ってから滅多に人が来ない所なんで、

そこでしこたま酒を飲んでからやりはじめたんや。

3人でちんぽ舐めあいながら地下足袋だけになり持って来たいちぢく浣腸を3本ずつ入れあった。

しばらくしたら、けつの穴がひくひくして来るし、糞が出口を求めて腹の中でぐるぐるしている。

浮浪者のおっさんにけつの穴をなめさせながら、兄ちゃんのけつの穴を舐めてたら、

先に兄ちゃんがわしの口に糞をドバーっと出して来た。

それと同時におっさんもわしも糞を出したんや。もう顔中、糞まみれや、

3人で出した糞を手で掬いながらお互いの体にぬりあったり、

糞まみれのちんぽを舐めあって小便で浣腸したりした。ああ～～たまらねえぜ。

しばらくやりまくってから又浣腸をしあうともう気が狂う程気持ちええんじゃ。

浮浪者のおっさんのけつの穴にわしのちんぽを突うずるっ込んでやると

けつの穴が糞と小便でずるずるして気持ちが良い。

にいちゃんもおっさんの口にちんぽ突っ込んで腰をつかって居る。

糞まみれのおっさんのちんぽを掻きながら、思い切り射精したんや。

それからは、もうめちゃくちゃにおっさんと兄ちゃんの糞ちんぽを舐めあい、

糞を塗りあい、二回も男汁を出した。もう一度やりたいぜ。

やはり大勢で糞まみれになると最高やで。こんな、変態親父と糞あそびしないか。

ああ～～早く糞まみれになろうぜ。

岡山の県北であえる奴なら最高や。わしは163*90*53,おっさんは165*75*60、や

糞まみれでやりたいやつ、至急、メールくれや。

土方姿のまま浣腸して、糞だらけでやろうや。*/
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define llMIN numeric_limits<long long>::min()
#define intMIN numeric_limits<int>::min()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
int main(void){
  int n;
  cin>>n;
  vl a(n);
  rep(i,n){
    cin>>a[i];
  }
  multiset<ll> nums;
  rep(i,n){
    if(i==0){
      nums.insert(a[n-i-1]);
      continue;
    }
    auto itr= nums.upper_bound(a[n-1-i]);
    if(itr!=nums.end()){
      nums.erase(itr);
      nums.insert(a[n-1-i]);
    }else{
      nums.insert(a[n-1-i]);
    }
  }
  cout<<nums.size()<<endl;
  return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repi(i,n) for(ll i=n-1;i>=0;i--)
#define sll(n) scanf("%lld", &n);
#define slf(n) scanf("%lf", &n);
typedef long long ll;
typedef double lf;
static const ll max_n = 200010;
static const ll mod = 2019;
static const ll max_value = 100000000000100;
// vector<vector<vector<ll>>> dp(max_n, vector<vector<ll>>(max_n, vector<ll>(max_n*max_n, 0)));
// static const ll max_x = max_value * max_value;
vector<ll> A(max_n);
// vector<ll> cards(max_n);
// vector<ll> S(max_n);
// vector<pair<ll, ll>> times_vec(max_n);
// ll N, M;


void Main(){
    // bool is_ok = true;
    // printf("------------- V=%lld---------\n", V);
    ll N, a;
    sll(N);
    rep(i,N){
        sll(a);
        A[i] = a;
    }

    // ll now_xor = A[0];
    ll now_sum = 0;
    ll r = 0;
    ll num = 0;
    for(ll l=0;l<N;l++){
        while(r<N && (now_sum+A[r])==(now_sum ^ A[r])){
            now_sum += A[r];
            r++;
        }
        num += (r - l);
        if(l==r) r++;
        else now_sum -= A[l];
    }
    printf("%lld\n", num);

}

int main(){
    Main();

    return 0;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	cout<<max({a+b,a-b,a*b})<<endl;;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0, sizeof(a))

#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 true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

VI w;
int dp[301][301];

int rec(int l, int r){
    if(dp[l][r] != -1) return dp[l][r];

    if(r-l < 2) return dp[l][r] = 0;
    if(r-l == 2 && abs(w[r-1]-w[l])<2) return dp[l][r] = 2;
    if(r-l == 2 && abs(w[r-1]-w[l])>1) return dp[l][r] = 0;

    if(abs(w[r-1]-w[l])<2 && rec(l+1,r-1) == r-l-2) return dp[l][r] = r-l;
    int res = 0;
    FOR(i,l+1,r){
        chmax(res, rec(l,i)+rec(i,r));
    }
    return dp[l][r] = res;
}
int main(void){
    
    int n;
    cin >> n;
    while(n != 0){
        w.assign(n,0); REP(i,n) cin >> w[i];
        REP(i,n+1)REP(j,n+1) dp[i][j] = -1;
        int ans = rec(0,n);
        cout << ans << en;
        cin >> n;
    }
    return 0;
}


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

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

    long h, n;
    for (h = 1; h <= 3500; h++) {
        for (n = 1; n <= 3500; n++) {
            long a = N * h * n;
            long b = 4 * h * n - N * n - N * h;

            if (b > 0 && a % b == 0) {
                cout << h << " " << n << " " << (a / b) << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
A, B, C, D = gets.split.map(&:to_i)

cd_lcm = C.lcm(D)

before_a = A - 1

to_a = before_a - (before_a / C + before_a / D - before_a / cd_lcm)
to_b = B - (B / C + B / D - B / cd_lcm)

puts to_b - to_a


Measured memory_bytes: 1788
#include <stdio.h>
int main(){
                int seven[1000001];
                int K,i;

                scanf("%d",&K);

                if(K % 2 == 0){
                        printf("-1");
                        return 0;
                }
                seven[1] = 7 % K;
                if(seven[1] == 0){
                        printf("1");
                        return 0;
                }

                for(i = 2; i <= K; i++){
                        seven[i] = (seven[i-1] * 10 + 7) % K;
                        if(seven[i]==0)break;
                }

                if(i<=K)printf("%d",i);
                else printf("-1");
                return 0;
}

Measured memory_bytes: 5576
package main

import (
	"fmt"
	"math"
)

func main() {
	var N, D, X, r int
	fmt.Scan(&N, &D)
	var x [][]int
	for i := 0; i < N; i++ {
		w := make([]int, D)
		for j := 0; j < D; j++ {
			fmt.Scan(&X)
			w[j] = X
		}
		x = append(x, w)
	}
	for i := 0; i < N-1; i++ {
		for j := i + 1; j < N; j++ {
			p := 0
			for k := 0; k < D; k++ {
				q := x[i][k] - x[j][k]
				p += q * q
			}
			n := math.Sqrt(float64(p))
			if n == float64(int64(n)) {
				r++
			}

		}
	}
	fmt.Println(r)
}

Measured memory_bytes: 512
#include <stdio.h>
long long a, b;
long long gcd(long long gcd_a, long long gcd_b) {
	if (gcd_a < gcd_b) {
		long long gcd_c;
		gcd_c = gcd_a;
		gcd_a = gcd_b;
		gcd_b = gcd_c;
	}
	if (!gcd_b)return gcd_a;
	return gcd(gcd_b, gcd_a % gcd_b);
}
int main() {
	scanf("%lld%lld", &a, &b);
	b *= a / gcd(a, b);
	printf("%lld\n", b);
}

Measured memory_bytes: 128
array_index = gets(chomp:true).to_i
  array = gets(chomp:true).split.map(&:to_i)

  rep_count = 0

  for loop_num in 0...array_index

    rigth_ope_index = array_index - 1
    left_cmp_index = rigth_ope_index - 1

    while left_cmp_index >= loop_num 

      if array[left_cmp_index] > array[rigth_ope_index]

        temp_elem = array[rigth_ope_index]

        array[rigth_ope_index] = array[left_cmp_index]
        array[left_cmp_index] = temp_elem

        rep_count += 1
      end

      left_cmp_index -= 1
      rigth_ope_index -= 1
    end

  end

  puts array.join(" ")
  puts rep_count



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

using namespace std;
typedef long long LL;
const int mod=2019;

LL modinv(LL x){
	LL m=mod, u=1, v=0;
	while(m){
		LL t=x/m;
		x-=t*m; swap(x,m);
		u-=t*v; swap(u,v);
	}
	u%=mod;
	if(u<0) u+=mod;
	return u;
}

LL modpow(LL x, LL n){
	LL r=1;
	while(n){
		if(n&1) r=r*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return r;
}

int main(){
	string S;
	cin >> S;
	int N=S.size();
	vector<int> dp(N+1);
	map<int,LL> m;
	m[0]++;
	rep(i,N){
		int k=S[i]-'0';
		dp[i+1]=(dp[i]*10+k)%mod;
		int num=dp[i+1]*modinv(modpow(10,i))%mod;
		m[num]++;
	}
	LL ans=0;
	for(auto itr:m){
		LL p=itr.second;
		ans+=p*(p-1)/2;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4328
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int n;
    ll x;
    cin >> n >> x;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);
    sort(a.begin(),a.end());
    ll i=0;
    while(x-a.at(i)>=0){
        x-=a.at(i);
        i++;
        if(i==n)break;
    }    
    if(i==n&&x>0)cout << i-1 << endl;
    else cout << i << endl;
}


Measured memory_bytes: 3600
n=int(input())

A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

A.sort()
B.sort()
C.sort()


Bnum=[]
a=0
for i in range(n):
    while a!=n and B[i]>A[a] :
        a+=1
    Bnum.append(a)

Cnum=[]
b=0
s=0
for i in range(n):
    while b!=n and C[i]>B[b]:
        s+=Bnum[b]
        b+=1
    Cnum.append(s)

print(sum(Cnum))

Measured memory_bytes: 23476
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
bool vis[3][3];
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);

    map<ll , pair<ll,ll> > mp;
    for(ll i=0;i<3;i++){
        for(ll j=0;j<3;j++){
            ll x;cin>>x;
            mp[x]={i,j};
        }
    }

    ll n;cin>>n;
    for(ll i=0;i<n;i++){
        ll x;cin>>x;
        if(!mp.count(x))continue;
        vis[mp[x].first][mp[x].second]=1;
    }

    for(ll i=0;i<3;i++){
        bool f=1;
        for(ll j=0;j<3;j++)f&=vis[i][j];
        if(f)return cout<<"Yes" , 0;
    }

    for(ll j=0;j<3;j++){
        bool f=1;
        for(ll i=0;i<3;i++)f&=vis[i][j];
        if(f)return cout<<"Yes" , 0;
    }

    if(vis[0][0] && vis[1][1] && vis[2][2])return cout<<"Yes" , 0;
    if(vis[0][2] && vis[1][1] && vis[2][0])return cout<<"Yes" , 0;

    cout<<"No";

}




Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define N 100010
#define lint long long
#define gc getchar()
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
struct edges{
	int to,pre,wgt;
}e[N<<1];int h[N],etop,vis[N],col[N],can;lint nc,mc,a[5];
inline int add_edge(int u,int v,int w)
{	return e[++etop].to=v,e[etop].pre=h[u],h[u]=etop,e[etop].wgt=w;	}
inline int mol(int x) { return x%=3,(x<0?x+3:x); }
int dfs(int x)
{
	a[col[x]]++,vis[x]=1,nc++;
	for(int i=h[x],y;i;i=e[i].pre) mc+=(e[i].wgt==1);
	for(int i=h[x],y;i;i=e[i].pre)
		if(!vis[y=e[i].to]) col[y]=mol(col[x]+e[i].wgt),dfs(y);
		else if(col[y]!=mol(col[x]+e[i].wgt)) can=0;
	return 0;
}
int main()
{
	int n=inn(),m=inn();lint ans=0;
	for(int i=1,u,v;i<=m;i++)
		u=inn(),v=inn(),add_edge(u,v,1),add_edge(v,u,-1);
	for(int i=1;i<=n;i++) if(!vis[i])
	{
		can=1,mc=nc=a[0]=a[1]=a[2]=0ll,dfs(i);
//		debug(i)sp,debug(can)sp,debug(a[0])sp,debug(a[1])sp,debug(a[2])ln;
		if(!can) ans+=nc*nc;
		else if(a[0]&&a[1]&&a[2]) ans+=a[0]*a[1]+a[1]*a[2]+a[2]*a[0];
		else ans+=mc;
	}
	return !printf("%lld\n",ans);
}

Measured memory_bytes: 6912
N, A, B, C = map(int,input().split())
L = [int(input()) for k in range(N)]

def toq(N):
    ret = ""
    t = 8
    while 4**t > 1:
        ret += str(N//(4**t))
        N -= (4**t)*(N//(4**t))
        t -= 1
    ret += str(N%4)
    return ret[::-1]

ans = float("inf")
for k in range(4**N):
    a, b, c = 0, 0, 0
    e = 0
    q = toq(k)
    for d in range(N):
        if q[d] == "1":
            a += L[d]
            e += 1
        if q[d] == "2":
            b += L[d]
            e += 1
        if q[d] == "3":
            c += L[d]
            e += 1
    if a*b*c > 0:
        ans = min(ans, abs(A-a)+abs(B-b)+abs(C-c) + 10*(e-3))
print(ans)

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

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

    int n;
    cin >> n;
    vector<int> A(n), B(n), C(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    for(int i = 0; i < n; i++){
        cin >> B[i];
    }
    for(int i = 0; i < n; i++){
        cin >> C[i];
    }

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

    long long ans = 0;

    // B基準
    for(int i = 0; i < n; i++){
        long long a_i = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
        long long c_i = upper_bound(C.begin(), C.end(), B[i]) - C.begin();
        ans += a_i * (n - c_i);
    }

    cout << ans << endl;

    return 0;
}

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

int n;
string s;
char *last, *cur;

int main() {
	cin >> s;
	n = (int)s.length();
	last = new char[2]();
	cur = new char[2]();

	int ans = 0;
	int ll = 0, cl = 0;
	for (int i = 0; i < n; i++) {
		cur[cl] = s[i];
		cl++;
		if (ll != cl || last[ll - 1] != cur[cl - 1]) {
			ans++;
			swap(last, cur);
			ll = cl;
			cl = 0;
		}
	}

	cout << ans << endl;

 	return 0;
}

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

int main(){
  int N, T, A;
  cin >> N >> T >> A;
  int H[N];
  for (int i=0; i<N; i++){
    cin >> H[i];
  }
  double temp[N], diff[N];
  double min_diff=1000000;
  int ans=0;
  for (int i=0; i<N; i++){
    temp[i]=T-H[i]*0.006;
    diff[i]=abs(temp[i]-A);
    if (min_diff>=diff[i]){
      min_diff=diff[i];
      ans=i+1;
    }
  }
  cout << ans << endl;
}


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

int main() {
  int a;
  cin >> a;
  int h = a/100;
  int t = a/10 - 10*h;
  int o = a - 10*t - 100*h;
  int ans = h + t + o;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define plint pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    ll n,k;
    cin >> n >> k;
    ll ans = 0;
    const ll maxvalue = (1+n)*n/2;

    // k~n個選ぶ
    FOR(i,k,n+1){
        ll minsum = (1+(i-1))*(i-1)/2;
        ll maxsum = maxvalue - (1+(n-i))*(n-i)/2;
        ans += (maxsum-minsum+1)%MOD; // こまめに小さくしておく
    }
    // n+1個選ぶのは1パターン

    cout << (ans+1)%MOD << "\n";
    return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;

#define N_MAX 100000
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)

typedef pair<ll, ll> P;

bool pairCompare(const P& p1, const P& p2){
  return p1.second > p2.second;
}

int main(){
  ll N, K;
  scanf("%lld %lld", &N, &K);

  vector<P> sushi;
  rep(i, N){
    ll t, d;
    scanf("%lld %lld", &t, &d);
    sushi.push_back(P(t, d));
  }
  sort(sushi.begin(), sushi.end(), pairCompare);

  vector<ll> sushi_first;
  vector<ll> sushi_other;
  int used[N] = {};
  rep(i, N){
    if(!used[sushi[i].first-1]){
      sushi_first.push_back(sushi[i].second);
      used[sushi[i].first-1] = 1;
    }else{
      sushi_other.push_back(sushi[i].second);
    }
  }

  ll variety;
  ll tmp = 0;
  if(K <= sushi_first.size()){
    variety = K;
  }else{
    variety = sushi_first.size();
    rep(i, K - variety) tmp += sushi_other[i];
  }
  tmp += variety * variety;
  rep(i, variety) tmp += sushi_first[i];

  ll ans = tmp;
  while(variety){
    if(sushi_other.size() <= K - variety) break;
    if(sushi_first[variety-1] >= sushi_other[K-variety]) break;
    tmp += sushi_other[K-variety] - sushi_first[variety-1] - (2 * variety - 1);
    ans = max(ans, tmp);
    variety--;
  }
  cout << ans << endl;

  return 0;
}


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

typedef long long LL;

const int N=100000,mod=1000000007;

int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}

int n;
char s[N*2+9];

void into(){
  scanf("%d%s",&n,s+1);
}

int ans;

void Get_ans(){
  int now=0;
  ans=1;
  for (int i=1;i<=n<<1;++i){
	(now&1)==(s[i]=='B')?(smul(ans,now),--now):++now;
	if (now<0) {ans=0;return;}
  }
  if (now) ans=0;
  for (int i=1;i<=n;++i) smul(ans,i);
}

void work(){
  Get_ans();
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 3972
// https://beta.atcoder.jp/contests/abc078
// status:

#define SUBMIT
//#define DEBUG

#include <utility>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <queue>
#include <numeric>
#include <limits>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const int MAX_N = 2000;
int N, Z, W;
int a[MAX_N];

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    auto program_input = std::string(R"(3 100 1000
10 100 100
)");
    stringstream stream(program_input);
#endif
    stream >> N >> Z >> W;
    for (int i = 0; i < N; ++i) stream >> a[i];

    if (N == 1) cout << abs(a[0] - W) << endl;
    else cout << max(abs(a[N - 1] - W), abs(a[N - 2] - a[N - 1])) << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		char x[]=sc.next().toCharArray();
		int s=0;
		int g=0;
		for (int i = 0; i < x.length; i++) {
		     if(x[i]=='A'){s=i;break;}
		}
		for (int i = 0; i < x.length; i++) {
			 if(x[x.length-i-1]=='Z'){g=x.length-i-1;break;}
		}
		System.out.println(g-s+1);
		
		}
		
	}

Measured memory_bytes: 14760
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
ll f[1010],dp[1010][1010];
int s[1010],vis[1010],lk[1010];
inline int read()
{
	char c=getchar();int x=0,flag=1;
	while(!isdigit(c)){if(c=='-') flag=-1;c=getchar();}
	while(isdigit(c)) x=x*10+c-'0',c=getchar();
	return x*flag;
}
int dfs(int l,int r)
{
	//cout<<l<<r;
	if(l>=r||(s[r]-s[l-1])&1) return 0;
	if(~dp[l][r]) return dp[l][r];
	for(int i=l;i<=r;i++) if(vis[i]&&(lk[i]>r||lk[i]<l)) return dp[l][r]=0;
	ll ans=f[s[r]-s[l-1]];
	for(int k=l;k<r;k++)
	{
		ans=(ans-dfs(l,k)*f[s[r]-s[k]]%mod+mod)%mod;
	}
	return dp[l][r]=ans;
}
int main()
{
	int n=read()<<1,k=read();
	for(int i=1;i<=k;i++)
	{
		int a=read(),b=read();
		lk[a]=b;
		lk[b]=a;
		vis[a]=vis[b]=1;
	}
	f[0]=1;
	for(int i=2;i<=1000;i+=2) f[i]=f[i-2]*(i-1)%mod;
	for(int i=1;i<=n;i++) s[i]=s[i-1]+1-vis[i];
	ll ans=0;
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++) ans=(ans+dfs(i,j)*f[s[n]-s[j]+s[i-1]])%mod;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 8192
from collections import deque
import itertools

c = 0
l =deque([])

n = int(input())

for i in range(n):
    m = list(map(int,input().split()))
    if m[0] == 0:
        l.appendleft(m[1])

    elif m[0] == 1:
        l.rotate(-m[1])
        c += m[1]
    
    elif m[0] == 2:
        l.popleft()

ans = list(itertools.islice(l,len(l)-c,None)) + list(itertools.islice(l,None,len(l)-c))
for j in ans:
    print(j)


Measured memory_bytes: 27676
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
    lli n, r, g, b;
    cin >> r >> g >> b;
    cin >> n;

    lli cnt = 0;

    while (g <= r) {
        g *= 2;
        cnt++;
    }
    while (b <= g) {
        b *= 2;
        cnt++;
    }

    // cout << r << " " << g << " " << b << endl;
    // cout << cnt << endl;
    if (cnt <= n) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <complex>
#include <string>
#include <sstream>
#include <iomanip>
#include <climits>
#include <functional>
#include <bitset>
#include <tuple>

using namespace std;

typedef long long  ll;

vector<string> res;

void Rec(string s, char c)
{
    if (c == 'a') {
        res.push_back(s);
        return ;
    }

    const int n = s.size();
    for (int i = 0; i < n; ++i) {
        if (s[i] == c)
            return ;
        if (s[i] == c - 1) {
            string tmp(s);
            tmp[i] = c;
            Rec(tmp, c - 1);
        }
    }

    Rec(s, c - 1);
}

int main()
{
    string s;

    while (cin >> s) {
        if (s == "#")
            break;

        res.clear();

        Rec(s, 'z');

        sort(res.begin(), res.end());
        res.erase(unique(res.begin(), res.end()), res.end());

        const int n = res.size();
        cout << n << '\n';
        if (n <= 10) {
            for (int i = 0; i < n; ++i)
                cout << res[i] << '\n';
        }
        else {
            for (int i = 0; i < 5; ++i)
                cout << res[i] << '\n';
            for (int i = n - 5; i < n; ++i)
                cout << res[i] << '\n';
        }
    }

    return 0;
}

Measured memory_bytes: 2348
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n, a, b;
	cin >> n >> a >> b;

	cout << min(n * a, b) << endl;

}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

const int INF = 1e9 + 5;

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

  int n;
  cin >> n;

  vector<int> h(n);

  for (auto &i : h) {
    cin >> i;
  }

  vector<int> dp(n, INF);
  dp[0] = 0;

  for (auto i = 0; i < n; ++i) {
    for (auto j : {i + 1, i + 2}) {
      if (j < n) {
        dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]));
      }
    }
  }

  cout << dp.back() << "\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef array <ll, 2> pii;
typedef vector <int> vi;

typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;



int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	int x, y;
	cin >> x >> y;
	int z = y - 2 * x;
	if (z < 0 || z & 1) {
		cout << "No";
		return 0;
	}
	z /= 2;
	if (z > x) {
		cout << "No";
		return 0;
	}
	cout << "Yes";
}


Measured memory_bytes: 3612
A,B,K = map(int,input().split())
for i in range(K):
    if i %2 ==0:
        if A %2 != 0:
            A -= 1
        B += A//2
        A //= 2
    else:
        if B %2 != 0:
            B -= 1
        A += B//2
        B //= 2
print ("{0} {1}".format(A,B))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  double T, X;
  cin >> T >> X;
  cout << T / X << endl;
  return 0;
}

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

using lint = long long;
#define bit(n) ((lint)1 << n);
const int INF = 1e9;
const lint LINF = 1e18;

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

struct res {
    string name;
    int id, point;
    bool operator < (res that) {
        if (name != that.name) {
            return name < that.name;
        } else {
            return point > that.point;
        }
    }
};

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

    int n;
    cin >> n;
    vector<res> ress(n);
    for (int i = 0; i < n; i++) {
        ress[i].id = i + 1;
        cin >> ress[i].name >> ress[i].point;
    }
    sort(ress.begin(), ress.end());
    for (int i = 0; i < n; i++) {
        cout << ress[i].id << endl;
    }

    return 0;
}

Measured memory_bytes: 256
# 一行に整数ひとつだけ
n = gets.chomp.to_i

k = []
n.times do
  k << gets.chomp.split.map(&:to_i)
end

k.sort_by! { |a| a[1]}

curr = 0
good = true
k.each do |kk|
  curr += kk[0]
  if curr > kk[1]
    good = false
    break
  end
end

puts good ? 'Yes' : 'No'

Measured memory_bytes: 22544
i = int(input())
a = []
for x in range(1, i+1):
    a.append(x)
x = 0
while x < len(a):
    if a[x] % 3 == 0:
        a[x] = 'Fizz'
    elif a[x] % 5 == 0:
        a[x] = "Buff"
    elif a[x] % 3 == a[x] % 5 == 0 :
        a[x] = 'FizzBuzz'
    x = x + 1
fil = [e for e in a if isinstance(e, int)]
print(sum(fil))



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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

const ll INF = 1e16;

class FordFulkerson {
public:
    struct Edge { int to; ll cap; int rev; };
    int V;
    vector<vector<Edge>> G;
    vector<bool> used;
    FordFulkerson(int V): V(V), G(V), used(V, false) {}

    void add_edge(int from, int to, ll cap) {
        G[from].push_back((Edge){to, cap, (int)G[to].size()});
        G[to].push_back((Edge){from, 0, (int)G[from].size()-1});
    }
    ll dfs(int v, int t, ll f) {
        if (v == t) return f;
        used[v] = true;
        for (Edge &e: G[v]) {
            if (used[e.to] || e.cap == 0) continue;
            ll ret = dfs(e.to, t, min(f, e.cap));
            if (ret > 0) {
                e.cap -= ret;
                G[e.to][e.rev].cap += ret;
                return ret;
            }
        }
        return 0;
    }
    ll maxflow(int s, int t) {
        ll res = 0, f;
        while (1) {
            fill(used.begin(), used.end(), false);
            if ((f = dfs(s, t, INF)) <= 0) break;
            res += f;
        }
        return res;
    }
};

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> bd(H);
    for (int i=0; i<H; ++i) cin >> bd[i];

    FordFulkerson nw(H + W + 2);
    const int S = H + W;
    const int T = H + W + 1;

    pair<int,int> ps, pt;
    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            if (bd[i][j] == 'o') {
                nw.add_edge(i, H+j, 1);
                nw.add_edge(H+j, i, 1);
            } else if (bd[i][j] == 'S') {
                nw.add_edge(S, i, INF);
                nw.add_edge(S, H+j, INF);
                ps = {i, j};
            } else if (bd[i][j] == 'T') {
                nw.add_edge(i, T, INF);
                nw.add_edge(H+j, T, INF);
                pt = {i, j};
            }
        }
    }

    if (ps.first == pt.first || ps.second == pt.second) {
        cout << -1 << endl;
        return 0;
    }
    cout << nw.maxflow(S, T) << endl;

    return 0;
}

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

struct Comp {
  bool operator()(const std::pair<int, int> &a, const std::pair<int, int> &b) {
    if (a.second != b.second) {
      return a.second < b.second;
    }
    return a.first > b.first;
  }

};

pair<int, int> arr[200005];

int main (){
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i){
		cin >> arr[i].first >> arr[i].second;
	}
	Comp comp_functor;
	sort(arr, arr + n, comp_functor);
	int start = 0;
	for (int i = 0; i < n; ++i){
		start += arr[i].first;
		if (start > arr[i].second){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint
{
    long long x; // typedef long long ll;
    mint(long long x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(long long t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1)
    {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

mint choose(int n, int a)
{
    mint x = 1, y = 1;
    for (int i = 0; i < a; i++)
    {
        x *= n - i;
        y *= i + 1;
    }
    return x / y;
}

mint rpower(int x, int n)
{
    if (n == 0)
        return mint(1);
    mint ret = rpower(x, n / 2);
    ret *= ret;
    if (n % 2 == 1)
        ret *= x;
    return ret;
}

mint rpower2(int n)
{
    if (n == 0)
        return mint(1);
    mint ret = rpower2(n / 2);
    ret *= ret;
    if (n % 2 == 1)
        ret *= 2;
    return ret;
}

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    mint ans = rpower(2, n);
    ans -= 1;
    ans -= choose(n, a);
    ans -= choose(n, b);
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<18,INF=1<<30;
vector<int> dx={-1,0,1,0},dy={0,-1,0,1};

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
        vector<int> A(N),B(N);
        for(int i=1;i<N;i++){
            int a,b;cin>>a>>b;
            A[i]=A[a]+dx[b];
            B[i]=B[a]+dy[b];
        }
        
        sort(all(A));
        sort(all(B));
        
        cout<<A[N-1]-A[0]+1<<" "<<B[N-1]-B[0]+1<<endl;
    }
    
}



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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);

  int d, t, s;
  cin >> d >> t >> s;
  if (d <= t * s) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}


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

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


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

int main() {
  int N,M,X,b;
  cin >> N >>M>>X;
vector<int>A(N),C(N+1);
  for(int i=0;i<M;i++){
    cin>>b;
    A[b]++;
  }
  C[0]=0;
  for(int i=1;i<N+1;i++){
    C[i]=C[i-1]+A[i-1];
  }
  

  cout << min(C[X],C[N]-C[X]) <<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
//typedef pair<ll, ll> P;
//typedef pair<double, P> T;

const ll mod = 1000000007;
const ll INF = 100000010000;

ll N, x[100010], sum[100010];

ll ans;

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

ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2 == 1)
	{
		return x * pow_mod(x, y - 1) % mod;
	}
	else
	{
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x)
{
	return pow_mod(x, mod - 2);
}

void init()
{
	
}

void output()
{
	//cout << ans << endl;
}



void solve()
{
	ll x;
	cin >> x;
	vector<ll> vec;
	for (int i = x; ; i++)
	{
		bool jud = true;
		for (int j = 2; j * j <= i; j++)
		{
			if (i % j == 0) jud = false;
		}

		if (jud)
		{
			cout << i << endl;
			break;
		}
	}
	
}

int main()
{
	init();
	
	solve();

	

	output();
	ll N;
	cin >> N;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final long MOD = 1000000007;
		int N = sc.nextInt();
		long A = sc.nextLong();
		long B = sc.nextLong();
		if(A>B) {
			long temp = A;
			A = B;
			B = temp;
		}
		long[] S = new long[N+1];
		S[0] = -(B+1);
		for(int i=0; i<N; i++)
			S[i+1] = sc.nextLong();
		
		for(int i=2; i<N+1; i++) {
			if(S[i]-S[i-2]<A) {
				System.out.println(0);
				sc.close();
				return;
			}
		}
		
		long[] dp = new long[N+1];
		dp[0] = 1;
		
		int idxZero = 0;
		int idxB = 0;
		long sum = 0;
		for(int i=1; i<=N; i++) {
			while(S[i] - S[idxB]>=B) {
				sum = (sum + dp[idxB])%MOD;
				idxB++;
			}
			dp[i] = sum;
			if(S[i]-S[i-1]<A) {
				while(idxZero<i-1) {
					if(idxZero<idxB)
						sum = (sum - dp[idxZero] + MOD)%MOD;
					dp[idxZero]=0;
					idxZero++;
				}
			}
		}

		long ans = 0;
		for(int i=0; i<N+1; i++)
			ans = (ans + dp[i])%MOD;
		System.out.println(ans);
		
		sc.close();
	}
}


Measured memory_bytes: 48492