akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,s[333][333]={},t[333][333]={},r[333][333]={};
	int c=0;
	cin>>n;
	FOR(i,0,n){
		string st;
		cin>>st;
		FOR(j,0,n){

			s[i][j]=st[j]-'a';
		}
	}
	FOR(i,0,n){
		FOR(j,0,n){
			int f=1;
			FOR(d,1,n){
				int i1=i+d,j1=j+d;
				if(i1-n>=0)i1-=n;
				if(j1-n>=0)j1-=n;
				if(s[i1][j]!=s[i][j1])f=0;

			}
			r[i][j]=f;
		}
	}
	/*
	FOR(i,0,n){
		FOR(j,0,n){
			printf("%2d ",r[i][j]);
		}
		cout<<endl;
	}//*/
	FOR(a,0,1){
		FOR(b,0,n){
			int f=1;
			FOR(d,0,n){
				int i1=d-a,j1=d-b;
				if(i1<0)i1+=n;
				if(j1<0)j1+=n;
				if(r[i1][j1]==0)f=0;
			}
			c+=f*n;
		}
	}
	cout<<c<<endl;
    return 0;
}


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

int main(){
    int n,q;
    cin >> n >> q;
    vector<tuple<int,int,int>> vec;
    for(int i=0;i<n;i++){
        int s,t,x;
        cin >> s >> t >> x;
        vec.emplace_back(make_tuple(s-x,x,1));
        vec.emplace_back(make_tuple(t-x,x,0));
    }
    for(int i=0;i<q;i++){
        int d;
        cin >> d;
        vec.emplace_back(make_tuple(d,2e9,-1));
    }
    sort(vec.begin(),vec.end());
    set<int> st;
    st.insert(2e9);
    for(auto t:vec){

        if(get<2>(t) == 1){
            st.insert(get<1>(t));
        }
        else if(get<2>(t) == 0){
            st.erase(get<1>(t));
        }
        else if(get<2>(t) == -1){
            if(*st.begin()<2e9) cout << *st.begin() << endl;
            else cout << -1 << endl;
        }
    }
}

Measured memory_bytes: 18408
import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

l=[lmp() for i in range(3)]
n1=l[0][0]-l[0][1]
n2=l[0][0]-l[0][2]

for i in range(1,3):

    if n1!=l[i][0]-l[i][1] or n2!=l[i][0]-l[i][2]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 38256
#include<iostream>
#include<cstdlib>
#define N 16
using namespace std;
int cost = 45,pos0;
int puzzle[N];
int dis() {
  int sum = 0;
  for (int i = 0; i < N; ++i)
    if (puzzle[i] != N-1) sum += abs(i / 4 - puzzle[i] / 4) + abs(i % 4 - puzzle[i] % 4);
  return sum;
}
void fswap(int x,int y) {
  int tmp;
  tmp = puzzle[x];
  puzzle[x] = puzzle[y];
  puzzle[y] = tmp;
}
void rec(int p,int move) {
  int d = dis(); //0ならばパズル完成
  if (d + move > cost) return;
  if (d == 0) {
    cost = move;
    return;
  }
  if (p != 1 && pos0 >= 4) fswap(pos0, pos0 - 4),pos0-=4, rec(0, move + 1),pos0+=4, fswap(pos0, pos0 - 4); //上に動かせるor動かす必要がある
  if (p != 0 && pos0 < 12) fswap(pos0, pos0 + 4),pos0+=4, rec(1, move + 1),pos0-=4, fswap(pos0, pos0 + 4); //下に動かせるor動かす必要がある
  if (p != 3 && pos0 % 4 > 0) fswap(pos0, pos0 - 1),--pos0, rec(2, move + 1),++pos0, fswap(pos0, pos0 - 1); //左に動かせるor動かす必要がある
  if (p != 2 && pos0 % 4 < 3) fswap(pos0, pos0 + 1),++pos0, rec(3, move + 1),--pos0, fswap(pos0 , pos0 + 1); //右に動かせるor動かす必要がある
	
}
int main() {
  for (int i = 0; i < N; ++i) {
    cin >> puzzle[i];
    if (puzzle[i] == 0) {
      puzzle[i] = N - 1;
      pos0 = i;
    }
    else --puzzle[i];
  }
  rec(-1,0);
  cout << cost << endl;
  return 0;
}



Measured memory_bytes: 3112
# ABC066b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

s = input()[:-1]


def isGu(st):
    if (len(st) % 2 != 0):
        return False
    flag = True
    for i in range(len(st) // 2):
        if (st[i] != st[i + len(st) // 2]):
            #print(i, i + len(st) // 2)
            flag = False
    return flag


for i in range(2, len(s), 2):
    if (isGu(s[:-i])):
        print(len(s[:-i]))
        exit()
print(0)

Measured memory_bytes: 3064
/* -------------------------------- Template -------------------------------- */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }

// template<typename T> constexpr T inf = [](){ assert(false); };
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;

struct yes_no : std::numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve();

int main() {
  std::locale loc(std::locale(), new yes_no);
  std::cout << std::boolalpha << std::setprecision(12) << std::fixed;
  std::cout.imbue(loc);
  solve();
  return 0;
}

using namespace std;

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

int a[128000];

void solve() {
  int N, x;
  cin >> N >> x;
  REP(i,N) cin >> a[i+1];
  ll res = 0;
  REP(i,N) {
    if (a[i] + a[i+1] > x) {
      int d = min(a[i+1], a[i] + a[i+1] - x);
      a[i+1] -= d;
      res += d;
    }
  }
  cout << res << endl;
  return;
}


Measured memory_bytes: 640
def f(str1, str2, it1, arr)
  #p [str1, str2, it1, arr]
  result = Array.new(arr.size)
  result[0] = it1
  str2[1..-1].each_with_index{|i, idx|
    if str1[it1] == i
      result[idx + 1] = arr[idx]
    else
      result[idx + 1] = arr[idx + 1] > result[idx] ? result[idx] + 1 : arr[idx +  1] + 1
    end
  }
  if it1 != str1.size - 1
    f(str1, str2, it1 + 1, result)
  else
    #p result[-1]
    return result[-1]
  end
end
def lgs(str1, str2)
  return ((str1.size + str2.size) - f([" "] + str1.split(//), [" "] + str2.split(//), 1, Array.new(str2.size + 1){|i|i})) / 2
end
def main(input = STDIN)
  input.gets.to_i.times do
    puts lgs(input.gets.chomp, input.gets.chomp)
  end
end
main



Measured memory_bytes: 33500
import java.util.Scanner;
import java.util.Arrays;
 
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int [] abc = new int[3];
         
        for(int i = 0; i < abc.length; i++){
            abc[i] = scan.nextInt();
        }
 		
        Arrays.sort(abc);
        System.out.println(abc[0] + " " + abc[1] + " " + abc[2]);
    }
}


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

int goukei(vector<int> v)
{
	int sum = 0;
	rep(i, v.size()) sum += v.at(i);
	return sum;
}
int main(void)
{
  vector<int> test(6);
	rep(i, 6) cin >> test.at(i);
	int min1 = 101;
	rep(i, 4) min1 = min(min1, test.at(i));
	int min2 = min(test.at(4), test.at(5));
	int sum = goukei(test)-min1-min2;
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3164
import math

def sub(a, b):
    return [x-y for x,y in zip(a,b)]

def dot(a, b):
    return sum(x*y for x,y in zip(a,b))

def cross(a, b):
    return [a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0]]

def abs2(a):
    return sum([x*x for x in a])

def deg(a, b):
    return (math.acos(dot(a,b)/math.sqrt(abs2(a)*abs2(b))))

N,Q = map(int,input().split())
ls = [list(map(int,input().split())) for i in range(N)]

for i in range(Q):
    sx,sy,sz,dx,dy,dz = map(int,input().split())
    cost = 0
    s = [sx,sy,sz]
    d = [dx,dy,dz]
    sd = sub(d,s)
    ds = sub(s,d)
    for v in ls:
        if abs(deg(sub(v[:3],s),sd)) < math.pi/2 and abs(deg(sub(v[:3],d), ds)) < math.pi/2:
            if abs2(cross(sub(v[:3],s),sd)) <= abs2(sd)*v[3]**2:
                cost += v[4]
        else:
            if min(abs2(sub(v[:3],s)), abs2(sub(v[:3],d))) <= v[3]**2:
                cost += v[4]
    print(cost)


Measured memory_bytes: 5764
#include <iostream>


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

  if(C - (A - B)>=0){
    std::cout << C - (A - B) << std::endl;
  }else{
    std::cout << 0 << std:: endl;
  }  
 return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。(int64_t)
int main(){
    long long Max = 0 , max =0 , n , a;
	vector<int> v;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a;
		if (a > Max){
			max = Max;
			Max = a;
        }
		else if (a > max)
		  max = a;
		  v.push_back(a);
        }
	
	for (int i = 0; i < n; i++){
		if (v[i] != Max){
		cout << Max << endl;
        }
		else{
		cout << max << endl;
        }
	}
    return 0;
}

Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int sum;
  int n;
  cin>>n;
int p[n];
  sum=0;
  for(int i=0;i<n;i++)
    cin>>p[i];
  for(int j=0;j<n-1;j++)
  {
    if(p[j]>=p[j+1]){
     
      sum+=(p[j]-p[j+1]);
       p[j+1]=p[j];
    }
  }
   cout<<sum<<'\n';  
    
    return 0;
}

Measured memory_bytes: 4344
prime = [0,0] + [1]*100010
for i in range(int((100010)**0.5)):
    if prime[i]:
        for j in range(i*2,100010,i):
            prime[j] = 0
alike = [(prime[i] and prime[(i+1)//2]) for i in range(100001)]
for i in range(1,100001): alike[i] += alike[i-1]

q = int(input())
for i in range(q):
    l,r = map(int,input().split())
    print(alike[r] - alike[l-1])

Measured memory_bytes: 7908
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
  ll x,y;
  cin>>x>>y;
  ll ans=LINF;
  rep(i,2){
    rep(j,2){
      ll xx=(i==0?x:-x);
      ll yy=(j==0?y:-y);
      if(xx<=yy)ans=min(ans,yy-xx+i+j);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a, b, c, d, n;
	cin>>a>>b>>c>>d>>n;
	long long ans = 0;
	if(d <= c * 2 && d <= b * 4 && d <= a * 8){
		ans += d * (n / 2);
		n %= 2;
	}
	if(c <= b * 2 && c <= a * 4){
		ans += c * n;
		n = 0;
	}
	if(b <= a * 2){
		ans += b * n * 2;
		n = 0;
	}
	ans += a * n * 4;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int n = sc.nextInt();
			int ans = 0;
			for(int a=0;a<=9;a++) {
				for(int b=0;b<=9;b++) {
					for(int c=0;c<=9;c++) {
						for(int d=0;d<=9;d++) {
							if (a+b+c+d==n) {
								ans++;
							}
						}
					}
				}
			}
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 18852
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

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

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).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; }
using namespace std;

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

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<P> a(n);
    rep (i, n) {
        cin >> a[i].first; a[i].second = i;
    }
    sort(all(a)); reverse(all(a));
    vector<vector<ll> > dp(n + 1, vector<ll>(n + 1));
    rep (i, n) {
        rep (j, i + 1) {
            chmax(dp[j + 1][n - i + j], dp[j][n - i + j] + a[i].first * abs(j - a[i].second));
            chmax(dp[j][n - 1 - i + j], dp[j][n - i + j] + a[i].first * abs((n - i - 1 + j) - a[i].second));
        }
    }
    ll ans = 0;
    rep (i, n + 1) chmax(ans, dp[i][i]);
    cout << ans << '\n';
    return 0;
}

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

int gcd2(int a, int b){
  int c,max = 0;
  max = b;
  if(max < a){
    max = a;
    a = b;
    b = max;
  }
  c = b % a;
  if(c == 0){
    return a;
  }else{
    return gcd2(a,c);
  }
}

int gcd3(int a, int b, int c){
  int x,y;
  x = gcd2(a,b);
  y = gcd2(x,c);
  return y;
}

int main (void){
  int k,ans = 0;

  cin >> k;

  for(int i = 1; i <= k;i++){
    for(int s = 1; s <= k ;s++){
      for(int t = 1; t <= k ;t++){
        ans = ans + gcd3(i,s,t);
      }
    }
  }
  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 3636
package main

import (
  "fmt"
  "bufio"
  "os"
)

// 使用floyd O(n^3)解法
func main() {
  var N, M int
  fmt.Scanf("%d %d\n", &N, &M)
  scanner := bufio.NewScanner(os.Stdin)
  g := make([][]byte, 0)
  for scanner.Scan() {
    line := scanner.Text()
    g = append(g, []byte(line))
  }
  fmt.Println(solve(N, M, &g))
}

func solve(n int, m int, g *[][]byte) int {
  dp := make([][]int, n+1)
  for i:=range dp {
    dp[i] = make([]int, m+1)
  }
  dp[1][1] = 1
  for i:=1;i<=n;i++ {
    for j:=1;j<=m;j++ {
      if i==1 && j==1 {
        continue
      } else if (*g)[i-1][j-1] == '.' {
        dp[i][j] = (dp[i-1][j]+dp[i][j-1])%(1e9+7)
      }
    }
  }
  return dp[n][m]
}

func max(a, b int) int {
  if a > b {
    return a
  }
  return b
}
// dp[i][j] = dp[i-1][j]+dp[i][j-1]

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000

using namespace std;
typedef long long ll;
typedef pair<ll ,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;

int n;
int main(){
	cin >> n;
	map<string, int>mp;
	for(int i = 0; i < n; i ++){
		string s; cin >> s;
		mp[s]++;
	}
	int maxv = 0;
	for(auto& x : mp)maxv = max(maxv, x.second);
	for(auto it = mp.begin(); it != mp.end(); it++){
		if(it->second == maxv) cout << it->first << endl;
	}

}

Measured memory_bytes: 25216
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        if(!(cin >> n))
            return 0;

        vector<int> a(n);
        for(int i=0; i<n; ++i)
            cin >> a[i];
        sort(a.begin(), a.end());

        int ret = 0;
        for(int i=0; i<n; ++i)
            ret += a[i] * (n-i);

        cout << ret << endl;
    }
}

Measured memory_bytes: 0
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define itr(v)          for(auto it:v)
#define show(arr,n) for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fd(i,n)         for(int i=n-1;i>=0;i--)
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

bool cmp(int a,int b) {return a>b;}
int fast_pow(int b,int p,int m=1){
     if(p==0) return 1;
     if(p==1) return b;
    int res=fast_pow(b,p/2,m);  res=(res*res)%m;
    if(p%2==0) return res; else return  (b*res)%m;
}
int mmi(int a,int m){ return fast_pow(a,m-2,m);}

int a[200001],b[200001];

int32_t main()
{
    FIO
    int k;
    cin>>k;
    fi(i,9) a[i]=i+1;
    int s=0,f=9;
    while(f<k){
        int c=a[s]%10;
        if(c-1>=0){
            a[f++]=a[s]*10+(c-1);
        }
        a[f++]=a[s]*10+c;
        if(c+1<=9){
            a[f++]=a[s]*10+(c+1);
        }
        s++;
    }
    // fi(i,k) cout<<a[i]<<" "; cout<<"\n";
    sort(a,a+k);
    cout<<a[k-1]<<"\n";
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
a = list(map(int, input().split()))

m = d = t = 0
for i in range(len(a)):
  if a[i] == 1:
    m += 1
  elif a[i] == 2:
    d += 1
  else:
    t += 1

D = [[[0] * (N + 1) for i in range(d + t + 1)] for j in range(t + 1)]
su = 0
D[t][d][m] = 1
for i in range(t, -1, -1):
  for j in range(d + t - i, -1, -1):
    for k in range(N - i - j, -1, -1):
      y = D[i][j][k]
      if i + j + k != 0:
        su += y * N /(i + j + k)
      if i >= 1:
        D[i - 1][j + 1][k] += y * i / (i + j + k)
      if j >= 1: 
        D[i][j - 1][k + 1] += y * j / (i + j + k)
      if k >= 1:
        D[i][j][k - 1] += y * k / (i + j + k)

print(su)


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

int main(){
    int H,W,N;
    cin >> H >> W >> N;
    int A = (N + H - 1) / H;
    int B = (N + W - 1) / W;
    cout << min(A,B) << endl;
}

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

int main(){
    double weight;
    while(cin >> weight){
        if(weight<=48.0) cout << "light fly" << endl;
        else if(weight>48.0 && weight<=51.0) cout << "fly" << endl;
        else if(weight>51.0 && weight<=54.0) cout << "bantam" << endl;
        else if(weight>54.0 && weight<=57.0) cout << "feather" << endl;
        else if(weight>57.0 && weight<=60.0) cout << "light" << endl;
        else if(weight>60.0 && weight<=64.0) cout << "light welter" << endl;
        else if(weight>64.0 && weight<=69.0) cout << "welter" << endl;
        else if(weight>69.0 && weight<=75.0) cout << "light middle" << endl;
        else if(weight>75.0 && weight<=81.0) cout << "middle" << endl;
        else if(weight>81.0 && weight<=91.0) cout << "light heavy" << endl;
        else cout << "heavy" << endl;   
    }
}


Measured memory_bytes: 3072
import Control.Applicative
import Data.List.Split
import Control.Monad

oneSideLenght :: [Int]
oneSideLenght = [9,3,3,3,3,9]

operation1 :: [(Int,Int)]
operation1 = [(7,22),(8,23),(9,24),(10,12),(13,18)]

operation2 :: [(Int,Int)]
operation2 = [(1,28),(2,29),(3,30),(21,19),(16,15)]

operation3 :: [(Int,Int)]
operation3 = [(1,24),(4,27),(7,30),(10,21),(16,18)]

operation4 :: [(Int,Int)]
operation4 = [(3,22),(6,25),(9,28),(12,19),(13,15)]

{- 一面が全て同じ色かチェックする -}
checkOneSideAns :: Bool -> [Int] -> Bool
checkOneSideAns tf [] = tf
checkOneSideAns tf (x1 : xs)
    | null xs = tf
    | x1 == head xs = checkOneSideAns tf xs
    | otherwise = False

{- 面ごとに同じ色かチェックする -}
checkAllSideAns :: [Int] -> Bool
checkAllSideAns xs = all (checkOneSideAns True) (side xs)
    where
        side = splitPlaces oneSideLenght

{- 値交換 -}
swap i j xs = swap' withIdx
    where
        withIdx = zip [0..] xs
        swap' = map f
            where
                f (idx,x)
                    | idx == i = xs !! j
                    | idx == j = xs !! i
                    | otherwise = x

{-  -}
swapOperation :: [Int] -> [(Int,Int)] -> [Int]
swapOperation xs op = swapOperation' xs op 0
    where
        swapOperation' xs' op' idx
            | length op' <= idx = xs'
            | otherwise = swapOperation' (swapPair (op' !! idx) xs') op' (idx+1)
        swapPair (pair1, pair2) = swap (pair1-1) (pair2-1)

solve :: [Int] -> Int
solve xs = solve' xs 0 0
    where
        solve' xs' count operation
            | count >= 8 = count
            | checkAllSideAns xs' = count
            | operation == 0 = minimum [solve' (swapOperation xs' operation1) (count+1) 1,solve' (swapOperation xs' operation2) (count+1) 2,solve' (swapOperation xs' operation3) (count+1) 3,solve' (swapOperation xs' operation4) (count+1) 4]
            | operation == 1 = minimum [solve' (swapOperation xs' operation2) (count+1) 2,solve' (swapOperation xs' operation3) (count+1) 3,solve' (swapOperation xs' operation4) (count+1) 4]
            | operation == 2 = minimum [solve' (swapOperation xs' operation1) (count+1) 1,solve' (swapOperation xs' operation3) (count+1) 3,solve' (swapOperation xs' operation4) (count+1) 4]
            | operation == 3 = minimum [solve' (swapOperation xs' operation1) (count+1) 1,solve' (swapOperation xs' operation2) (count+1) 2,solve' (swapOperation xs' operation4) (count+1) 4]
            | operation == 4 = minimum [solve' (swapOperation xs' operation1) (count+1) 1,solve' (swapOperation xs' operation2) (count+1) 2,solve' (swapOperation xs' operation3) (count+1) 3]

spaceToDot = map (read :: String -> Int) . words



main :: IO()
main = do
    num <- (read :: String -> Int) <$> getLine
    ss <- replicateM num getLine
    let colorInfo = (map (read :: String -> Int) . words) <$> ss
    mapM_ (print . solve) colorInfo

Measured memory_bytes: 5552
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
import math
import bisect
import numpy as np
from collections import defaultdict, deque
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
# MOD = 10 ** 9 + 7
INF = float("inf")


def dijkstra(s, n, graph):
    dist = [INF] * n
    visited = [False] * n
    dist[s] = 0
    hq = [(0, s)]  # (重み，頂点)
    while hq:
        di, pi = heappop(hq)
        visited[pi] = True
        for dj, pj in graph[pi]:
            if visited[pj]:
                continue
            if dist[pj] > di + dj:
                dist[pj] = di + dj
                heappush(hq, (dist[pj], pj))
    return dist


def main():
    N, M = map(int, input().split())
    graph = [[] for _ in range(N)]
    edge = []
    for _ in range(M):
        a, b = map(int, input().split())
        a, b = a - 1, b - 1
        graph[a].append((1, b))
        graph[b].append((1, a))
        edge.append((a, b))
    cnt = 0
    for a, b in edge:
        graph[a].remove((1, b))
        graph[b].remove((1, a))
        d = dijkstra(0, N, graph)
        if INF in d:
            cnt += 1
        graph[b].append((1, a))
        graph[a].append((1, b))
    print(cnt)


if __name__ == '__main__':
    main()

Measured memory_bytes: 12188
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<stack>
#include<queue>
#include<cstring>
#include<vector>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef long long int ll;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}
#define MAX_NUM 50
long long comb[MAX_NUM + 1][MAX_NUM + 1];

ll par[100000], depth[100000];
static void calc_comb()
{
	for (uint32_t i = 0; i <= MAX_NUM; i++) {
		for (uint32_t j = 0; j <= i; j++) {
			if ((j == 0) || (i == j)) {
				comb[i][j] = 1;
			}
			else {
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			}
		}
	}
}


void init(ll n) {
	REP(i, n) {
		par[i] = i;
		depth[i] = 0;
	}
	return;
}

ll find(ll x) {
	if (par[x] == x) { return x; }
	else { return par[x] = find(par[x]); }
}

void merge(ll x, ll y) {
	x = find(x); y = find(y);
	if (x == y) { return; }
	if (depth[x] > depth[y]) {
		par[y] = x;
	}
	else {
		par[x] = y;
		if (depth[x] == depth[y]) {
			depth[y]++;
		}
	}
}

bool same(ll x, ll y) {
	if (find(x) == find(y)) {
		return false;
	}
	return true;
}
int lcs(string X, string Y) {
	const int N = max(X.size(), Y.size()) + 1;
	vector<vector<int> > c(N, vector<int>(N, 0));
	int m = X.size();
	int n = Y.size();
	int maxl = 0;
	X = ' ' + X;
	Y = ' ' + Y;
	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() {
	ll n;
	ll q, h, s, d; cin >> q >> h >> s >> d >> n;
	if (q * 2 < h) { h = q * 2; }
	if (h * 2 < s) { s = h * 2; }
	ll ct = 0;
	if (s * 2 < d) { d = s * 2; }
	while (n) {
		if (n /2) {
			ct += n / 2 * d;
			n -= n / 2 * 2;
		}
		else  { ct += n / 1 * s; n = 0; }
	}
	cout << ct << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){ 
   string s,e;
   cin>>s>>e;
   rep(i,s.size()+e.size()){
      i%2==0? cout<<s[i/2]:cout<<e[i/2];
   }






return 0;
}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cout << #a << " = " << a << endl

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

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

vector<ll> get_primes(ll n) {
    vector<ll> primes(n+1, 1);
    primes[0] = primes[1] = 0;
    for(ll i = 2; i*i < n; ++i)
        if(primes[i]) for(ll j = i*i; j < n+1; j+=i) primes[j] = 0;
    return primes;
}

int main() {
    ll N; cin >> N;
    vector<ll> primes = get_primes(55555);
    
    REP(i, 55556) if (primes[i]) if (i % 5 == 1) {
        cout << i;
        
        N--;
        if (N == 0) break;
        cout << " ";
    }
    cout << endl;
    
    return 0;
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

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

ll dp[100+1][100000+1] = {0};

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

    ll w[N], v[N];
    for (int i = 0; i < N; i++) cin >> w[i] >> v[i];
    //for (int i = 0; i < N; i++) cout << w[i] << v[i] << endl;

    
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= W; j++) {
            if (j >= w[i]) {
                //cout << dp[i][j-w[i]] << endl;
                chmax(dp[i+1][j], dp[i][j-w[i]] + v[i]);
                //cout << dp[i+1][j] << endl;
            }
            chmax(dp[i+1][j], dp[i][j]);
        }
    }
    /*
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= W; j++) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/
    cout << dp[N][W] << endl;
    return 0;
}



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

using namespace std;

main(){
	char w[100];
	cin>>w;
	int a=0;
	while(true){
		char t[1000];
		cin>>t;
		if (strcmp(t , "END_OF_TEXT" )==0){
			break;
		}
		if(strcasecmp(w,t) ==0){
			a=a+1;
		}
	}
	printf("%d\n",a);
}



Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define vec2(name,i,j,k) vector<vector<ll>> name(i,vector<ll>(j,k))
#define vec3(name,i,j,k,l) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k,l)))
#define pb push_back
#define MOD 1000000007 //998244353
#define PI 3.141592653
#define INF 100000000000000 //14
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
int main(){
    ll d, t; cin >> d;
    vector<ll> ansl(365,0);
    vector<ll> c(26);
    vector<ll> las(26,0);
    vec2(s,d,26,0);
    REP(i,26) cin >> c[i];
    REP(i,d)REP(j,26) cin >> s[i][j];
    ll con = 0;
    FOR(i,1,d){
        ll max = -1*INF;ll mind = -1;
        REP(j,26)if(max<s[i-1][j]){
            max=s[i-1][j];
            con-=c[j]*(i-las[j]);
            mind=j;
        }
        ansl[i-1]=mind;
        con+=max+c[mind]*(i-las[mind]);
        las[mind]=i;
        //cout << con << endl;
    }

    REP(i,d) cout << ansl[i]+1 << endl;
}

Measured memory_bytes: 3736
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys

sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline--------------------------------------------        ]
    X = int(input())
    sx = str(X)
    lsx = len(sx)
    sx1 = sx[:lsx-2]
    sx2 = sx[lsx-2:]
    if lsx > 2:
        if int(sx1)*5 >= int(sx2):
            print(1)
        else:
            print(0)
    else:
        print(0)
if __name__ == "__main__":
    main() #endline===============================================
    

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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int r = Integer.parseInt(br.readLine());

		if (r < 1200) {
			System.out.println("ABC");
		} else if (r < 2800) {
			System.out.println("ARC");
		} else {
			System.out.println("AGC");
		}

	}

}


Measured memory_bytes: 21332
#include<iostream>

using namespace std;

typedef long long ll;
ll mo=1000000007;
ll N,M,K;

ll comb(ll N_, ll C_) {
	const int NUM_=400001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}

ll modpow(ll a, ll n) {
	ll r=1;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

ll comb(int P_,int Q_) {
	if(P_<0 || Q_<0 || Q_>P_) return 0;
	ll p=1,q=1;
	Q_=min(Q_,P_-Q_);
	for(int i=1;i<=Q_;i++) p=p*P_%mo, q=q*i%mo,P_--;
	
	return p*modpow(q,mo-2)%mo;
}

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


    ll res = 0;
    for(int i=1;i<M;i++) {
        ll d = (i*(M-i))%mo;
        d *= (N*N)%mo;
        res = (res+d)%mo;
    }

    for(int i=1;i<N;i++) {
        ll d = (i*(N-i))%mo;
        d *= (M*M)%mo;
        res = (res+d)%mo;
    }
    cout<<(res%mo)*comb(N*M-2, K-2)%mo;
}

Measured memory_bytes: 9600
use std::io::*;

type Card = [u8; 2];

fn bubble_sort(slice: &mut [Card]) {
	let mut flag = true;

	while flag {
		flag = false;

		for j in (1..slice.len()).rev() {
			if slice[j][1] < slice[j - 1][1] {
				slice.swap(j, j - 1);
				flag = true;
			}
		}
	}
}

fn selection_sort(slice: &mut [Card]) {
	for i in 0..slice.len() {
		let mut minj = i;

		for j in i..slice.len() {
			if slice[j][1] < slice[minj][1] {
				minj = j;
			}
		}
		if i != minj {
			slice.swap(i, minj);
		}
	}
}

fn output<W: Write>(out: &mut W, slice: &[Card]) {
	out.write_all(&slice[0]);

	for v in &slice[1..] {
		out.write(b" ");
		out.write_all(v);
	}
}

fn main() {
	let input = {
		let mut buf = vec![];
		stdin().read_to_end(&mut buf);
		unsafe { String::from_utf8_unchecked(buf) }
	};
	let mut lines = input.split('\n');

	let n = lines.next().unwrap().parse().unwrap();

	let mut vec_o = Vec::with_capacity(n);
	let iter = lines
		.next()
		.unwrap()
		.split(' ')
		.map(|s| unsafe { *(s.as_bytes().as_ptr() as *const [u8; 2]) });
	vec_o.extend(iter);

	let out = stdout();
	let mut out = BufWriter::new(out.lock());

	let mut vec1 = vec_o.clone();
	bubble_sort(&mut vec1);

	output(&mut out, &vec1);
	out.write_all(b"\nStable\n");

	let mut vec2 = vec_o.clone();
	selection_sort(&mut vec2);

	output(&mut out, &vec2);
	out.write_all(if vec1 == vec2 {
		b"\nStable\n"
	} else {
		b"\nNot stable\n"
	});
}



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


public class Main{
	public static void main(String[]args)throws IOException{
	
		BufferedReader br=
				new BufferedReader(new InputStreamReader(System.in));
		String str=br.readLine();
		String[] str1=str.split(" ",0);
		int n1=Integer.parseInt(str1[0]);
		int n2=Integer.parseInt(str1[1]);
		int n3=0;
		int n4=0;
		int ans[]=new int[n1];

		for(int i=0;i<n2;i++){
			String str2=br.readLine();
			String[] str3=str2.split(" ",0);
			n3=Integer.parseInt(str3[0]);
			n4=Integer.parseInt(str3[1]);
		ans[n3-1]++;
		ans[n4-1]++;
		}
	 for(int i=0;i<n1;i++){
	System.out.println(ans[i]);
	 }
	}
}
		



Measured memory_bytes: 21204
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007


int main(int argc, char const *argv[]) {
  int a,b;
  std::cin >> a >> b;
  if(b%a==0) std::cout << a+b << '\n';
  else std::cout << b-a << '\n';
  return 0;
}


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

int main(void) {
    int N,M,K,A;
    int cnt = 0;

    cin >> N >> M ;
    map<int,int> mp;
    for(int i=0;i<N;i++) {
        cin >> K;
        for(int j=0;j<K;j++) {
            cin >> A;
            mp[A]++;
        }
    }

    for(auto m:mp) {
        if(m.second == N){
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}


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

int main()
{
    int n;

    while (cin >> n, n != 0){
        string str;

        cin >> str;
        while (n-- > 0){
            ostringstream enc;
            for (int i = 0; i < str.length();){
                int cnt = 0;
                char c = str[i];

                for (; i < str.length() && str[i] == c; i++, cnt++);
                enc << cnt << c;
            }
            str = enc.str();
        }
        cout << str << endl;
    }

    return 0;
}

Measured memory_bytes: 1380
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    double ans;
    if(n%2==0)
    {
        ans=0.5;
    }else
    {
        double a=n/2;
        a++;
        ans=a/(double)n;
    }
    cout<<fixed<<setprecision(7)<<ans<<endl;
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

bool check(vector<long long>& a, long long n){
	show( all_of(all(a), [n](const long long i){show(i);return i < n;}))
		return all_of(all(a), [n](const long long i){show(i);return i < n;});
}

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

	vector<long long> a(n);
	cin >> a;

	sort(all(a), greater<long long>());

	long long ans = 0;
	while(true){
		long long div;
		rep(i,n){
			div = a[i] / n;
			a[i]%=n;
			ans += div;
			rep(j,n){
				if(i == j) continue;
				a[j] += div;
			}
		}
		if(div < n and check(a, n)) break;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll N, M;

    cin >> N >> M;

    // M = answer * k (arbitrary integer number k (>= N))

    for (ll answer = M / N; answer >= 1 ; answer --){
        if (M % answer == 0){
            cout << answer << endl; 
            return 0;
        }
    }

    return 0;
}

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

const int MAX_V = 100;
const int INF = 100000;

int cost[MAX_V][MAX_V];
int mincost[MAX_V];
bool used[MAX_V];

int prim(int V) {
  for (int i = 0; i < V; i++) {
    mincost[i] = INF;
    used[i] = false;
  }

  mincost[0] = 0;
  int res = 0;

  while(true) {
    int v = -1;
    for (int u = 0; u < V; u++) {
      if (! used[u] and (v == -1 or mincost[u] < mincost[v]))
        v = u;
    }

    if (v == -1)
      break;

    used[v] = true;

    res += mincost[v];

    for (int u = 0; u < V; u++)
      mincost[u] = min(mincost[u], cost[v][u]);
  }

  return res;
}

int main() {
  int n;
  while (cin >> n and n != 0) {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        cost[i][j] = INF;

    int m, a, b, dist;
    cin >> m;

    for(int i = 0; i < m; i++) {
      scanf("%d,%d,%d", &a, &b, &dist);
      dist = dist / 100 - 1;
      cost[a][b] = cost[b][a] = dist;
    }

    int val = prim(n);

    cout << val << endl;
  }
}

Measured memory_bytes: 1284
#include<iostream>
#include<vector>
using namespace std;
int main(){
	long long a,n,k,res=0;
	cin>>n>>k;
	if(k%2==0){
		long long i=n/k;
		long long j=(n+k/2)/k;
//		cout<<i<<" "<<j<<endl;
		res+=i;
		res+=i*(i-1)*3;
		res+=i*(i-1)*(i-2);
		res+=j;
		res+=j*(j-1)*3;
		res+=j*(j-1)*(j-2);
	}else{
		long long i=n/k;
//		cout<<i<<endl;
		res+=i;
		if(i>=1){
			res+=i*(i-1)*3;
		}
		if(i>=2){
			res+=i*(i-1)*(i-2);
		}
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define test ll t; cin>>t; while(t--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
#define MAX 1000005
#define forci(p,q) for(int i=p;i<q;i++)
bool prime[MAX];
/*ull sieve()
{
	memset(prime,true,sizeof(prime));
	for(ull p=2;p*p<MAX;p++)
	{
		if(prime[p]==true){
			for(ull i=2*p;i<MAX;i+=p)
			{
				prime[i]=false;
			}
		}
	}
	prime[0]=0;
	prime[1]=0;
}*/
using namespace std;
signed main()
{
	fastio;
	int s,w;
	cin>>s>>w;
	if(w>=s)
		cout<<"unsafe"<<endl;
	else
		cout<<"safe"<<endl;
	
	
	
	
	
	
	
	
}









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

int main()
{
  int64_t N, M, x, y;
  cin >> N >> M;
  vector<int> Count(N, 1);
  vector<bool> Red(N, false);
  Red.at(0) = true;
  for (int i = 0; i < M; i++)
  {
    cin >> x >> y;
    x--;
    y--;
    Count.at(x)--;
    Count.at(y)++;
    if (Red.at(x))
      Red.at(y) = true;
    if (Count.at(x) == 0)
      Red.at(x) = false;
  }
  int64_t cnt = 0;
  for (int i = 0; i < N; i++)
  {
    if (Red.at(i))
      cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 640
//created by missever

#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

const int mod = 1e9 + 7;
const int maxn = 2e5 + 5;

int add(int x, int y) {
    x += y;
    if(x >= mod) x -= mod;
    return x;
}

int mul(int x, int y) {
    LL z = 1LL * x * y;
    return z - z / mod * mod;
}

int a[maxn];
int lowbit(int x) {
    return x & (-x);
}

void add(int x) {
    while(x < maxn) {
        a[x]++;
        x += lowbit(x);
    }
}

int ff(int x) {
    int res = 0;
    while(x) {
        res += a[x];
        x -= lowbit(x);
    }
    return res;
}

vector<int> f[30];
char s[maxn];
int d[30],num[30];
bool vis[maxn];

int main() {
#ifdef CX_TEST
    freopen("E:\\program--GG\\test_in.txt", "r", stdin);
#endif
    int n,i,j,k;
    scanf("%s",s);
    n = strlen(s);
    for(i = 0;i < n; i++) {
        j = s[i] - 'a';
        f[j].push_back(i);
    }
    LL ans = 0;
    for(i = j = 0;i < 26; i++) j += f[i].size() & 1;
    for(i = 0;i < 26; i++) num[i] = f[i].size();
    if(n & 1) {
        if(j > 1) return puts("-1"),0;
    } else if(j) return puts("-1"),0;
    for(i = j = 0,k = -1;i < (n / 2); i++) {
        while(vis[j] || num[s[j] - 'a'] < 2) {
            if(!vis[j] && num[s[j] - 'a'] == 1) k = i;
            j++;
        }
        int u = s[j] - 'a';
        d[u]++;
        num[u] -= 2;
        int v = f[u][f[u].size() - d[u]];
        ans += n - i - 1 - v + ff(v);
        add(v);
        vis[j] = vis[v] = 1;
        //cout<<s[j]<<" "<<v<<" "<<ans<<endl;
    }
    if(k != -1) ans += n / 2 - k;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2168
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	cin>>n;
	if(n==1){
		cout<<"Hello World"<<endl;
	}else{
		int a, b;
		cin>>a>>b;
		cout<<a+b<<endl;
	}
	return 0;
}

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

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N];
    HashMap<Integer, Integer> map = new HashMap<>();
    int max1 = 0, max2 = 0;
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
      Integer cnt = map.getOrDefault(A[i], 0);
      map.put(A[i], cnt + 1);
      if (A[i] >= max1) {
        max2 = max1;
        max1 = A[i];
      } else if (A[i] >= max2) {
        max2 = A[i];
      }
    }
    for (int i = 0; i < N; i++) {
      int ans;
      if (A[i] == max1) {
        if (map.get(max1) > 1) {
          ans = max1;
        } else {
          ans = max2;
        }
      } else {
        ans = max1;
      }
      System.out.println(ans);
    }
  }
}

Measured memory_bytes: 98684