akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = Console.ReadLine().Split();
            var N = int.Parse(ss[0]);
            var K = int.Parse(ss[1]);

            var S = Console.ReadLine();

            var diff = 'A' - 'a';
            for (int i = 0; i < N; i++)
            {
                if (i == K - 1)
                {
                    Console.Write(Char.ToLower(S[i]));
                }
                else
                {
                    Console.Write(S[i]);
                }
            }

            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
int ans[1005][1005];
int con[10005];
int main()
{
    int N,M,i,j,k,ok=0,now=1;
    scanf("%d",&N);
    for(i=1;i*(i+1)/2<=N;i++)
    {
        if(i*(i+1)/2==N)
        {
            printf("Yes\n");
            printf("%d\n",i+1);
            ok=1;
            for(j=1;j<=i+1;j++)
            {
                for(k=j+1;k<=i+1;k++)
                {
                    ans[j][con[j]++]=now;
                    ans[k][con[k]++]=now;
                    now++;
                }
            }

            for(j=1;j<=i+1;j++)
            {
                printf("%d ",i);
                for(k=0;k<i;k++) printf("%d ",ans[j][k]);
                printf("\n");
            }
        }
    }
    if(!ok) printf("No\n");
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main()
{
    string s;
    cin>>s;
    int a{};
    for(int i=0;i<s.size();i++){
        a^=s[i];
    }
    if(a==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60; const ll mod=1e9+7; const int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------
ld v[1000];

int main(){
	int n; cin >> n;
	FOR(i,0,n-1){
		cin >> v[i];
	}
	sort(v, v+n);
	ld ans = (v[0]+v[1])/2;
	FOR(i,2,n-1){
		ans += v[i]; ans /= 2;
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;

namespace aizu
{
    class OnlineJudge
    {
        const int Max = 1000000;
        static void Main()
        {
            bool[] check = new bool[Max];
            int[] prime = new int[Max];
            int count = 1;
            for(int i=3; i < Max; i += 2) {
                if(!check[i]) {
                    ++count;
                    for(int l = 2; i * l < Max; ++l) {
                        check[l * i] = true;
                    }
                }
                prime[i] = count;
            }
            prime[2] = 1;
            string num;
            while((num = Console.ReadLine()) != null) {
                int val = int.Parse(num);
                if(val != 2 && (val & 1) == 0) {
                    --val;
                }
                Console.WriteLine(prime[val]);
            }
        }
    }
}

Measured memory_bytes: 10500
class Main{
  
  public static void main(String args[]){
    int n = new java.util.Scanner(System.in).nextInt();
    
    boolean prime[] = new boolean[n+1];

    java.util.Arrays.fill(prime,true);
    prime[0] = false;
    prime[1] = false;
        
    for(int i = 2; i < prime.length; i++){
      if(prime[i]){
        for(int j = i + i ; j < prime.length; j += i){
          prime[j] = false;
        }
      }
    }
    
    int[] v = new int[n+1];
    for(int i = 0; i< n+1;i++){
      primes(prime,i,v);
    }
//    System.out.println(java.util.Arrays.toString(v));

    int dp[][] = new int[n+2][77];
    dp[0][1] = 1;
    
    for(int i =0 ; i < n+1 ; i++){
      for(int j = 0; j < 76;j++){
        for(int k = 0 ; k <= v[i]; k++){
          if(j * (k+1) > 75) break;
          dp[i+1][j*(k+1)] += dp[i][j];
        }
      }
//      System.out.println(i+" "+java.util.Arrays.toString(dp[i+1]));
    }
    
    System.out.println(dp[n+1][75]);
  }
  
  static int[] primes(boolean[]primes, int target, int[] res){
    for(int i =0; i < primes.length; i++){
      if(primes[i]){
        int t = target;
        while(t % i == 0 && t > 0){
          res[i]++;
          t /= i;
        }
      }
    }
    return res;
  }
}

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

using namespace std;
typedef long long LL;

const int MAXN = 234567;
int dp[87][2];

int main() {
    int N;
    while (~scanf("%d", &N)) {
          LL ans = 0;
          for (int i = 0; i <= 20; i++) {
              dp[i][0] = dp[i][1] = 0;
          }
          for (int i = 1; i <= N; i++) {
              int tmp;
              scanf("%d", &tmp);
              int maxl = 0;
              for (int j = 0; j <= 20; j++) {
                  int curl;
                  if (tmp & (1 << j)) {
                     curl = dp[j][0] + 1;
                     dp[j][1] = dp[j][0];
                     dp[j][0] = i;
                  } else {
                     curl = dp[j][1] + 1;
                  }
                  // printf("i = %d j = %d\n", i, j);
                  // printf("1 = %d 2 = %d\n", dp[j][0], dp[j][1]);
                  maxl = max(maxl, curl);
              }
              ans += (i - maxl + 1);
          }
          printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// Still trying to be normal
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).saize()
using namespace std;
const ll INF = 1e17 + 9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,p;
    cin>>n>>p;
    string s;
    cin>>s;
    ll ans=0;
    if(p!=2 && p!=5){
        ll mod[10000];
        memset(mod,0,sizeof mod);
        mod[0]=1;
        ll ant=0;
        ll base = 1;
        per(i,n,0){
            ll ant2=ant;
            ll modact = (ant+(((s[i]-'0')%p)*base)%p)%p;
            ant=modact;
            // cout<<modact<<" "<<mod[modact]<<endl;
            if(s[i]!='0')ans+=mod[modact];
            else ans+=mod[ant2];
            base*=10;
            base%=p;
            mod[modact]++;
        }
    }
    if(p==2){
        ll qtp=0;
        // if((s[s.size()-1]-'0')%2==0)qtp++;
        per(i,n,0){
            ans+=qtp+((s[i]-'0')%2==0);
            if((s[i]-'0')%2==0)qtp++;
        }
    }
    else if(p==5){
        ll qt50=0;
        // if(s[s.size()-1]=='0' || s[s.size()-1]=='5')qt50++;
        per(i,n,0){
            ans+=qt50+((s[i]-'0')==0 || (s[i]-'0')==5);
            if(((s[i]-'0')==0 || (s[i]-'0')==5))qt50++;
        }
    }
    cout<<ans<<'\n';
    return 0;   
}

Measured memory_bytes: 720
import sys
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
from functools import partial, reduce
from collections import Counter


def f_chain(*args):
    return reduce(lambda x, f: f(x), args)

def main():
    n = II()
    aa = [II() for _ in range(n)]
    c_cnt = Counter(aa).values()
    f_chain(c_cnt,
            partial(map, lambda x: 1 if x%2==1 else 0),
            sum,
            print)

if __name__ == '__main__':
    main()

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

int main() {
  int N;
  cin >> N;
  
  int total = 0;
  for (int i=0; i<N; i++) {
    int l, r;
    cin >> l >> r;
    total += r - l + 1;
  }
  cout << total << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,l;
    cin>>n>>l;
    int ans=0,min_a=l;
    bool flag;
    rep(i,n){
        ans=ans+l+i;
        if(abs(min_a)>abs(l+i)){
            min_a=l+i;
        }
    }
    cout<<ans-min_a<<endl;

    return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

// edit

void solve() {
    int n;
    cin >> n;
    set<string> neri;
    REP(i, n) {
        string tmp;
        cin >> tmp;
        neri.insert(tmp);
    }
    cout << SZ(neri) << endl;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

bool end_flag = false;
LL N;

int dfs(int idx, LL now) {
    if(idx == 0) {
        bool use_3 = false;
        bool use_5 = false;
        bool use_7 = false;

        LL tmp = now;
        while(tmp != 0){
            if(tmp % 10 == 3) use_3 = true;
            if(tmp % 10 == 5) use_5 = true;
            if(tmp % 10 == 7) use_7 = true;

            tmp /= 10;
        }
        if(!use_3 || !use_5 || !use_7) return 0;

        if(N < now) end_flag = true;
        return now <= N;
    }

    int ans = 0;
    ans += dfs(idx - 1, now * 10 + 3);
    ans += dfs(idx - 1, now * 10 + 5);
    ans += dfs(idx - 1, now * 10 + 7);

    return ans;
}

void solve(){
    int ans = 0;
    REP2(i, 3, 10){
        ans += dfs(i, 0);
        if(end_flag) break;
    }

    cout << ans << endl;
}

int main(){
    scanf("%lld",&N);
    solve();
    return 0;
}


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

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

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

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

signed main(void)
{
  int a, b;
  while(cin >> a >> b) {
    cout << gcd(a, b) << " " << lcm(a, b) << endl;
  }

  return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define tam 500001
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define CLASSNAME WarmupWithTwins
#define FUNCNAME determineTwinsAge
using namespace std;

typedef long long       ll;
typedef pair<ll, ll>  ii;
typedef vector<ll>     vi;
typedef vector<ii> vii;
typedef long double lldb;
const ll MOD=1e9+7;
ll F[tam],F2[tam];
ll pot(ll base,ll exp)
{
    ll auxb=base%MOD,resp=1;
    while(exp>0)
    {
        if (exp&1)
            resp*=auxb,resp%=MOD;
        auxb*=auxb;
        auxb%=MOD;
        exp/=2;
    }
    return resp;
}
ll C(ll x,ll y)
{
    if (y>x)return 0;
    ll resp=F[x];
    resp*=F2[y];resp%=MOD;
    resp*=F2[x-y];resp%=MOD;
    return resp;
}
int main()
{
    F[0]=F2[0]=1;
    forr(i,1,tam)
    {
        F[i]=F[i-1]*i;F[i]%=MOD;
        F2[i]=F2[i-1]*pot(i,MOD-2);F2[i]%=MOD;
        
    }
    ios::sync_with_stdio(false);cin.tie(0);
    ll H,W;
    cin>>H>>W;
    ll A,B;
    cin>>A>>B;
    ll a2,b2,suma,formas=0;
    forr(a,A+1,H+1)
    {
        a2=H-a+1,b2=B;
        suma=C(a2-1+b2-1,a2-1);
        a2=a;b2=W-B;
        suma*=C(a2-1+b2-1,a2-1);suma%=MOD;
        formas+=suma;formas%=MOD;
    }
    /*cout<<formas<<endl;
    ll resta=C(H-A+1-1+B-1,B-1);
    cout<<resta<<" ";
    resta*=C(W-B+1-1+A-1,A-1),resta%=MOD;
    cout<<resta<<endl;
    resta%=MOD;
    formas-=resta;formas+=MOD;formas%=MOD;*/
    cout<<formas<<endl;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    string L;
    cin >> L;
    int n = L.size();
    vector<vector<ll>> dp(2, vector<ll>(n+1));    // 0: イコール, 1: 未満
    dp[0][0] = 1;
    rep(i,n) {
        if(L[i]=='1') {
            dp[0][i+1] = (dp[0][i] * 2) % MOD;
            dp[1][i+1] = (dp[0][i] + dp[1][i] * 3) % MOD;
        } else {
            dp[0][i+1] = dp[0][i];
            dp[1][i+1] = (dp[1][i] * 3) % MOD;
        }
    }
	cout << (dp[0][n] + dp[1][n]) % MOD << endl;
	return 0;
}


Measured memory_bytes: 2816
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap map = new HashMap();
    for (int i=0;i< n;i++){
    	String key=sc.next();
    	if (!map.containsKey(key)){
    		map.put(key,key);
    	}
    }

    System.out.println(map.size());
  }
}


Measured memory_bytes: 66516
#-------最強ライブラリSCC(Python) ver25252------
import sys
sys.setrecursionlimit(1000000)

class scc_graph:
  # n 頂点数
  def __init__(s, n): 
    s._n = n
    s.g = {}
  def num_vertices(s): return s._n
  # 辺を追加 frm 矢元 to 矢先
  # O(1)
  def add_edge(s, frm, to): 
    if frm in s.g: s.g[frm].append(to)
    else: s.g[frm] = [to]

  # グループの個数と各頂点のグループidを返す
  def scc_ids(s):
    now_ord = group_num = 0
    visited = []
    low = [0] * s._n
    ord = [-1] * s._n
    ids = [0] * s._n
    # 再帰関数 
    def dfs(self, v, now_ord, group_num):
      low[v] = ord[v] = now_ord
      now_ord += 1
      visited.append(v)
      if v in s.g:
        for to in s.g[v]:
          if ord[to] == -1:
            now_ord, group_num = self(self, to, now_ord, group_num)
            low[v] = min(low[v], low[to])
          else:
            low[v] = min(low[v], ord[to])
      if low[v] == ord[v]:
        while True:
          u = visited.pop()
          ord[u] = s._n
          ids[u] = group_num
          if u == v: break
        group_num += 1
      return now_ord, group_num

    for i in range(s._n):
      if ord[i] == -1: now_ord, group_num = dfs(dfs, i, now_ord, group_num)
    for i in range(s._n):
      ids[i] = group_num - 1 - ids[i]
    return group_num, ids

  # 強連結成分となっている頂点のリストのリスト トポロジカルソート済み
  # O(n + m)
  def scc(s):
    group_num, ids = s.scc_ids()
    counts = [0] * group_num
    for x in ids: counts[x] += 1
    groups = [[] for _ in range(group_num)]
    for i in range(s._n):
      groups[ids[i]].append(i)
    return groups

  class edge:
    def __init__(s, frm, to):
      s.frm = frm
      s.to = to


#-------最強ライブラリここまで------

def main():
  input = sys.stdin.readline
  n, m = list(map(int, input().split()))
  ab = [tuple(map(int, input().split())) for _ in range(m)]

  g = scc_graph(n)

  for u, v in ab:
    g.add_edge(u, v)

  scc = g.scc()

  print(len(scc))

  for v in scc:
    print(len(v), end = " ")
    for x in v:
      print(x, end = " ")
    print("")

main()

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e13 + 5);

using ql = pair<ll, ll>;

const int MAX_N = (int)(3e2 + 5);

int n, m;
ll l;

ll cost[MAX_N][MAX_N];

int q;

ql jump[MAX_N][MAX_N];

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &m);

  scanf("%lld", &l);

  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      cost[i][j] = INF;
      cost[j][i] = INF;

      jump[i][j] = ql(INF, INF);
      jump[j][i] = ql(INF, INF);
    }
    cost[i][i] = 0L;
    jump[i][i] = ql(INF, INF);
  }

  for (int i = 0; i < m; ++i) {
    int a, b;
    ll c;

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

    cost[a][b] = c;
    cost[b][a] = c;
  }

  for (int s = 1; s <= n; ++s) {
    priority_queue<pair<ql, int>, vector<pair<ql, int>>, greater<pair<ql, int>>>
        pq;

    pq.push(make_pair(ql(0L, 0L), s));

    jump[s][s] = ql(0L, 0L);

    while (!pq.empty()) {
      auto cur = pq.top();
      pq.pop();

      ll times = cur.first.first;
      ll running = cur.first.second;
      int node = cur.second;

      if (cur.first > jump[s][node]) continue;  // check used

      // jump[s][node] = cur.first;

      for (int i = 1; i <= n; ++i) {
        if (s == i) continue;
        if (cost[node][i] > l) continue;

        ll streched_running = running + cost[node][i];

        ll next_times = (streched_running > l) ? times + 1 : times;
        ll next_running =
            (streched_running > l) ? cost[node][i] : streched_running;

        auto candidate = ql(next_times, next_running);

        if (jump[s][i] <= candidate) continue;  // pruning

        jump[s][i] = candidate;

        pq.push(make_pair(candidate, i));
      }
    }
  }

  scanf("%d", &q);

  for (int i = 0; i < q; ++i) {
    int s, t;
    scanf("%d %d", &s, &t);

    ll ans = (jump[s][t].first == INF) ? -1L : jump[s][t].first;

    printf("%lld\n", ans);
  }

  return 0;
}


Measured memory_bytes: 3908
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n,m;
    cin >> n >> m;
    if(n%2==1){
    int l = m;
    int r = m+1;
    rep(i,m){
        cout << l << ' ' << r << endl;
        l--;
        r++;
    }
    }else{
        int l = 1;
        int r = l+m-1;
        while(l<r){
            cout << l << ' ' << r << endl;
            l++;
            r--;
        }
        r=n;
        l=r-m;
        while(l<r){
            cout << l << ' ' << r << endl;
            l++;
            r--;
        }
    }
}


Measured memory_bytes: 3640
#include<cstdio>
#include<iostream>
#include<map>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#include<cstdlib>
using namespace std;
typedef long long LL;
const LL mod = 1e9+7;
char a[20];
int main(){
	scanf("%[^\n]s",a);
	printf("%c",a[0]+'A'-'a');
	for(int i = 1;i < strlen(a);i++){
		if(a[i-1]==' ')printf("%c",a[i]+'A'-'a');
		}
	return 0;
	}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using lint = long long int;

constexpr lint MOD = 1000000007;

template <typename T>
void fast_integer_moebius(std::vector<T> &f)
{
    int N = f.size() - 1;
    std::vector<int> is_prime(N + 1, 1);
    for (int p = 2; p <= N; p++) if (is_prime[p]) {
        for (int q = p * 2; q <= N; q += p) is_prime[q] = 0;
        for (int j = p; j <= N; j += p) f[j / p] -= f[j];
    }
}

lint power(lint x, lint n, lint MOD)
{
    lint ans = 1;
    while (n > 0)
    {
        if (n & 1) (ans *= x) %= MOD;
        (x *= x) %= MOD;
       n >>= 1;
    }
   return ans;
}

int main()
{
    int N, K;
    cin >> N >> K;
    vector<lint> vec(K + 1);
    for (int g = 1; g < vec.size(); g++)
    {
        vec[g] = power(K / g, N, MOD);
    }

    fast_integer_moebius(vec);
    lint ret = 0;
    for (int g = 1; g < vec.size(); g++) ret = (ret + g * vec[g]) % MOD;
    cout << ret << "\n";
}


Measured memory_bytes: 4264
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    ArrayList[] list = new ArrayList[N];
    for(int i = 0; i < N; i++) {
      list[i] = new ArrayList<Integer>();
    }
    for(int i = 0; i < M; i++) {
      int a = sc.nextInt() - 1;
      int b = sc.nextInt() - 1;
      list[a].add(b);
      list[b].add(a);
    }
    ArrayList<Integer> list0 = list[0];
    String ans = "IMPOSSIBLE";
    for(int i = 0; i < list0.size(); i++) {
      if(list[list0.get(i)].contains(N - 1)) {
        ans = "POSSIBLE";
        break;
      }
    }
    System.out.println(ans);
  }
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

ll gcd(ll x, ll y){ return y? gcd(y, x%y): x; }

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll a, b, c, d;
	cin >>a >>b >>c >>d;
	
	ll z =  c * d /gcd(c,d);
	
	ll ans = b / c  - (a-1)/c ;
	ans += b / d - (a-1) /d;
	ans -= b / z - (a-1) /z;
	cout << b +1 -a -ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  int res= 0 ;
  for(int i=0;i<n;++i){
    int curr;cin>>curr;
    if(curr>=k)res++;
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var S string
	fmt.Scan(&S)
	SS := []byte(S)
	c :=  []byte("CODEFESTIVAL2016")
	ans := 0
	for i, s := range c {
		if s!=SS[i]{
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

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

    cin>>n;
    rep(i,100){
        rep(j,100){
            cnt=4*i+7*j;
            if(cnt==n){
                Cout("Yes");
                return 0;
            }
        }
    }
    Cout("No");
    return 0;
}


Measured memory_bytes: 768
import Data.Array

main = interact $ unlines . sol . lines

sol (s:ss) = [[g i j | j <- [1..w]] | i <- [1..h]]
  where
  [h,w] = map read $ words s
  t = listArray ((1,1),(h,w)) . map f . filter (>='#') $ concat ss
  f '.' = 0
  f '#' = 1
  g i j 
    | t!(i,j)==1  = '#'
    | otherwise   = head . show $ sum 
        [t!(i',j') | i' <- [max 1 (i-1)..min h (i+1)], j' <- [max 1 (j-1)..min w (j+1)]] 

Measured memory_bytes: 4976
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define l1 long
#define ld long double
#define lld long long double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(x) cout<<"$ "<<x<<" $"<<endl
#define bug(x) cout<<"& "<<x<<" &"<<endl
#define all(v) v.begin(),v.end()
#define lop1(i,j,n) for(int i=j; i<n; ++i)
#define lop2(i,j,n) for(int i=j; i<=n; ++i)
#define lop3(i,n,j) for(int i=n; i>j; --i)
#define lop4(i,n,j) for(int i=n; i>=j; --i)
#define view(v) for(auto i: v) cout<<i<<" "
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
const ll M=1e9+7;
const ld PI=3.1415926536;
//int p[N];
//int find(int k){ return p[k]==k ? k : p[k]=find(p[k]); }
using namespace std;

void solve()
{
    ll a;
    cin>>a;
    cout<<pow(a,2)+pow(a,3)+a<<endl;
    return;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    fast
    int t=1;
	//cin>>t;
    while(t--) solve();
	return 0;
}


Measured memory_bytes: 4308
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		int N = in.nextInt();
		if(N <= 999) {
			System.out.print("ABC");
		}else {
			System.out.print("ABD");
		}
		in.close();
		
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

static const int N = 1000;

int lcs(string X, string Y) {
    int c[N + 1][N + 1];
    int m = X.size();
    int n = Y.size();
    int maxl = 0;
    X = ' ' + X;
    Y = ' ' + Y;
    for (int i = 0; i <= m; ++i) {
        c[i][0] = 0;
    }

    for (int i = 0; i <= n; ++i) {
        c[0][i] = 0;
    }

    for (int i = 1; i <= m; ++i) {
        for (int j = 1; j <= n; ++j) {
            if (X[i] == Y[j])
                c[i][j] = c[i - 1][j - 1] + 1;
            else {
                c[i][j] = max(c[i - 1][j], c[i][j - 1]);
            }
            maxl = max(maxl, c[i][j]);
        }
    }

    return maxl;
}

int main() {
    string s1, s2;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> s1 >> s2;
        cout << lcs(s1, s2) << endl;
    }
    return 0;
}

Measured memory_bytes: 7028
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>

using namespace std;


int main()
{
	string str[100],str2[200000],strmemo="";
	long long int n, m, a, b, c, now[200][200] = {},x[200006],y[200006],X=0,Y=0;
	const long long int mod = 1000000007;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> y[i];
	}
	for (long long int i = 1; i < n; i++) {
		long long int tmp = (x[i] - x[i - 1]);
		tmp %= mod;
		tmp *= i;
		tmp %= mod;
		X += tmp * (n - i);
		X %= mod;
	}
	for (long long int i = 1; i < m; i++) {
		long long int tmp = X * (y[i] - y[i - 1]);
		tmp %= mod;
		tmp *= (m - i);
		tmp %= mod;
		tmp *= i;
		tmp %= mod;
		Y += tmp;
		Y %= mod;
	}
	cout << Y;
}


Measured memory_bytes: 4480
#include <iostream>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(void) {
    int n, x;
    cin >> n >> x;
    int l[n];
    rep(i, n) cin >> l[i];

    int d = 0, i = 0;
    while(d <= x) {
        d += l[i++];
    }
    cout << i << endl;

}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
using namespace std;

int main(){

  int a, b, c, x, ans=0;
  cin >> a >> b >> c >> x;

  for(int i=0; i<=a; i++){
    for(int j=0; j<=b; j++){
      for(int k=0; k<=c; k++){
        if(x==i*500+j*100+k*50){
          ans++;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};
/*
const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
*/

int main(){
    ll a,b; cin >> a >> b;
    //Eratosthenes();
    map<ll,int> mp;

    //ll tmp = sqrt(max(a,b));
    if (a == 1 || b == 1){
        cout << 1 << endl;
        return 0;
    }
    ll l = GCD(max(a,b), min(a,b));
    //cout << l << endl;
    for (ll i = 2; i <= sqrt(l)+100; i++){
        while (l % i == 0){
            mp[i]++;
            l /= i;
        }
    }
    if (l > 1) mp[l]++;
    cout << mp.size()+1 << endl;
}



Measured memory_bytes: 256
#include <fstream>
#include <sstream>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <functional>

using namespace std;

int COUNT(string X, string Y) {
	set<string> SET, ANS;

	int M =X.size();

	for (int i = 0; i < M; i++) {
		SET.insert(X.substr(i, 1));
	}

	int count = 0;
	int H = Y.size();
	for (int i = 0; i < H; i++) {
		if (SET.find(Y.substr(i, 1)) != SET.end()) { ANS.insert(Y.substr(i,1)); }
	}

	return ANS.size();
}

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

	string S;
	cin >> S;

	string X, Y;

	int ans = 0;

	for (int i = 1; i < N; i++) {
		X = S.substr(0, i); 
		Y = S.substr(i, N - i);
		//cout << "X= " << X << "   Y= " << Y <<" "<<COUNT(X,Y)<< endl;
		if (COUNT(X, Y) > ans) { ans = COUNT(X, Y); }
	}

	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var ND = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (N, D) = (ND[0], ND[1]);

        double GetDistance(long p, long q) => Math.Sqrt(p * p + q * q);

        var ans = 0;

        for (int i = 0; i < N; i++)
        {
            var XY = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var (X, Y) = (XY[0], XY[1]);
            if (GetDistance(X, Y) <= D)
                ans++;
        }

        WriteLine(ans);
    }
}


Measured memory_bytes: 41228
import java.util.Scanner;

public class Main {

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

	    long q=gl();
	    long h=gl();
	    long s=gl();
	    long d=gl();
	    long n=gl();
	    q=q*4;
	    h=h*2;
	    long m=Math.min(Math.min(q, h), s);

        if(2*m<=d) {
		    System.out.println(m*n);
        } else if(n%2==0) {
        	System.out.println(d*n/2);
        } else {
        	System.out.println(d*(n-1)/2 + m);
        }
	}

	 // ユークリッドの互除法
    public static long uclid(long m, long n) {
    	if (m<n) {
			m^=n;
			n^=m;
			m^=n;
		}

		while(true) {
			long t=m%n;
			if (t==0) {
				return n;
			} else {
				m=n;
				n=t;
			}
		}
    }
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35592
N = int(input())
T = []
for _ in range(N):
    T.append(int(input()))
    
T = sorted(T)

def gcd(a, b):
    if(b > a):
        a, b = b, a
    while b:
        a, b = b, a%b
    return a

if max(T) > 5*10**17:
    print(max(T))
    
else:
    tmp = max(T)
    for i in range(N):
        if tmp % T[i] != 0:
            tmp = T[i]//gcd(tmp, T[i])*tmp

    print(int(tmp))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    int s;
    cin >> s;
    ll n = 1e5;
    for(int i = 0; i < s; i++){
        n = n + n / 20;
        if(n % 1000 != 0) n = (n / 1000 + 1) * 1000;
    }
    cout << n << "\n";
}


Measured memory_bytes: 3072
import sys
def main():
    def input():
        return sys.stdin.readline()[:-1]
    N, Q = map(int,input().split())
    ans = []
    if N == 1:
        for k in range(Q):
            v, w = map(int,input().split())
            ans.append(min(v,w))
    else:
        for k in range(Q):
            v, w = map(int,input().split())
            while v!=w:
                if v > w:
                    v, w = w, v
                w = (w+N-2)//N
            ans.append(v)
    print(*ans,sep="\n")

if __name__ == '__main__':
    main()


Measured memory_bytes: 53980
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n) {
    vi a(n);
    rep(i, n) cin >> a[i];
    sort(rall(a));
    rep(i, n) a[i] *= i + 1;
    cout << accumulate(all(a), 0) << endl;
  }
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define invrep(i, n) for(int i = (n)-1; i >= 0; i--)        // n-1, n-2, ..., 0
#define invREP(i, x, n) for(int i = (n)-1; i >= (x; i--)    // n-1, n-2, ..., x
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define PB push_back

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";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; }


int main(){
    char a; cin >> a;
    if(a == 'A') COUT('T');
    else if(a == 'T') COUT('A');
    else if(a == 'C') COUT('G');
    else COUT('C');
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> P;
int mod = 1e9+7;

vector<P> prime_factorize(int N){
	vector<P> ans;
	for(int a = 2; a*a <= N; a++){
		if(N%a == 0){
			int ex = 0;
			while(N%a == 0){
				ex++;
				N /= a;
			}
			ans.push_back(P(a, ex));
		}
	}
	if(N != 1) ans.push_back(P(N, 1));
	return ans;
}

signed main(){
	int N; cin >> N;
	int mod = 1e9 + 7;
	vector<int> exp(N + 1, 0);
	for(int n = 2; n <= N; n++){
		const auto &ans = prime_factorize(n);
		for(auto p : ans) exp[p.first] += p.second; 
	}
	int ans = 1;
	for(int i = 2; i <= N; i++){
		ans *= (exp[i] + 1);
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]
x,y = map(int, input().split())
if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define for_tests(t, tt) int t; scanf("%d", &t); for(int tt = 1; tt <= t; tt++)
#ifndef ONLINE_JUDGE
#define debug(args...) fprintf(stderr,args)
#else
#define debug(args...)
#endif //ONLINE_JUDGE
template<typename T> inline T abs(T t) { return t < 0? -t : t; }
const ll modn = 1000000007;
inline ll mod(ll x) { return x % modn; }
#define IOS() ios::sync_with_stdio(0),cin.tie(0)

const int MAXN = 212345;

ll n, m, k;

ll gcd(ll a, ll b){
    if(a == 0) return b;
    return gcd(b%a, a);
}

int main (){
	scanf("%lld", &n);
    ll lc = (n*360)/gcd(n, 360);
    printf("%lld\n", lc/n);
}



Measured memory_bytes: 3824
(defun main ()
  (let ((input (read-line)))
    (loop :with output-so-far := '()
          :for c :across input
          :do (ecase c
                ((#\0 #\1) (push c output-so-far))
                ((#\B) (pop output-so-far)))
          :finally (write-line (coerce (nreverse output-so-far) 'string)))))

(main)


Measured memory_bytes: 4576
#include <stdio.h>
int main (){
    int a,b,v;
    scanf ("%d",&v);
    scanf ("%d %d", &a,&b);
    for (int i=a ; i<=b ; i++)
    {
        if (i%v==0){
        printf("OK");
        return 0;    
        }
        else {
        }
    }
    printf("NG");
return 0;
}

Measured memory_bytes: 1732
def main():
    S = input()
    T = input()
    l_s = len(S)
    l_t = len(T)

    cnt_list = []
    for i in range(l_s - l_t + 1):
        cnt = 0
        S_ = S[i: i+l_t]
        for j in range(l_t):
            if S_[j] != T[j]:
                cnt += 1
        cnt_list.append(cnt)

    ans = min(cnt_list)
    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 8988
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
    int n,m,k;
    cin>>n>>m>>k;

    UnionFind uf(n);
    vector<vector<int>> G1(n),G2(n);

    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        uf.merge(a,b);
        G1[a].push_back(b);
        G1[b].push_back(a);
    }

    rep(i,k){
        int a,b;
        cin>>a>>b;
        a--,b--;
        G2[a].push_back(b);
        G2[b].push_back(a);
    }

    rep(i,n){
        int ans=uf.size(i)-1-G1[i].size();
        rep(j,G2[i].size()){
            if(uf.issame(i,G2[i][j])) ans--;
        }
        cout<<ans<<" ";
    }
    cout<<endl;
}

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

int main() {
  int N; cin >> N;
  vector<int> a(N), b(N), c(N);
  rep(i, N) cin >> a[i] >> b[i] >> c[i];

  vector<vector<int>> dp(N + 1, vector<int>(3, 0));

  rep(i, N) {
    dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a[i];
    dp[i + 1][1] = max(dp[i][2], dp[i][0]) + b[i];
    dp[i + 1][2] = max(dp[i][0], dp[i][1]) + c[i];
  }

  cout << max({ dp[N][0] , dp[N][1] , dp[N][2] }) << endl;
}

Measured memory_bytes: 6912
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String s = sc.next();
		String p[] = s.split("-", 0);
		if (p.length != 2 || p[0].length() != a || p[1].length() != b)
			System.out.println("No");
		else if (isNumber(p[0]) && isNumber(p[1]))
			System.out.println("Yes");
		else
			System.out.println("No");
	}
	public static boolean isNumber(String str) {
		try {
			Integer.parseInt(str);
			return true;
		} catch (NumberFormatException e) {
			return false;
		}
	}
}

Measured memory_bytes: 24532
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <unordered_set>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int H, W, M;
  cin >> H >> W >> M;
  vector<pair<int, int>> Hcnt(H, {0, 0});
  vector<pair<int, int>> Wcnt(W, {0, 0});

  unordered_set<int64_t> bomb;
  rep(i, M) {
    int bh, bw;
    cin >> bh >> bw;
    bh--, bw--;
    Hcnt[bh] = {Hcnt[bh].first + 1, bh};
    Wcnt[bw] = {Wcnt[bw].first + 1, bw};
    int64_t key = bh * 1e6 + bw;
    bomb.emplace(key);
  }
  auto cmp = [](const auto& lhs, const auto& rhs) {
    if (lhs.first == rhs.first)
      return lhs.second < rhs.second;
    else
      return lhs.first > rhs.first;
  };
  sort(Hcnt.begin(), Hcnt.end(), cmp);
  sort(Wcnt.begin(), Wcnt.end(), cmp);

  // rep(i, H) cout << Hcnt[i].first << ", " << Hcnt[i].second << endl;
  // rep(i, W) cout << Wcnt[i].first << ", " << Wcnt[i].second << endl;

  int hi = Hcnt[0].second;
  int hnum = Hcnt[0].first;
  int wi = Wcnt[0].second;
  int wnum = Wcnt[0].first;
  int answer = hnum + wnum;
  int64_t key = hi * 1e6 + wi;
  if (bomb.count(key) == 0) {
    cout << answer << endl;
    return 0;
  }

  answer--;
  for (int i = 1; i < H; ++i) {
    if (hnum != Hcnt[i].first) break;
    int64_t tmp_key0 = Hcnt[i].second * 1e6 + wi;
    if (bomb.count(tmp_key0) == 0) {
      cout << (answer + 1) << endl;
      return 0;
    }
  }
  for (int i = 1; i < W; ++i) {
    if (wnum != Wcnt[i].first) break;
    int64_t tmp_key1 = hi * 1e6 + Wcnt[i].second;
    if (bomb.count(tmp_key1) == 0) {
      cout << (answer + 1) << endl;
      return 0;
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 21972
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

typedef long long ll;

#define REP(var,n) for(int var=0;var<(n);var++)
#define REPP(var,n) for(int var=1;var<(n);var++)
#define ALL(c) (c).begin(),(c).end()

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

    ll a[N], sum[N];
    REP(i,N){
       cin >> a[i];
       if(i>0){
           sum[i] = sum[i-1]+a[i];
       }
       else{
           sum[0] = a[0];
       }
    }
    int j,k,l;
    int x=1;
    int y=0;
    int z=2;// 各切れ目を表す。

    vector<ll> result(4);
    vector<ll> value;
    for(x=1;x<N-2; x++){
        //左、右の総和を計算する
        ll leftsum = sum[x];
        ll rightsum = sum[N-1]-sum[x];

        for(j=y;j<=x;j++){
            //もし端っこまで行ったらその手前で切らないといけない
            if(j==x){
               y=x-1;
               break;
            }
            //全体の半分超えたところを覚えておく
            if(sum[j] > leftsum/2){
                y=j;
                break;
            }
        }
        for(k=z;k<N;k++){
            if(k==N-1){
                z=N-2;
                break;
            }
            
            if(sum[k]-sum[x] > rightsum/2){
                z=k;
                break;
            }
        }
        for(int j=y-1;j<=y;j++){
            if(j>=0){
                for(int k=z-1;k<=z;k++){
                    result[0] = sum[j];
                    result[1] = sum[x]-sum[j];
                    result[2] = sum[k]-sum[x];
                    result[3] = sum[N-1]-sum[k];                
                    sort(result.begin(), result.end());
                    value.push_back(result[3]-result[0]);                  
                }
            }
        }

    }
    sort(value.begin(), value.end());
    cout << value[0] << endl;
}


Measured memory_bytes: 13548