akhauriyash/Code-Regression huggingface dataset:
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System;
using System.Collections;
using System.Threading.Tasks.Dataflow;
using System.Runtime.InteropServices.ComTypes;

class Program
{
    #region Reader
    static string ReadStr => Console.ReadLine();
    static string[] ReadStrs => Console.ReadLine().Split(' ');
    static int ReadInt => Convert.ToInt32(Console.ReadLine().Trim());
    static int[] ReadInts => Console.ReadLine().Trim().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
    static long ReadLong => Convert.ToInt64(Console.ReadLine().Trim());
    static long[] ReadLongs => Console.ReadLine().Trim().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
    #endregion
    #region Method
    const int mod = 1000000007;
    public static int Mod(int a, int mod) { return a % mod >= 0 ? a % mod : a % mod + mod; }
    public static long Mod(long a, long mod = mod) { return a % mod >= 0 ? a % mod : a % mod + mod; }
    #endregion

    static void Main()
    {
        char[] s = ReadStr.ToArray();

        int a = 0;
        for (int i = 0; i < s.Length; i++)
        {
            a+= s[i] - 48;
            
        }
        if (a % 9 == 0) WriteLine("Yes");
        else WriteLine("No");

    }
}



Measured memory_bytes: 27812
#include <iostream>
#include <climits>

using namespace std;

int *A;
int N;
int SwapNum;

void BubbleSort()
{
  bool flag = true;
  int i = 0;
  SwapNum = 0;

  do
  {

    flag = false;
    for(int j = N - 1; j >= i + 1; --j)
    {
      if(A[j] < A[j-1])
      {
	int tmp = A[j];
	A[j] = A[j-1];
	A[j-1] = tmp;

	flag = true;
	++SwapNum;
      }

    }

    ++i;


  }while(flag);

  return;
}

void SelectionSort()
{

  SwapNum = 0;
  for(int i = 0; i < N; ++i)
  {
    int mini = i;
    bool flag = false;

    for(int j = i; j < N; ++j)
    {
      if(A[j] < A[mini])
      {
	mini = j; 
	flag = true;	
      }
    }

    if(flag)
    {
      int tmp = A[i];
      A[i] = A[mini];
      A[mini] = tmp;

      ++SwapNum; 
    }
  }

  return;

}

int main()
{
  cin >> N;

  A = new int[N];

  for(int i = 0; i < N; ++i)
    cin >> A[i];

  //BubbleSort();
  SelectionSort();

  cout << A[0];
  for(int i = 1; i < N; ++i)
    cout << " " << A[i];

  cout << endl;
  cout << SwapNum << endl;

  delete [] A;


}


Measured memory_bytes: 3104
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

int main(){
    int N;
    cin>>N;
    ll num=0,ten=0;
    for(int i=0;i<N;i++){
        ll a,b;
        cin>>a>>b;
        if(num<a){
            num=a; ten=b;
        }
    }
    cout<<num+ten<<endl;
}



Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cmath>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)

using namespace std;

typedef double D;
const int N = 200010;
const D pi = acos(-1);

struct A{ int x, y;} a[N], a0[N], q[N];

bool cmp(A a, A b) { return a.x < b.x;}

int main()
{
	int x1, y1, x2, y2, n;
	scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
	scanf("%d", &n);
	Rep(i, n) scanf("%d%d", &a[i].x, &a[i].y);
	if (x1 > x2) {
		Rep(i, n) a[i].x = 1e8 - a[i].x;
		x1 = 1e8 - x1, x2 = 1e8 - x2;
	}
	if (y1 > y2) {
		Rep(i, n) a[i].y = 1e8 - a[i].y;
		y1 = 1e8 - y1, y2 = 1e8 - y2;
	}
	int cnt = 0;
	Rep(i, n) if (a[i].x >= x1 && a[i].x <= x2 && a[i].y >= y1 && a[i].y <= y2) a0[++ cnt] = a[i];
	
	sort(a0 + 1, a0 + 1 + cnt, cmp);
	
	int ta = 0;
	
	Rep(i, cnt) {
		int l = 1, r = ta + 1;
		while (l < r) {
			int mid = (l + r) >> 1;
			if (q[mid].y > a0[i].y) r = mid;
			else l = mid + 1;
		}
		q[l] = a0[i], ta = max(ta, l);
	}
	D ans = (x2 - x1 + y2 - y1) * 100.0 + ta * (5 * pi - 20);
	if (ta == min(x2 - x1, y2 - y1) + 1) ans += 5 * pi; 
	
	printf("%.12lf\n", ans);
	
	return 0;
}


Measured memory_bytes: 4864
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  int m = sc.nextInt();
  long[] x = new long[100001];
  int a = 1000000007;
  if (Math.abs(n - m) > 1) {
    System.out.println('0');
    return;
  }
  x[0] = 1;
  for(int i = 1; i <= 100000; i++)x[i] = x[i - 1] * i % a;
  long ans = x[n] * x[m] % a;
  if(n == m) ans = ans * 2 % a;
  System.out.println(ans);
  return;
}}


Measured memory_bytes: 23636
N, M = list(map(int, input().split(" ")))
m = set()

for _ in range(M):
    a, b = list(map(int, input().split(" ")))
    if a < b:
        m.add((a,b))
    else:
        m.add((b,a))


for i in range(2, N):
    if (1, i) in m and (i, N) in m:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

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

  string s;
  cin >> s;
  reverse(all(s));
  const string t[] = {
    "maerd",
    "remaerd",
    "resare",
    "esare"
  };
  int idx = 0;
  while(idx < (int)s.size()) {
    bool flag = false;
    rep(i, 4) {
      if(s.substr(idx, t[i].size()) == t[i]) {
	idx += t[i].size();
	flag = true;
	break;
      }
    }
    if(!flag) break;
  }
  cout << (idx == (int)s.size() ? "YES" : "NO")  << endl;

  return 0;
}


Measured memory_bytes: 512
#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(){
    int n;cin >> n;
    vector<int> a(n);
    rep(i , n) cin >> a[i];
    int m; cin >> m;
    vector<int> b(m);
    rep(i ,m) cin >> b[i];
    vector<int> result;
    set_difference(a.begin(),a.end(),b.begin(),b.end(),inserter(result,result.end()));
    for( auto x : result){
        cout << x << endl;
    }
}


Measured memory_bytes: 5388
str = gets.split
N,D = str[0].to_i, str[1].to_i
r = Array.new(N){Array.new(D)}
for x in 0...N do
    str = gets.split
    for y in 0...D do
        r[x][y] = str[y].to_i
    end
end

answer = 0
a = 0
for x in 0...N-1 do
    for y in x+1...N do
        a = 0
        for z in 0...D do
            a += (r[x][z] - r[y][z]) ** 2
        end
        i = 1
        while i*i <= a
            if i*i == a
                answer += 1
            end
            i += 1
        end
    end
end

puts answer

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1000000000
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, a[100010], b[100010];
int ans;

signed main() {
	cin >> n;
	for (int i = 0; i <= n; i++)cin >> a[i];
	for (int i = 0; i < n; i++)cin >> b[i];
	for (int i = 0; i < n; i++) {
		int cnt = 0;
		cnt += min(a[i], b[i]);
		a[i] -= cnt;
		b[i] -= cnt;
		int cnt2 = 0;
		cnt2 = min(a[i + 1], b[i]);
		b[i] -= cnt2;
		a[i + 1] -= cnt2;
		ans += cnt + cnt2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
N = int(input())
a,b,c = [],[],[]
for i in range(N):
    aa,bb,cc = map(int,input().split())
    a.append(aa)
    b.append(bb)
    c.append(cc)

dp = [ [0 for i in range(3)] for i in range(N+1)]

dp[0][0] = a[0]
dp[0][1] = b[0]
dp[0][2] = c[0]

for i in range(1,N):
    for j in range(3):
        if j == 0:
                dp[i][1] = max(dp[i][1] , dp[i-1][j] + b[i])
                dp[i][2] = max(dp[i][2] , dp[i-1][j] + c[i])
        elif j == 1:
                dp[i][0] = max(dp[i][0] , dp[i-1][j] + a[i])
                dp[i][2] = max(dp[i][2] , dp[i-1][j] + c[i])
        elif j == 2:
                dp[i][0] = max(dp[i][0] , dp[i-1][j] + a[i])
                dp[i][1] = max(dp[i][1] , dp[i-1][j] + b[i])

print(max([dp[N-1][0] , dp[N-1][1] , dp[N-1][2]]))


Measured memory_bytes: 36168
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl
#define P pair<int,int>

signed main(){
    string S;
    cin >> S;
    if(S[0]!='A'){
        cout << "WA" << endl;return 0;
    }
    int C=0;
    REP(i,S.size()){
        if(i>=2 &&i!=S.size()-1&& S[i]=='C'){
            C++;
        }
    }
    if(C!=1){
        cout << "WA" << endl;return 0;
    }
    C=0;
    REP(i,S.size()){
        if('a'<=S[i] && S[i]<='z'){
            C++;
        }
    }
    if(S.size()-C!=2){
        cout << "WA" << endl;return 0;
    }
    cout << "AC" << endl;
    
	return 0;
}

Measured memory_bytes: 256
program sample
  implicit none
  integer N, a, k, t, i
  integer, allocatable :: x(:)
  read(*,*) N
  allocate(x(N))
  k = 1
  t = 1
  read(*,*) x
  do i = 1, N
   
   if ( mod(x(i), 2) == 0) then
    k = k * 2
   endif
    t = t * 3
   
  end do
  write(*,*) t - k
  
  stop
end program sample 

Measured memory_bytes: 256
fun main(args : Array<String>) {
    val N = readLine()!!.toLong()
    count(0, N)
    println(cnt)
}

var cnt = 0
fun count(num: Long, limit: Long) {
    if (num > limit) {
        return
    }

    if (is753(num)) {
        cnt++
    }

    count(num * 10 + 3, limit)
    count(num * 10 + 5, limit)
    count(num * 10 + 7, limit)
}



fun is753(num: Long) : Boolean {
    val str = num.toString()
    return str.contains("7") && str.contains("5") && str.contains("3")
}


Measured memory_bytes: 33608
N, Q = map(int, input().split())


graph = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)


counts = [0 for _ in range(N)]
for _ in range(Q):
    p, x = map(int, input().split())
    counts[p-1] += x


used = [False for _ in range(N)]
used[0] = True
buf = [0]
while len(buf) > 0:
    i = buf.pop()
    for child in graph[i]:
        if not used[child]:
            counts[child] += counts[i]
            buf.append(child)
            used[child] = True


print(' '.join(list(map(str, counts))))


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

int main(){
    string s;
    cin >>s;
    string collect="CODEFESTIVAL2016";
    int ans = 0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=collect[i])ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/
signed main(){
	string s;
	cin>>s;
	int ans=0;

	rep(i,s.size()){
		ans+=s[i]-'0';
		ans%=9;
	}
	if(ans%9==0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 3700
import functools
import operator

n,m= map(int,input().split())
def fib(n):
  x,y=1,2
  if n==1 or n==0:
    return x
  elif n==2:
    return y
  else:
    for i in range(n-2):
      x, y = y,x+y
    return y
if m==0:
  print(fib(n)%1000000007)
else:
  li=[int(input()) for i in range(m)]
  l=len(li)
  a=0
  b=0
  c=[]
  for i in range(l):
    b=li[i]-1
    c.append(b-a)
    a=li[i]+1
  c.append(n-(li[-1]+1))
  c2=[i for i in c if i<0]
  if sum(c2)<0:
    print(0)
  else:
    ans=list(map(fib,c))
    result = functools.reduce(operator.mul, ans)
    print(result%1000000007)

Measured memory_bytes: 9108
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int a,b,k;
    cin >> a >> b >> k;
    
    cin >> a >> b >> k;
    if(b - a + 1 < k * 2){
          for(int i = a;i <= b;i++){
                cout << i << endl;
          }
    }else{
          for(int i = 0;i < k;i++){
                cout << a + i << endl;
          }
          for(int i = 0;i < k;i++){
                cout << b - k + 1 + i << endl;
          }
    }
}


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

int main()
{
    int h, w;
    cin >> h >> w;
    string board[h];
    rep(i, h) cin >> board[i];
    int dy[4] = {1, 0, -1, 0};
    int dx[4] = {0, 1, 0, -1};
    vector<vector<bool>> check(h, vector<bool>(w, false));
    rep(i, h)
    {
        rep(j, w)
        {
            if (board[i][j] == '#')
            {
                rep(k, 4)
                {
                    int y = j + dy[k];
                    int x = i + dx[k];
                    if (x < 0 || x >= h || y < 0 || y >= w)
                        continue;
                    if (board[x][y] == '#')
                        check[i][j] = true;
                }
            }
        }
    }
    bool ok = true;
    rep(i, h)
    {
        rep(j, w)
        {
            if (board[i][j] == '#' && check[i][j] == false)
                ok = false;
        }
    }
    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(){
  char a,b;

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

  if(a == 'H'){
    if(b == 'H') printf("H");
    if(b == 'D') printf("D");
  }
  else if(a == 'D'){
    if(b == 'H') printf("D");
    if(b == 'D') printf("H");
  }

  return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector <int>;
using vll = vector <ll>;
using vvi = vector <vi >;
using pii = pair <int, int>;
using pll = pair <long, long>;
using vpi = vector <pii >;

#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define dg(x) cout << #x << " = " << x << endl

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

    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == 'R')
            cnt++;
    }
    if (cnt == 1 || cnt == 3 || cnt == 0)
        cout << cnt << endl;
    else
    {
        if (s[0] == s[1] || s[1] == s[2])
            cout << 2 << endl;
        else
            cout << 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3604
n, k = map(int, input().split())
a = list(map(int, input().split()))

mod = 1000000007

ans = 0

for i in range(n):
    # 内部での転倒数
    cnt = 0
    for j in range(i):
        if a[i] < a[j]:
            cnt += 1

    # 全体
    cnt2 = 0
    for j in range(n):
        if a[i] < a[j]:
            cnt2 += 1

    ans += cnt * k
    ans %= mod
    ans += cnt2 * ((k - 1) * k // 2)
    ans %= mod

print(ans)


Measured memory_bytes: 3188
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
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; }
typedef unsigned long ul;
typedef unsigned int ui;
string S;
int N[4],ans,i,j;
inline void solve(){
  IN(S);
  REP(i,4)N[i]=S[i]-'0';
  REP(i,8){
    ans=N[0];
    REP(j,3){
      if(i&(1<<j))ans+=N[j+1];
      else ans-=N[j+1];
    }
    if(ans==7){
      cout<<N[0];
      REP(j,3){
        if(i&(1<<j))cout<<"+"<<N[j+1];
        else cout<<"-"<<N[j+1];
      }
      cout<<"=7"<<endl;
      return;
    }
  }
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
A = []
for _ in range(N):
    A.append(list(map(int, input().split())))

ans = 0
for i in range(N):
    total = 0
    for j in range(M):
        total += B[j] * A[i][j]
    if total + C > 0:
        ans += 1

print(ans)


Measured memory_bytes: 3064
struct B{int w,s,v;}A[1111];n,i;long p[22222],s;c(a,b)struct B*a,*b;{s=a->w+a->s-b->w-b->s;}main(j){for(scanf("%*d");~scanf("%d%d%d",&A[n].w,&A[n].s,&A[n].v);n++);for(qsort(A,n,12,c);i<n;i++)for(j=A[i].s;~j;)s=fmax(s,p[j+A[i].w]=fmax(p[j--+A[i].w],p[j]+A[i].v));printf("%ld",s);}

Measured memory_bytes: 380
#include<stdio.h>
#include<string.h>
int main(void)
{
	char s[100][101];
	char x[101];
	int n,l,i,j,len,a;
	scanf("%d %d",&n,&l);
	for(i=0;i<n;i++){
		scanf("%s",s[i]);
	}
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(strcmp(s[i],s[j])>0){
				strcpy(x,s[i]);
				strcpy(s[i],s[j]);
				strcpy(s[j],x);
			}
		}
	}
	for(i=0;i<n;i++){
		printf("%s",s[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
long long lcm(long long A, long long B){
  return A / __gcd(A, B) * B;
}
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
    A[i] /= 2;
  }
  bool flg = true;
  for (int i = 0; i < N; i++){
    if (__builtin_ctz(A[i]) != __builtin_ctz(A[0])){
      flg = false;
    }
  }
  if (!flg){
    cout << 0;
  } else {
    int a = 1 << __builtin_ctz(A[0]);
    for (int i = 0; i < N; i++){
       A[i] /= a;
    }
    long long LCM = 1;
    for (int i = 0; i < N; i++){
      LCM = lcm(LCM, A[i]);
      if (LCM > M){
        flg = false;
      }
    }
    LCM *= a;
    if (!flg){
      cout << 0;
    } else {
      int c = M / LCM;
      cout << (c + 1) / 2;
    }
  }
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;

int main()
{
	int x;
	cin >> x;
	int ans = 0;

	for (int i = 1; i < x; i++) {
		int y = x / i;
		if (x % i == 0)y--;
		ans += y;
	}

	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 3804
from itertools import accumulate as ac
from math import factorial as fc
from collections import Counter

f=lambda a,b:fc(a)//(fc(a-b)*fc(b)) if a>=b>=0 else 0

n,m=map(int,input().split())
*a,=map(int,input().split())
*aa,=map(lambda x:x%m,ac([0]+a))
d=Counter(aa)

v=sum(f(i,2) for i in d.values())
print(v)


Measured memory_bytes: 15912
import math
n = int(input())
n1 = n
if n == 1:
    print(0)
else:
    a = [0]*(int(math.sqrt(n)) + 1)
    a[1] = 1
    ans = 0
    for i in range(2, int(math.sqrt(n)) + 1):
        if a[i] == 0:
            for j in range(i+i, int(math.sqrt(n)) + 1, i):
                a[j] = 1
    for i in range(2, len(a)):
        if a[i] == 0:
            k = 1
            s = i
            while n % s == 0:
                # print(s)
                ans += 1
                n //= s
                s *= i
            while n % i == 0:
                n //= i
    # print(n)
    f = 1
    for j in range(2, int(math.sqrt(n)) + 2):
        if n % j == 0:
            f = 0
            break
    if f and n != 1:
        ans += f
    # print(n1 // i)

    if ans == 0:
        print(1)
    else:
        print(ans)
    # print(len('997764507000'))


Measured memory_bytes: 75944
n = int(input())
a = list(map(int, input().split()))
data = []
ans = []
t = 1
for i in a:
    data.append([i, t])
    t+=1
data = sorted(data, key=lambda x: x[0])
t=0
for i in data:
    ans.append(str(i[1]))
result = ' '.join(ans)
print(result)

Measured memory_bytes: 28476
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main () {

	int N,K;
	cin >> N >> K;
	vector < int > A(N);
	REP(i,N) cin >> A[i];

	int ans = 0;
	int sum = 0;
	while (sum < N) {
		ans += 1;
		if (sum == 0) {
			sum += K;
		} else {
			sum += (K - 1);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5005;
int arr[maxn], n, k;
bool can(int excl) {
	bitset<maxn> dp; 
	dp[0] = 1;
	for(int i=0; i<n; i++) 
		if(i != excl) 
			dp |= (dp << arr[i]);
	for(int i=k-1; i>=max(0, k-arr[excl]); i--) 
		if(dp[i]) return 1;
	return 0;
}
int main(int argc, char const *argv[]) {
	cin>>n>>k;
	for(int i=0; i<n; i++) 
		cin>>arr[i];
	sort(arr, arr+n);
	int lo = 0, hi = n; 
	while(lo < hi) {
		int mid = lo + hi >> 1;
		if(can(mid)) hi = mid; 
		else lo = mid+1;
	} cout<<lo<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll x, y; cin >> x >> y;
    while(true){
        if(x >= y){
            x = x % y;
        }else{
            y = y % x;
        }
        if(x == 0){
            cout << y << endl;
            break;
        }
        if(y == 0){
            cout << x << endl;
            break;
        }
    }

}


Measured memory_bytes: 3092
import sys
input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
sys.setrecursionlimit(10**7)

import numpy as np
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall

n = int(input())
S = np.frombuffer(read(),'S1').reshape(n, n+1)[:, :n].astype(np.int64)
G = csgraph_from_dense(S)

F = floyd_warshall(G).astype(np.int64)

C = [-1]*n
def dfs(v, c):
  C[v] = c
  for nv, i in enumerate(S[v]):
    if not i:
      continue
    if C[nv] != -1:
      if not (C[v] ^ C[nv]):
        return False
    else:
      if not dfs(nv, c^1):
        return False
  return True

if dfs(0, 0):
  ans = F.max() + 1
  print(ans)
else:
  print(-1)

Measured memory_bytes: 16956
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    int N; cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a[i];
    sort(a.begin(),a.end());
    if(a[0]+1 < a[N-1]){
        cout << "No" << endl;
        return 0;
    }
    if(a[0] == a[N-1]){
        if(a[0] == N-1) cout << "Yes" << endl;
        else if(a[0] <= N/2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else{
        int cnt1 = 0,cnt2 = 0;
        rep(i,N-1){
            if(a[i] != a[i+1]){
                cnt1 = i+1;
                cnt2 = N-cnt1;
                break;
            }
        }
        if(cnt1 < a[N-1] && a[N-1]-cnt1 <= cnt2/2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 640
s = list(str(input()))
t = list(str(input()))
ans = []
an = 0
if len(s) < len(t):
    print("UNRESTORABLE")
    exit()
for i in range(len(s)-len(t)+1):
    cou = s[i:i+len(t)]
    for k in range(len(t)):
        if s[i+k] != t[k] and s[i+k] != "?" and t[k] != "?":
            break
        if k == len(t)-1:
            ans.append(s[:i]+t+s[i+len(t):])
for h in range(len(ans)):
    for f in range(len(s)):
        if ans[h][f] == "?":ans[h][f] = "a"
    ans[h] = "".join(ans[h])
if ans == []:
    print("UNRESTORABLE")
    exit()
ans.sort()
print(ans[0])


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

int lcs(string s1,string s2)
{
	int m = s1.size();
	int n = s2.size();
	int c[1005][1005];
	for (int i = 1; i <= m; i++)c[i][0] = 0;
	for (int j = 1; j <= n; j++)c[0][j] = 0;
	int maxz = 0;
	s1 = " " + s1;
	s2 = " " + s2;
	for(int i=1;i<=m;i++)
		for (int j = 1; j <= n; j++) {
			if (s1[i] == s2[j])
				c[i][j] = c[i-1][j-1] + 1;
			else {
				c[i][j] = max(c[i - 1][j], c[i][j - 1]);
			}
			maxz = max(maxz, c[i][j]);
		}
	return maxz;
}
int main()
{
	int N;
	scanf("%d", &N);
	while (N--) {
		string s1, s2;
		cin >> s1>>s2;
		cout << lcs(s1, s2) << endl;
	}
	return 0;
}

Measured memory_bytes: 7092
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,m; cin >> n >> m;
    map<int,bool> ng;
    rep(i,m){
        int a; cin >> a;
        ng[a]=true;
    }  
    vint dp(n+1,0);
    dp[0]=1;
    rep(i,n){
        if(i+1<=n) if(ng[i+1]==false){
            dp[i+1]+=dp[i]%MOD;
            dp[i+1]%=MOD;
        }
        if(i+2<=n) if(ng[i+2]==false){
            dp[i+2]+=dp[i]%MOD;
            dp[i+2]%=MOD;
        }
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 7296
n,m=io.read("*n","*n")
a={}
for i=1,n do
    a[i]={}
    a[i][1],a[i][2]=io.read("*n","*n")
end
c={}
for i=1,m do
    c[i]={}
    c[i][1],c[i][2]=io.read("*n","*n")
end

checkpoint={}
for i=1,n do
    min={2000000000000001,51}
    for j=1,m do
        manhattan=math.abs(a[i][1]-c[j][1])+math.abs(a[i][2]-c[j][2])
        if min[1]>manhattan then
            min[1],min[2]=manhattan,j
        end
    end
    table.insert(checkpoint,min)
end

for i=1,n do
    print(checkpoint[i][2])
end

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

bool is_tri(ll a, ll b, ll c) {
    return (a+b > c) && (b+c>a) && (a+c>b);
}
bool neq(ll a, ll b, ll c) {
    return (a != b) && (b != c) && (c != a);
}

int main() {
    int n;
    cin >> n;
    vector<ll> arr(n, 0);
    for(auto& val: arr)
        cin >> val;
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i+1; j < n; j++) {
            for(int k = j+1; k < n; k++) {
                if (neq(arr[i], arr[j], arr[k]) && is_tri(arr[i], arr[j], arr[k]))
                    ans += 1;
            }
        }
    }
    cout <<ans << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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 gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int N,M,X,Y;
cin >> N >> M >> X >> Y;
int MX = X, MY = Y;
vi x(N),y(M);
rep(i,N) {
    cin >> x[i];
    MX = max(MX, x[i]);
}
rep(i,M) {
    cin >> y[i];
    MY = min(MY, y[i]);
}

if(MX < MY) cout << "No War" << endl;
else cout << "War" << endl;




return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a * c <= b) cout << c << endl;
    else cout << b / a << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll d[100005][15],mod=1e9+7;
int main(){
    string s;
    cin>>s;
    int n=s.length();
    s=" "+s;
    d[0][0]=1;
    for(int i=1;i<=n;i++){
        if(s[i]!='?'){
            ll x=s[i]-'0';
            for(int k=0;k<13;k++){
                d[i][(10*k+x)%13]=(d[i-1][k]%mod+d[i][(10*k+x)%13]%mod)%mod;
            }
        }
        else{
            for(int j=0;j<10;j++){
                for(int k=0;k<13;k++){
                    d[i][(10*k+j)%13]=(d[i-1][k]%mod+d[i][(10*k+j)%13]%mod)%mod;
                }
            }
        }
    }
    cout<<d[n][5]%mod<<endl;
}

Measured memory_bytes: 12156
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
U_MAP mp;
    
//------ Believe yourself as a genius!!!!!! ------

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i=1; i*i<=n; i++) {
    if(n%i==0) {
      ret.push_back(i);
      if(i*i!=n)ret.push_back(n/i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>m;
    vector<ll> yakusuu1=divisor(n);
    vector<ll> yakusuu2=divisor(m);
    rep(i,Size(yakusuu1))mp[yakusuu1[i]]++;
    vector<ll> yakusuu;
    rep(i,Size(yakusuu2)){
        if(mp[yakusuu2[i]]==0)continue;
        yakusuu.p_b(yakusuu2[i]);
    }
    sort(all(yakusuu));
    rep(i,Size(yakusuu)){
        int ok=1;
        rrep(j,1,i){
            if(yakusuu[i]%yakusuu[j]==0)ok=0;
        }
        if(ok)ans++;
    }
    Cout(ans);
    return 0;
}

Measured memory_bytes: 768
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;
public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 26;
	static int MOD = 998244353;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {
		int n = 100010;
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			boolean[] isPrimes = new boolean[n];
			getPrimes(isPrimes, n);

			int[] sum = new int[n];
			for (int i = 0; i < n; i++) {
				sum[i] = calc(i, isPrimes);
			}
			for (int i = 0; i < n-1; i++) {
				sum[i+1] += sum[i];
			}

			int q = in.nextInt();
			int[] l = new int[q], r = new int[q];
			for (int i = 0; i < q; i++) {
				l[i] = in.nextInt();
				r[i] = in.nextInt();
			}

			for (int i = 0; i < q; i++) {
				out.println(sum[r[i]] - sum[l[i]-1]);
			}

		}

		int calc (int n ,boolean[] isPrimes) {

			if (n % 2 == 1 && isPrimes[n] && isPrimes[(n+1)/2]) {
				return 1;
			} else {
				return 0;
			}
		}

		public static void getPrimes(boolean[] isPrime, int n) {
			Arrays.fill(isPrime, true);
			isPrime[0] = isPrime[1] = false;
			for (int i = 2; i <= Math.sqrt(isPrime.length); i++) {
				if (!isPrime[i])
					continue;
				for (int j = i + i; j < isPrime.length; j += i) {
					isPrime[j] = false;
				}
			}
		}
	}




	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}
}

Measured memory_bytes: 48720
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N, M = input_nums()
    lights = {}
    for i in range(M):
        s = input_nums()[1:]
        lights[i] = s
    p = input_nums()
    cnt = 0
    for bit in range(1<<N):
        on = True
        # M個の電球について調べていく
        for l in range(M):
            ll = lights[l]
            cnt_each = 0
            # N個のスイッチの状態において、電球lが点灯するか調べる
            for i in range(N):
                if bit & (1<<i):
                    # そもそもスイッチがつながってない場合はスキップ
                    if not (i+1) in ll:
                        continue
                    cnt_each += 1
            if cnt_each%2 == p[l]:
                continue
            else:
                on = False
                break
        if on:
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
def resolve():
    N = int(input())
    S = input()
    dp = [[0]*(N+1) for _ in range(N+1)]
    for i in reversed(range(N)):
        for j in reversed(range(N)):
            if S[i] == S[j]:
                dp[i][j] = dp[i+1][j+1] + 1
    
    ans = 0
    for i in range(N):
        for j in range(i, N):
            ans = max(min(dp[i][j], j-i), ans)
    print(ans)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 270172
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000003  
//1000000007
#define P pair<ll, ll>


ll cnt[26];
string s;
int main() {
	cin >> s;
	ll ans = s.size() * (s.size() - 1) / 2 + 1;
	REP(i, s.size()) {
		cnt[s[i] - 'a']++;
	}
	REP(i, 26) {
		ans -= cnt[i] * (cnt[i] - 1) / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        List<String> cm = new ArrayList<>();
        for (int i = 0; i < h; i++) {
            String s = sc.next();
            if (s.contains("#")) {
                cm.add(s);
            }
        }
        sc.close();
        List<Integer> b = new ArrayList<>();
        for (int i = 0; i < w; i++) {
            boolean f = true;
            for (String x : cm) {
                if (!x.substring(w - i - 1, w - i).equals("."))
                    f = false;
            }
            if (f) {
                b.add(w - i - 1);
            }
        }
        for (String x : cm) {
            for (int i = 0; i < w; i++) {
                boolean f = true;
                for (int j : b) {
                    if (i == j)
                        f = false;
                }
                if (f)
                    System.out.print(x.substring(i, i + 1));
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 26848
N=int(input())

AB = []
for i in range(N):
    AB.append(list(map(int,input().split())))

AB = sorted(AB, key=lambda x: x[1])

t = 0
for i in range(N):
    t += AB[i][0]
    if t > AB[i][1]:
        print('No')
        exit()
        
print('Yes')

Measured memory_bytes: 55256
#include<bits/stdc++.h>
#define eps 1e-8
#define pr pair<int,int>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int maxx = 1e5;

int main()
{
	int n;
	string s1;
	cin >> n;
	s1 = to_string(n);
	int flag = 0;
	for(int i = 0; i < s1.size(); i ++)
	{
		if(s1[i] == '7'){
			flag = 1;
			break;
		}
	 } 
	if(flag) puts("Yes");
	else puts("No");
	return 0;
}



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

using namespace std;

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


    int ans = 0 ;

    for(i=1; i<=N; i++){
        ans += L+i-1;
    }

    if(L >= 0)
        ans -=  L ;
    else if( L <= -1 * N)
        ans -= (L + N - 1 );

    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
  ll N,K;
  cin>>N>>K;
  ld coin=0;
  if(N>=K){
  rep1(i,K-1){
    ll p=i;
    ll count=0;
    while(p<K){
      p*=2;
      count++;
    }
    coin+=1/pow(2.0,count);
  }
  
  ld ans=coin/N+(N-K+1.0)/N;
  cout << std::fixed << std::setprecision(13) << ans << endl;

  }
  else{
    rep1(i,N){
      ll p=i;
      ll count=0;
      while(p<K){
        p*=2;
        count++;
      }
      coin+=1/pow(2.0,count);
    }
    
    ld ans=coin/N;
    cout << std::fixed << std::setprecision(13) << ans << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i, start, end) for(ll i=(ll)start; i<(ll)end; i++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(i,0,len) cout << a[i] << " ";

int main(){
  ll s, a, b;
  cin >> s;
  a = s / 100;
  b = s % 100;
  if (a > 0 && a <= 12){
    if (b > 0 && b <= 12){
      print("AMBIGUOUS");
    }else{
      print("MMYY");
    }
  }else{
    if (b > 0 && b <= 12){
      print("YYMM");
    }else{
      print("NA");
    }
  }
  
  return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >

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

int main() {
  int n;
  cin >> n;
  cout << (n>999 ? "ABD" : "ABC") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

struct s{
	int x;
	int y;
	int num;
};

int main(){
	int n;
	cin >> n;
	
	int a[2][n];

	rep(i,0,2){
		rep(j,0,n){
			cin >> a[i][j];
		}
	}
		

	struct s tmp = {0,0,a[0][0]};
	queue<struct s> st;
	st.push(tmp);
	
	int dp[2][n];
	rep(i,0,2){
		rep(j,0,n){
			dp[i][j] = 0;
		}
	}

	while(!st.empty()){
		struct s sss = st.front();
		st.pop();
		int x = sss.x;
		int y = sss.y;
		int na = sss.num;
		
		//printf("y:%d x:%d n:%d\n",y,x,na);
		if(dp[y][x] > na ){
			continue;
		}
		else{
			dp[y][x] = na;
						
			if( y == 0 ){
				struct s tmp1 = {x,1,na+a[1][x]};
				st.push(tmp1);
			}
			
			if(x < n - 1){
				struct s tmp2 = {x+1,y,na+a[y][x+1]};
				st.push(tmp2);
			}

		}
	}
	
	P(dp[1][n-1]);

	ret 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var array = Console.ReadLine().Split().ToArray().Select(int.Parse).ToArray();
            var A = array[0];
            var B = array[1];

            Console.WriteLine(Lcm(A, B));
        }

        // 最小公倍数
        public static decimal Lcm(decimal a, decimal b)
        {
            return a * b / Gcd(a, b);
        }

        // ユークリッドの互除法 
        public static decimal Gcd(decimal a, decimal b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }
    }
}


Measured memory_bytes: 13396