akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
typedef pair<int,int> pii;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=(int)(n);v>=0;v--)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
const ll INFLL = 1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;}
//------------------------------------------------------------------------------

signed main() {
    int ans=0;
    int m=INF;
    REP(j,3) {
        int a;
        cin>>a;
        m=min(m,a);
    }
    ans+=m;
    m=INF;
    int a,b;
    cin>>a>>b;
    ans+=min(a,b);
    cout<<ans-50<<endl;
    return 0;
}

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

int main() {
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> ans;
    if (n % 2) {
        for ( int a = 1, b = n; a < b; a++, b-- ) {
            ans.emplace_back(a, b);
        }
    } else {
        for ( int a = 1, b = n; a < b; a++, b-- ) {
            if ( b-a>n-(b-a) ) {
                ans.emplace_back(a, b);
            } else {               
                ans.emplace_back(a, b-1);
            }
        }
    }
    for ( int i=0; i<m; i++ ) {
        cout << ans[i].first << ' ' << ans[i].second << '\n';
    }
    return 0;
}

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

#define EACH(i, a) for (auto &&i : a)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RFOR(i, a, b) for (int i = (int)b - 1; i >= (int)a; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREPS(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(x) (x).begin(), (x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF (1L << 30)
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << *i << " ";
  cout << endl;
}
template <class T>
void pvp(T a, T b) {
  for (T i = a; i != b; ++i)
    cout << "(" << i->first << ", " << i->second << ") ";
  cout << endl;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}

using ll = long long;
#define int ll

//**********

signed main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n;
  string s;

  cin >> n;
  cin >> s;
  int ans = 0;
  int cnt = 0;

  REPS(i, n - 1) {
    cnt = 0;
    REP(j, n - i) {
      if (s[j] == s[j + i]) {
        // cout << j << j + i << s[j] << endl;
        cnt++;
      } else {
        chmax(ans, min(cnt, i));
        cnt = 0;
      }
    }
    chmax(ans, min(cnt, i));
  }
  cout << ans << endl;
  return 0;
};


Measured memory_bytes: 384
import java.util.*;
import java.io.*;

public class Main {

	static void solve (Scanner in, PrintWriter out, Methods ms) {

		int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();
		String ans = "";
		if (a > b && a > c) ans = "A";
		if (b > a && b > c) ans = "B";
		if (c > a && c > b) ans = "C";
		out.println(ans);

	}



	public static void main (String[] args) {

		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		Methods ms = new Methods();
		solve(in, out, ms);
		in.close();
		out.close();

	}

	static class Methods {

		public void print (Object... ar) {System.out.println(Arrays.deepToString(ar));}

		public int max (int... ar) {Arrays.sort(ar); return ar[ar.length-1];}

		public int min (int... ar) {Arrays.sort(ar); return ar[0];}

		public long gcd (long a, long b) {return b > 0 ? gcd(b,a%b) : a;}

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

		public long factorial (int i) {
			if (i == 1) return 1;
			else return i * factorial(i-1);
		}

		public int manhat (int x1, int y1, int x2, int y2) {
			return Math.abs(x1 - x2) + Math.abs(y1 - y2);
		}

		public double euclid (double x1, double y1, double x2, double y2) {
			return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
		}

		public boolean isPrime (int n) {
			if (n == 2) return true;
			if (n < 2 || n % 2 == 0) return false;
			for (int i = 3; i <= Math.sqrt(n); i += 2) if(n % i == 0) return false;
			return true;
		}

	}

}


Measured memory_bytes: 26428
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define x3 dflgkg
#define y1 dskgj
#define y2 dskfj
#define y3 dfhgdh
#define SQ 320
#define PI 3.14159265359
#define MOD 1000000007
typedef int ll;
using namespace std;
int  n,i,j,k,z,m,q,r,timer,v,tot,x,y,xx, yy,INF, sz;
int a[100500], cnt[100500];
int main() {
    //freopen("input.txt","r",stdin);
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
    	cin >> a[i];
    	if (i == 0) continue;
    	if (a[i - 1] + a[i] >= k) {
            cout << "Possible" << endl;
            for (int j = 1; j < i; j++)
                cout << j << endl;
            for (int j = n-1; j > i; j--)
                cout << j << endl;
            cout << i << endl;
            return 0;
        }
	}
        
    cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 1152
# B
N = int(input())
S = input()
enc = ""

def rot_n(c, n):
    if 'a' <= c and c <= 'z':
        return chr((ord(c) - ord('a') + int(n)) % 26 + ord('a'))
    
    if 'A' <= c and c <= 'Z':
        return chr((ord(c) - ord('A') + int(n)) % 26 + ord('A'))
    
    return c

def rot(s, n):
    c = (rot_n(c, n) for c in s)
    return ''.join(c)

print(rot(S, N))

Measured memory_bytes: 40048
// https://atcoder.jp/contests/abc173/tasks/abc173_b
#include <stdio.h>
#include <string.h>

int main(){
    
    char a[100000][50];
    int n, i;
    
    if(scanf("%d", &n)==1){
        for(i= 0; i<n; i++)
            scanf("%s", a[i]);
    }
    
    int b= 0;
    int c= 0;
    int d= 0;
    int e= 0;

    char *f= "AC";
    char *g= "WA";
    char *h= "TLE";
    char *j= "RE";
    
    
    for(i= 0; i<n; i++)
    {
    if(strcmp(a[i], f)==0)
        b++;
    else if(strcmp(a[i], g)==0)
        c++;
    else if(strcmp(a[i], h)==0)
        d++;
    else if(strcmp(a[i], j)==0)
        e++;
    }
    
    printf("AC x %d\n", b);
    printf("WA x %d\n", c);
    printf("TLE x %d\n", d);
    printf("RE x %d\n", e);

    return 0;
}


Measured memory_bytes: 6616
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<30)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,M,C;
  cin >>  N >> M >> C;
  int B[M];
  for(int i=0;i<M;i++){
    cin >> B[i];
  }
  int A[N][M];
  int ans=0;
  int cnt=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin >> A[i][j];
      cnt+=A[i][j]*B[j];
    }
    if(cnt+C>0){
      ans++;
    }
    cnt=0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.text.DecimalFormat;
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        sc.useDelimiter(",");
        DecimalFormat df = new DecimalFormat("0.00000000");
        
        double a = Double.parseDouble(sc.next());
        double b = Double.parseDouble(sc.next());
        double degree = Double.parseDouble(sc.next());
        double radian = Math.toRadians(degree);
        double c = Math.sqrt(a*a + b*b - 2.0*a*b*Math.cos(radian));
        double height = b*Math.sin(radian);
        double area = a*b*Math.sin(radian)*0.5;
        out.println(area);
        out.println(a+b+c);
        out.println(height);
        
        out.flush();
    }
}


Measured memory_bytes: 26216
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int m;
    cin >> m;
    vector<int> a(m);
    int s = 0;
    for (int i = 0; i < m; i++) {
        cin >> a[i];
        s += a[i];
    }
    if (s > n) {
        cout << -1;
        return 0;
    } else {
        cout << n - s;
    }
}
/*

*/


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int n,m;
char chair[200];

void A(char ch){
  int i=1;
  while(chair[i]!='#') i++;
  chair[i]=ch;
}

void B(){
  int i=n;
  while(chair[i]!='#')i--;
  chair[i]='B';
}

void C(int kai){
  if(kai==0){
    if(n%2)chair[(n+1)/2]='C';
    else chair[n/2+1]='C';
    return;
  }

  for(int i=1;i<=n;i++){
    if(chair[i]=='#')continue;
    if(chair[i+1]=='#') chair[i+1]='C',i=n+2;
    else if(chair[i-1]=='#') chair[i-1]='C',i=n+2;
   
  }
}

void D(){
  int R=0,L=0;
  while(chair[n-R]=='#')R++;
  while(chair[L+1]=='#')L++;
  
  int M=0,idx=0,cnt=0;
  for(int i=1;i<=n;i++){
    if(chair[i]=='#')cnt++;
    else cnt=0;
    if(M+M%2<cnt) M=cnt,idx=i;
  }
  if(M<=2&&L<=1&&R<=1) A('D');
  else if(L-1>=(M-1)/2&&L-1>=R-1)chair[1]='D';
  else if(R-1>(M-1)/2)chair[n]='D';
  else chair[(idx-M+1)+(M-1)/2]='D';

}

int main(){
  while(1){
    cin>>n>>m;
    if(!n&&!m)break;
    memset(chair,'#',sizeof(chair));
    chair[0]=chair[n+1]=0;
    for(int i=0;i<m;i++){
      char a;
      cin>>a;
      if(a=='A') A(a);
      if(a=='B') B();
      if(a=='C') C(i);
      if(a=='D') D();
    }
    printf("%s\n",chair+1);
  }
  return 0;
}

Measured memory_bytes: 1120
#include <iostream>
#include <map>
#include <vector>

#define DIV 998244353

using namespace std;

int pow(int a, int b) {
    long long ret = a;
    for (int i = 0; i < b - 1; ++i) {
        ret = (ret * a) % DIV;
    }
    return ret;
}

int mul(int a, int b) {
    long long ret = 1L * a * b;
    return ret % DIV;
}

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    if (v[0] != 0) {
        cout << 0 << endl;
        return 0;
    }
    map<int, int> m;
    for (int num : v) ++m[num];

    int answer = 1;
    int prev = 1;
    for (int i = 0; i < m.end()->first; ++i) {
        int b = m[i];
        if (i == 0) {
            if (b > 1) {
                cout << 0 << endl;
                return 0;
            }
        } else {
            if (b == 0) {
                cout << 0 << endl;
                return 0;
            }
            answer = mul(answer, pow(prev, b));
            prev = b;
        }
    }
    cout << answer << endl;
}


Measured memory_bytes: 5376
#include<stdio.h>
int main()
{
  int i;
  char A[6];
  for(i=0;i<6;i++)
  {
    scanf("%c",&A[i]);
  }
  if((A[2]==A[3])&&(A[4]==A[5]))
  {
    printf("Yes");
  }
  else
    printf("No");
  return 0;
}


Measured memory_bytes: 128
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


double dist(pll a,pll b){
    a.F-=b.F;
    a.S-=b.S;
    return sqrt(a.F*a.F+a.S*a.S);
}


int main(){
    ll n;
    cin>>n;
    vector<pll> P(n);
    for(int i=0;i<n;i++){
        cin>>P[i].F>>P[i].S;
    }
    vector<vector<double>> dp(n,vector<double>(n,E));
    dp[0][0]=0;
    for(int i=1;i<n;i++){
        for(int t=0;t<i;t++){
            dp[i][t]=min(dp[i][t],dp[i-1][t]+dist(P[i],P[i-1]));
            dp[i][i-1]=min(dp[i][i-1],dp[i-1][t]+dist(P[t],P[i]));
        }
    }
    double ans=E;
    for(int i=0;i<n;i++){ans=min(ans,dp[n-1][i]+dist(P[i],P[n-1]));}
    cout<<fixed<<setprecision(12)<<ans<<endl;
    
    
    
    
    return 0;
}



Measured memory_bytes: 10716
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    cin>>n;

    again:
    int c=0;
    for(i = 2; i <= n / 2; ++i)
  {
      if(n % i == 0)
      {
          c++;
          n++;
          goto again;

      }

  }
  if(c==0)
  {
      cout<<n;
  }
}



Measured memory_bytes: 256
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

const ll C_MAX = 1000;
ll n, m, ans;
vll a, b, c;
vvll d;

int main() {
    fast_io; cout_precision;
    cin >> n >> m;
    d.assign(n, vll(n, C_MAX + 1));
    for (ll i = 0; i < n; i++) {
        d[i][i] = 0;
    }
    a.resize(m); b.resize(m); c.resize(m);
    for (ll i = 0; i < m; i++) {
        cin >> a[i] >> b[i] >> c[i]; a[i]--; b[i]--;
        d[a[i]][b[i]] = min(d[a[i]][b[i]], c[i]);
        d[b[i]][a[i]] = min(d[b[i]][a[i]], c[i]);
    }
    for (ll k = 0; k < n; k++) {
        for (ll i = 0; i < n; i++) {
            for (ll j = 0; j < n; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    ans = m;
    for (ll i = 0; i < m; i++) {
        for (ll j = 0; j < n; j++) {
            if (abs(d[j][a[i]] - d[j][b[i]]) == c[i]) {
                ans--;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=200001 ;
int main()
{
   fast ;
   ///Mission-500
   ll a,b ;
   cin>>a>>b ;
   ll ans=a*b ;
   ans/=__gcd(a,b) ;

   cout<<ans ;

}


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();
        String s = sc.next();
        String[] str = s.split("");
        int k = sc.nextInt();
        String target = str[k - 1];
        for (int i = 0; i < str.length; i++) {
            if (!target.equals(str[i])) {
                str[i] = "*";
            }
        }
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < str.length; i++) {
            result.append(str[i]);
        }
        System.out.println(result.toString());
    }

}


Measured memory_bytes: 23892
import java.util.*;

public class Main {

	private void doit(){
		Scanner sc = new Scanner(System.in);
		long mod = 1000000007;
		while(sc.hasNext()){
			int n = sc.nextInt();
			int k = sc.nextInt();
			int x = sc.nextInt();
			int y = sc.nextInt();
			long sum = (long)(Math.min(k, n) * x) + (long)(y * (Math.max(n - k, 0)));
			System.out.println(sum);
		}

	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


Measured memory_bytes: 9556
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum P = 10L^^9+7;

void main()
{
    auto N = readln.chomp.to!int;
    auto DP = new long[][][][](4, 4, 4, N);
    DP[0][0][0][0] = 1;
    DP[0][0][1][0] = 1;
    DP[0][0][2][0] = 1;
    DP[0][0][3][0] = 1;
    foreach (i; 1..N) {
        foreach (a; 0..4) foreach (b; 0..4) foreach (c; 0..4) foreach (x; 0..4) {
            if (i >= 2 && x == 1 && c == 2 && b == 0) continue;
            if (i >= 2 && x == 1 && c == 0 && b == 2) continue;
            if (i >= 2 && x == 2 && c == 1 && b == 0) continue;
            if (i >= 3 && x == 1 && c == 2 && a == 0) continue;
            if (i >= 3 && x == 1 && b == 2 && a == 0) continue;
            (DP[b][c][x][i] += DP[a][b][c][i-1]) %= P;
        }
    }
    long r;
    foreach (a; 0..4) foreach (b; 0..4) foreach (c; 0..4) {
        (r += DP[a][b][c][N-1]) %= P;
    }
    writeln(r);
}

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

typedef long long int ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<ll, ll> Pair;
typedef vector<Pair> VP;

#define MOD 1000000007
#define times(n) rep(_idx, n)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define in(a, l, r) (l <= a && a < r)
#define pb push_back
#define mk make_pair
#define out(x) cout << (x) << endl;
#define DU(x) cerr << #x << " = " << (x) << endl;

template<typename _Ty>ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "[]";return ostr;}ostr << "[" << v.front();for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}ostr << "]";return ostr;}

int main() {
    int N; cin >> N;
    out((N / 2 + N % 2) / (double)N);
    return 0;
}

Measured memory_bytes: 256
import fractions
import sys

N,X,D = map(int,input().split())

"""

X+0D
X+1D
X+2D
...
X+(N-1)D

からとってくる

aX + bD

aX中にlcmがtこあるとき、 newa = (aX-t*lcm) // X = a - t*lcm//X
newl += lcm*t // D

で、aX > lcm(X,D)だったらaをへらして?の範囲をうしろにずらす
各aについて計算量はO(1)

3,4,2のとき
4
6
8
lcm = 4

0,4,6,8,10,12,14,18

XD両方負だと問題なし
Dが負の時 >> 大事なのは aXを変換できるならDにする>aを減らす
?X > !Dにする

X  D
3 -3

X + 0D = 3
X + 1D = 0

0X = 0
1X + 

lcm = 3
なので,0は X+-1Dに変換可能

0 100 200 300

"""

if X == 0 and D == 0:
    print (1)
    sys.exit()
elif D == 0:
    print (N+1)
    sys.exit()
elif X == 0:
    print (N * (N-1) // 2 + 1 )
    sys.exit()

l = [ [] for i in range(N+1)]
r = [ [] for i in range(N+1)]
lcm = X*D // fractions.gcd(X,D)


bl = 0
br = 0


for a in range(N+1):


    if a > 0:
        bl += a-1
        br += N-a

    #print (bl,br)

    t = (a*X) // lcm
    #print (a,t*lcm//X)
    a -= t*lcm // X

    l[a] .append(bl + lcm*t // D)
    r[a] .append(br + lcm*t // D)

ans = 0


for a in range(N+1):

    now = 0
    nl = 0
    lind = 0
    rind = 0
    l[a].sort()
    r[a].sort()
    
    for i in range(2 * len(l[a])):

        if rind == len(r[a]) or (lind != len(l[a]) and l[a][lind] <= r[a][rind]):
            if now == 0:
                nl = l[a][lind]
            now += 1
            lind += 1
        else:
            now -= 1
            if now == 0:
                ans += r[a][rind] - nl + 1
            rind += 1
        
 

#print (l)
#print (r)
print (ans)


Measured memory_bytes: 67708
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define N	    100001
#define rep(i,a,b)  for(int i=a;i<b;i++)
int main() {
	int n;
	cin>>n;
	int a[n + 1], b[n + 1], c[n + 1];
	a[n] = b[n] = c[n] = 0;
	int A[n], B[n], C[n];
	for(int i = 0; i <n; i++) 
		cin>>A[i]>>B[i]>>C[i];
	for(int i = n - 1; i >= 0; i--) {
		c[i] = C[i] + max(a[i + 1], b[i + 1]);
		b[i] = B[i] + max(a[i + 1], c[i + 1]);
		a[i] = A[i] + max(b[i + 1], c[i + 1]);
	}
	cout<<max(a[0], max(b[0], c[0]))<<endl;
}


Measured memory_bytes: 2560
#include<stdio.h>

int main(void){
	int h;
	int h1 = 0, h2 = 0, h3 = 0;
        for(int i = 0; i < 10 ; i++){
		scanf("%d", &h);
		if(h <= h3){
		}
		else if(h3 < h && h <= h2){
			h3 = h;
		}
		else if(h2 < h && h <= h1){
			h3 = h2;
			h2 = h;
		}
		else{
			h3 = h2;
			h2 = h1;
			h1 = h;
		}
        }
	printf("%d\n%d\n%d\n", h1, h2, h3);	
}

Measured memory_bytes: 1812
#include <stdio.h>
#include <math.h>

#define N 4
#define N2 16
#define LIMIT 45
#define TRUE 1
#define FALSE 0

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'};

int MDT[N2][N2];

typedef struct Puzzle {
  int board[N2];
  int space;
  int MD;
} Puzzle;

struct Puzzle state;
int limit;
int path[LIMIT];

int min(int a, int b) {
  if (a < b) {
    return a;
  } else {
    return b;
  }
}

int max(int a, int b) {
  if (a > b) {
    return a;
  } else {
    return b;
  }
}

int abs(int a) {
  if (a < 0) {
    return -a;
  }
  
  return a;
}

int swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

int calculateManhattanDistance(Puzzle puzzle) {
  int sum = 0;

  for (int i = 0; i < N2; i = i + 1) {
    if (puzzle.board[i] == N2) {
      continue;
    }

    sum += MDT[i][puzzle.board[i] - 1];
  }

  return sum;
}

int doDepthFirstSearch(int depth, int prev) {
  if (state.MD == 0) {
    return TRUE;
  }

  if (depth + state.MD > limit) {
    return FALSE;
  }

  int sx = state.space / N;
  int sy = state.space % N;

  Puzzle tmp;

  for (int r = 0; r < N; r = r + 1) {
    int tx = sx + dx[r];
    int ty = sy + dy[r];

    if ((tx < 0) || (ty < 0) || (tx >= N) || (ty >= N)) {
      continue;
    }

    if(max(prev, r) - min(prev, r) == 2) {
      continue;
    }

    tmp = state;

    state.MD -= MDT[tx * N + ty][state.board[tx * N + ty] - 1];
    state.MD += MDT[sx * N + sy][state.board[tx * N + ty] - 1];

    swap(&state.board[tx * N + ty], &state.board[sx * N + sy]);

    state.space = tx * N + ty;

    if (doDepthFirstSearch(depth + 1, r)) {
      path[depth] = r;
      
      return TRUE;
    }

    state = tmp;
  }

  return FALSE;
}

int isSolved() {
  for (int i = 0; i < N2; i = i + 1) {
    if (state.board[i] != i + 1) {
      return FALSE;
    } 
  }

  return TRUE;
}

void doIterativeDpeepening(char *answer, Puzzle input) {
  input.MD = calculateManhattanDistance(input);

  for (limit = input.MD; limit <= LIMIT; limit = limit + 1) {
    state = input;

    if (doDepthFirstSearch(0, -LIMIT)) {
      for (int i = 0; i < LIMIT; i++) {
	answer[i] = '*';
      }

      for (int i = 0; i < limit; i++) {
	answer[i] = dir[path[i]];
      }

      return;
    }
  }
}

void initManhattanDistanceTable() {
  for (int i = 0; i < N2; i = i + 1) {
    for (int j = 0; j < N2; j = j + 1) {
      MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
    }
  }
}

Puzzle readInitialBoard() {
  Puzzle input;
  
  for (int i = 0; i < N2; i = i + 1) {
    scanf("%d", &input.board[i]);

    if (input.board[i] == 0) {
      input.board[i] = N2;
      input.space = i;
    }
  }

  return input;
}

int main(void) {
  initManhattanDistanceTable();

  Puzzle input = readInitialBoard();
  
  char answer[LIMIT];

  for (int i = 0; i < LIMIT; i = i + 1) {
    answer[i] = '*';
  }
  
  doIterativeDpeepening(answer, input);

  int count = 0;
  
  for (int i = 0; i < LIMIT; i = i + 1) {
    if (answer[i] == '*') {
      break;
    } else {
      count = count + 1;
    }
  }
  
  printf("%d\n", count);

  return 0;
}



Measured memory_bytes: 2144
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int[] w = new int[n];
		int[] e = new int[n];
		if(s.charAt(0) == 'W') w[0] =  1;
		else e[0] = 1;
		for(int i = 0 ; i < n - 1 ; i++) {
			if(s.charAt(i + 1) == 'W') w[i + 1] = w[i] + 1;
			else w[i + 1] = w[i];
		}
		for(int i = 0 ; i < n - 1 ; i++) {
			if(s.charAt(i + 1) == 'E') e[i + 1] = e[i] + 1;
			else e[i + 1] = e[i];
		}
//		System.out.println(Arrays.toString(w));
//		System.out.println(Arrays.toString(e));
		int ans = Integer.MAX_VALUE;
		// i番目の位置よりも左のWの個数と右のEの個数を求める
		for(int i = 0 ; i < n ; i++) {
			if(i == 0) ans = Math.min(ans, e[n - 1] - e[i]);
			else ans = Math.min(ans, w[i - 1] + e[n - 1] - e[i]);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 31096
#include"bits/stdc++.h"
//#include<boost/multi_array.hpp>
//#include<boost/optional.hpp>
//#include<boost/range/irange.hpp>
//#include<boost/range/algorithm.hpp>
//#include<boost/range/adaptors.hpp>

using namespace std;
//namespace adaptor = boost::adaptors;

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main()
{
	int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++)
    {
        int div = 0;
        for(int j = 1; j <= i; j++){
            if(i % j == 0)
            {
                div++;
            }
        }
        if(div == 8 && i%2 == 1) {
            ans++;
        }
    }
    cout << ans << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
A=[]
for a in range(n):
  A.append(list(map(int, input().split())))
B=[]
for b in range(m):
  B.append(int(input()))
for i in range(n):
  num=0
  for j in range(m):
    num += A[i][j]*B[j]
  print(num)



Measured memory_bytes: 6012
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Apolloliu
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

//#define print(s)      cerr << s << endl
//#define print(a, b)      cerr << a << " "  << b << endl
#define MEM(a,b)    memset(a, b, sizeof(a))
#define UN(a)       sort(all(a)), a.erase(unique(all(a)), a.end())
#define REV(a)      reverse(all(a))
#define MP(a, b)    make_pair(a, b)
#define PAIR(a, b)  pair<int, int>(a, b)

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

const int MOD = 1e9 + 7;
const int maxn = 1;
const double EPS = 1e-8;

int a[123465];
int lcm(int a, int b){
	return a / __gcd(a, b) * b;
}
class CSkip {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n, x;
		memset(a, 0, sizeof(a));
		in >> n >> x;
		for (int i = 1; i <= n; ++i) {
			in >> a[i];
		}
		int res = abs(x - a[1]);
		for (int i = 2; i <= n; ++i) {
			res = __gcd(abs(x - a[i]), res);
		}
		out << res << '\n';
	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	CSkip solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

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

int main()
{
	int i, j, k, i2;
	int x = 0;
	int flg = 0;
	char s[201];
	cin >> s;

	for (i = 0; s[i] != '\0'; i++);
	i2 = i;
	for (j=0; j<i2; j++)
	{
		flg = 0;
		i--;
		if (i % 2 == 0)
		{
			for (k = 0; k < i / 2; k++)
			{
				if (s[k] != s[i / 2 + k])
				{
					flg = 1;
				}
			}
			if (flg == 0)
			{
				cout << i;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}


int main(){
  int N, K;
  cin >> N >> K;
  vector<ll> h(N);
  rep(i,N) cin >> h.at(i);
  sort(all(h));
  rep(i,K) h.pop_back();
  ll sum = 0;
  rep(i,N-K){
    sum += h.at(i);
  }

  cout << sum << endl;

}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < A[i].size(); j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}
template < typename T, typename U >
ostream &operator<<(ostream &os, const pair< T, U > &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

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

struct edge {
	int from, to, d, c, i;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

template < typename A, size_t N, typename T >
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> Q;
	int ans = (N - 2) * (N - 2);
	vector< set< pii > > ss(2);
	while (Q--) {
		int q, x;
		cin >> q >> x;
		--q;
		auto it = ss[q].lower_bound(pii(x, -100));
		pii p;
		if (it == ss[q].end())
			p = pii(0, N);
		else
			p = *it;
		ans -= (p.second - 2);
		ss[1 - q].insert(pii(p.second, x));
	}
	cout << ans << endl;
	return 0;
}

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

#define REP(i,a) for(long i=0;i<(a);++i)

typedef std::vector<int>  VI;

int N;
VI imos(100002, 0);
int main() {
    std::cin >> N;

    REP(i, N) {
        int a, b;
        std::cin >> a >> b;
        ++imos[a];
        --imos[b+1];
    }

    int x = 0, ans = 0;
    for(int i=0; i<=N+1; ++i) {
        x += imos[i];
        if(x + 1 >= i) {
            ans = i - 1;
        }
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 3068
#include <stdio.h>
#include <string.h>
main(){
  char s[100];
  int kazu=0,i;
  while(fgets(s,sizeof(s),stdin)!=NULL){
    kazu=strlen(s);
    while(1){
      if(strstr(s,"the")!='\0' || strstr(s,"this")!='\0'
	 || strstr(s,"that")!='\0')break;
      else{
	for(i=0;i<kazu;i++){
	  if(s[i]>='a' && s[i]<='y'){
	    s[i]+=1;
	  }
	  else if(s[i]=='z'){
	    s[i]='a';
	  }
	}
      }
    }
    printf("%s",s);
  }
  return 0;
}

Measured memory_bytes: 524
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<vector<vector<int>>> v3int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef vector<vector<vector<ll>>> v3ll;
typedef list<int> liint;
typedef pair<int, int> pint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, int>> vpll_int;
typedef vector<pair<int, ll>> vpint_ll;
typedef set<pair<int, int>> spint;
typedef set<pair<ll, int>> spll;
typedef unordered_map<int, unordered_set<int>> Graph;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vint D1(N), D2(N);
    rep(i, N) cin >> D1[i] >> D2[i];
    REP(i, 1, N - 1) {
        if ((D1[i] == D2[i]) && (D1[i - 1] == D2[i - 1]) && (D1[i + 1] == D2[i + 1])) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

namespace ABC098
{
    public class QuestionC
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine().AsSpan();

            var sumW = new int[n + 1];
            for (int i = 0; i < n; i++)
            {
                sumW[i + 1] = sumW[i] + (s[i] == 'W' ? 1 : 0);
            }

            var sumE = new int[n + 1];
            for (int i = 0; i < n; i++)
            {
                sumE[i + 1] = sumE[i] + (s[i] == 'E' ? 1 : 0);
            }

            var min = Enumerable.Range(0, n).Select(i => sumW[i] + (sumE[n] - sumE[i + 1])).Min();
            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 32004
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
using namespace std;
int printNcR(int n, int r) 
{ 
  
  if(n<r)
    return 0;
    // p holds the value of n*(n-1)*(n-2)..., 
    // k holds the value of r*(r-1)... 
    long long p = 1, k = 1; 
  
    // C(n, r) == C(n, n-r), 
    // choosing the smaller value 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
  
            // gcd of p, k 
            long long m = __gcd(p, k); 
  
            // dividing by gcd, to simplify product 
            // division by their gcd saves from the overflow 
            p /= m; 
            k /= m; 
  
            n--; 
            r--; 
        } 
  
        // k should be simplified to 1 
        // as C(n, r) is a natural number 
        // (denominator should be 1 ) . 
    } 
  
    else
        p = 1; 
  
    // if our approach is correct p = ans and k =1 
   return p;
   // cout << p << endl; 
}
void solve()
{
    //Enter your code here Tanmay:)
    int n,m;
    cin>>n>>m;
    int x=printNcR(n,2)+printNcR(m,2);
    cout<<x<<endl;
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
/*
int eulortotent(int n)
     {
    //Enter your code here Tanmay:)
    int total=n;
        for(int p=2;p*p<=n;p++)
        {
            if (n%p==0)
        {
            total /= p;
            total *= (p-1);
            while ( n % p == 0 ) 
                n /= p;
        }
    }

    if(n>1)
    {
        total/=n;
        total*=(n-1);
    }

  return total;
}
*/

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>

using namespace std;

int main() {

    int a, b,e;
    char c;
    do {
        cin >> a >> c >> b;
        if (c == '?') {
            break;
        }
        else if (c == '+') {
            e = a + b;
        }
        else if (c == '-') {
            e = a - b;
        }
        else if (c == '*') {
            e = a * b;
        }
        else if (c == '/') {
            e = a / b;
            }
        cout << e  << endl;
        
    } while (1);

    return 0;
}


Measured memory_bytes: 3076
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
bool isPrime(int n){
	if(n<=1 || (n&1)==0&&n!=2)return false;
	for(int i=3;i*i<=n;i+=2)
		if(n%i==0)return false;
	return true;
}
int main(){
	vector<int> prime;
	for(int i=2;;i++){
		if(isPrime(i)){
			prime.push_back(i);
			if(50000<i)break;
		}
	}
	int n,index;
	while(cin>>n){
		index = lower_bound(prime.begin(),prime.end(),n)-prime.begin();
		if(n==prime[index])cout<<prime[index-1]<<' '<<prime[index+1]<<endl;
		else cout<<prime[index-1]<<' '<<prime[index]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
#define Task ""

using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    int odd = n/2 + (n % 2 > 0);
    cout << fixed << setprecision(6) << odd*1.0 / n;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

ll N;
void dfs(string s,char c) {
    if (s.length() == N) {
        cout << s << endl;
    }
    else {
        for (char i = 'a';i<=c+1;i++) {
            dfs(s + i,max(i,c));
        }
    }

}

int main() {
    cin >> N;
    dfs("",'a'-1);
}

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

int main()
{
	ios::sync_with_stdio(false);
	
	int n,x;
	cin>>n>>x;
	vector<int> a(n+1);
	
	for(int i=1;i<=n;i++)
		cin>>a[i];
	
	long long ans=0;
	
	for(int i=1;i<n;i++)
	{
		if(a[i]+a[i+1]>x)
		{
			ans+=a[i]+a[i+1]-x;
			if(x-a[i]>=0)
				a[i+1]=x-a[i];
			else
				a[i+1]=0;
		}
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
N, C = map(int, input().split())

tt = [[0] * (10 ** 5 + 1) for _ in range(C)]
for _ in range(N):
    s, t, c = map(int, input().split())
    for i in range(s - 1, t):
        tt[c - 1][i] = 1

ct = [0] * (10 ** 5 + 1)
for i in range(C):
    for j in range(10 ** 5 + 1):
        ct[j] += tt[i][j]

print(max(ct))


Measured memory_bytes: 29428
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

void main(){
	auto ip = readln.chomp.to!(dchar[]);
	(ip.sort().array == "abc" ? "Yes" : "No").writeln;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
//#define int long long

void solve() {
    int N; cin >> N;
    ll K; cin >> K;
    ll A[100100];
    rep(i, N) {
        cin >> A[i];
    }
    ll res = 0;
    per(k, 50) {
        //大きいものから優先すべし
        //小さいものからとってもしょうがない
        int cnt = 0;
        rep(i, N) {
            if((ll)A[i] & (1LL<<k)) cnt ++;
        }
        if(cnt <= N / 2 && res + (1LL<<k) <= K) {
            res += (1LL<<k);
        }
    }
    ll ans = 0;
    rep(i, N) {
        ans += (res ^ A[i]);
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

using namespace std;

int main()
{
  int n, m; cin >> n >> m;
  vector< vector<int> > vec(n, vector<int> (m));
  vector<int> line(m);
  for(int i = 0;i < n;i++)
  {
    for(int j = 0;j < m;j++)
    {
      cin >> vec[i][j];
    }
  }
  for(int i = 0;i < m;i++)
  {
    cin >> line[i];
  }
  for(int i = 0;i < n;i++)
  {
    int ans = 0;
    for(int j = 0;j < m;j++)
    {
      ans += vec[i][j] * line[j];
    }
    cout << ans << endl;
  }
}


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

int main(void){
   int L,R,d;
   cin>>L>>R>>d;
   int count=0;
   for(int i=L;i<=R;i++){
      if(i%d==0) count++;
   }
   cout<<count<<endl;
   return 0;
}


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

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

ll eval(ll x, ll y) {
	return (x<0 ? 0LL:x/y+1);
}

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	ll a,b,x; cin>>a>>b>>x;
	cout << eval(b,x) - eval(a-1,x) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int cnt;

main(){
  int i,num;
  char box,array[100001];
  scanf("%d",&num);
  scanf("%s",array);
  
  cnt = 1; box = array[0];
  for(i=1;i<num;i++){
    if(box == array[i])
      continue;
	cnt++;
    box = array[i];
  }
  
  printf("%d",cnt);
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

void solve() {
	ll T, D, L; scanf("%lld %lld %lld", &T, &D, &L); if (T == 0 and D == 0 and L == 0) exit(0);
	vector<ll> x(T); for (int i = 0; i < T; i++) scanf("%lld", &x[i]);
	ll res = 0;
	vector<ll> time(300000);
	for (int i = 1; i <= T; i++) {
		if (x[i - 1] >= L) {
			time[i]++;
			time[i + D]--;
		}
	}
	for (int i = 1; i <= T; i++) time[i + 1] += time[i];
	for (int i = 1; i < T; i++) res += time[i] > 0;
	printf("%lld\n", res);
}

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

	int kkt = 89;
	while (kkt) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 6360