akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

int field[109][109];

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    
    mem(field,-1);
    
    int i=0, j=0, d=0;
    int di[] = { 0, 1, 0, -1};
    int dj[] = { 1, 0, -1, 0};
    rep1(c,N){
        int n; cin >> n;
        
        for(int k=0; k<n; k++){
            
            field[i][j] = c;
            
            if( i+di[d] < 0 || i+di[d] >= H || j+dj[d] < 0 || j+dj[d] >= W || field[i+di[d]][j+dj[d]]!=-1) d = (d+1)%4;
            
            i += di[d];
            j += dj[d];
        }
    }
    
    rep(i,H){
        rep(j,W){
            if(j)cout<<" ";
            cout<<field[i][j];
        }
        cout<<endl;
    }
    
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if((a%2==0 && b%2==0 ) ||(a%2==1 && b%2==1))cout << (a+b)/2 << endl;
  else cout << 1+(a+b)/2 << endl;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for (int i = 0; i < s.size() - 2; ++i) {
    if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
      ++ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
{-# LANGUAGE TupleSections #-}
import Control.Applicative
import Control.Monad
import Data.List
import qualified Data.IntMap as MP
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)

readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

includingBoxes h w [a, b] = [w * x + y |
                            x <- [a - 2, a - 1, a], x >= 0, x <= h - 3,
                            y <- [b - 2, b - 1, b], y >= 0, y <= w - 3]

frequency = MP.toList . MP.fromListWith (+) . map (, 1)

solve h w ls = find <$> [0..9]
    where boxes    = ls >>= includingBoxes h w
          boxFreqs = frequency boxes
          freqs    = frequency . filter (<= 9) . map snd $ boxFreqs
          zeros    = (h - 2) * (w - 2) - length boxFreqs
          find v   = MP.findWithDefault 0 v $ MP.fromList $ (0, zeros):freqs

main = do
    [h, w, n] <- map read . words <$> getLine
    ls        <- replicateM n $ map pred <$> readInts
    mapM print $ solve h w ls


Measured memory_bytes: 212348
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
bool b[33000];
int main() {	
	fill(b, b + 33000, true);
	b[0] = false;
	b[1] = false;
	for (int i = 2; i < 33000; i++) {
		if (b[i]) {
			int j = 2;
			while (i*j < 33000) {
				b[i*j] = false;
				j++;
			}
		}
	}
	int n;
	while (cin >> n&&n != 0) {
		int sum = 0;
		for (int i = 0; i <= n / 2; i++) {
			if (b[i] && b[n - i]) {
				sum++;
			}
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

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

	cin >> a >> b >> c;

	if ((c - a - b > 0) &&
		(4 * a * b < (c - a - b) * (c - a - b))) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


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

#define mod 1'000'000'007
typedef long long ll;

template<typename T>
void deb(initializer_list<T> l)
{
	for (auto &e : l)
		cout << e << ' ';
	cout << endl;
}

void solve()
{
	int n;
	cin >> n;
	int x = ceil(n / 1000.0);
	x *= 1000;
	cout << x - n;
}

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

	int t = 1;
	// cin >> t;
	while (t--)
		solve();

	return 0;
}


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

#define int long long int
const int mxN = 1e5+10;
int n, k, a[mxN];
int dp[mxN];

int play(int rem) {         
    if(rem < 0)
        return 1;

    if(dp[rem] != -1)
        return dp[rem];
    
    int ans = 0;
    for(int i=1; i<=n; i++)
        ans = ans | play(rem-a[i]) ^ 1;

    return dp[rem] = ans;
}

void solve() {
    cin >> n >> k;
    for(int i=1; i<=n; i++)
        cin >> a[i];

    memset(dp, -1, sizeof(dp));

    if(play(k))   
        cout << "First\n";
    else 
        cout << "Second\n";
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 4224
package main

import "fmt"

func main() {

	var S string
	fmt.Scanf("%s", &S)

	var count int
	for i := 0; i < len(S)/2; i++ {
		if S[i] != S[len(S)-1-i] {
			count++
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 1840
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

struct tri{
  ll f,s,t;
};

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;ll K;cin >> N >> K;
  vector<PII> v(N);
  ll b;
  b = K+2*N-1;
  int index = 0;
  if(2*K-1>N){
    cout << -1 << endl;
    return 0;
  }
  repp(x,K,K+N){
    if((x&1)==0)continue;
    v[index].first = x+b;
    v[index].second = x;
    ++index;
    --b;
  }
  repp(x,K,K+N){
    if(x&1)continue;
    v[index].first = x+b;
    v[index].second = x;
    ++index;
    --b;
  }

  sort(all(v));
  ll c = K+2*N;
  queue<tri> que;
  rep(i,N){
    if(v[i].first>c){
      cout << -1 << endl;
      return 0;
    }
    que.push({v[i].second,v[i].first-v[i].second,c});
    ++c;
  }
  while(!que.empty()){
    tri t = que.front();que.pop();
    cout << t.f SP t.s SP t.t << endl;
  }
  return 0;
}


Measured memory_bytes: 5504
local n = io.read("*n")
local ans = 1
io.read()
local str = io.read("*l")
for i = 1, n-1 do
  if string.sub(str, i, i) ~= string.sub(str, i+1, i+1) then
    ans = ans + 1
  end
end
print(ans)

Measured memory_bytes: 1008
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		int team[];
		int ranking[];
		int rankNumber;
		int max;
		int count;

		n = sc.nextInt();
		team = new int[n];
		ranking = new int[n];
		rankNumber = 1;
		max = 0;
		count = 0;

		for (int i = 0; i < n * (n - 1) / 2; i++) {
			int j = sc.nextInt();
			int k = sc.nextInt();
			int l = sc.nextInt();
			int m = sc.nextInt();
			if (m < l) {
				team[j - 1] += 3;
			} else if (l == m) {
				team[j - 1] += 1;
				team[k - 1] += 1;
			} else {
				team[k - 1] += 3;
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (max < team[j]) {
					max = team[j];
				}
			}
			for (int j = 0; j < n; j++) {
				if (team[j] == max) {
					ranking[j] = rankNumber;
					team[j] = -1;
					count++;
				}
			}
			rankNumber += count;
			count = 0;
			max = 0;
		}
		for (int i = 0; i < n; i++) {
			System.out.println(ranking[i]);
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<utility>
#include<tuple>
#include<cmath>

using namespace std;
typedef long long ll;

int main(){
    double a,b,x;cin >> a >> b >> x;
    double s = x/a;
    double ans;
    double c;
    #if TEST
        cout << s << endl;
    #endif
    if(a*b/(double)2 >s){
        c = (s*(double)2)/(double)b;
        ans = atan((double)b/(double)c);
    }
    else{
        c = 2*(a*b-s)/a;
        ans = atan((double)c/(double)a);
    }
    #if TEST
        cout <<  c << endl;
        cout << ans << endl;
    #endif
    ans =(ans/(double)M_PI)*(double)180;
    printf("%.7f\n",ans);
    return 0; 
}

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

const int B = 8000;

int N;
int xs[2];
char buf[114514];
bool dp[2][2][2*B+1];
vector<int> nums[2];

int main() {
  scanf("%s", buf);
  N = strlen(buf);
  for (int k=0; k<2; k++) {
    scanf("%d", &xs[k]);
  }

  int t = 0;
  for (; t<N; t++) {
    if (buf[t] == 'T') break;
    xs[0]--;
  }

  int grp = 0;
  int cnt = 0;
  for (; t<N; t++) {
    if (buf[t] == 'T') {
      if (cnt > 0) nums[grp].emplace_back(cnt);
      grp ^= 1;
      cnt = 0;
    } else {
      ++cnt;
    }
  }
  if (cnt > 0) nums[grp].emplace_back(cnt);

  for (int k=0; k<2; k++) {
    int src = 0;
    int dst = 1;

    dp[k][src][B] = true;
    for (int d : nums[k]) {
      for (int j=-B; j<=B; j++) {
        if (!dp[k][src][B+j]) continue;
        if (-B <= j-d) dp[k][dst][B+j-d] = true;
        if (j+d <= B) dp[k][dst][B+j+d] = true;
      }

      swap(dst, src);
      fill(dp[k][dst], dp[k][dst]+2*B+1, false);
    }

    if (xs[k] < -B || B < xs[k] || !dp[k][src][B+xs[k]]) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}


Measured memory_bytes: 384
def main():
    A = int(input())
    B = int(input())
    C = int(input())
    X = [[0] * 3 for _ in range(3)]
    X[0][0] = A
    X[0][1] = B
    X[1][1] = C
    X[2][0] = A + B - C
    X[2][2] = B + C - X[2][0]
    total = A + C + X[2][2]
    X[0][2] = total - A - B
    X[1][0] = total - A - X[2][0]
    X[1][2] = total - X[1][0] - C
    X[2][1] = total - B - C
    for i in range(3):
        print(*X[i])


if __name__ == "__main__":
    main()


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

using namespace std;

using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    char a;
    cin >> a;
    for (char i = 'a'; i <='z'; ++i) {
        if (i == a) {
            cout << 'a' << '\n';
            return;
        }
    }
    cout << 'A' << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


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

int main(){
 int N,A,B;
  cin >> N >> A >> B;
  int plan1,plan2;
  plan1 = A * N;
  plan2 = B;
  
  if(plan1 < plan2){//値段小さいほう
   cout << plan1 << endl; 
  }else{
   cout << plan2 << endl;
  }
}

Measured memory_bytes: 256
program ABC154D
    implicit none
    integer(8)::N,K,i
    real(8)::result=0
    real(8),allocatable,dimension(:)::P,E
    read(5,*)N,K
    allocate(P(N))
    allocate(E(N))
    read(5,*)(P(i),i=1,N)

    do i=1,N
        if(i==1)then
            E(i)=((P(i)*(P(i)+1))/2)/P(i)
        else
            E(i)=E(i-1)+((P(i)*(P(i)+1))/2)/P(i)
        end if
    end do

    do i=K,N
        if(i==K)then
            if(E(i)>result)result=E(i)
        else if(E(i)-E(i-K)>result)then
            result=E(i)-E(i-K)
        end if
    end do

    print'(f0.10)',result
end program ABC154D

Measured memory_bytes: 3968
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
#include<cstring>
using namespace std;

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

enum {migi, hidari, mae, ushiro, ccw, cw};
int dx[] = {0,0,1,-1,0,0};
int dy[] = {1,-1,0,0,0,0};
int op[7][4] = {
  {0,0,0,0},
  {6,6,3,3},
  {4,4,5,5},
  {5,5,1,1},
  {2,2,6,6},
  {3,3,2,2},
  {1,1,4,4},
};

int roll(int old, int dir) {
  return op[old][dir];
}

const int EMPTY = 0;
const int WHITE = 0;
const int BLUE = 1;
const int RED = 2;

char goal[3][3];

struct State {
  int step;
  char t[3][3];

  int HashCode() {
    int h = 0;
    REP(i, 3) REP(j, 3) {
      h = h * 7 + t[i][j];
    }
    return h;
  }
};

State Decode(int h, int step) {
  State state;
  state.step = step;
  for(int i = 2; i >= 0; i--)
    for(int j = 2; j >= 0; j--){
      state.t[i][j] = h % 7;
      h /= 7;
    }
  return state;
}

bool isGoal( State &state ) {
  REP(i, 3) REP(j, 3) {
    if( goal[i][j] == 'E' ) {
      if( state.t[i][j] != EMPTY ) return false;
    }
    if( goal[i][j] == 'W' ) {
      if( state.t[i][j] != 1 && state.t[i][j] != 2 ) return false;
    }

    if( goal[i][j] == 'B' ) {
      if( state.t[i][j] != 3 && state.t[i][j] != 4 ) return false;
    }

    if( goal[i][j] == 'R' ) {
      if( state.t[i][j] != 5 && state.t[i][j] != 6 ) return false;
    }
  }
  return true;
}

unsigned char visited[(40353607 + 7) / 8];

bool GetVisited(int h) {
  return visited[h >> 3] & (1 << (h & 7));
}

void SetVisited(int h) {
  visited[h >> 3] |= (1 << (h & 7));
}

int Solve(int x, int y) {
  memset(visited, 0, sizeof(visited));

  State start;
  start.step = 0;
  REP(i, 3) REP(j, 3) {
    if( x == i && y == j ) {
      start.t[i][j] = EMPTY;
    } else {
      start.t[i][j] = 1;
    }
  }

  queue<State> up;
  up.push( start );
  SetVisited( start.HashCode() );

  while( !up.empty() ) {
    State cur = up.front();
    up.pop();

    if( cur.step > 30 ) break;

    if( isGoal( cur ) ) {
      return cur.step;
    }

    REP(x,3) REP(y, 3) {
      if( cur.t[x][y] == EMPTY ) {
        REP(k, 4) {
          int nx = x - dx[k];
          int ny = y - dy[k];
          if( 0 <= nx && nx < 3 && 0 <= ny && ny < 3 ) {
            State next = cur;

            next.t[x][y] = roll(cur.t[nx][ny], k);
            next.t[nx][ny] = EMPTY;

            int h = next.HashCode();
            if( GetVisited(h) )continue;
            SetVisited( h );

            next.step++;
            up.push( next );
          }
        }
        break;
      }
    }
  }

  return -1;
}

int main() {
  while( 1 ) {
    int x, y;
    scanf("%d%d", &x, &y);
    if( x == 0 && y == 0 ) break;

    REP(i, 3) REP(j, 3) {
      scanf(" %c", &goal[j][i]);
    }

    cout << Solve(x - 1, y - 1) << endl;
  }
  return 0;
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int a, b, c, d, n, x, y;
    string s, t;


    auto Yes = [&](bool t){
        cout << (t ? "Yes" : "No") << endl;
    };
    auto YES = [&](bool t){
        cout << (t ? "YES" : "NO") << endl;
    };
    auto tri = [&](bool t, string a, string b){
        cout << (t ? a : b) << endl;
    };

    cin >> s;
    for(auto& x : s){
        if(x == '1')
            t.push_back('1');
        else if(x == '0')
            t.push_back('0');
        else if(t.size())
            t.pop_back();
    }
    cout << t << endl;
}


Measured memory_bytes: 256
S = input()
N = len(S)
num = 0
i=0
X=num%2
while num<N:
  if S[num] == "0":
    i+=1
  if not num==X+N-1:
    if S[num+1] == "1":
      i+=1
  num+=2
if N-i>i:
  print(i)
else:
  print(N-i)


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

// template {{{
/* vim: set foldmethod=marker: */

// constant
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const double PI = acos(-1);
#define EPS 1e-14

// typedef
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;

// input
inline int inputi(){ int x; scanf("%d", &x); return x; }
inline double inputd(){ double x; scanf("%lf", &x); return x; }
inline string inputs(){ string x; cin >> x; return x; }

// short
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

// repetition
#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--)
#define REPit(type, i, obj) for (type::iterator i = (obj).begin(); i != (obj).end(); i++)
#define RREPit(type, i, obj) for (type::iterator i = (obj).rbegin(); i != (obj).rend(); i++)

// container util
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define sz(obj) ((int)(obj).size())
#define sort(obj) sort(all(obj))
#define exist(obj, key) ((obj).find(key) != (obj).end())
#define clear(array) memset((array), 0, sizeof(array))

// print util
#define print(x) cout << (x) << endl
template <class T> inline void printall(vector<T> v){ REP(i, sz(v)) cout << v[i] << "\n "[i < sz(v) - 1]; }
#define dump(x) cerr << #x << ": " << (x) << endl
#define debug(x) cerr << #x << ": " << (x) << " (" << __LINE__ << ")" << endl

//template }}}

int main()
{
    int n;
    while (n = inputi(), n){
        int cnt = 0;
        while (n != 1){
            n = n % 2 ? n * 3 + 1 : n / 2;
            cnt++;
        }
        print(cnt);
    }

    return 0;
}

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

ll mod = 1e9 + 7;

vector<int> primes;
const int sieve_size = 1000;
vector<bool> sieve(sieve_size + 1, true);
void prime_sieve() {
  sieve[0] = false;
  sieve[1] = false;
  for (int i = 2; i <= sieve_size; i++) {
    if (!sieve[i])
      continue;
    primes.push_back(i);
    for (int j = i * i; j <= sieve_size; j += i)
      sieve[j] = false;
  }
}

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

  prime_sieve();

  vector<int> v(N + 1, 0);
  for (int i = 1; i <= N; i++) {
    int n = i;
    for (auto p : primes) {
      while (n % p == 0) {
        v[p]++;
        n /= p;
      }
      if (p > i)
        break;
    }
  }

  ll ans = 1;
  rep(i, N + 1) if (v[i] != 0) ans = ans * (v[i] + 1) % mod;
  cout << ans << endl;
}

Measured memory_bytes: 256
c1,d=gets.chomp.split(' ').map{|n| n}
c2,d=gets.chomp.split(' ').map{|n| n}

if(c1[0]==c2[2] && c1[1]==c2[1] && c1[2]==c2[0])
	puts "YES"
else
	puts "NO"
end


Measured memory_bytes: 1788
//三角形两边之和大于第三边 

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<utility>
#include<set>

using namespace std;

const int maxn=200010;

struct node 
{
	int x,y;
};

int n;
node town[maxn];

pair<int,int> xx[maxn],yy[maxn];

int dist(int x,int y)
{
	return min(abs(town[x].x-town[y].x),abs(town[x].y-town[y].y));
}

///union find set
int par[maxn];
void reset()
{
	for(int i=0; i<maxn; i++)
	{
		par[i]=i;
	}
}
int find(int x)
{
	if(par[x]!=x)
	{
		return par[x]=find(par[x]);
	}
	return x;
}
bool unite(int x,int y)
{
	int fax=find(x),fay=find(y);
	if(fax==fay)return 1;
	if(fax==y)return 0;
	par[fax]=fay;
	return 1;
}
bool same(int x,int y)
{
	if(find(x)==find(y))return 1;
	return 0;
}
///////////////////


int main()
{
	ios::sync_with_stdio(0);
	reset();
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>town[i].x>>town[i].y;
		xx[i]=make_pair(town[i].x,i);
		yy[i]=make_pair(town[i].y,i);
	}
	
	sort(xx+1,xx+n+1);
	sort(yy+1,yy+n+1);
	
	set<pair<int,pair<int,int> > > edge;
	
	for(int i=1;i<n;i++)//n+1
	{
		edge.insert(make_pair(dist(xx[i].second,xx[i+1].second),make_pair(xx[i].second,xx[i+1].second)));
		edge.insert(make_pair(dist(yy[i].second,yy[i+1].second),make_pair(yy[i].second,yy[i+1].second)));
	}
	
	int used=0;
	long long value=0;
	for(set<pair<int,pair<int,int> > >::iterator it=edge.begin();it!=edge.end();it++)//kruskal
	{
		if(used==n-1)break;
		if(find(it->second.first)!=find(it->second.second))
		{
			unite((*it).second.first,(*it).second.second);
			used++;
			value+=(*it).first;
		}
	}
	cout<<value<<'\n';
	return 0;
}

/*
3 1 5 3 9 7 8

6 8 3 4 9 12 19 18 1 13 5 7 6
*/

Measured memory_bytes: 17024
#include <algorithm>
#include <iostream>
#include <vector>

struct Point {
    int x, y;
};
using Points = std::vector<Point>;

bool operator<(const Point& left, const Point& right) {
    if (left.x == right.x)
        return left.y < right.y;
    else
        return left.x < right.x;
}

int main() {
    int n;
    std::cin >> n;

    Points points{};
    for (int i = 0; i < n; ++i) {
        int x, y;
        std::cin >> x >> y;

        Point point;
        point.x = x;
        point.y = y;
        points.push_back(point);
    }

    std::sort(points.begin(), points.end());

    for (auto iter = points.begin(); iter != points.end(); ++iter) {
        Point point = *iter;
        std::cout << point.x << ' ' << point.y << std::endl;
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    int a, b; cin >> a >> b;
    int ans;
    if (a <= 0 && b >= 0) ans = 0;
    else if (a > 0 && b > 0) ans = 1;
    else ans = (b - a) % 2 == 0 ? -1 : 1;

    if (ans == 0) {
        cout << "Zero" << endl;
    }
    else if (ans > 0) {
        cout << "Positive" << endl;
    }
    else {
        cout << "Negative" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int total(int,int,int,int);
int main(){
	int n,k;
	cin>>n>>k;
	int sum=k;
	for(int i=1;i<n;i++){
		sum=sum*(k-1);
	}
	cout<<sum<<endl;
}
int total(int a,int b,int c,int d){
	int sum=a+b+c+d;
	return sum;
}


Measured memory_bytes: 256
import sys,math,copy,queue,itertools,bisect,collections
from heapq import *
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(-1,0),(0,1),(0,-1))

N = NI()
A = [0] + LI()

s = {}
for i in range(1,N+1):
    x = i - A[i]
    if x in s:
        s[x] += 1
    else:
        s[x] = 1

ans = 0
for i in range(1,N):
    x = i + A[i]
    if x in s:
        ans += s[x]
    s[i - A[i]] -= 1
print(ans)

Measured memory_bytes: 115144
from copy import deepcopy
s = input()
t = deepcopy(s)
n = len(s)
flg = 0
x = 2
if s[0] == s[n-1]:
  if n%2:
    print("Second")
  else:
    print("First")
  exit()
for i in range(1,n-1):
  if s[i] == s[0] and flg:
    x += 1
    flg = 0
  elif s[i] == s[n-1] and not flg:
    x += 1
    flg = 1
if (n-x+flg)%2:
  print("First")
else:
  print("Second")


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

#define fo1(i, n) for (int i = 0; i < n; i++)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int((x).size())
using ll = long long; using vi = vector<int>; using ii = pair<int,int>;
const int oo = 0x3f3f3f3f; const ll OO = ll(oo)*oo;
#ifndef DEBUG
#define endl '\n'
#define debugf(...)
#define debug(...)
#else
#define debugf(...) printf(__VA_ARGS__)
#define debug(...) __VA_ARGS__
#endif
const int N = 100005;

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

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

    string s; cin >> s;
    reverse(all(s));
    vi ans;

    int lastGood = 0;
    int lastPos = 0;
    fo1(i, n+1) {
        if (s[i] == '0') {
            lastGood = i;
        }

        if (i - lastPos == m || i == n) {
            if (lastPos == lastGood) {
                cout << -1 << endl;
                return 0;
            }

            ans.emplace_back(lastGood - lastPos);
            lastPos = lastGood;
        }
    }

    reverse(all(ans));
    n = sz(ans);
    fo1(i, n)
        cout << (i ? " " : "") << ans[i];
    cout << endl;

    return 0;
}

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

int main()
{
	int seq[50], len, i, not_inorder=0;
	scanf("%d", &len);

	for (i = 0; i < len; i++)
	{
		scanf("%d", &seq[i]);
	}

	for (i = 0; i < len; i++)
	{
		if (seq[i] != i+1)
		{
			not_inorder++;
		}
	}

	if (not_inorder == 2 || not_inorder == 0)
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
int main(){
int n;
cin>>n;
ll a,b,c,a1,b1,c1;
cin>>a>>b>>c>>a1>>b1>>c1;
V<ll> dp(n+1,0);
for(int i=0;i<=n;i++){
   dp[i]=i;
   if(i>=a)chmax(dp[i],dp[i-a]+a1);
   if(i>=b)chmax(dp[i],dp[i-b]+b1);
   if(i>=c)chmax(dp[i],dp[i-c]+c1);
}
ll ma=dp[n];
V<ll> dp2(ma+1,0);
for(int i=0;i<=ma;i++){
   dp2[i]=i;
   if(i>=a1)chmax(dp2[i],dp2[i-a1]+a);
   if(i>=b1)chmax(dp2[i],dp2[i-b1]+b);
   if(i>=c1)chmax(dp2[i],dp2[i-c1]+c);
}
cout<<dp2[ma]<<endl;
}

Measured memory_bytes: 195712
def inpl(): return [int(i) for i in input().split()]

W, H = inpl()
p = [(int(input()), 0) for _ in range(W)]
q = [(int(input()), 1) for _ in range(H)]
pq = sorted(p+q)
cW = W+1
cH = H+1
ans = 0
for i, j in pq:
    if j == 1:
        ans += i*cW
        cH -= 1
    else:
        ans += i*cH
        cW -= 1
print(ans)

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

int main(){
  int64_t N,C;
  cin>>N>>C;
  vector<int64_t> x(N),v(N);
  for(int i=0;i<N;++i){
    cin>>x[i]>>v[i];
  }

  int64_t ans=0;
  //時計
  vector<int64_t> c(N,0);
  int64_t sum=0;
  for(int i=0;i<N;++i){
    sum += v[i];
    c[i]=sum-x[i];
  }
  vector<int64_t> c_max(N,0);
  c_max[0]=c[0];
  for(int i=1;i<N;++i) c_max[i]=max(c_max[i-1],c[i]);
  //反時計
  vector<int64_t> cc(N,0);
  sum=0;
  for(int i=N-1;i>=0;--i){
    sum += v[i];
    cc[i]=sum-(C-x[i]);
  }
  vector<int64_t> cc_max(N,0);
  cc_max[N-1]=cc[N-1];
  for(int i=N-2;i>=0;--i) cc_max[i]=max(cc_max[i+1],cc[i]);
  
  ans=max(ans,max(c_max[N-1],cc_max[0]));
  //時計-反時計
  for(int i=0;i<N-1;++i){
    ans=max(ans,c[i]-x[i]+cc_max[i+1]);
  }
  //反時計-時計
  for(int i=N-1;i>0;--i){
    ans=max(ans,cc[i]-(C-x[i])+c_max[i-1]);
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    ll N, K, ans=0; scanf("%lld %lld", &N, &K);
    FOR(k, K, N+2){
        ans = (ans + (ll)k * (N + 1 -k) + 1) % mod;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
 
#define si(x) scanf("%d",&x)
#define sf(x) scanf("%lf",&x)
#define sl(x) scanf("%lld",&x)
#define pr(x) printf("%d\n",x)
#define prll(x) printf("%ld\n",x)
 
#define ll long long int
#define ull unsigned long long int
#define F first
#define S second
 
#define rep(i,x,y) for(long int i=x;i<y;i++)
#define ii pair<int,int> 
#define pll pair<ll,ll> 
#define vi vector<int> 
#define vvi vector< vi > 
#define vl vector<long long int>
#define vvl vector< vl >
#define vii vector< ii >
#define vvii vector< vii >
#define priority_queue pq;
#define sz(a) ll((a).size()) 
#define pb push_back 
#define mp make_pair
 
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end() 
#define tr(i,c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ison(x,i) (((x) >> (i)) & 1)	//checks if ith bit is on
#define set0(x,i) (x & ~(1 << i))		//set ith bit in x to be zero
#define clr(a) memset(a,0,sizeof(a))
 
#define MOD 1000000007
#define INF 4000000000000000000
#define MAX 200000+5
using namespace std;

long int ans[MAX]={0};
map<long int,long int> m;

int main()
{
	string s;
	cin>>s;
	int n = s.size();
	m.insert(mp(0,0));
	bitset<26> t;
	t.reset();
	rep(i,0,n)
	{
		ans[i]=i+1;
		t.flip(s[i]-'a');
		long int p = t.to_ulong();
		auto it = m.find(p);
		if(it!=m.end())
			ans[i] = min(ans[i],it->S+1);
		for(long int j=0;j<26;j++)
		{
			t.flip(j);
			p = t.to_ulong();
			t.flip(j);
			it = m.find(p);
			if(it!=m.end())
			{
				// printf("[%ld %ld]\n",p,it->S);
				ans[i] = min(ans[i],it->S+1);
			}
		}
		p = t.to_ulong();
		it = m.find(p);
		if(it==m.end())
			m.insert(mp(p,ans[i]));
		else
			it->S = min(it->S,ans[i]);
		// printf("INSERTED (%ld %ld)\n",p,it->S);
		// printf("ans[%ld] = %ld\n",i,ans[i]);
	}
	prll(ans[n-1]);
	return 0;
}

Measured memory_bytes: 14468
#include <iostream>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

typedef map <string,int> M;
M puzzle;

int main(void){
	string S="01234567";
	puzzle[S]=0;
	queue<string> q;
	q.push(S);
	while(!q.empty()){
  		string tmp=q.front();
		q.pop();
		int num=puzzle[tmp];
		int zero;
		for(int i=0;i<8;i++)
			if(tmp[i]=='0')
				zero=i;
		if(0<=zero && zero<=3){
			swap(tmp[zero],tmp[zero+4]);
			if(puzzle.find(tmp) == puzzle.end())
				puzzle[tmp]=(num+1),q.push(tmp);
			swap(tmp[zero],tmp[zero+4]);
		}
		if(4<=zero && zero<=7){
			swap(tmp[zero],tmp[zero-4]);
			if(puzzle.find(tmp) == puzzle.end())
				puzzle[tmp]=(num+1),q.push(tmp);
			swap(tmp[zero],tmp[zero-4]);
		}
		if(zero%4 !=0){
			swap(tmp[zero],tmp[zero-1]);
			if(puzzle.find(tmp) == puzzle.end())
				puzzle[tmp]=(num+1),q.push(tmp);
			swap(tmp[zero],tmp[zero-1]);
		}
		if(zero%4 !=3){
			swap(tmp[zero],tmp[zero+1]);
			if(puzzle.find(tmp) == puzzle.end())
				puzzle[tmp]=(num+1),q.push(tmp);
			swap(tmp[zero],tmp[zero+1]);
		}
	}
	while(1){
		string tar,tmp;
		for(int i=0;i<8;i++)
			cin >> tmp,tar+=tmp;
		if(cin.eof())
			break;
		int ans=puzzle[tar];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define WHITE 0
#define GRAY 1
#define BLACK 2

int M[101][101];
int d[101], f[101];
int searchPos[101];
int color[101];
int tt = 0;
int n;
stack<int> s;

int nextPoint(int curPoint){
    for(int i=searchPos[curPoint];i<n;++i){
        searchPos[curPoint] += 1;
        if(M[curPoint][i]==1 && color[i] == WHITE){
            return i;
        }
    }
    return -1;
}

void dfs(int point){
    d[point] = ++tt;
    color[point] = GRAY;
    while(1){
        int next = nextPoint(point);
        if(next != -1){
            dfs(next);
        }
        else{
            f[point] = ++tt;
            color[point] = BLACK;
            return;
        }
    }
}

int main(){
    int u, z, y;
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        searchPos[i] = 0;
        color[i] = WHITE;
        for(int j=0;j<n;++j){
            M[i][j] = 0;
        }
    }
    for(int i=0;i<n;++i){
        cin >> u >> z;
        for(int j=0;j<z;++j){
            cin >> y;
            M[u-1][y-1] = 1;
        }
    }

    dfs(0);
    for(int i=0;i<n;++i){
        if(color[i]==WHITE){
            dfs(i);
        }
    }
    for(int i=0;i<n;++i){
        printf("%d %d %d\n",i+1,d[i],f[i]);
    }
    return 0;
}



Measured memory_bytes: 3216
#include <cstdio>
#include <cctype>
#include <utility>
#include <array>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (int n; (n = in());) {
		array<int, 7> A = {};
		while (n--) {
			int a = in();
			A[a < 60 ? a / 10 : 6]++;
		}
		for (int c: A)
			outl(c);
	}
}


Measured memory_bytes: 2416
def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    # divisors.sort()
    return divisors


res = []
N = int(input())
for i in range(1, N + 1):
    if i % 2 == 0:
        continue
    else:
        r = make_divisors(i)
        if len(r) == 8:
            res.append(i)
print(len(res))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
  }
  vector<ll> c(3);
  ll ans=1;
  for(ll i=0;i<n;i++) {
    if(i==0) {
      if(a[i]!=0) {
        ans=0;
      }
      else {
        ans*=3;
        c[0]++;
      }
    }
    else {
      ll temp=0;
      for(ll j=0;j<3;j++) {
        if(c[j]==a[i]) {
          if(temp==0) {
            c[j]++;
          }
          temp++;
        }
      }
      ans=(ans*temp)%mod;
    }
  }
  cout << ans << endl;
}

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

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var list = new Dictionary<string, List<(int, int)>>();

            var n = int.Parse(Console.ReadLine());
            for (var i = 0; i < n; i++)
            {
                var inputs = Console.ReadLine().Split(" ");
                var s = (inputs[0]);
                var p = int.Parse(inputs[1]);

                List<(int, int)> l;
                if (list.ContainsKey(s))
                {
                    l = list[s];
                }
                else
                {
                    l = new List<(int, int)>();
                    list.Add(s, l);
                }
                l.Add((p, i + 1));
            }

            var keys = list.Keys.OrderBy(x => x);

            foreach (var key in keys)
            {
                list[key] = list[key].OrderByDescending((x) => x.Item1).ToList();
            }

            foreach (var k in keys)
            {
                var l = list[k];
                foreach (var x in l)
                {
                    Console.WriteLine(x.Item2);
                }
            }
        }
    }
}


Measured memory_bytes: 28696
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int [] a = new int[n];
		
		for(int i=0; i<n; i++) {
			a[i] = sc.nextInt();
		}
		for(int i=0; i<n/2; i++) {
			int temp = a[i];
			a[i] = a[n-1-i];
			a[n-1-i] = temp;
		}
		for(int i=0; i<n-1; i++) {
			System.out.print(a[i] +" ");			
		}
		System.out.println(a[n-1]);

		
	}
}



Measured memory_bytes: 26380
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int dice[6]{};
    for(int i=0;i<6;i++)cin>>dice[i];
    int a,b;
    int dicee[6]{};
    for(int i=0;i<6;i++)dicee[i]=dice[i];
    int n;
    cin>>n;
    for(int k=0;k<n;k++){
    cin>>a>>b;
    //up-a
    int c{};
    for(int s=0;s<4;s++)
    {
        if(dice[1]==a&&dice[0]==b){
            cout<<dice[3]<<endl;
            c++;
            break;
        }
        if(dice[1]==a&&dice[3]==b){
            cout<<dice[5]<<endl;
            c++;
            break;
        }
        if(dice[1]==a&&dice[5]==b){
            cout<<dice[2]<<endl;
            c++;
            break;
        }
        if(dice[1]==a&&dice[2]==b){
            cout<<dice[0]<<endl;
            c++;
            break;
        }
        
        else 
        {
            int newdice[6]{};//S移動
            newdice[0]=dice[4];
            newdice[1]=dice[0];
            newdice[2]=dice[2];
            newdice[3]=dice[3];
            newdice[4]=dice[5];
            newdice[5]=dice[1];
            
            for(int i=0;i<6;i++)dice[i]=newdice[i];//reset
        }
    }
    if(c!=1)
    {
        if(dicee[2]==a&&dicee[0]==b)cout<<dicee[1]<<endl;
        if(dicee[2]==a&&dicee[1]==b)cout<<dicee[5]<<endl;
        if(dicee[2]==a&&dicee[5]==b)cout<<dicee[4]<<endl;
        if(dicee[2]==a&&dicee[4]==b)cout<<dicee[0]<<endl;
        
        if(dicee[3]==a&&dicee[4]==b)cout<<dicee[5]<<endl;
        if(dicee[3]==a&&dicee[0]==b)cout<<dicee[4]<<endl;
        if(dicee[3]==a&&dicee[1]==b)cout<<dicee[0]<<endl;
        if(dicee[3]==a&&dicee[5]==b)cout<<dicee[1]<<endl;
    }
    }
    /*while(dice[0]!=a)
    {
        newdice[0]=dice[3];
        newdice[1]=dice[1];
        newdice[2]=dice[0];
        newdice[3]=dice[5];
        newdice[4]=dice[4];
        newdice[5]=dice[2];
        
        for(int i=0;i<6;i++)dice[i]=newdice[i];//reset
    }*/
    return 0;
}



Measured memory_bytes: 3080
n, k = map(int, input().split())
mod = 1000000007
a = []

i = 1
while i * i <= n:
    a.append(i)
    a.append(n // i)
    i += 1
m = len(a)
a.append(0)
a.sort()

dp = [0] * m
dp[0] = 1
acc = [0]  * m
for _ in range(k):
    acc[0] = dp[0]
    for j in range(1, m):
        acc[j] = (acc[j-1] + dp[j]) % mod # 累積和
    for j in range(m):
        dp[j] = acc[m-j-1] * (a[j+1] - a[j]) % mod
ans = 0
for x in dp:
    ans = (ans + x) % mod
print(ans)


Measured memory_bytes: 75220
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

int main(void){
    string a,b;
    int n;
    int aa=0,bb=0;
    int i,j;
    int la,lb,l;
    
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a>>b;
        j=0;
        la=a.length(),lb=b.length();
        if(la>lb){
            l=la;
        }
        else{
            l=lb;
        }
        
        while(1){
            if(a[j]<b[j]){
                bb+=3;
                break;
            }
            else if(a[j]>b[j]){
                aa+=3;
                break;
            }
            j++;
            if(j==l){
                aa++;
                bb++;
                break;
            }
        }
    }
    cout<<aa<<" "<<bb<<endl;

	return 0;
}


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

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define ll long long int

#define pii pair <int, int>
#define pll pair <ll, ll>

#define vi vector <int>
#define vpii vector <pii>
#define vpll vector <pll>

#define mp make_pair
#define F first
#define S second
#define line cout << "\n"

const ll mod = 1e9 + 7;


int main(){
    fast;
    ll T = 1;
    //cin >> T;
    while(T--)
    {
        string s;
        cin >> s;
        if(s[2] == s[3] && s[4] == s[5])
            cout << "Yes";
        else
            cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        p: [[usize; 3]; n],
    }
    let mut dp = vec![vec![0; 3]; n + 1];

    for i in 1..n + 1 {
        for j in 0..3 {
            for k in 0..3 {
                if j == k {
                    continue;
                }
                dp[i][k] = std::cmp::max(dp[i][k], dp[i - 1][j] + p[i - 1][k]);
            }
        }
    }
    println!(
        "{}",
        std::cmp::max(dp[n][0], std::cmp::max(dp[n][1], dp[n][2]))
    );
}


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

string field[69][69];

string strComp(string a, string b) 
{
	string str = a;
	if (a.size() > b.size()) {}
	else if (a.size() < b.size()) str = b;
	else {
		for (int i = 0; i < a.size(); i++) {
			if (a[i] > b[i]) break;
			else if (a[i] < b[i]) {
				str = b;
				break; 
			}
		}
	}
	
	return str;
}

int main()
{	
	int w, h;
	string str;
	while (cin >> w >> h, w | h) {
		string s = "";
		for (int i = 0; i < h; i++) {
			cin >> str;
			for (int j = 0; j < w; j++) {
				if (str[j] >= '0' && str[j] <= '9') {
					field[i][j] = str[j];
					if (i > 0) {
						field[i][j] = field[i - 1][j] + str[j];
					}
					if (j > 0) {
						field[i][j] = strComp(field[i][j - 1] + str[j], field[i][j]);
					} 
					if (field[i][j] == "0") field[i][j] = "";
					s = strComp(s, field[i][j]);
				} else {
					field[i][j] = "";
				}
			}
		}
		cout << s << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1384
#include <iostream>
#include <vector>
#include <stack>
#include <queue>

using namespace std;


int main(){
	int n; cin >> n;

	int f1 = 1;
	int f2 = 1;
	int f3 = 0;
	for (int i = 2; i <= n; ++i){
		f3 = f1 + f2;
		f1 = f2;
		f2 = f3;
	}
	if (n == 1){
		cout << 1 << endl;
		return 0;
	}
	if (n == 2){
		cout << 2 << endl;
		return 0;
	}
	cout << f3 << endl;

	return 0;
}

Measured memory_bytes: 3072