akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    out.println((reader.nextInt() + reader.nextInt()) % 24);
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

int main() {

    int n,minj,v,count=0;
    cin >> n;

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

    
    for(int i=0;i<n;i++){
        minj=i;
        for(int j=i;j<n;j++){
            if(a[j]<a[minj]){
                minj=j;                
            }
        }
        if(minj != i){
                v=a[minj];
                a[minj]=a[i];
                a[i]=v;
                count++;
        }
    }

    cout<<a[0];
    for(int i=1;i<n;i++){
        cout<<" "<<a[i];
    }
    cout << endl << count << endl;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <bitset>
#include <string>
#include <array>
#include <random>
#include <chrono>
#include <algorithm>
#include <unordered_map>

int main(void){
	int n, l;
	std::cin >> n >> l;
	int sum = (l + (l + n - 1)) * n / 2;
	if(l + n - 1 <= 0){
		sum -= l + n - 1;
	}
	else if(l > 0){
		sum -= l;
	}
	std::cout << sum << std::endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int x[10000] = {},i = 1,l = 1;;
  while(1){
    scanf("%d",&x[i]);
    if(x[i] == 0) break;
    i++;
  }
  for(;l < i;l++){
    printf("Case %d: %d\n",l,x[l]);
  }
  return 0;
}



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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define l_l pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 998244353LL;
const ll INF = (1LL << 60LL);

ll dp[200010];

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

  vector<pair<ll, ll>> list;
  for (ll i = 0; i < K; i++) {
    ll a, b;
    scanf("%lld %lld", &a, &b);
    list.emplace_back(make_pair(a, b));
  }

  ll plus = 1;
  for (ll i = 1; i < N; i++) {
    plus = (plus + dp[i] + MOD) % MOD;
    for (ll j = 0; j < list.size(); j++) {
      ll from = list[j].first;
      ll to = list[j].second;

      if (i + from < N + 5) {
        dp[i + from] += plus;
        dp[i + from] %= MOD;
      }
      if (i + to + 1 < N + 5) {
        dp[i + to + 1] -= plus;
        dp[i + to + 1] %= MOD;
      }
    }
  }

  cout << (dp[N] % MOD + MOD) % MOD << endl;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long

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

	int n;
	cin >> n;
	int a[n+5] = {0};
	for(int i=1; i<=n; i++) cin >> a[i];
	ll amt = 1000;
	for(int i=1; i<=n-1; i++){
		ll stocks = 0;
		if(a[i] < a[i+1]){
			stocks = amt/a[i];
			amt += (a[i+1] - a[i]) * stocks;
		}
	}
	cout << amt;
	return 0;
}

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

#define MOD 1000000007

using namespace std;


int main()
{
	int n,a,b;
	cin >> n >> a >> b;
	
	if(n*a > b)cout << b << endl;
	else cout << n*a << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
vector<pii>ko[150000];
vector<pii>dat[150000];
void dfs(int node, ll cst, ll med)
{
	if (ko[node].empty())
	{
		dat[node].push_back(make_pair(cst, cst));
		return;
	}
	dfs(ko[node][0].first, ko[node][0].second, med);
	dfs(ko[node][1].first, ko[node][1].second, med);
	int u = ko[node][0].first, v = ko[node][1].first;
	if (dat[u].size() > dat[v].size())swap(u, v);
	vector<pii>z;
	for (int i = 0; i < dat[u].size(); i++)
	{
		int upp1 = upper_bound(dat[v].begin(), dat[v].end(), make_pair(med - dat[u][i].first, 1000000000000000000LL)) - dat[v].begin() - 1;
		if (upp1 >= 0)z.push_back(make_pair(dat[u][i].second, dat[v][upp1].second)), z.push_back(make_pair(dat[v][upp1].second, dat[u][i].second));
		int upp2 = upper_bound(dat[v].begin(), dat[v].end(), make_pair(med - dat[u][i].second, 1000000000000000000LL)) - dat[v].begin() - 1;
		if (upp2 >= 0)z.push_back(make_pair(dat[u][i].first, dat[v][upp2].second)), z.push_back(make_pair(dat[v][upp2].second, dat[u][i].first));
	}
	sort(z.begin(), z.end());
	ll b1 = -1, b2 = 1000000000000000000LL;
	for (int i = 0; i < z.size(); i++)
	{
		if (b1 == z[i].first)continue;
		if (b2 <= z[i].second)continue;
		b1 = z[i].first, b2 = z[i].second;
		dat[node].push_back(z[i]);
	}
	for (int i = 0; i < dat[node].size(); i++)dat[node][i].first += cst, dat[node][i].second += cst;
}
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num - 1; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		za--;
		ko[za].push_back(make_pair(i + 1, zb));
	}
	ll beg = 0, end = 10000000000000LL;
	for (;;)
	{
		if (beg == end)break;
		ll med = (beg + end) / 2;
		for (int i = 0; i < num; i++)dat[i].clear();
		dfs(0, 0, med);
		if (dat[0].empty())beg = med + 1;
		else end = med;
	}
	printf("%lld\n", beg);
}

Measured memory_bytes: 36720
#include<cstdio>
const int B=10000;
int H,W,h,w;
int main(){
	scanf("%d%d%d%d",&H,&W,&h,&w);
	if(H%h==0&&W%w==0)puts("No");
	else{
		puts("Yes");
		for(int i=0;i<H;i++)
			for(int j=0;j<W;j++)
				printf("%d%c",H%h?i%h<h-1?B:-B*(h-1)-1:j%w<w-1?B:-B*(w-1)-1," \n"[j==W-1]);
	}
}

Measured memory_bytes: 1792
N = int(input())
Xs = list(map(int, input().split()))
Xs2 = sorted(Xs)
m1 = Xs2[N//2-1]
m2 = Xs2[N//2]
for i in range(N):
  X = Xs[i]
  if X <= m1:
    print(m2)
  else:
    print(m1)


Measured memory_bytes: 25228
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#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 ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=998244353;
signed main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  int res=0;
  vector<vector<int>> dp(c+d+5,vector<int>(c+d+5,0));
  dp[a][b]=1;
  for(int i=a+1;i<=c;++i){
      dp[i][b]=dp[i-1][b]*b;
      dp[i][b]%=MOD;
  }
  for(int i=b+1;i<=d;++i){
      dp[a][i]=dp[a][i-1]*a;
      dp[a][i]%=MOD;
  }
  for(int x=a;x<c;++x){
      for(int y=b;y<d;++y){
          dp[x+1][y+1]=dp[x][y+1]*(y+1)+dp[x+1][y]*(x+1)-dp[x][y]*x*y+MOD*inf;
          dp[x+1][y+1]%=MOD;
      }
  }
  cout<<dp[c][d]<<"\n";
  return 0;
}

Measured memory_bytes: 285204
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int cnt[N];
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,m;
   cin>>n>>m;
   int c=0;
   for(int i=0;i<m;i++)
   {
       int x,y;
       cin>>x>>y;
       cnt[x]+=1;
       cnt[y+1]-=1;
   }
   for(int i=1;i<=n;i++)
   {
       cnt[i]+=cnt[i-1];
   }
   for(int i=1;i<=n;i++)
   {
       if(cnt[i]==m)c++;
   }
   cout<<c<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];

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

  cout<<A.size()<<endl;

  return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n, x, t;
  cin >> n >> x >> t;
  cout << (n+x-1)/x * t << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3604
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);



	class b {

		int i;

		int j;



		b(int a, int c) {

			i = a;

			j = c;

		}



		boolean reachable(b o) {

			return this.i == o.i || this.j == o.j;

		}

	}



	int km(boolean[] a, int b) {

		int z = 0;

		for (int i = 0; i < a.length; i++) {

			z += a[i] ? 1 : 0;

			z *= 2;

		}

		return z * 100 + b;

	}



	int rec(boolean[] used, int now, int count, int[][] map) {

		if (ht.containsKey(km(used, now))) {

			return ht.get(km(used, now));

		}

		if (count == used.length - 1) {

			if (!list.get(now).reachable(list.get(0))) {

				// ht.put(km(used, now),0);

				return 0;

			}

			// ht.put(km(used, now),1);

			return 1;

		}

		int sum = 0;

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

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

		b bnow = list.get(now);

		for (int i = 0; i < 4; i++) {

			int x = bnow.j;

			int y = bnow.i;

			for (;; x += dx[i], y += dy[i]) {

				if (y >= map.length || x >= map[0].length || x < 0 || y < 0) {

					break;

				}

				if (map[y][x] > 0) {

					// System.out.printf("%x ",1<<(count*4));

					// System.out.println("push"+i);

					int q = map[y][x];

					used[q] = true;

					map[y][x] = -1;

					sum += rec(used, q, count + 1, map);

					map[y][x] = q;

					// System.out.printf("%x ",1<<(count*4));

					// System.out.println("pop"+i);

					used[q] = false;

					break;

				}

			}

		}

		if (count % 3 == 1)

			ht.put(km(used, now), sum);

		return sum;

	}



	LinkedList<b> list = new LinkedList<Main.b>();

	HashMap<Integer, Integer> ht = new HashMap<Integer, Integer>();



	void run() {

		for (;;) {

			int w = sc.nextInt();

			int h = sc.nextInt();

			if ((h | w) == 0) {

				break;

			}

			b start = null;

			list.clear();

			ht = new HashMap<Integer, Integer>();

			int[][] map = new int[h][w];

			int id = 1;

			for (int i = 0; i < h; i++) {

				for (int j = 0; j < w; j++) {

					map[i][j] = -1;

					int z = sc.nextInt();

					if (z == 1) {

						list.addLast(new b(i, j));

						map[i][j] = id;

						id++;

					}

					if (z == 2) {

						start = new b(i, j);

						list.addFirst(start);

						map[i][j] = 0;

					}

				}

			}

			int n = list.size();



			boolean[] used = new boolean[n];

			System.out.println(rec(used, 0, 0, map));

		}

	}



	public static void main(String[] args) {

		Main m = new Main();

		m.run();

	}

}

Measured memory_bytes: 30000
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    s = input()
    t = input()
    S = sorted(map(s.count, set(s)))
    T = sorted(map(t.count, set(t)))
    print("Yes" if S == T else "No")


if __name__ == '__main__':
    main()


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;
using PP = pair<int, 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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int INFLL = 1e18;
const int MOD = 1e9 + 7;

int dp[100010];

signed main(){
    int N; cin >> N;
    vector<int> a( N );
    REP( i, N ) cin >> a[i];

    fill( dp, dp + 100010, INF );

    REP( i, N ){
        *lower_bound( dp, dp + 100010, a[i] ) = a[i];
    }

    cout << lower_bound( dp, dp + 100010, INF ) - dp << endl;
}



Measured memory_bytes: 4428
def LunLun(k, count, base):
    nx = []
    n = len(base)
    if count + n >= k:
        ans = base[k - count - 1]
        print(ans)
        exit()

    for x in base:
        count += 1
        p = x % 10
        x *= 10
        a = x + p - 1
        b = a + 1
        c = b + 1
        n = 3
        if p == 0:
            n -= 1
            nx.extend([b, c])
        elif p == 9:
            n -= 1
            nx.extend([a, b])
        else:
            nx.extend([a, b, c])

    return LunLun(k, count, nx)


def main():
    k = int(input())
    base = range(1, 10)
    LunLun(k, 0, base)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 18300
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N, C, K;
    cin >> N >> C >> K;

    // pn(C);
    // pn(K);

    vector<ll> T(N);
    FOR(i, 0, N){
        cin >> T.at(i);
    }
    sort(ALL(T));

    // vprint(T);

    ll bus_count = 1;
    ll arrive_time = T[0];
    ll passenger_num = 0;
    FOR(i, 0, N){
        if(T[i] <= arrive_time + K && passenger_num < C){
            passenger_num++;
        }else{
            // 新しいバス
            bus_count++;
            arrive_time = T[i];
            passenger_num = 1;
        }
    }

    p(bus_count);
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N, W;
struct Node {
  int w;
  int v;
  Node() = default;
  Node(int _w, int _v) : w(_w), v(_v) {}
};
ll ret = 0;
vector<vector<Node>> tv(4);


void dfs(int bk, ll wsum, ll vsum) {
  if (wsum > W) return;
  if (bk == 4) {
    ret = max(ret, vsum);
    return;
  }

  ll cwsum = 0;
  ll cvsum = 0;

  auto &cbuk = tv[bk];
  dfs(bk + 1, wsum , vsum);
  for (int i = 0; i < cbuk.size(); ++i) {
    wsum += cbuk[i].w;
    vsum += cbuk[i].v;
    if (wsum > W) break;
    dfs(bk + 1, wsum , vsum);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> N >> W;

  vector<Node> v(N);
  for (int i = 0; i < N; ++i) {
    auto &el = v[i];
     cin >> el.w >> el.v;
  }

  sort(v.begin(), v.end(), [](Node &n1, Node &n2) {
    if (n1.w != n2.w) return n1.w < n2.w;
    return n1.v > n2.v;
  });

  ll base = v[0].w;

  for (auto &el : v) {
    tv[el.w - base].push_back(el);
  }

  dfs(0, 0, 0);
  cout << ret << endl;
}

Measured memory_bytes: 256
def main():
    # import sys
    # readline = sys.stdin.readline
    # readlines = sys.stdin.readlines
    N = int(input())
    A = [(a, i) for i, a in enumerate(map(int, input().split()))]
    A.sort(reverse=True)
    
    dp = [[-float('inf')] * (N + 1) for _ in range(N + 1)]
    dp[0][0] = 0
    for k in range(N):
        for i in range(k + 1):
            j = k - i
            here = dp[i][j]
            a, idx = A[k]
            dp[i + 1][j] = max(dp[i + 1][j], here + a * ((N - 1 - i) - idx))
            dp[i][j + 1] = max(dp[i][j + 1], here + a * (idx - j))
            # print(k, i)

    ans = 0
    for i in range(N + 1):
        j = N - i
        ans = max(ans, dp[i][j])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 194800
#include <iostream>
#include <string>
int main()
{  
  int A, B;
  std::string op;
  
  std::cin >> A >> op >> B;
  
  if(op == "+")
  {
    std::cout << A + B;
  }
  else
  {
    std::cout << A - B;
  }
  
  return 0;
}

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

using namespace std;

typedef long long ll;

int r[17][100001];

int solve(int a, int b) {
    int res = 1;
    for (int i = 16; i >= 0; i--) {
        if (r[i][a] >= b) continue;
        res += (1 << i);
        a = r[i][a];
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; i++) cin >> x[i];
    int l, q;
    cin >> l >> q;
    for (int i = 0; i < n; i++) {
        r[0][i] = (int)(upper_bound(x.begin(), x.end(), x[i] + l) - x.begin()) - 1;
    }
    for (int k = 0; k < 16; k++) {
        for (int i = 0; i < n; i++) {
            r[k + 1][i] = r[k][r[k][i]];
        }
    }
    for (int i = 0; i < q; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if (a > b) swap(a, b);
        cout << solve(a, b) << "\n";
    }
    return 0;
}

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

using namespace std;

using ll = long long;

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

    int n;
    string s;

    cin >> n >> s;
    vector<int> cnt_w(n), cnt_e(n);
    for (int i = 1; i < n; ++i) {
        if (s[i - 1] == 'W') cnt_w[i] += cnt_w[i - 1] + 1;
        else cnt_w[i] += cnt_w[i - 1];
    }
    for (int i = n - 2; 0 <= i; --i) {
        if (s[i + 1] == 'E') cnt_e[i] += cnt_e[i + 1] + 1;
        else cnt_e[i] += cnt_e[i + 1];
    }

    int min_d = n;
    for (int i = 0; i < n; ++i)
        min_d = min(min_d, cnt_w[i] + cnt_e[i]);

    cout << min_d << endl;

    return 0;
}


Measured memory_bytes: 2964
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>


#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	string s; cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

int main(void) {
  while (true) {
    int a, l, ans, res;
    cin >> a >> l;
    if(!a && !l) break;

    vector<int> b, before;
    before.push_back(a);
    FOR(i, 1, 21) {
      b = {0, 0, 0, 0, 0, 0};
      b.resize(l);
      string aa = to_string(a);
      REP(j, aa.size()) b[j] = (aa[j] - '0');
      sort(ALL(b));
      //REP(j, b.size()) cout << b[j] << " "; cout << endl;
      string aamin = "", aamax = "";
      REP(j, b.size()) { aamin += to_string(b[j]); }
      REP(j, b.size()) { aamax += to_string(b[b.size() - j - 1]); }
      REP(j, (l - b.size())) { aamax += '0'; }
      //cout << aamin << " " << aamax << endl;
      a = stoi(aamax) - stoi(aamin);
      //cout << a << endl;
      bool flag = true;
      REP(j, before.size()) {
        if (a == before[j]) {
          ans = j;
          res = i - j;
          flag = false;
        }
      }
      if (!flag)
        break;
      before.push_back(a);
    }

    cout << ans << " " << a << " " << res << endl;
  }
  return 0;
}

Measured memory_bytes: 3176
//This is getting accepted!
// I HATE BUG
// God Of The Bugs
// 12/11/2016
#include<bits/stdc++.h>

using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FI first
#define SE second
#define pb push_back
#define mp make_pair
#define ll long long
#define sz(a) ((int)(a).size())
#define __builtin_popcount __builtin_popcounll
#define ld long double

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> ppi;

const double PI = acos(0) * 2;
const double EPS = 1e-8;
const ll MOD = 1e9 + 7;
const int MAXN = 2e5 + 5;
const int oo = 1e9;
const double foo = 1e30;

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcounll(s);}
template<class T> T sqr(T x) { return x * x; }

inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

deque<int> st;
int n, a[MAXN];

int main() {
//#ifndef ONLINE_JUDGE
//    freopen("inp.txt", "r", stdin);
////    freopen("out.txt", "w", stdout);
//#endif

	cin >> n;
	for (int i=0; i<n; i++) cin >> a[i];
	
	for (int i=0; i<n; i++) {
		if (i % 2) st.push_back(a[i]);
		else st.push_front(a[i]);
	}
	
	while (!st.empty()) {
		if (n % 2 == 0) {
			cout << st.back() << " ";
			st.pop_back();
		}
		else {
			cout << st.front() << " ";
			st.pop_front();
		}
	}

	return 0;
}


Measured memory_bytes: 3840
h,w,k = map(int, input().split())
S = []
for _ in range(h):
    S.append(list(input()))

ans = [[0]*w for _ in range(h)]
ans = []
first_row_flag = True
first_row_cnt = 0
curr_num = 1
for i in range(h):
    row = []
    curr_s_row = S[i]
    if '#' in S[i]:
        ichigo = 0
        for j in range(w):
            if curr_s_row[j] == '#':
                ichigo += 1
                if ichigo >= 2: curr_num += 1
            row.append(curr_num)

        
        curr_num += 1
        
        if first_row_flag:
            first_row_flag = False
            for j in range(first_row_cnt):
                ans.append(row)
        ans.append(row)
    
    else:
        if first_row_flag:
            first_row_cnt+=1
        else:
            ans.append(ans[-1])

for row in ans:
    print(*row)

Measured memory_bytes: 48732
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define N 2005

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

	int n, a;
	string s;
	cin >> n;
	vector<pair<pair<string, int>,int>> res(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> s >> a;
		res[i] = make_pair(make_pair(s, a), i);
	}
	sort(res.begin(), res.end(), [](auto a, auto b){
		if(a.ff.ff == b.ff.ff)
			return a.ff.ss > b.ff.ss;
		return a.ff.ff < b.ff.ff;
	});
	for(auto e : res)
	{
		cout << e.ss + 1<< "\n";
	}
	return 0;
}

Measured memory_bytes: 256
n, m, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

asum = [0]
a.each do |ai|
  asum << asum.last + ai
end
asum << asum.last + k + 1

bsum = [0]
b.each do |bi|
  bsum << bsum.last + bi
end
bsum << bsum.last + k + 1

ans = 0
asum.each_with_index do |av, i|
  break if av > k
  j = bsum.bsearch_index{|x| x + av > k}
  ans = [ans, i + j - 1].max
end
puts ans


Measured memory_bytes: 45128
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <cassert>
using namespace std;
int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++){
		cin >> A[i];
	}
	vector<int> B(N);
	for (int i = 0; i < N; i++){
		cin >> B[i];
	}
	vector<pair<int, int>> A2(N);
	for (int i = 0; i < N; i++){
		A2[i] = make_pair(A[i], i);
	}
	vector<pair<int, int>> B2(N);
	for (int i = 0; i < N; i++){
		B2[i] = make_pair(B[i], i);
	}
	sort(A2.begin(), A2.end());
	sort(B2.begin(), B2.end());
	bool ok = true;
	for (int i = 0; i < N; i++){
		if (B2[i].first < A2[i].first){
			ok = false;
		}
	}
	if (!ok){
		cout << "No" << endl;
	} else {
		ok = false;
		for (int i = 0; i < N - 1; i++){
			if (A2[i + 1].first <= B2[i].first){
				ok = true;
			}
		}
		if (ok){
			cout << "Yes" << endl;
		} else {
			vector<vector<int>> E(N);
			for (int i = 0; i < N; i++){
				E[A2[i].second].push_back(B2[i].second);
				E[B2[i].second].push_back(A2[i].second);
			}
			vector<bool> used(N, false);
			used[0] = true;
			queue<int> Q;
			Q.push(0);
			while (!Q.empty()){
				int v = Q.front();
				Q.pop();
				for (int w : E[v]){
					if (!used[w]){
						used[w] = true;
						Q.push(w);
					}
				}
			}
			for (int i = 0; i < N; i++){
				if (!used[i]){
					ok = true;
				}
			}
			if (ok){
				cout << "Yes" << endl;
			} else {
				cout << "No" << endl;
			}
		}
	}	
}

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

int main() {
  string s;
  cin >> s;
  if (s != "AAA" && s != "BBB") cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 100000+5
#define MOD 20190823
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
inline void read(ll &f){
	f=0;
    ll x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
char c;
int main(){
	cin>>c;
	cout<<char(c+1)<<endl;
	return 0;
}

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

int main() {
  int n, i, ans1 = 0, ans2 = 0;
  cin >> n;
  vector<int> a(n), c(9, 0);
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }

  for (i = 0; i < n; i++) {
    if (1 <= a[i] && a[i] < 400) {
      c[0] = 1;
    } else if (400 <= a[i] && a[i] < 800) {
      c[1] = 1;
    } else if (800 <= a[i] && a[i] < 1200) {
      c[2] = 1;
    } else if (1200 <= a[i] && a[i] < 1600) {
      c[3] = 1;
    } else if (1600 <= a[i] && a[i] < 2000) {
      c[4] = 1;
    } else if (2000 <= a[i] && a[i] < 2400) {
      c[5] = 1;
    } else if (2400 <= a[i] && a[i] < 2800) {
      c[6] = 1;
    } else if (2800 <= a[i] && a[i] < 3200) {
      c[7] = 1;
    } else {
      ++c[8];
    }
  }
  for (i = 0; i < 8; i++) {
    ans1 += c[i];
  }
  ans2 = ans1 + c[8];
  if (ans1 == 0) {
    ans1 = 1;
  }
  cout << ans1 << ' ' << ans2 << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
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 gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main() {
  INIT;
	VAR(int,n,k);
  VAR(string,s);

  int ans=0, cng=0;
  REP(i,s.size()-1){
    if(s[i]==s[i+1]) ++ans;
    else cng++;
  }

  if (cng>1) ans += min(cng,k*2);
  else ans++;

  ans = min(ans,n-1);

  OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 512
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]

dy = [0, 1, 0, -1]
dx = [1, 0, -1, 0]

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            flag = False
            for k in range(4):
                y = i + dy[k]
                x = j + dx[k]
                if 0 <= y < h and 0 <= x < w:
                    if s[y][x] == "#":
                        flag = True
            if flag == False:
                print("No")
                exit()
print("Yes")


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(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; }


int main(){
    int k; cin >> k;
    int odd = 0, even = 0;
    rept(i, 1, k+1){
        if(i%2==0)even++;
        else odd++;
    }
    cout << odd * even << ln;
}
    

 


Measured memory_bytes: 3588
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;



int main() {
    ios_base::sync_with_stdio(false); 

    int n,m;
    cin >> n >> m;
    if (n%2==1) {
        rep(i,m) {
            cout << 1+i << ' ' << n-1-i << endl;
        }
    } else if (n%4==0) {
        int k=(n-1)/2;
        int s=min(k/2+1,m);
        rep(i,s) {
            cout << 1+i << ' ' << n-i << endl;
        }
        repr(i,k/2+1,m) {
            cout << 1+i << ' ' << n-1-i << endl;
        }
    } else {
        int k=(n-1)/2;
        int s=min(k/2,m);
        rep(i,s) {
            cout << 1+i << ' ' << n-i << endl;
        }
        repr(i,k/2,m) {
            cout << 1+i << ' ' << n-1-i << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3628
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 200000
#define mp make_pair
#define pb push_back
#define ll long long
#define uint unsigned int
#define pii pair<int, int>
#define ull unsigned long long
#define sz(v) ((int)(v).size())
#define foreach(it, v) for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); it++)
#define gc() fgetc(stdin)
template<typename T> void read(T &a) {
	register int b = 1, c; a = 0;
	for (c=gc(); c > 57 || c < 48; c=gc()) if (c == 45) b = -1;
	for (; c >= 48 && c <= 57; c=gc()) a = a * 10 + c - 48;
	a *= b;
}
#ifdef DEBUG
struct Timer {
	int Stime;
	Timer() { Stime = clock(); }
	~Timer() {
		printf("\nTimer Report : Current Running Time = %dms\n", clock() - Stime);
		system("pause");
	}
}Timer0;
#endif

int n, a[N + 5];
map<ll, int> M;

int main() {
	read(n);
	for (int i = 0; i < n; i++) read(a[i]);
	ll sum = 0, ans = 0;
	for (int i = 0; i < n; i++) {
		sum += a[i];
//		printf("%d\n", sum);
		ans += M[sum] + !sum;
		M[sum]++;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < (int) n; i++)
#define forin(i, a, b) for(int i = a; i < (int) b; i++) 
#define rofin(i, a, b) for(int i = a; i > b; i--)
#define v vector
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define debug(i) cout << #i << ": " << i << endl
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int nax = 1e3 + 5;
const int modulo = 1e9 + 7;
char grid[nax][nax];

void add_self(int &a, int b) {
    a += b;
    if(a>=modulo) {
        a-=modulo;
    }
}

int main() {
    crap;
    int H, W;
    cin >> H >> W;
    vector<vi> dp(H, vi(W,0));

    forn(i, H) {
        forn(j, W) {
            cin >> grid[i][j];
        }
    }

    dp[0][0] = 1;
    forn(row, H) {
        forn(col, W) {
            for(int r2 : {row, row + 1}) {
                int c2 = col;
                if(r2==row) {
                    c2+=1;
                }
                if(r2 < H && c2 < W && grid[r2][c2] == '.') {
                    add_self(dp[r2][c2], dp[row][col]);
                }
            }
        }
    }

    cout << dp[H-1][W-1] << endl;
}

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

int main() {
  int a = 0,b = 0;
  rep(i,4){
    int s;
    cin >> s;
    a += s;
  }
  rep(i,4){
    int s;
    cin >> s;
    b += s;
  }
  cout << max(a,b) << endl;
}


Measured memory_bytes: 3076
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int dp[1010][100010]; //dp[i][j]:= i個目まで入れていい時のjまでの価値を入れた時の最小重量

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, W; cin >> N >> W;
    int w[110], v[110];
    rep(i, N) cin >> w[i] >> v[i];
    rep(i, 1010)rep(j, 100010) dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i, N) {
        REP(j, 0, 100000) {
            dp[i + 1][j] = dp[i][j];
            if (j - v[i] < 0) continue;
            else dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
        }
    }
    //rep(i, N + 1) rep(j, 200) cout << i << " " << j << " " << dp[i][j] << " " << (dp[i][j] <= W) << endl;
    int ans = 0;
    rep(i, 100010) if (dp[N][i] <= W) ans = max(ans, i);
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 789504
#include<stdio.h>
int main(void){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(x-r<0){
    printf("No\n");
  }else if(y-r<0){
    printf("No\n");
  }else if(x+r>W){
    printf("No\n");
  }else if(y+r>H){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  return 0;
}


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

ll n, ans;

bool check(int x){
    ll t = n;
    while(t%x == 0) t /= x;
    return t%x == 1;
}

int main()
{
    cin >> n;
    ll m = n-1;
    for(int i = 2; (ll)i*i <= m; i++){
        if(m%i) continue;
        ans++;
        if((ll)i*i != m) ans++;
    }
    if(m > 1) ans++;
    for(int i = 2; (ll)i*i <= n; i++){
        if(n%i) continue;
        ans += check(i);
        if((ll)i*i != n) ans += check(n/i);
    }
    cout << ans+1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int ssort(int A[],int N){
  int i,j,t,sw=0,minj;
  for(i=0;i<N-1;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A[j]<A[minj]) minj=j;
    }
    t=A[i]; A[i]=A[minj]; A[minj]=t;
    if(i!=minj) sw++;
  }
  return sw;
}
int main(){
  int A[100],N,i,sw;

  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);
  sw=ssort(A,N);
  for(i=0;i<N;i++){
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",sw);

  return 0;
}

Measured memory_bytes: 604
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
// const int MOD = 1e9 + 7;
const int MOD = 10007;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

int n;
String s;

int main() {
    cin >> n >> s;
    for (int i = 0; i < s.length(); i++) {
        char ch = s[i];
        int base = ch - 'A';
        (base += n) %= 26;
        putchar(base + 'A');
    }
    puts("");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus>=201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, long long K, std::vector<long long> A){
  ll ans=0,x=0;
  auto sum = [&](ll x){
    ll ret=0;
    for (auto &&i : A)
    {
      ret+=(x^i);
    }
    return ret;
  };
  Rev(i,60){
    if(x+(1LL<<i)>K)continue;
    ll z=sum(x),o=sum(x|(1LL<<i));
    if(z<o){
      x|=(1LL<<i);
    }
  }
  cout<<sum(x)<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define  ll   long long int
#define  sz   200010

using namespace std;


int main()
{



    ll s=0;

    ll i,j,n;

    cin>>n;

    for(i=1;i<=n;i++)
    {
        if(i%3!=0 && i%5!=0)
        {
            s+=i;
        }
    }

    cout<<s<<endl;

    return 0;
}



Measured memory_bytes: 3636
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<queue>
#include<stack>
#include<cmath>
#define int long long
using namespace std;
inline void read(int &x){
	x=0;int f=1;char c=getchar();
	while(c>'9'||c<'0'){if(c=='-') f=-1;c=getchar();	}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	x*=f;
}
const int mod = 998244353;
inline int quick_pow(int a,int b){
	int res=1;
	while(b){
		if(b&1) res = (res*a)%mod;
		a = (a*a)%mod;
		b>>=1;
	}
	return res;
}
int inv[300100],jc[300100];
inline int C(int n,int m){
	return ((jc[n]*inv[n-m])%mod*inv[m])%mod;
}
int n,a,b,k,ans;
//void write(int x){
//	if(x<0) putchar('-'),x=-x;
//	if(x>9) write(x/10);
//	putchar(x%10+48);
//}
signed main()
{
	read(n),read(a),read(b),read(k); 
	jc[0]=1;
	for(int i=1;i<=300000;i++) jc[i]=(jc[i-1]*i)%mod;
	inv[300000] = quick_pow(jc[300000],mod-2);
    inv[0]=1;
	for(int i=299999;i;i--) inv[i]=(inv[i+1]*(i+1))%mod;
//	cout<<inv[2]<<endl;
//    cout<<" KLK "<<endl; 
	//a b为得分 答案为k
//	cout<<C(2,2)<<endl; 
	for(int i=0;i<=k/a&&i<=n;i++){
//		if(i>=100000) write(i),cout<<endl;
		if((k-i*a)%b!=0) continue;
		int j=(k-i*a)/b;
		if(j>n) continue;
		ans+=(C(n,i)*C(n,j))%mod;
		ans%=mod;
//		int tmp=ans;
//		cout<<tmp<<endl;
//		cout<<ans<<endl;
//	    printf("%lld YYY\n",ans);
	}
//	cout<<ans<<endl;
	printf("%lld",ans);
//	write(ans); 
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#define ll long long
using namespace std;

int i,j;
char s[11],t[11];
bool m=1;

int main()
{
    cin>>s;
    cin>>t;
    j=strlen(s);
    for(i=0;i<j;i++)
    {
        if(s[i]!=t[i])
        {
            m=0;
            break;
        }
    }
    if(m) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
#include<queue>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=2000+10;
struct dong{
    int x,y;
    friend bool operator <(dong a,dong b){
        return a.x<b.x;
    }
} zlt;
priority_queue<dong> dl;
bool bz[maxn][maxn],pd[maxn];
int a[maxn],d[maxn];
int h[maxn],go[maxn*maxn],nxt[maxn*maxn];
int i,j,k,l,t,n,m,tot,now;
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
void add(int x,int y){
    d[y]++;
    go[++tot]=y;
    nxt[tot]=h[x];
    h[x]=tot;
}
void dfs(int x){
    pd[x]=1;
    int i;
    fo(i,1,n)
        if (bz[x][i]&&!pd[i]){
            add(x,i);
            dfs(i);
        }
}
int main(){
    scanf("%d",&n);
    fo(i,1,n) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    fo(i,1,n-1)
        fo(j,i+1,n)
            if (gcd(a[i],a[j])>1) bz[i][j]=bz[j][i]=1;
    fo(i,1,n)
        if (!pd[i]) dfs(i);
    fo(i,1,n)
        if (!d[i]){
            zlt.x=a[i];
            zlt.y=i;
            dl.push(zlt);
        }
    fo(i,1,n){
        zlt=dl.top();
        dl.pop();
        now=zlt.y;
        printf("%d ",a[now]);
        t=h[now];
        while (t){
            d[go[t]]--;
            if (!d[go[t]]){
                zlt.x=a[go[t]];
                zlt.y=go[t];
                dl.push(zlt);
            }
            t=nxt[t];
        }
    }
    puts("");
}


Measured memory_bytes: 7168
# get line input split by space
def getLnInput():
    return input().split()


# ceil(a / b) for a > b
def ceilDivision(a, b):
    return (a - 1) // b + 1


def main():
    while True:
        H, W = list(map(int, getLnInput()))
        printFromSharp = True
        if H == 0 and W == 0:
            break
        if H != 0 or W != 0:
            for i in range(H):
                isCurrentSharp = printFromSharp
                for j in range(W):
                    print("#" if isCurrentSharp else ".", end="")
                    isCurrentSharp = not isCurrentSharp
                print()
                printFromSharp = not printFromSharp
        print()
    return


main()

Measured memory_bytes: 9056