akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
     
    #define INF 1e9
    #define llINF 1e18
    #define MOD 1e9+7
    #define pb push_back
    #define mp make_pair 
    #define F first
    #define S second
    #define ll long long
    using namespace std;
    map<ll,ll>ma;
    int main(){
      int a;
      cin>>a;
      vector<ll>num(a);
      vector<ll>sum(a);
      for(int i=0;i<a;i++){
        cin>>num[i];
        if(i!=0)
          sum[i]=sum[i-1]+num[i];
        else
          sum[i]=num[i];
      }
      if(a==1&&num[0]==0)
        cout<<1<<endl;
      else{
      sort(sum.begin(),sum.end());
      ll ans=0;
      for(int i=0;i<a-1;i++){
        ll cnt=1;
        while(i<a-1&&sum[i]==sum[i+1]){
          cnt++;
          i++;
        }
        if(sum[i]==0)
          ans+=(cnt*(cnt+1))/2;
        else
          ans+=(cnt*(cnt-1))/2;
      }
      cout<<ans<<endl;
      }
      return 0;
    }

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


int con(int a){
    if(a < 0) return -1 * a;
    else return a;
} 


int main(){
    int n, l,sum = 0;
    cin >> n >> l;
    for(int i = 1;i <= n;i++){
        sum += l + i - 1;
    }
    int lmin = 1000,fl;
    for(int i = 1;i <= n;i++){
        if(con(l + i - 1) < lmin) fl = i;
        lmin = min(con(l + i -1),lmin);
    }
    cout << sum - (l + fl - 1) << endl;

    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>

#define R 1000000007

using namespace std;

int main()
{
	int a, b;
  	cin >> a >> b;
  	if( a >= 1 && a <= 9 && b >= 1 && b <= 9)
      cout << a * b << '\n';
  	else
      cout << -1 << '\n';
}

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

using namespace std;

int main()
{
  long long int n, ans = 0;

  scanf("%lld", &n);

  vector<long long int> a(3 * n);

  for (int i = 0; i < 3 * n; i++)
  {
    scanf("%lld", &a[i]);
  }

  sort(a.begin(), a.end(), greater<int>());

  for (int i = 0; i < n; i++)
  {
    ans += a[2 * i + 1];
  }

  printf("%lld", ans);
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int N;
	cin >> N;
	vector<int> v(N);
	vector<int> c(N);
	for(int i=0; i<N; i++){
		cin >> v[i];
	}
	for(int i=0; i<N; i++){
		cin >> c[i];
	}
	vector<int> sum(N);
	for(int i=0; i<N; i++){
		sum[i]=v[i]-c[i];
	}
	int max=0;
	for(int i=0; i<N; i++){
		if(sum[i]>0)max+=sum[i];
	}
	cout << max << endl;
	return 0;
}

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

int q(int x, int y) {
	if (x < y) return y;
	else return x;
}

int main() {
	v(a); v(b);
	int c;
	c = q(a + b, a - b);
	c = q(c, a * b);
	printf("%d\n", c);
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static Map<Integer, Integer> map = new HashMap<>();

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long ans = 1;
        final int MOD = (int) (Math.pow(10, 9) + 7);
        for (int i = 1; i <= n; i++) {
            getPf(i);
        }
        for(int a : map.values()) {
            ans *= (a + 1);
            ans %= MOD;
        }
        System.out.println(ans);
    }

    // 素因数分解
    private static Map<Integer, Integer> getPf(int n) {
        for (int i = 2; i * i <= n; i++) {
            while (n % i == 0) {
                map.merge(i, 1, Integer::sum);
                n /= i;
            }
        }
        if (n != 1) {
            map.merge(n, 1, Integer::sum);
        }
        return map;
    }
}

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

int main(){
	long long n,a,cnt=0;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a;
		if(a%2) cnt++;
	}
	if(cnt%2==0){
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100005
#define NIL -1

struct Node{int p,l,r;};

struct Node T[MAX];
int n,D[MAX];

void print(int u){
  int i, c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);
  
  if(T[u].p == NIL )printf("root, ");
  else if(T[u].l == NIL )printf("leaf, ");
  else printf("internal node, ");
  
  printf("[");
  
  for( i=0  , c=T[u].l; c != NIL; i++, c =T[c].r ){
    if(i !=0)printf(", ");
    printf("%d",c);
  }
  
  printf("]");
  printf("\n");
}

int rec(int u,int p){
  D[u] = p;
  if(T[u].r !=NIL)rec(T[u].r,p);
  if(T[u].l !=NIL)rec(T[u].l,p+1);
}

int main(){
  int i,j,d,c,v,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++)T[i].p = T[i].l = T[i].r = NIL;
  
  for( i = 0; i < n; i++ ){
    scanf("%d %d",&v,&d);
    for( j = 0; j < d; j++ ){
      scanf(" %d",&c);
      if( j == 0 ) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  for( i = 0; i < n; i++ ){
    if(T[i].p == NIL)r = i;
  }
  
  rec(r, 0);
  
  for( i = 0; i < n; i++ )print(i);
  
  return 0;
}



Measured memory_bytes: 6392
#include <bits/stdc++.h>
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
#define endl '\n'
using namespace std;
using ll = long long int;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 1123456;
int main() {
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);
    printf("%d\n", k/n*m);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main()
{
	string n;
	int sum=0, m, n1;
	cin >> n;
	n1 = stoi(n);
	m = n.length();
	rep(i,m){
		sum += n[i]-48;
	}
	if(n1%sum == 0) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
using ll = long long;

const long double PI = acos(-1);
const int MOD = 1e9 + 7;

int main() {
    int k;
    string s;
    cin >> k >> s;
    

    int len = s.size();
    if(len <= k) cout << s << endl;
    else {
        for(int i = 0; i < k; i++) {
            cout << s[i];
        }
        cout << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
#define FOR(i, a, b) for (ll i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (ll i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 100005
int n; ll m;
int q;
pair<pii, int> qs[MN];
vi e[MN]; //0 edges
int cc[MN];

void dfs(int cn, int c){
    if(cc[cn] == c) return;
    cc[cn] = c;
    for(auto nn : e[cn]){
        dfs(nn, c);
    }
}

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

    cin >> n >> m >> q;
    F0R(i, q){
        cin >> qs[i].f.f >> qs[i].f.s >> qs[i].s;
        if(qs[i].s == 0){
            e[qs[i].f.f].pb(qs[i].f.s);
            e[qs[i].f.s].pb(qs[i].f.f);
        }
    }
    int t = 0;
    F0R(i, n){
        if(cc[i] == 0){
            dfs(i, ++t);
        }
    }
    F0R(i, q){
        if(qs[i].s == 1){
            if(cc[qs[i].f.f] == cc[qs[i].f.s]){
                cout << "No\n";
                return 0;
            }
        }
    }
    if(m == n-1){
        F0R(i, q){
            if(qs[i].s == 1){
                cout << "No\n";
                return 0;
            }
        }
        cout << "Yes\n";
        return 0;
    }
    ll mx = n-t+1LL*t*(t-1)/2;
    //cout << t << " " << mx << "\n";
    if(m <= mx){
        cout << "Yes\n";
    } else{
        cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair<int , int>
#define pll pair<long long int,long long int>
#define mod 1000000007
#define inf 1e18+7
#define eps 0.00001
#define endl '\n'
int main()
{
    fastio;
    
    ll n,m,x;
    cin>>n>>m>>x;
    ll a[n+1]={0};
    for(ll i=0;i<m;i++)
    {
        ll x;
        cin>>x;
        a[x]=1;
    }  
    ll i=0,s1=0,s2=0;
    for(i=0;i<=x;i++)
        s1+=a[i];
    for(i=x;i<=n;i++)
        s2+=a[i];
    cout<<min(s1,s2);

}

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

namespace competitive_programming
{
    class Program
    {
        static void Main(string[] args)
        {
            var main = new Program();
            main.solve();
        }

        void solve()
        {
            int[] xyz = Console.ReadLine().Split(' ').Select(val => int.Parse(val)).ToArray();
            int x = xyz[0];
            int y = xyz[1];
            int z = xyz[2];

            Console.WriteLine(z + " " + x + " " + y);
        }
    }

    struct Vector2
    {
        public Vector2(long x, long y)
        {
            this.x = x;
            this.y = y;
        }
        public long x;
        public long y;
    }

    struct Vector3
    {
        public int x;
        public int y;
        public int z;
    }
}


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

using namespace std;

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

  int n, k, x, y;
  cin >> n >> k >> x >> y;
  if (n <= k) {
    cout << n * x << "\n";
  } else {
    cout << (k * x) + (n - k) * y << "\n";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
          using namespace std;
          #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
          #define M_PI 3.14159265358979323846
          #define data data_
          #define ff first
          #define ss second

          int main()
          {
          // clock_t begin = clock();
          // #ifndef ONLINE_JUDGE
          // freopen("input.txt", "r", stdin);
          // freopen("output.txt", "w", stdout);
          // #endif
          tani_nachi_ke  

          long long n;
          cin >> n;
          long long ans = n;
          for(long long i = 1; i*i<=n; i++)
          {
               if(n%i==0)
               {
                    ans = min(i-1 + (n/i) -1,ans);
               }
          }
          cout << ans << endl;

          // #ifndef ONLINE_JUDGE 
          // clock_t end = clock();
          // cout<<endl<<double(end - begin) / CLOCKS_PER_SEC*1000<<" ms";
          // #endif 
          // return 0;
          }

Measured memory_bytes: 256
h,w = map(int,input().split())
g = [['.'] * (w+2) for i in range(h+2)]
ss = set() #'#'のset
for i in range(h):
  g[i+1][1:-1] = list(input())
  for j in range(w):
    if g[i+1][j+1] == '#':
      ss.add((i+1,j+1))
if g[1][1] == '.':
  print('Impossible')
  exit()
cur = (1,1)
ts = set() #通った点のset
ts.add(cur)
while cur != (h,w):
  if g[cur[0]+1][cur[1]] == '#':
    cur = (cur[0]+1,cur[1])
    ts.add(cur)
  elif g[cur[0]][cur[1]+1] == '#':
    cur = (cur[0],cur[1]+1)
    ts.add(cur)
  else:
    print('Impossible')
    exit()
if ts == ss:
  print('Possible')
else:
  print('Impossible')

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

const ll mod = 998244353;

int main() {
    int n, s;
    cin >> n >> s;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> dp(s+1, 0);
    dp[0] = 1;
    rep(i, n) {
        vector<ll> p(s+1, 0);
        swap(dp, p);
        rep(j, s+1) {
            dp[j] += (p[j] * 2) % mod;
            dp[j] %= mod;
            if (j + a[i] <= s) {
                dp[j+a[i]] += p[j];
                dp[j+a[i]] %= mod;
            }
        }
    }
    cout << dp[s] << endl;
}


Measured memory_bytes: 3692
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    int a, b, d, r;
    double f;

    cin >> a >> b;
    
    d = a / b;
    r = a % b;
    f = 1.0 * a / b;

    cout << d << " " << r << " " << fixed << setprecision(6) << f << " " << endl;

    return 0;
}


Measured memory_bytes: 3284
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  int n, k;
  cin >> n >> k;
  double ans = 0;
  for (int i = 1; i <= n; i++) {
    int num = 0;
    int s = i;
    while (s < k) {
      s *= 2;
      num++;
    }
    ans += pow(0.5, num) / double(n);
  }

  printf("%.10f\n", ans);

  return 0;
}


Measured memory_bytes: 256
n,x=map(int,(input().split()))
list_m=[int(input()) for _ in range(n)]
if x-sum(list_m)<0:
    print("fail")
x=x-sum(list_m)
ans=0
while x-min(list_m)>=0:
    x = x-min(list_m)
    ans+=1
print(ans+n)

Measured memory_bytes: 3188
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle
using ll = long long ;
int main() {
    int n, k;
    cin >> n >> k;

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

    int dp[n];
    for(int i = 0; i < n; i++)
    	dp[i] = INT_MAX;
    dp[0] = 0;

    for(int i = 1; i < n; i++) {
        for(int j = 1; j <= k && j <= i; j++)
            dp[i] = min(dp[i], dp[i-j]+abs(a[i]-a[i-j]));
    } 
    cout << dp[n-1];  
    return 0;
}

Measured memory_bytes: 1024
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <list>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<Pii> s;
    REP(i, N)
    {
        int a, b;
        cin >> a >> b;
        s.push_back(Pii(a, b));
    }

    sort(s.begin(), s.end());

    ll cnt = 0;
    ll ret = 0;
    REP(i, N)
    {
        if (M > cnt)
        {
            ll n = min(M - cnt, (long long)s[i].second);
            cnt += n;
            ret += s[i].first * n;
        }
    }

    cout << ret << endl;
}

void cheatsheet()
{
    // loop
    // vector<int> vec(10);
    vector<int> vecloop;
    REP(i, 10)
    {
        vecloop.push_back(i);
    }

    // swap
    int a = 1;
    int b = 5;
    swap(a, b); // -> a = 5, b = 1

    // sort
    int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    sort(arr, arr + 9, greater<int>()); // 9 8 7 6 5 4 3 2 1

    // lower
    vector<int> vec(arr, end(arr));
    sort(vec.begin(), vec.end());
    cout << lower_bound(vec.begin(), vec.end(), 2)[0]; // 2

    // map
    map<Pll, ll> m;
    m[Pll(10, 100)] = 100;
}

Measured memory_bytes: 1400
using System;

class p0009{
	p0009(){
		string str;
		int mx = 1000001;
		
		bool[] f = new bool[mx];
		for(int i = 0; i < mx; ++i)
			f[i] = true;
		f[0] = f[1] = false;
		
		for(int i = 0; i < mx; ++i)
			if(f[i])
				for(int j = i*2; j < mx; j+=i)
					f[j] = false;
		
		
		while((str=Console.ReadLine())!=null){
			int count = 0, n = int.Parse(str);
			for(int i = 2; i <= n; ++i) if(f[i]) ++count;
			Console.WriteLine("{0}", count);
		}
	}
	
	static void Main(string[] args){
		new p0009();
	}
}

Measured memory_bytes: 6608
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

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

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> P(N);
    for (int n = 0; n < N; ++n) cin >> P[n];
    
    int Res = 0;
    for (int n = 1; n < N-1; ++n) {
        set<int> S;
        S.insert(P[n-1]);
        S.insert(P[n]);
        S.insert(P[n+1]);
        auto it = S.begin();
        ++it;
        if (*it == P[n]) {
            ++ Res;
        }
    }
    cout << Res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
	int n;
	cin >> n;
	llong t=0, a=0;
	cin >> t >> a;
	llong tmp_t, tmp_a, rate_t, rate_a, rate;
	REP(i, n-1){
		cin >> tmp_t >> tmp_a;
		if(t > tmp_t || a > tmp_a){
			rate_t = t%tmp_t==0 ? (llong)(t/tmp_t) : (llong)(t/tmp_t) + 1;
			rate_a = a%tmp_a==0 ? (llong)(a/tmp_a) : (llong)(a/tmp_a) + 1;
			rate = max(rate_t, rate_a);
			t = rate * tmp_t;
			a = rate * tmp_a;
		} else {
			t = tmp_t;
			a = tmp_a;
		}
	}
	cout << t+a << '\n';
	
	return 0;
}


Measured memory_bytes: 256
s = input()

fst = int(s[0:2])
snd = int(s[2:4])

if fst > 0 and fst <= 12:
    # MMYY, AMBIGUOUS
    if snd > 0 and snd <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    # YYMM, NA
    if snd > 0 and snd <= 12:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3060
n, m = map(int, input().split())
G = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
def bridge(g, v, s=0):
    bl = [False] * v
    c_memo = [0] * v
    c_used = [False] * v
    b_g = [[] for i in range(v)]
    def dfs(v, f, l):
        bcnt = fcnt = 0
        c_used[v] = True
        for t in g[v]:
            if not c_used[t]:
                ll = []
                ret = dfs(t, v, ll)
                if ret>0:
                    l += ll
                else:
                    b_g[t] = ll
                    for u in ll:
                        b_g[u].append(t)
                    l.append(t)
                bcnt += ret
            else:
                if t==f:
                    if fcnt==1:
                        c_memo[f] -= 1
                        bcnt += 1
                    fcnt += 1
                elif not bl[t]:
                    c_memo[t] -= 1
                    bcnt += 1
        bl[v] = True
        bcnt += c_memo[v]
        return bcnt
    dfs(s, -1, b_g[s])
    for u in b_g[s]:
        b_g[u].append(s)
    return b_g
G = bridge(G, n)
ans = 0
for i in range(n):
    for v in G[i]:
        if i < v:
            ans += 1
print(ans)

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A + B  == C + D) {
    cout << "Balanced" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
  else {
    cout << "Left" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	private void compute(){
		Scanner sc = new Scanner(System.in);
		int sum = 0;
		for( int i = 0; i < 10; i++){
			int x =  sc.nextInt();
			sum += x;
		}
		System.out.println(sum);
		}
	
	public static void main(String args[]){
		new Main().compute();
	}
	
}

Measured memory_bytes: 17308
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(v) for (auto itr = v.begin(), itr != v.end(); ++itr)
#define LB(v, x) lower_bound(v.begin(), v.end(), x) - v.begin()
#define UB(v, x) upper_bound(v.begin(), v.end(), x) - v.begin()
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll dp[2001][2001];

void cmax(ll &a, ll b) { a = max(a, b); }

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

    int N;
    cin >> N;
    vector<pair<ll, ll>> p(N);
    REP(i, N) {
        cin >> p[i].first;
        p[i].second = i;
    }
    SORTR(p);

    FOR(i, 1, N + 1) {
        FOR(j, 0, i + 1) {
            if (j > 0) {
                cmax(dp[i][j],
                     dp[i - 1][j - 1] +
                         p[i - 1].first * abs(p[i - 1].second - j + 1));
            }
            if (j < i) {
                cmax(dp[i][j],
                     dp[i - 1][j] + p[i - 1].first * abs(N - 1 - (i - 1 - j) -
                                                         p[i - 1].second));
            }
        }
    }
    ll res = 0;
    FOR(i, 1, N + 1) cmax(res, dp[N][i]);
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 26280
import java.util.*

fun main(args : Array<String>) {
        val scanner = Scanner(System.`in`)
        println(inOutExec(scanner))
        }

        fun inOutExec(scanner: Scanner): String {
        val numOfPref = scanner.nextInt()
        val numOfCity = scanner.nextInt()

        val citiesIn = mutableListOf<Pair<Int, Int>>()
        repeat(numOfCity) {
        citiesIn.add(Pair(scanner.nextInt(), scanner.nextInt()))
        }

        val cityCodeMap = citiesIn
        .groupByTo(mutableMapOf()) { it.first }
        .flatMap { entry -> entry.value // List<Pair<Int, Int>>
        .sortedBy { info -> info.second }
        .mapIndexed { index, pair ->
        pair to "%06d%06d".format(pair.first, index + 1) } } // Pair<Pair<Int, Int>, String>
        .toMap()

        return citiesIn.joinToString(separator = "\n", postfix = "\n") { cityCodeMap[it]!! }
        }


Measured memory_bytes: 154528
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

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

int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}
// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}


#pragma endregion

//ABC 135 -C City Saver
#define MAX 100001
//#define MAX 101
int cnt_m(int* a, int* b, ll* ans);
int cnt_m(int* a, int* b, ll* ans) {
	if (*a >= *b) {
		*ans += *b;
		*a -= *b;
		return 0;
	}
	
	*ans += *a;
	*b -= *a;
	*a = 0;
	return 1;
}


int main(void) {
	int n, i;
	ll  ans = 0;
	int a[MAX], b[MAX];


	scanf("%d", &n);

	for (i = 0; i < n+1; i++) 
		scanf("%d", &a[i]);

	for (i = 0; i < n; i++)
		scanf("%d", &b[i]);

	int rc = 0;
	for (i = 0; i < n; i++) {
		rc = cnt_m(&a[i], &b[i], &ans);
//		printf("\n%d ", ans);
		if (rc == 0) continue;
		if (i + 1 > n) break;
		rc = cnt_m(&a[i + 1], &b[i], &ans);
//		printf("\n%d ", ans);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	using P = pair<ll,ll>;
	
	ll K,x,y;
	cin >> K >> x >> y;
	if(K%2 ==0 && (x+y)%2 != 0){
		cout << -1 << endl;
		return 0;
	}
	V<P> ps;
	ps.emplace_back(x,y);
	function<P(P)> Next = [&](P p){
		ll x = p.fs, y = p.sc;
		if(x < 0){
			P t = Next(P(-x,y));
			return P(-t.fs,t.sc);
		}
		if(y < 0){
			P t = Next(P(x,-y));
			return P(t.fs,-t.sc);
		}
		if(x < y){
			P t = Next(P(y,x));
			return P(t.sc,t.fs);
		}
		if(x + y >= 2*K){
			return P(x-K,y);
		}
		if(x + y == K){
			return P(0,0);
		}
		return P(x+y-(x+y)/2,-K+(x+y)/2);
	};
	while(ps.back() != P(0,0)){
		ps.pb(Next(ps.back()));
	}
	int M = ps.size();
	cout << M-1 << endl;
	rep(i,M-1) cout << ps[M-2-i].fs << " " << ps[M-2-i].sc << endl;
}


Measured memory_bytes: 5996
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int point;
	vector<int>a(200);

	for(int i=0;i<n;i++){
		cin>>a.at(i);
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());

	for(int i=0;i<n;i+=2){
		point+=a.at(i);
		point-=a.at(i+1);
	}
	cout<<point<<endl;
	return 0;
}

Measured memory_bytes: 256
/**
 *      AGC 24 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-11 01:24:02
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int A, B, C; cin >> A >> B >> C;
    ll K; cin >> K;

    if (A == B){
        cout << 0 << endl;
    }
    else if (K % 2 == 1){
        cout << B - A << endl;
    }
    else if (K % 2 == 0){
        cout << A - B << endl;
    }

    return 0;
}

Measured memory_bytes: 256
using System;

public class SingleSourceShortestPath
{
	const int MAX = 100;
	const int INFTY = Int32.MaxValue;
	const int WHITE = 0;
	const int GRAY = 1;
	const int BLACK = 2;

	static int vertexNum; // ????????° = V
	static int[,] M = new int[MAX,MAX]; // ????????????????¨????????????£??\??????

	static void dijkstra() {
		int minv;
		int[] d = new int[MAX]; // ?§????s????????????v?????§??????????????????????¨????
		int[] color = new int[MAX]; // ?¨??????¶???????????§??¨???

		// ?????????
		for (int i = 0; i < vertexNum; i++) {
			d[i] = INFTY;
			color[i] = WHITE; 
		}

		// ????????????????????????
		d[0] = 0;
		color[0] = GRAY;

		while (true) {
			minv = INFTY;
			int u = -1;
			for (int i = 0; i < vertexNum; i++) {
				// ???????¨???????????????????????????´???
				if (minv > d[i] && color[i] != BLACK) {
					u = i;
					minv = d[i]; //????°???????????????´??°
				}
			}
			// ???????????¢?´¢?????????????????????
			if (u == -1)
				break;
			// ?¨????????????????????????´
			color[u] = BLACK;

			for (int v = 0; v < vertexNum; v++) {
				//???????¨?????????????????????????u??¨v?????????????????????
				if (color[v] != BLACK && M[u,v] != INFTY) {
					if (d[v] > d[u] + M[u,v]) {
						d[v] = d[u] + M[u,v];
						color[v] = GRAY;
					}
				}
			}
		}
		// ????????¨?????????????????????
		for (int i = 0; i < vertexNum; i++) {
			Console.WriteLine ("{0} {1}", i, (d[i] == INFTY ? -1 : d[i]));
		}
	}
	public static void Main(String[] args) {
		// ????????°
		vertexNum = int.Parse(Console.ReadLine ());
		// ??????????????????
		for (int i = 0; i < vertexNum; i++) {
			for (int j = 0; j < vertexNum; j++) {
				M[i,j] = INFTY;
			}
		}

		int k, c, u, v;
		for (int i = 0; i < vertexNum; i++) {
			string[] readLine = Console.ReadLine().Split(' ');
			int s = 0;
			u = int.Parse(readLine[s]);	// ????????????
			s++;
			k = int.Parse(readLine[s]); 	// ????¬???°
			for (int j = 0; j < k; j++) {
				s++;
				v = int.Parse(readLine[s]);	// ??£??\?????????????????????
				s++;
				c = int.Parse(readLine[s]); // u??¨v????????????????????????
				M[u, v] = c;
			}
		}
		dijkstra ();
	}
}

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

signed main(){
  int N;
  cin>>N;
  int ne=1005,fa=0;
  rep(i,N){
    int H;
    cin>>H;
    ne=min(ne,H);
    fa=max(fa,H);
  }
  cout<<fa-ne<<endl;
}

Measured memory_bytes: 256
import queue

def main():
    n = int(input())
    rows = []
    for i in range(n):
        rows.append([int(x) for x in input().split()])

    vum = {}
    for row in rows:
        u,k = row[0],row[1]
        ul = []
        if k > 0:
            for j in row[2:]:
                ul.append(j)
        vum.update({u:ul})
    # print(vum)

    ### bfs ###
    q = queue.Queue()
    D = [-1]*n # 最短距離
    s = 1 # 始点
    step = 0
    D[s-1] = step
    while True:
        # print('s',str(s))
        step = D[s-1] + 1
        for v in vum[s]:
            # print('v',str(v))
            if D[v-1] < 0:
                # print('append v',str(v),str(step))
                q.put(v)
                D[v-1] = step
        if q.empty():
            break
        # print(list(q.queue),V)
        s = q.get()

    for i,d in enumerate(D):
        print(str(i+1),d)

if __name__ == '__main__':
    main()



Measured memory_bytes: 7016
import sys
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall as f
def main():
  t=np.fromstring(sys.stdin.buffer.read(),int,sep=' ')
  n,m,l=t[:3]
  m=m*3+3
  d=f(f(csr_matrix((t[5:m:3],(t[3:m:3],t[4:m:3])),[n+1]*2),0)<=l)[t[m+1::2],t[m+2::2]]
  d[d>n]=0
  print('\n'.join((d.astype(int)-1).astype(str).tolist()))
main()

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

int main() {
	string s;
	cin >> s;
	//ACGT
	int k = 0,mk=0;
	for(int i=0;i<s.size();i++)
	{
		char x = s.at(i);
		if(x=='A'||x=='C'||x=='G'||x=='T')
		{
			mk++;
		}
		else
		{
			mk=0;
		}
		k = max(k,mk);
	}
	cout << k << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+100;
typedef long long ll;
int n,m;
ll sum,ans,d,c;
int main(){
	scanf("%d",&n);
	for (int i = 0; i < n; ++i){
		scanf("%lld%lld",&d,&c);
		sum += d*c;
		ans += c;
	}
	ans = ans - 1 + (sum - 1) / 9;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
n,k=map(int, input().split())
x=list(map(int, input().split()))

ans=float('inf')
for i in range(n-k+1):
    r=x[i]
    l=x[i+k-1]
    if r<0 and 0<=l:
        tmp_ans=min(2*abs(r)+l, abs(r)+2*l)
    elif 0<=r:
        tmp_ans=l
    else:
        tmp_ans=abs(r)
    ans=min(ans,tmp_ans)
print(ans)

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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;
const ll MAXN = 1e6 + 5;

vector < ll > fact(MAXN);

ll pwr(ll a, ll b){
  ll res = 1;
  while(b > 0){
    if(b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}

ll inv(ll a){
  return pwr(a, mod - 2);
}

ll comb(ll n, ll r){
  return (((fact[n] * inv(fact[n - r]) % mod)  * inv(fact[r])) % mod);
}

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

  fact[0] = 1;
  for(int i = 1; i < MAXN; i++) fact[i] = (i * fact[i - 1]) % mod;

  ll x, y;
  cin >> x >> y;
  if((x + y) % 3 != 0){
    cout << 0 << endl;
  }else{
    ll ans = 0;
    for(int n = 0; n <= x; n++){
      if((x - n) % 2 == 0){
        ll m = (x - n) / 2;
        if(2 * n + m != y) continue;
        ans += comb(n + m, n);
        ans %= mod;
      }
    }
    cout << ans << '\n';
  }
}


Measured memory_bytes: 8064
// https://atcoder.jp/contests/arc095/tasks/arc095_a
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize,
        x: [i32; n]
    };

    let mut x = x.into_iter().zip(0..n).collect::<Vec<_>>();
    x.sort();

    let mut ans = vec![0; n];
    for i in 0..n {
        let idx = x[i].1;
        if i < n/2 {
            ans[idx] = x[n/2].0;
        } else {
            ans[idx] = x[n/2-1].0;
        }
    }
    println!("{}", join!(ans, "\n"));
}


Measured memory_bytes: 24568
class UnionFind():
    def __init__(self, n):
        # 正==子: 根の頂点番号 / 負==根: 連結頂点数
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        #要素xが属するグループの根を返す
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        #要素xが属するグループと要素yが属するグループとを併合する
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        # 要素xが属するグループのサイズ（要素数）を返す
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
        # 要素x, yが同じグループに属するかどうかを返す
        return self.find(x) == self.find(y)
 
    def members(self, x):
        # 要素xが属するグループに属する要素をリストで返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):
        # すべての根の要素をリストで返す
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):
        # グループの数を返す
        return len(self.roots())
 
    def all_group_members(self):
        # {ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
        return {r: self.members(r) for r in self.roots()}
 
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
        
########################################
n,m,k = map(int, input().split())
u = UnionFind(n)
ans = [0]*n

for i in range(m):
    a,b = map(int,input().split())
    u.union(a-1,b-1)
    ans[a-1] -= 1
    ans[b-1] -= 1

for i in range(n):
    ans[i] += u.size(i) - 1

for i in range(k):
    c,d = map(int,input().split())
    if u.same(c-1,d-1):
        ans[c-1] -= 1
        ans[d-1] -= 1

print(*ans)


Measured memory_bytes: 81592
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N = readint()
    sp = [readstrs() for _ in range(N)]
    S = list(map(lambda x: x[0], sp))
    t = {x: [] for x in S}
    for v in sp:
        t[v[0]].append(v[1])

    for k in t.keys():
        t[k] = sorted(list(map(int, t[k])), reverse=True)

    for k, v in sorted(t.items()):
        for vv in v:
            print(sp.index([k, str(vv)]) + 1)


if __name__ == "__main__":
    main()


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

#define ALL(a) (a).begin(), (a).end()
#define ll long long

using namespace std;

signed main(){
    string s,t;
    cin >> s >> t;
    for(int i = 0; i < s.size(); i++){
        s = s.back() + s.substr(0,s.size()-1);
        if(s == t){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>

int main(){

    std::string s;
    std::getline(std::cin, s);

    for(auto&& e : s){
        if(std::islower(e)){
            e = std::toupper(e);
        }else{
            e = std::tolower(e);
        }
    }

    std::cout << s << std::endl;

    return 0;
}



Measured memory_bytes: 3180
def resolve():
    MOD = 10 ** 9 + 7
    H, W = map(int, input().split())
    G = [list(input()) for _ in range(H)]

    dp = [[0] * W for _ in range(H)]
    dp[0][0] = 1

    for i in range(H):
        for j in range(W):
            if i + 1 < H and G[i + 1][j] == ".":
                dp[i + 1][j] += dp[i][j]
                dp[i + 1][j] %= MOD
            if j + 1 < W and G[i][j + 1] == ".":
                dp[i][j + 1] += dp[i][j]
                dp[i][j + 1] %= MOD
    print(dp[H-1][W-1])


if __name__ == "__main__":
    resolve()


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

int main(){
	int a,b;
	string s;
	cin >> a >> b >> s;
	int num[10]={};
	rep(i,10)num[i]=i;
	rep(i,a+b+1){
		if(i==a){
			if(s[i]!='-'){puts("No");return 0;}
			continue;
		}
		if(!isdigit(s[i])){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}


Measured memory_bytes: 256
#500円玉
a = int(input())
#100円玉
b = int(input())
#50円玉
c = int(input())
#50の倍数
x = int(input())

h = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            y = 500*i + 100*j + 50*k
            if x == y:
                h += 1
print(h)



Measured memory_bytes: 9112
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999999;



int main(){
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    a*=100;
    b*=100;
    int ans1=0;
    int ans2=0;
    ld maxcon=-1;
    for(int A=0;A*a<=f;A++){
        for(int B=0;B*b<=f;B++){
            int water=A*a+B*b;
            if(water==0 || water>f) continue;
            int maxsuger=water/100*e;
            for(int C=0;C*c<=maxsuger;C++){
                for(int D=0;D*d<=maxsuger;D++){
                    int suger=C*c+D*d;
                    if(water+suger>f) continue;
                    if(suger>maxsuger) continue;
                    if(maxcon<(ld)suger/water){
                        maxcon=(ld)suger/water;
                        //cout<<maxcon<<endl;
                        ans1=water+suger;
                        ans2=suger;
                    }
                }
            }

        }
    }
    cout<<ans1<<" "<<ans2<<endl;
    
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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; }

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  char x,y;
  cin >> x >> y;

  cout << (x-y>0 ? '>' : y-x>0 ? '<' : '=') << endl;
  return 0;
} 

Measured memory_bytes: 3600
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.abs
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    out.println("ABC$n")
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 34120
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

int[] calc(int[] a) {
	int t;
	int p;
	t = a[1] + a[2] + a[3] + (a[4] + a[5]) * a[8];
	p = a[6] * a[7] * a[8] - a[0];
	return [t, p];
}

void main(){
	while(true) {
		auto n = readInt();
		if(n == 0) return;

		alias A = Tuple!(string, "name", int[], "tp");
		A[] a;
		for(int i; i < n; ++i) {
			auto s = readln().chomp.split;
			a ~= A(s[0], calc(s[1..$].map!(to!int).array));
		}
		a.sort!((x,y) => x.tp[1] * y.tp[0] > x.tp[0] * y.tp[1] || (x.tp[1] * y.tp[0] == x.tp[0] * y.tp[1] && x.name < y.name));
		a.each!(x => writeln(x.name));
		writeln("#");
	}
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> sub(N, 0);
  
  rep(i, N-1) {
    int A;
    cin >> A;
    --A;
    ++sub[A];
  }
  
  for(int i : sub) cout << i << endl;
  
  return 0;
}

Measured memory_bytes: 4032
n = gets.to_i
arr = gets.chomp.split(" ").map(&:to_i)
num_times_arr = Array.new(n,0)
arr.each do |i|
  num_times_arr[i - 1] += 1
end
sum = 0
num_times_arr.each do |i|
  sum += i * (i - 1) / 2
end
arr.each do |i|
  puts sum - num_times_arr[i - 1] + 1
end

Measured memory_bytes: 24580
def Main():
    N = int(input())
    adj = [[0]*N for i in range(N)]

    for n in range(N):
        u, k, *V = map(int, input().split())
        
        if k > 0:
           for i in V:
            adj[u - 1][i - 1] = 1

    for i in range(N):
        print(*adj[i])

Main()


Measured memory_bytes: 6380
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

ll choose2(ll n) {
    return n*(n-1)/2;
}

int main() {
    int N;
    cin>>N;
    vi A(N);
    rep(i,N) cin>>A[i];
    rep(i,N) A[i]--;
    vi v(N);
    rep(i,N) v[A[i]]++;
    ll tot=0;
    rep(i,N) tot+=choose2(v[i]);
    rep(i,N) {
        ll answer=tot;
        answer-=choose2(v[A[i]]);
        answer+=choose2(v[A[i]]-1);
        cout<<answer<<endl;
    }
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X;
  cin >>X;
  //縺ｹ縺堺ｹ玲焚縺ｧ縺ゅｋ縺・
  vector<bool> expo(X+1);
  expo[1] = true;
  //2縺九ｉx縺ｾ縺ｧ
  for(int b=2;b<=X;b++){
    int v = b*b;
    while(v<=X){
      expo[v] = true;
      v *= b;
    }
  }

  //陦ｨ遉ｺ
  for(int i=X;i>=1;i--) if(expo[i]){
    cout <<i<<endl;
    return 0;
  }
}


Measured memory_bytes: 256