akhauriyash/Code-Regression huggingface dataset:
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 10 ** 9 + 7
N, K = lr()
M = int(N**.5)

# M+1以上で、Nを割るとxになるもの
upper_cnt = np.zeros(M+1, dtype=np.int64) # 1-indexed
A = np.arange(M+1, dtype=np.int64)
upper_cnt[1:] = N // A[1:] - np.maximum(M, N // (A[1:]+1)) # Mの時はlowerで数えるので0に

# 桁DP
lower = np.zeros(M+1, dtype=np.int64) # 1-indexed
upper = np.zeros(M+1, dtype=np.int64)
#最初は制限なしなので1を置いておく
lower[1] = 1
for i in range(K):
    prev_lower = lower.copy()
    prev_upper = upper.copy()
    lower_cum = prev_lower.cumsum() % MOD
    upper_cum = prev_upper.cumsum() % MOD
    # lower と upper から lower へ
    lower = np.zeros(M+1, dtype=np.int64)
    lower[1:] += (lower_cum[-1] + upper_cum[-1])
    lower[1:] -= upper_cum[:-1] # 大きすぎる値を引く
    # upper から upper はなし
    # lower から upper へ
    upper = lower_cum * upper_cnt
    lower %= MOD; upper %= MOD

answer = (lower[1:].sum() + upper[1:].sum()) % MOD
print(answer)


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

int main()
{
    vector<string> w({"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"});
    string str;
    cin >> str;
    //cout << str << endl;
    for (int i = 0; i < 7;i++){
        if(str==w.at(i)){
            cout << 7-i << endl;
        }
    }

}

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

if L > 0:
    print((2 * L + N) * (N - 1) // 2)
elif L >= - N + 1:
    print(N * (N - 1) // 2 + L * N)
else:
    print((2 * L + N - 2) * (N - 1) // 2)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1e9 + 7;
int N;
int dp[110][5][5][5];

int main(){
    cin >> N;

    for(int i = 1; i <= 4; i++){
        dp[1][0][0][i] = 1;
    }
    for(int i = 1; i <= N; i++){
        for(int j = 0; j <= 4; j++){
            for(int k = 0; k <= 4; k++){
                for(int l = 0; l <= 4; l++){
                    if(j == 1 && k == 3 && l == 2) dp[i][j][k][l] = 0;
                    if(j == 3 && k == 1 && l == 2) dp[i][j][k][l] = 0;
                    if(j == 1 && k == 2 && l == 3) dp[i][j][k][l] = 0;
                    for(int m = 1; m <= 4; m++){
                        if(j == 1 && k == 3 && m == 2) continue;
                        if(j == 1 && l == 3 && m == 2) continue;
                        dp[i + 1][k][l][m] += dp[i][j][k][l];
                        dp[i + 1][k][l][m] %= mod;
                    }
                }
            }
        }
    }
    ll ans = 0;
    for(int i = 1; i <= 4; i++){
        for(int j = 1; j <= 4; j++){
            for(int k = 1; k <= 4; k++){
                ans += dp[N][i][j][k];
                ans %= mod;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      Graph graph = new Graph(n);
      String[] vInfo;
      int[][] weight = new int[n][n];

      for(int i=0, j=0; i<n; i++, j=0) {
        vInfo = br.readLine().split(" ");
        for (String var : vInfo) {
          if(var.equals("")) continue;
          else weight[i][j++] = Integer.parseInt(var);
        }
        graph.setVertex(i, weight[i]);
      }

      System.out.println( graph.calcMSTWeightSum() );
    }
    catch (IOException e) {
      System.err.println(e);
    }
  }


  class Graph {

    Vertex[] vertices;

    public Graph(int size ) {
      vertices  = new Vertex[size];
    }

    public void setVertex(int id) {
      vertices[id] = new Vertex(id);
    }
    public void setVertex(int id, int[] distance) {
      setVertex(id);
      setAjacent(id, distance);
    }
    public void setAjacent(int id, int[] distance) {
      vertices[id].distance = distance;
    }

    public int calcMSTWeightSum() {
      return  prim();
    }

    private int prim() {
      int minCost;
      int minV;
      vertices[0].minAjacent = 0;
      vertices[0].parent = Vertex.NILL;

      while( true ) {
        minCost = Integer.MAX_VALUE;
        minV = Vertex.NILL;

        for (Vertex v : vertices) {
          if( (v.state != Vertex.BLACK) && (v.minAjacent < minCost) ) {
            minV = v.id;
            minCost = v.minAjacent;
          }
        }

        if(minV == Vertex.NILL) break;

        vertices[minV].state = Vertex.BLACK;

        for (Vertex v : vertices) {
          if((v.state != Vertex.BLACK) && (v.distance[minV] != Vertex.NILL)) {
            if( v.distance[minV] < v.minAjacent ) {
              v.minAjacent = v.distance[minV];
              v.parent = minV;
              v.state = Vertex.GRAY;
            }
          }
        }
        continue;
      }

      minCost = 0;
      for (Vertex v: vertices) {
        if( v.parent != Vertex.NILL )
          minCost += v.minAjacent;
      }

      return minCost;
    }

    class Vertex {

      static final int NILL  =-1;
      static final int WHITE = 0;
      static final int GRAY  = 1;
      static final int BLACK = 2;
      int id;
      int state;
      int minAjacent;
      int parent;
      int[] distance;

      public Vertex(int id) {
        this.id = id;
        state = WHITE;
        minAjacent = Integer.MAX_VALUE;
      }
    }
  }
}


Measured memory_bytes: 27308
#include<iostream>
using namespace std;
int main(void){
	int n0,n,s,d;
	cin>>n0;
	n=n0;
	s=0;
	while(n){
		d=n%10;
		s=s+d;
		n=n/10;
	}
	if(n0%s==0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}


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

void solve(int TestCase) {
    string s, t;
    cin >> s >> t;
    auto ret = 0;
    for(auto i = 0; i < s.size(); ++i) ret += (s[i] != t[i]);
    cout << ret << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int t = 1;
    //cin >> t;
    for(auto i = 1; i <= t; ++i) {
        //cout << "Case #"<< i << ": ";
        solve(i);
    }
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < (n); i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, k, n) for (int i = (k); i < (n); i++)
#define REPEACH(itr, k) for (auto &&itr : k)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;


const ll INF = 1ll << 60;
const ll MOD = 1000000007;
vector<int> v;

int main()
{
    long long n,m;
    cin >> n >> m;
    if(n*2>=m){
        cout << m/2 << endl;
    }
    else{
        cout << n+(m-n*2)/4 << endl;
    }
}

Measured memory_bytes: 256
import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    H, W = map(int, rl().split())
    ch, cw = map(lambda n: int(n) - 1, rl().split())
    dh, dw = map(lambda n: int(n) - 1, rl().split())
    S = [rl().rstrip() for _ in range(H)]
    
    INF = 10 ** 9
    costs = [[INF] * W for _ in range(H)]
    que = deque([(0, ch, cw)])
    while que:
        cost, cy, cx = que.popleft()
        if cy == dh and cx == dw:
            print(cost)
            return
        for dy, dx in ((-1, 0), (0, 1), (1, 0), (0, -1)):
            ny, nx = cy + dy, cx + dx
            if 0 <= ny < H and 0 <= nx < W:
                if S[ny][nx] == '#':
                    continue
                if costs[ny][nx] <= cost:
                    continue
                que.appendleft((cost, ny, nx))
                costs[ny][nx] = cost
        for dy in range(-2, 3):
            for dx in range(-2, 3):
                ny, nx = cy + dy, cx + dx
                if 0 <= ny < H and 0 <= nx < W:
                    if S[ny][nx] == '#':
                        continue
                    if costs[ny][nx] <= cost + 1:
                        continue
                    que.append((cost + 1, ny, nx))
                    costs[ny][nx] = cost + 1
    print(-1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 123732
N = int(input())
L = list(map(int, input().split()))
ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            L1 = L[i]
            L2 = L[j]
            L3 = L[k]
            if (L1 != L2 and L2 != L3 and L3 != L1) and (L1 + L2 > L3 and L2 + L3 > L1 and L3 + L1 > L2):
                ans += 1

print(ans)

Measured memory_bytes: 68180
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <functional>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

typedef pair<int,int> P;

struct compare {
  bool operator () (const P& a, const P& b) const {
    if(a.second != b.second) return (a.second > b.second);
    return a.first < b.first;
  }
};

int main(){
  int i,j;
  int N,M;
  int a[1010][110];
  P d[110]; // < index, data >

  while(1){
    scanf("%d %d",&N,&M);
    if(N == 0 && M == 0) break;

    rep(i,N) rep(j,M) scanf("%d",&a[i][j]);
    rep(j,M){
      int t = 0;
      rep(i,N) t += a[i][j];
      d[j].first = j+1;
      d[j].second = t;
    }

    sort(d,d+M,compare());
    rep(i,M){
      cout << d[i].first;
      if(i != M-1) cout << ' '; else cout << endl;
    }
  }

  return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	string c;
	cin >> c;
	cout << char ((c[0] - 'a' + 1) % 26 + 'a') << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int a, b;
  cin >> a >> b;
  for (int i = 1; i < 4; i++) {
    if (i == a || i == b) continue;
    cout << i << endl;
  }
  return 0;
}

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

using namespace std;

int N, M;
char arr[1004][1004];
int q[1004*1004][4], f, r;
int wx[5] = {-1, 0, 1, 0}, wy[5] = {0, 1, 0, -1};

int main(){
    scanf("%d %d", &N, &M);
    for(int i = 1; i <= N; ++i) scanf("%s", arr[i]+1);
    for(int i = 1; i <= N; ++i) for(int j = 1; j <= M; ++j) if(arr[i][j] == '#'){
        q[r][0] = i, q[r][1] = j, q[r++][2] = 0;
    }
    while(f < r){
        for(int i = 0; i < 4; ++i){
            int nx = q[f][0] + wx[i], ny = q[f][1] + wy[i];
            if(arr[nx][ny] == '.'){
                q[r][0] = nx, q[r][1] = ny, q[r++][2] = q[f][2] + 1;
                arr[nx][ny] = '#';
            }
        }
        ++f;
    }
    printf("%d\n", !f ? 0 : q[f-1][2]);
    return 0;
}


Measured memory_bytes: 17532
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,k; cin>>n>>k;
    vector<int> p(n);
    rep(i,n) cin>>p[i];

    int ans = 0;
    sort(p.begin(), p.end());
    rep(i,k) ans+=p[i];
    cout << ans << '\n';
    return 0;
}

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

using namespace std;

#define ll long long 
#define REPL(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
static const int MAX = 10010;
static const ll INFTY = 1e12;
static const ll NUMMAX = 1000000007;
static const ll MOD = 1000000007;
 #define LOOP 10000000


int main() {

    int N, K, R, S, P;
    string T;
    ll ans = 0;
    
    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;

    REP( i, N ){
        if( T[i] == 'r' ){
            if( i >= K && T[i-K] == 'r' ){
                T[i] = 'A';
            } else {
                ans += P;
            }
        } else if( T[i] == 's' ){
            if( i >= K && T[i-K] == 's' ){
                T[i] = 'A';
            } else {
                ans += R;
            }
        } else{
            if( i >= K && T[i-K] == 'p' ){
                T[i] = 'A';
            } else {
                ans += S;
            }
        }
    }
    cout << ans << endl;
   // cout << T << endl;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct node{
  int key;
  struct node *left,*right,*parent;
}node;
typedef struct node* Node;


Node root,NIL;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = (Node)malloc(sizeof(node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}


void inorder(Node r){
  if(r == NIL) return;
  inorder(r->left);
  printf(" %d",r->key);
  inorder(r->right);
}


Node find(int k){
  Node x = root;
  while(x != NIL && k != x->key){ 
    if(k < x->key) x = x->left;
    else x = x->right;
  }
  return x;
}

void preorder(Node r){
  if(r == NIL) return;
  printf(" %d",r->key);
  preorder(r->left);
  preorder(r->right);
}

int main(){
  int m,k,i;
  char string[20];
  scanf("%d",&m);
  for(i = 0; i < m; i++){
    scanf("%s",string);
    if(strcmp(string,"insert") == 0){
      scanf("%d",&k);
      insert(k);
    }
    else if(strcmp(string,"find") == 0){
      scanf("%d",&k);
      if(NIL == find(k))printf("no\n");
      else printf("yes\n");
    }
    else if(strcmp(string,"print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
} 



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

using namespace std;

const int N=1005;
typedef vector<int> Vec;
typedef vector<Vec> Mat;

int main()
{
    int n;
    while(cin>>n)
    {
        Mat mat(N,Vec(N));

        for(int i=0;i<n;i++)
        {
            int x1,y1,x2,y2;
            cin>>x1>>y1>>x2>>y2;
            mat[x1][y1]++;
            mat[x2][y1]--;
            mat[x1][y2]--;
            mat[x2][y2]++;
        }
        int Max=0;
        for(int i=0;i<1001;i++)
        {
            for(int j=0;j<1001;j++)
            {
                Max=max(Max,mat[i][j]);
                mat[i+1][j]+=mat[i][j];
                if(j) mat[i+1][j]-=mat[i][j-1];
                mat[i][j+1]+=mat[i][j];
            }
        }
        cout<<Max<<endl;
    }
}



Measured memory_bytes: 6852
#include <cstdio>
#include <math.h>
using namespace std;
 
int main(){
	char x[1000];
	while(true){
		scanf("%s", x);
		if(x[0] == '0') break;
		int sum = 0;
		for(int i = 0; x[i] != '\0'; ++i){
			sum += x[i] - '0';
		}
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 964
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define print(xx) cout << (xx) << endl
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;

/* 

*/
//================== INPUT ========================
int N;
//=================================================
void input()
{
    cin>>N;

}
//=================================================
void solve()
{
    cout<<((N%111 == 0) ? (111 * (N/111)) : 111 * (N/111 + 1))<<endl;
}

//=================================================
signed main()
{
    input();
    solve();
    return 0;
}

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

unsigned long long achaValorMaximo(unsigned long long valorDosItens[], int pesoDosItens[], int capacidade, int qtdItens)
{
    unsigned long long tabelaDeMaximos[qtdItens + 1][capacidade + 1];

    for (int i = 0; i <= capacidade; i++)
    {
        tabelaDeMaximos[0][i] = 0;
    }
    for (int i = 0; i <= qtdItens; i++)
    {
        tabelaDeMaximos[i][0] = 0;
    }

    for (int i = 1; i <= qtdItens; i++)
    {
        for (int iCapacidade = 1; iCapacidade <= capacidade; iCapacidade++)
        {
            if (pesoDosItens[i - 1] <= iCapacidade)
            {
                if ((valorDosItens[i - 1] + tabelaDeMaximos[i - 1][iCapacidade - pesoDosItens[i - 1]]) > tabelaDeMaximos[i - 1][iCapacidade])
                {
                    tabelaDeMaximos[i][iCapacidade] = valorDosItens[i - 1] + tabelaDeMaximos[i - 1][iCapacidade - pesoDosItens[i - 1]];
                }
                else
                {
                    tabelaDeMaximos[i][iCapacidade] = tabelaDeMaximos[i - 1][iCapacidade];
                }
            }
            else
            {
                tabelaDeMaximos[i][iCapacidade] = tabelaDeMaximos[i - 1][iCapacidade];
            }
        }
    }
    return tabelaDeMaximos[qtdItens][capacidade];
}

int main()
{

    int qtdItens, capacidade;
    cin >> qtdItens >> capacidade;
    int pesoDosItens[qtdItens];
    unsigned long long valorDosItens[qtdItens];
    for (int i = 0; i < qtdItens; i++)
    {
        cin >> pesoDosItens[i] >> valorDosItens[i];
    }

    unsigned long long valorMaximo = achaValorMaximo(valorDosItens, pesoDosItens, capacidade, qtdItens);
    cout << valorMaximo << endl;
}


Measured memory_bytes: 79104
#include <iostream>
#include <string>
#include <map>

int main() {

    const int numberOfStatuses = 4;
    const std::string statuses[] = { "AC", "WA", "TLE", "RE" };

    std::map<std::string, int> counts;

    int n;
    std::cin >> n;

    for (int i=0; i<n; ++i) {
        std::string buf;
        std::cin >> buf;
        counts[buf]++;
    }

    for (int i=0; i<numberOfStatuses; ++i) {
        std::cout << statuses[i]
                  << " x "
                  << counts[statuses[i]]
                  << std::endl;
    }

    return 0;

}

Measured memory_bytes: 3636
def solve():
    MOD = 998244353
    N, K = map(int, input().split())
    LR_L = [[int(x) for x in input().split()] for y in range(K)]
    # S = set()
    # for i in range(K):
    #     _l, _r = map(int, input().split())
    #     _s = set(list(range(_l, _r+1)))
    #     S |= _s

    # dp[i] : iに到達する経路数
    dp = [0] * (N+1)
    dp[1] = 1
    dp[2] = -1
    for i in range(1, N+1):
        dp[i] += dp[i-1]
        dp[i] %= MOD
        # for d in S:
        #     if i-d > 0:
        #         dp[i] = (dp[i] + dp[i-d]) % MOD
        for li, ri in LR_L:
            if i + li < N+1:
                dp[i+li] += dp[i]
                dp[i+li] %= MOD
            if i + ri + 1 < N+1:
                dp[i+ri+1] -= dp[i]
                dp[i+ri+1] %= MOD
    print(dp[N])


solve()


Measured memory_bytes: 16860
n, k = gets.split.map { |t| t.to_i }
a    = gets.split.map { |t| t.to_i }

s = b = a.first(k).sum

(k ... n).each do |i|
  
  s += a[i] - a[i-k]
  
  if b < s
    puts "Yes"
  else
    puts "No"
  end
  
  b = s
end

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

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int arr[n];
    map<int,int>order;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        order[arr[i]]=i+1;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<order[i]<<" ";
    }
    
}

Measured memory_bytes: 8652
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
const long double eps = 1e-12;
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*2
#define REP(a,b) for(long long a = 0;a < b;++a)
long long inputs[300000];
long long dp[300000];
int main() {
	long long n,k;
	cin >> n >> k;
	REP(i, n) {
		cin >> inputs[i];
		if (i != 0) {
			dp[i] = 1e9;
			for (int q = 1; q <= k&&i-q >= 0; ++q) {
				dp[i] = min(dp[i],dp[i - q] + abs(inputs[i] - inputs[i - q]));
			}
		}
	}
	cout << dp[n - 1] << endl;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int res = 0;
    for (int i = 2; i < n; ++i) {
        string ch1 = {s[i-2]};
        string ch2 = {s[i-1]};
        string ch3 = {s[i]};
        string check = ch1 + ch2 + ch3;
        if (check == "ABC") ++res;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	ll ans = 0;
	for (int i = 1; i <= N-1; i++)
	{
		ans += i;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const ll INF = 1LL << 60;

int N;
ll dp[100010];
ll H[100010];

ll rec(int i){
    if(dp[i]<INF)return dp[i];
    if(0 == i)return 0;
    
    ll res = INF;
    chmin(res,rec(i-1)+abs(H[i]-H[i-1]));
    if(1 < i) chmin(res,rec(i-2)+abs(H[i]-H[i-2]));

    return dp[i]=res;
}

int main()
{
    cin >> N;
    REP(i,100010)dp[i]=INF;
    REP(i,N)cin >> H[i];
    cout << rec(N-1) << endl;
}

Measured memory_bytes: 9832
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
using namespace std;
 
using ll = long long;
const int INF = 1001001001;
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
 
int main()
{
  int n;
  string s;
  int q;
  cin >> n >> s >> q;
 
  vector<set<int>> man(26);
  rep(i,s.size()) man[s[i] - 'a'].insert(i+1);
  rep(i,q) {
    int what;
    cin >> what;
    if (what == 1) {
      int num;
      char chara;
      cin >> num >> chara;
      rep(j,26) {
        if (man[j].find(num) != man[j].end()) {
          man[j].erase(num);
        }
      }
      man[chara - 'a'].insert(num);
    } else {
      int l;
      int r;
      cin >> l >> r;
      int count = 0;
      rep(j,26) {
        // find larger than l
        auto itr = man[j].lower_bound(l);
        if (itr != man[j].end() && *itr <= r) {
          count++;
        }
      }
      cout << count << endl;
    }
  }
}

Measured memory_bytes: 24196
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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

        while (true) {
            int y = scanner.nextInt(), x = scanner.nextInt();

            if (x == 0 && y == 0) break;

            for (int i = 0; i < y; ++i) {
                for (int j = 0; j < x; ++j) {
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 34420
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> A(M);
  rep(i, M)
  {
    cin >> A[i];
  }
  int ans = 0;
  int rcount = 0;
  int lcount = 0;
  for (int i = 0; i < M; i++)
  {
    if (A[i] < X)
    {
      ++lcount;
    }
    else
    {
      ++rcount;
    }
  }
  ans = min(rcount, lcount);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	long long sum=0;
	long long n,a,b;
	cin>>n>>a>>b;
	long long t=n%(a+b);
	long long f=n/(a+b);
	sum+=f*a;
	if(t<a) sum+=t;
	else sum+=a;
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
l = int(input())
r = len(bin(l)[2:])-1

w = 2**r
outlist = []

for t in range(r,0, -1):
    if l - 2**r >= 2**(t-1):
        outlist.append("{} {} {}".format(t, r+1, w))
        w += 2**(t-1)
        l = l-2**(t-1)

print(r+1, len(outlist)+2*r)
for i in range(1, r+1):
    print("{} {} 0".format(i, i+1))
    print("{} {} {}".format(i, i+1, 2**(i-1)))
for j in outlist:
    print(j)

Measured memory_bytes: 3064
#include<stdio.h>

int main(void) {
	long N, A, B;
	long b_count;
	scanf("%ld %ld %ld", &N, &A, &B);

	b_count = (N / (A + B)) * A;
	if (A >= N % (A + B)) {
		b_count += N % (A + B);
	}
	else {
		b_count += A;
	}

	printf("%ld\n", b_count);

	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ALL(A)		(A).begin(),(A).end()
#define DUMP(A)    cout<<#A<<"="<<(A)<< endl
#define SIZE(A)    (int)((A).size())
using namespace std;
typedef long long ll;

int main(){
    int jun[]={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1};
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int fr,to;
        scanf("%d%d",&fr,&to);
        int mi=INT_MAX,miat;
        for(int j=0;j<15;j++){
            if(jun[j]==fr){
                for(int k=0;k<15;k++){
                    if(jun[(j+k)%15]==to){
                        if(k<mi){
                            mi=k;
                            miat=j;
                            break;
                        }
                    }
                }
            }
        }
        for(int j=0;j<=mi-1;j++){
            printf("%d ",jun[(j+miat)%15]);
        }
        printf("%d\n",jun[(mi+miat)%15]);
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  string s, t;
  cin >> s >> t;
  string rv = t;
  rep(i, t.size()){
    if(s == t){
      cout << "Yes" << endl;
      return 0;
    }
    string nx = t.substr(1);
    nx.push_back(t.front());
    t = nx;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    int n;cin>>n;
    ll sum = 0;
    vll a(n);
    map<ll, ll> m;
    rep(i, n){
        cin>>a[i];
        int t = m[a[i]-(i+1)];
        m[a[i]-(i+1)]++;
        //sum += a[i]-(i+1);
    }
    //sort(all(m));
    ll counter = 0;
    ll b;
    for(auto itr = m.begin(); itr != m.end(); ++itr){
        debug("%d %d %d\n", counter, itr->first, itr->second);
        counter += itr->second;
        if(counter >= (n+1)/2){
            b = itr->first;
            break;
        }
    }
    debug("%d\n", b);
    //ll avg = (ll)round((double)sum/n);
    ll ans = 0;
    rep(i, n){
        ans += abs(a[i]-(i+1)-b);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14336
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n;
    //vector<vector<ll>> v(tate,vector<ll> (yoko));
    vector<ll> v(n);
    vector<ll> muri(n);
    rep(i,n)   cin >> v[i];
    sort(all(v));
    rep(i,n-1){
        sum+=v[i];
        if(sum*2<v[i+1]){
            //sum=0;
            maxi=i+1;
        }
    }
    cout<<n-maxi<<endl;
    return 0;
}

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

//--------------------------------------------
#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(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

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

  scanf("%d %d %d",&a,&b,&c);

  bool flag = false;
  int sum = a;
  REP (i, b) {
    if (sum % b == c) {
      flag = true;
      break;
    }
    sum += a;
  }

  if (flag) printf("YES\n");
  else printf("NO\n");
}


Measured memory_bytes: 256
N,M = map(int,input().split())
X = list(map(int,input().split()))
if N>=M:
    print(0)
else:
    X = sorted(X)
    A = []
    for i in range(1,M):
        A.append(X[i]-X[i-1])
    A = sorted(A)
    print(sum(A[:M-N]))

Measured memory_bytes: 13968
#include <iostream>

using namespace std;

int main() {
    int a, b, c, x, count = 0;
    cin >> a >> b >> c >> x;
	for (int i = 0; i < a+1; i++){
    	for (int j = 0; j < b+1; j++){
        	if((x - 100*j - 500*i)>=0 & (x-100*j - 500*i)/50 <= c){
            	count++;
            }
        }
    }
  
    cout << count << endl;
  return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

using namespace std;
using ll = long long;

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 dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};


//////////////////////////////////////////////////


int main() {
    int n; cin >> n;
    vector<int> p(n), q(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> q[i];
    }
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        a[i] = i+1;
    }
    

    int cnt = 0;
    int b, c;
    do {
        cnt++;
        bool ok = true;
        for (int i = 0; i < n; i++)
        {
            if (p[i] != a[i]) ok = false;
        }
        if (ok) b = cnt;

        ok = true;
        for (int i = 0; i < n; i++)
        {
            if (a[i] != q[i]) ok = false;
        }
        if (ok) c = cnt;

    } while(next_permutation(a.begin(), a.end()));

    cout << abs(b-c) << endl;
    
    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int a, b, c;

int main() {
	cin >> a >> b >> c;
	if (a*b*c==175) cout << "YES" << ln;
	else cout << "NO" << ln;
}

Measured memory_bytes: 256
#![allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
use std::collections::HashMap;
fn main() {
    let _n: usize = read();
    let a: Vec<i64> = read_vec();
    let q: usize = read();
    let mut hm = HashMap::new();
    let mut ans = 0;
    for i in a {
        *hm.entry(i).or_insert(0) += 1;
        ans += i;
    }
    for _ in 0..q {
        let bc: Vec<i64> = read_vec();
        if let Some(&x) = hm.get(&bc[0]) {
            ans += (bc[1] - bc[0]) * x;
            *hm.entry(bc[1]).or_insert(0) += x;
            *hm.entry(bc[0]).or_insert(0) = 0;
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 7080
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef long long LL;

#ifdef __GNUC__
#define int128_t __int128
#else
typedef LL int128_t;
#endif

int main(int argc, char* argv[]) {
	LL x, k, d;
	cin >> x >> k >> d;
	if (x < 0) x = -x;
	LL r = (x + d - 1) / d;
	if (d >= x && k >= 9) {
		k = 8 + (k % 8);
	}
	int128_t X = x, K = k, D = d, kd = K * D;
	if (kd <= X) {
		x -= k * d;
		k = 0;
	} else if (k >= 100) {
		LL a = x % d;
		LL b = x - a;
		r = b / d;
		if (k >= r) {
			k -= r;
			x -= r * d;
			if (k >= 8) {
				k = 8 + (k % 8);
			}
		}
	}
	vector<LL> q;
	q.push_back(x);
	for (int t = 0; t < k; ++t) {
		vector<LL> nq;
		for (auto a : q) {
			nq.emplace_back(a - d);
			nq.emplace_back(a + d);
		}
		q = nq;
	}
	LL ans = 1LL << 60;
	for (auto a : q) {
		ans = min(ans, abs(a));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3872
// AOJ 2415: Sashimi
// 2017.12.8 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef long long ll;

ll w[4001];
char buf[48002], *p;
ll dp[4001][4001];
int k[4001][4001];

ll getlong()
{
	ll n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	p++;
	return n;
}

int main()
{
	int n, i, j, a, b;
	ll c;

	fgets(buf, 10, stdin), n = atoi(buf);
	fgets(p=buf, sizeof(buf), stdin);
	w[0] = getlong();
	for (i = 1; i < n; i++) w[i] = w[i-1] + getlong();

	memset(dp, 0x33, sizeof(dp));
	for (i = 0; i < n; i++) dp[i][i] = 0, k[i][i] = i;

	for (a = 1; a <= n; a++) for (i = 0, j = a; j < n; i++, j++) {
		for (b = k[i][j-1]; b <= k[i+1][j]; b++) {
			c = dp[i][b] + dp[b+1][j] + w[j];
			if (i > 0) c -= w[i-1];
			if (dp[i][j] > c) dp[i][j] = c, k[i][j] = b;
		}
	}
	printf("%lld\n", dp[0][n-1]);
	return 0;
}

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

typedef pair<int, int> pii;
typedef pair<double, int> pdi;
const int M = 1000000007;

double prim_cost(vector<vector<pdi>> edge) {
    int n = edge.size();
    vector<int> vis(n, 0);
    double c = 0;
    priority_queue<pdi> q;
    q.push(pdi(0, 0));
    while (!q.empty()) {
        pdi p = q.top();
        q.pop();
        if (vis[p.second]) continue;
        vis[p.second] = 1;
        c += p.first;
        for (auto& e : edge[p.second]) {
            if (!vis[e.second]) {
                q.push(pdi(e.first, e.second));
            }
        }
    }
    return c;
}

double norm(int x, int y) {
    return sqrt(x * x + y * y);
}

double dist(pii& p, pii& q) {
    return norm(p.first - q.first, p.second - q.second);
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<pii> coord(n);
    vector<vector<pdi>> edge(n);
    for (int i = 0; i < n; ++i) {
        cin >> coord[i].first >> coord[i].second;
        edge[i].push_back(pdi(0, (i + 1) % n));
    }
    double sum = 0;
    for (int i = 0; i < m; ++i) {
        int p, q;
        cin >> p >> q;
        --p;
        --q;
        double d = dist(coord[p], coord[q]);
        edge[p].push_back(pdi(d, q));
        edge[q].push_back(pdi(d, p));
        sum += d;
    }
    printf("%.9lf\n", sum - prim_cost(edge));
    return 0;
}

Measured memory_bytes: 6764
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const llint INF = 999999999999999999;

struct Edge {
  llint to, cost;  // 辺の接続先頂点, 辺の重み
  Edge(llint to, llint cost) : to(to), cost(cost) {}
};
int N;
vector<llint> dist;
vector<vector<Edge> > G;

bool BellmanFord(int N, int start){
    dist = vector<llint>(N, INF);
    dist[start] = 0;
    REP(i, N-1){
        REP(v, N){      // 始点
            REP(k, G[v].size()){
                Edge e = G[v][k];
                if(dist[v] != INF && dist[e.to] > dist[v] + e.cost){
                    dist[e.to] = dist[v] + e.cost;
                }
            }
        }
    }
    vector<bool> nega(N, false);
    REP(i, N){
        REP(v, N){      // 始点
            REP(k, G[v].size()){
                Edge e = G[v][k];
                if(nega[k]) nega[e.to] = true;
                if(dist[v] != INF && dist[e.to] > dist[v] + e.cost){
                    dist[e.to] = dist[v] + e.cost;
                    nega[e.to] = true;
                }
            }
        }
    }
    if(nega[N-1]) return true;
    return false;
}

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

    int M;
    cin >> N >> M;
    G = vector< vector<Edge> >(N);
    REP(i, M){
        llint a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        G[a].pb(Edge(b, -c));
    }
    if(BellmanFord(N, 0)) puts("inf");
    else cout << -dist[N-1] << "\n";
    return 0;
}

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

using Vi = vector<int>;
using Vs = vector<string>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef pair<int, int> P;
typedef long long ll;

const int INF = 10000000, MAX_N = 200000, MAX_M = 1000, MAX_W = 10000;

int asc(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}


int main() {
    int N; cin >> N;
    int dp[100][100], dp2[100][100];
    rep(i, 100) {
        rep(j, 100) {
            dp[i][j] = 0;
            dp2[i][j] = 0;
        }
    }
    
    rep(i,N + 1) {
        int a, b;
        b = i % 10;
        int p = i;
        while (p>9) {
            p /= 10;
        }
        a = p;
        dp[a][b] += 1;
        dp2[a][b] += 1;
    }

    int ans = 0;
    rep(a, 10) {
        rep(b, 10) {
            ans += dp[a][b] * dp2[b][a];
        }
    }
    cout << ans - 1 << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(void){
	ll n;
	cin >> n;
	char s[n + 1];
	cin >> s;
	ll cnt = 0;
	for(int i = 0; i < n - 1; i++){
		if(s[i] == 'O'){
			if(s[i + 1] == 'X') cnt++, i++;
		} else {
			if(s[i + 1] == 'O') cnt++, i++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
#define MAXN 1000000007
 
 
int main() {
	ll a,b;
	cin>>a>>b;
	cout<<a*b<<' '<<2*a+2*b<<endl;
}
	


Measured memory_bytes: 3084
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete


main = map (apply2 (-)) <$> replicateM 7 getInts >>= mapM_ print
    
    


Measured memory_bytes: 3712
l,r = map(int,input().split())

if r < 2019:
    print(l*(l+1)%2019)
    exit()

ans = 2019
for i in range(l,r):
    for j in range(i+1,r+1):
        ans = min(ans,(i*j)%2019)
        if ans == 0:
            print(0)
            exit()

print(ans)
    


Measured memory_bytes: 2940
A = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
S = list(input())
for s in S:
    if s in A:
        A.remove(s)
if A:
    print(A[0])
else:
    print('None')

Measured memory_bytes: 3956