akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
    int n,ans=1e9,s1=0,s2=0;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
        s2 += v[i];
    }
    for(int i=0;i<n;i++){
        s1+=v[i];
        s2-=v[i];
        ans= ans > abs(s1-s2) ? abs(s1-s2) : ans;
    }
    cout<<ans<<"\n";
    return 0;
}


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

typedef long long lli;
typedef pair<int,int> pii;
#define rep(i,n) for(lli i=0;i<(lli)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999


string fb(int n){
    if(n%15==0)return "FizzBuzz";
    if(n%5==0)return "Buzz";
    if(n%3==0)return "Fizz";
    stringstream ss;
    ss<<n;
    return ss.str();
}


int main(){
    int n,m;
    while(cin>>m>>n){
        if(n==0&&m==0)break;
        
        int mem[2000]={};
        rep(i,m) mem[i]=i;
        int less=m;
        
        
        int c=0;
        rep(i,n){
            string a;
            cin>>a;
            if(less==1)continue;
            string teac = fb(i+1);
            
            
            if(teac!=a){
                while(mem[c]==-1)c=(c+1)%m;
                mem[c]=-1;
                less--;
            }else{
                while(mem[c]==-1)c=(c+1)%m;
                c=(c+1)%m;
            }
            
    
        }
        
        bool f=false;
        rep(i,m){
            if(mem[i]!=-1){
                if(f)cout<<" ";
                f=true;
                cout<<mem[i]+1;
            }
        }
        cout<<endl;
        
    }
}

Measured memory_bytes: 1240
#include "bits/stdc++.h"

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;

	int ans = 0;

	for (int i = 1; i <= b - a; i++)
	{
		ans += i;
	}

	cout << (ans - b) << endl;

	return 0;
}

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

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N  = keyboard.nextInt();
		int A  = keyboard.nextInt();
		int B  = keyboard.nextInt();
		int C  = keyboard.nextInt();
		int D  = keyboard.nextInt();
		String S = keyboard.next();
		
		String[] masu = S.split("");
		
		String ans = "Yes";
		if(C > D) {	
		  ans = "No";
          int count = 0;
          for(int m = B-2; m <= D; m++) {
            if(masu[m].equals("#")) {
                count = 0;
            } else {
                    count++;
                    if(count == 3) {
                        ans = "Yes";
                        break;
                    }
              }
            }	
        }
		
  		int StartB = B;	

		if(ans.equals("Yes")) {
			for(int i = B-1; i < D-1; i++) {
				if(masu[i+1].equals(".")) {
					StartB++;
				}else if(masu[i+2].equals(".")) {
					StartB+=2;
                  	i++;
				}else {
					ans = "No";
					break;
				}
			}
		}

		int StartA = A;
		
		if(ans.equals("Yes")) {
			for(int i = A-1; i < C-1; i++) {
				if(masu[i+1].equals(".")) {
					StartA++;
				}else if(masu[i+2].equals(".")) {
					StartA+=2;
                  	i++;
				}else {
					ans = "No";
					break;
				}

			}
		}
		
		System.out.println(ans);
		keyboard.close();	
	}
}


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

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

  vector<int> n{A, B, C};
  sort(n.begin(), n.end());
  n.erase(unique(n.begin(), n.end()), n.end());

  if(n.size() == 2){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
def productall(a):
    N = len(a)
    if N == 0: return [1]
    A = [1] * N + a[:]
    P = 10 ** 9 + 7
    k = 12
    K = k * 8
    pa1 = (1 << k * 4 + 16) - ((1 << k * 4 + 16) % P)
    pa2 = (1 << k * 2 + 24) - ((1 << k * 2 + 24) % P)
    pa3 = (1 << k + 28) - ((1 << k + 28) % P)
    def modP(x):
        x -= ((x & m1) >> k * 4 + 16) * pa1
        x -= ((x & m2) >> k * 2 + 24) * pa2
        x -= ((x & m3) >> k + 28) * pa3
        return x
    
    c = 4
    m1 = int(("1" * (k * 4 - 16) + "0" * (k * 4 + 16)) * c, 2)
    m2 = int(("1" * (k * 6 - 24) + "0" * (k * 2 + 24)) * c, 2)
    m3 = int(("1" * (k * 7 - 28) + "0" * (k + 28)) * c, 2)
    for i in range(1, N)[::-1]:
        if i == 1 << i.bit_length() - 1:
            c *= 2
            m1 = int(("1" * (k * 4 - 16) + "0" * (k * 4 + 16)) * c, 2)
            m2 = int(("1" * (k * 6 - 24) + "0" * (k * 2 + 24)) * c, 2)
            m3 = int(("1" * (k * 7 - 28) + "0" * (k + 28)) * c, 2)
        A[i] = modP(A[2*i] * A[2*i+1])

    t = bin(A[1])[2:] + "_"
    return [int(t[-(i+1) * K - 1:-i * K - 1], 2) % P for i in range((len(t)+K-2) // K)]
def par(a):
    L = []
    while P[a] != a:
        L.append(a)
        a = P[a]
    for l in L:
        P[l] = a
    return a
def unite(a, b):
    pa = par(a)
    pb = par(b)
    if pa == pb: return
    if LEN[pa] < LEN[pb]:
        a, b, pa, pb = b, a, pb, pa
    P[pb] = pa
    if LEN[pa] == LEN[pb]: LEN[pa] += 1
    CNT[pa] += CNT[pb]
def cnt(a):
    return CNT[par(a)]

N = int(input())
P = [i for i in range(N)]
LEN = [1] * N
CNT = [1] * N
FULL = [0] * N
A = [int(a) - 1 for a in input().split()]
for i, a in enumerate(A):
    if a < 0: continue
    if par(i) != par(a):
        unite(i, a)
    else:
        FULL[i] = 1
for i in range(N):
    if FULL[i]:
        FULL[par(i)] = 1
X = []
Y = []
for i in range(N):
    if par(i) == i:
        if FULL[i] == 0:
            X.append(CNT[i])
        else:
            Y.append(CNT[i])
M = len(X)
mod = 10 ** 9 + 7
ans = (sum(X) + sum(Y) - len(Y)) * pow(N - 1, M, mod) % mod
L = productall([(a << 96) + 1 for a in X])
fa = 1
if M: ans = (ans + M * pow(N - 1, M - 1, mod)) % mod
for i, l in enumerate(L):
    if i == 0: continue
    ans = (ans - l * fa * pow(N - 1, M - i + mod - 1, mod)) % mod
    fa = fa * i % mod
print(ans)

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

int main() {
  int ans = 0;
  string a, b;
  cin >> a >> b;
  int howtimes = a.size();
  for(int i = 0; howtimes > i; i++) {
    if(a[i] != b[i]) {
      ans++;
    }
  }
  cout << ans << endl;
}

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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

ll N;
ll dp[20010];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>N;
  vector<tuple<ll,ll,ll> > blocks(N);
  for(ll i=0;i<N;i++){
    ll w,s,v;cin>>w>>s>>v;
    blocks[i]=make_tuple(s+w,s,v);
  }
  sort(blocks.begin(),blocks.end());
  for(ll i=0;i<N;i++){
    ll w,s,v;tie(w,s,v)=blocks[i];
    w -= s;
    for(ll j=s;j>=0;j--){
      dp[j+w]=max(dp[j+w],dp[j]+v);
    }
  }
  ll ans = 0;
  for(ll j=0;j<=20010;j++){
    ans = max(ans,dp[j]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        List<String> input = new ArrayList<String>();
        while (in.hasNextLine()) {
            input.add(in.nextLine());
        }
        in.close();
        int y = Integer.parseInt(input.get(0).split(" ")[0]);
        int x = Integer.parseInt(input.get(0).split(" ")[1]);
        int count = 0;
        for (int i = 0; i < y; i++) {
            for (int j = 0; j < x; j++) {
                if (input.get(i + 1).charAt(j) == '#') {
                    count++;
                }
            }
        }
        String str = y + x - 1 == count ? "Possible" : "Impossible";
        System.out.println(str);
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#include <math.h>
#define PI acos(-1)
using namespace std;
int R;
float ans;
int main( ) {
    cin>>R;
    // scanf("%d", &R);
    ans = 2*R*PI;
    cout<<ans;
    // printf("%f", ans);
    return 0;
}

Measured memory_bytes: 3784
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    string s;cin>>s;

    int result = 0;
    REP(i,3){
        result += s[i]-'0';
    }
    cout<<result<<endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <random>
#pragma comment(linker, "/STACK:836777216")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))
#define	N 4005

int cnt[N][3];
char s[N];

int getId(char a) {
	if (a == 'R') {
		return 0;
	}

	if (a == 'G') {
		return 1;
	}

	if (a == 'B') {
		return 2;
	}
}

int main(void) {
	int n;
	scanf("%d", &n);
	scanf("%s", &s);
	string a = (string)s;

	REP(i, 3) {
		cnt[n][i] = 0;
	}

	REPD(i, n) {
		REP(j, 3) {
			cnt[i][j] = cnt[i + 1][j];
		}
		cnt[i][getId(a[i])]++;
	}

	ll ans = 0;
	REP(i, n-2) {
		FOR(j, i + 1, n-1) {
			if (a[i] != a[j]) {
				int idi = getId(a[i]);
				int idj = getId(a[j]);
				int diff = j - i;

				REP(k, 3) {
					if (k != idi && k != idj) {
						ans += (ll)cnt[j + 1][k];
						if (j + diff < n && getId(a[j + diff]) == k) {
							ans--;
						}
					}
				}
			}
		}
	}

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


Measured memory_bytes: 3804
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int sx, sy, tx, ty;

void solve() {
    int dx = tx - sx;
    int dy = ty - sy;
    cout << string(dx, 'R') << string(dy, 'U') << string(dx, 'L') << string(dy, 'D');
    putchar('L');
    cout << string(dy + 1, 'U') << string(dx + 1, 'R');
    putchar('D');
    putchar('R');
    cout << string(dy + 1, 'D') << string(dx + 1, 'L');
    putchar('U');
}

int main() {
    cin >> sx >> sy >> tx >> ty;
    solve();
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a + n);
	cout << a[n - 1] - a[0] << endl;
	return 0;
}

Measured memory_bytes: 256
import itertools

def main():
    N,M=map(int,input().split())
    sw =[list(map(int, input().split())) for _ in range(M)]
    p=[int(x) for x in input().split()]
    ans=0
    
    for i in itertools.product([0,1],repeat=N):
        onof=True
        for j in range(M):
            counter=0
            for k in sw[j][1:]:
                counter+=i[k-1]
            if counter%2!=p[j]:
                onof=False
                break
        if onof:
            ans+=1
    print(ans)
    
if __name__=="__main__":
    main()

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename V>
class BIT {
public:
  vector<V> bit;
  int n;
  BIT (int n_)
  {
    n = n_;
    bit.resize(n + 1);
  }
  V sum(int i)
  {
    ++i; // 1-origin
    V s = 0;
    while (i > 0) {
      s += bit[i];
      i -= i & -i;
    }
    return s;
  }
  void add(int i, V x)
  {
    ++i; // 1-origin
    while (i <= n)
    {
      bit[i] += x;
      i += i & -i;
    }
    return ;
  }
  void set(int i, V x)
  {
    return add(i, x - bit[i]);
  }
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n, k;
  while (cin >> n >> k) {
    vector<lli> a(n);
    each (i, a) cin >> i;
    each (i, a) i-= k;

    vector<lli> acc(n);
    acc[0] = a[0];
    for (int i = 1; i < n; ++i) {
      acc[i] = acc[i - 1] + a[i];
    }

    vector<pair<lli, int>> v;
    v.push_back(make_pair(0, 0));
    each (i, acc) {
      v.push_back(make_pair(i, v.size()));
    }
    stable_sort(v.begin(), v.end());

    lli sum = 0;
    BIT<lli> bit(v.size());
    each (i, v) {
      sum += bit.sum(i.second);
      bit.add(i.second, 1);
    }
    cout << sum << endl;
  }
  
  return 0;
}


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

int main() {
  int n;
  scanf("%d",&n);
  double x[n];
  string u[n];

  double ans = 0;
  for (int i=0;i<n;i++){
    cin >> x[i] >> u[i];
    if (u[i] == "JPY"){
        ans+=x[i];
    }else{
      ans+= x[i] * 380000;
    }
  }
  cout << ans;  
}


Measured memory_bytes: 256
# import math
# from collections import Counter

# N = int(input()) # 1行, 単数
# arg = list(map(int, input().split())) # 1行, 配列
# D = Counter(arg) # 出現数カウント

# print('Yes')
# print('No')
# print()


arg = list(map(int, input().split())) # 1行, 配列

N = arg[0]
K = arg[1]
S = range(1,N+1)
l = []

for i in range(K):
  D = int(input()) # 1行, 単数
  A = list(map(int, input().split())) # 1行, 配列
  for j in A:
    l.append(j)


AM = list(set(S) - set(l))

print(len(AM))

Measured memory_bytes: 68340
def gcd(a,b):
	if b==0:return a
	return gcd(b,a%b)
a,b,c,d=map(int,input().split())
c=abs(c-a)
d=abs(d-b)
g=gcd(max(c,d),min(c,d))
j=int(c/g)
k=int(d/g)
print((j+k-1)*g)

Measured memory_bytes: 3064
N = int(input())
A = list(map(int,input().split()))

r_s=list(range(0,2801,400))
r_s[0]=1
r_s.append(3200)

r_e=list(range(399,3200,400))
r_e.append(4800)

def check_color(check):
    N=9
    for i in range(N):
        if r_s[i] <= check and r_e[i] >= check:
            return i
        
checklist=[]
checklist_8=[]
for a in A:
#     print( '======')
#     print(a)
    a=check_color(a)
#     print(a)
    if a != 8:
        checklist.append(a)
    else:
        checklist_8.append(a)

max_= len(set(checklist))+len(checklist_8)
min_= len(set(checklist))
        
max_ = max_
min_ = max(1,min_)

print(min_,max_)

Measured memory_bytes: 61732
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

vector<bool> ok(1000005, true);

void Main(){
    int n; cin >> n;
    vi a(n); 
    rep(i, n) cin >> a[i];
    sort(all(a));

    int ans = 0;
    // map<int, int> mp;
    
    rep(i, n){
        if(!ok[a[i]]) {
            ans++;
        }
        else {
            if(i != n-1 && a[i] == a[i+1]){
                ans++;
            }
            for(int j = a[i]; j < 1000005; j += a[i]){
                ok[j] = false;
            }      
        }
    }
    cout << n - ans << endl;
    
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 4240
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}
int lcm(int a, int b) {return a * b / gcd(a, b); }
long long bpow(long long a, long long b, long long m) 
{
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}
void go()
{
#ifndef ONLINE_JUDGE
  freopen("in.txt","r",stdin);
  freopen("out.txt","w",stdout);
  #endif
}
template<typename P> struct Cmp
{
    bool operator()(const P &p1, const P &p2)
    {
        return (p1.ss < p2.ss); 
    }
};

int main() 
{ 
    fast_io
    go();
    int arr[105]={0};
    int x,n;cin>>x>>n;
    map<int,int> mp;
    vi v(n);
    for0(i,n)
    {
      cin>>v[i];
      mp[v[i]]=1;
    }
    int i=x,j=x;
    while(1)
    {
      if(mp.find(i)==mp.end())
      {
        cout << i ;
        return 0;
      }
      else
      {
        i--;
      }
      if(mp.find(j)==mp.end())
      {
        cout << j;
        return 0;
      }
      else
      {
        j++;
      }
    }
} 























Measured memory_bytes: 3680
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        long[] num = new long[200010];

        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sc.next());
            num[a[i]]++;
        }

        long ans = 0;
        for (int i = 0; i < 200010; i++) {
            if (num[i] <= 1) {
                continue;
            }
            ans += num[i] * (num[i] - 1) / 2;
        }
        // System.out.println(ans);
        for (int i = 0; i < n; i++) {
            System.out.println(ans - ((num[a[i]] - 1)));
        }

        sc.close();
    }
}

Measured memory_bytes: 74536
#include<bits/stdc++.h>
using namespace std;
int main(){

  int N,M,Q;
    
  while(1){
    cin >>N>>M>>Q;
    if(N+M+Q == 0)break;
    char s[1100][50],l[1100][1100];
    int data[N][M];
    
    for(int i=0 ; i < Q ; i++)scanf("%s%s",s[i],l[i]);;
    
    for(int i=0 ; i < N ; i++)
      for(int j=0 ; j < M ; j++)
	data[i][j]=1;

    for(int i=0 ; i < Q-1 ; i++){
      for(int j=0 ; j < N ; j++){
	if(s[i][j] == '1'){
	  if(s[i+1][j] == '1'){
	    s[i+1][j]='0';
	  }else{
	    s[i+1][j]='1';
	  }
	}
      }
    }
    
    for(int i=0 ; i < Q ; i++){
      for(int j=0 ; j < N ; j++){
	for(int k=0 ; k < M ; k++){
	  if(s[i][j] != l[i][k])data[j][k] = 0;
	}
      }
    }

    for(int i=0 ; i < M ; i++){
      int cnt=0;
      int num;
      for(int j=0 ; j < N ; j++){
	cnt+=data[j][i];
	if(data[j][i])num=j;
      }
      if(cnt == 1){
	if(num <= 9){
	  cout <<num;
	}else{
	  cout <<(char)('A'+num-10);
	}
      }else{
	cout <<'?';
      }
    }
    cout <<endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 2464
N = int(input())
A = [int(input()) for _ in range(N)]

ans = []
front_max_list, back_max_list = [0], [0]

for i in range(N):
    front_max_list.append(max(front_max_list[i], A[i]))
    back_max_list.append(max(back_max_list[i], A[N - i - 1]))

for i in range(N):
    print(max(front_max_list[i], back_max_list[N - i - 1]))


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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

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

    int x;
    cin>>x;
    int a=x/500;
    x%=500;
    int b=x/5;
    cout<<1000*a+5*b;
}


Measured memory_bytes: 256
H, W, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(M)]

hl, wl = [0]*H, [0]*W
for i,j in A:
    hl[i-1] += 1
    wl[j-1] += 1

mt,mh = max(hl),max(wl)

a = 0
for i,j in A:
    if hl[i-1] == mt and wl[j-1] == mh:
        a += 1

print(mt+mh-1 if a == hl.count(mt) * wl.count(mh) else mt+mh)

Measured memory_bytes: 68312
a,b,k = gets.chomp.split.map(&:to_i)

count = 0

100.times do |i|
    if (a % (100 - i) == 0) && (b % (100 - i) == 0)
        count += 1
    end
    if count == k
        puts 100 - i
        break
    end
end


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

using namespace std;

#define MAX_V 100000

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



int V;
vector<int> G[MAX_V];
vector<int> rG[MAX_V];
vector<int> vs;
bool used[MAX_V];
int cmp[MAX_V];

void add_edge(int from, int to)
{
  G[from].push_back(to);
  rG[to].push_back(from);
}

void dfs(int v)
{
  used[v] = 1;
  for (int i = 0; i < (int)G[v].size(); i++) {
    if (!used[G[v][i]]) dfs(G[v][i]);
  }
  vs.push_back(v);
}

void rdfs(int v, int k)
{
  used[v] = 1;
  cmp[v] = k;
  for (int i = 0; i < (int)rG[v].size(); i++) {
    if (!used[rG[v][i]]) rdfs(rG[v][i], k);
  }
}

int scc()
{
  memset(used, 0, sizeof(used));
  vs.clear();
  for (int v = 0; v < V; v++) {
    if (!used[v]) dfs(v);
  }
  
  memset(used, 0, sizeof(used));
  int k = 0;
  for (int i = vs.size() - 1; i >= 0; i--) {
    if (!used[vs[i]]) rdfs(vs[i], k++);
  }
  return k;
}

typedef long long ll;

ll dp[1010];
vector<int> g[1010];
set<int> vis;
const int MOD = 1000000007;


ll sdfs(int curr, int par) {
  ll& ret = dp[curr];
  vis.insert(curr);
  if(ret + 1) return ret;
  ret = 1;
  for(auto && e: g[curr]) {
    if(e == par) continue;
    ret *= sdfs(e, curr);
    ret %= MOD;
  }
  return (ret + 1) % MOD;
}

int main()
{
  int M, a, b;
  cin >> V >> M;
  
  for (int i = 0; i < M; i++) {
    cin >> a >> b; a--; b--;
    add_edge(a, b);
  }

  
  int K = scc();
  
  int deg[1010] = {};
  
  rep(i, V) for(auto& e: G[i]) {
    if(cmp[i] != cmp[e]) {
      g[cmp[e]].push_back(cmp[i]);
      deg[cmp[i]] ++;
    }
  }
  
  rep(i, K) {
    sort(g[i].begin(), g[i].end());
    g[i].erase(unique(g[i].begin(), g[i].end()), g[i].end());
  }
  
  rep(i, 1010) dp[i] = -1;
  
  ll ans = 1;
  
  rep(i, K) {
    if(deg[i] == 0) {
      ans *= sdfs(i, -1);
      ans %= MOD;
    }
  }

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

Measured memory_bytes: 8088
str1 = gets.split
R,G,B,N = str1[0].to_i, str1[1].to_i, str1[2].to_i, str1[3].to_i

answer = 0

for x in 0..(N/R)
  for y in 0..((N-R*x)/G)
    if (N-R*x-G*y)%B == 0
      answer += 1
    end
  end
end

puts answer

Measured memory_bytes: 3836
SA, SB, SC = [input() for i in range(3)]
SA = SA + '0'
SB = SB + '0'
SC = SC + '0'

card = SA[0]
SA = SA[1:]

for i in range(303):
    if SA == '0' and card == 'a':
        print('A')
        break
    elif SB == '0' and card == 'b':
        print('B')
        break
    elif SC == '0' and card == 'c':
        print('C')
        break
    
    if card == 'a':
        card = SA[0]
        SA = SA[1:]
    elif card == 'b':
        card = SB[0]
        SB = SB[1:]
    elif card == 'c':
        card = SC[0]
        SC = SC[1:]

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		long N = reader.nextLong();
		long[] arr = new long[5];
		int minIndex = 0;
		long ans = 0;
		for (int i = 0; i < 5; i++) {
			arr[i] = reader.nextLong();
			if (arr[minIndex] > arr[i]) {
				minIndex = i;
			}
		}
		long length = N / arr[minIndex];
		if (N % arr[minIndex] != 0) {
			length++;
		}
		ans = length - 1 + 5;

		System.out.print(ans);
		reader.close();
	}
}





Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main()
{
  
  int n,k;
  cin>>n>>k;
 long long int arr[n+1];
  for(int i=1;i<=n;i++)
    cin>>arr[i];
 long long int minm[n+1];
  minm[2]=abs(arr[2]-arr[1]);
  minm[1]=0;
  for(int j=3;j<=n;j++)
  {
    long long int h=j-k;
    h=max(1ll,h);
    minm[j]=pow(10,15);
    while(h<j)
    {
     minm[j]=min(minm[h]+abs(arr[h]-arr[j]),minm[j]);
      h++;
    }
  }
  cout<<minm[n]<<endl;
  return 0;
}


Measured memory_bytes: 1792
import sys
def resolve():
    readline=sys.stdin.readline
    n=int(readline())
    answer=0

    table = [0] * (n + 1)
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
        answer+=table[i]*i
    print(answer)

    return

resolve()

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

int main(){
  string str;
  
  cin >> str;
  int temp;
  string mode = "i";
  if(str.length() % 2 == 1){
    cout << "No";
    return 0;    
  }
  
  while(str.length() > 0){
    if(mode == "i"){
      if(str.back() == 'i'){
        mode = "h";
        str.pop_back();
      }else{
        cout << "No";
        return 0;
      }
    }
    else if(mode == "h"){
      if(str.back() == 'h'){
        mode = "i";
        str.pop_back();
      }else{
        cout << "No";
        return 0;
      }
    }
  }
  cout << "Yes";
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<iostream>
#include <stdlib.h>
 
int main(){
  int X, N;
  std::cin>>X>>N;
  
  std::vector<int> v(100, 1);
  int ans;
  int ansdiff = 100;
  
  if(N==0){
  	std::cout<<X;
  }
  else if(N ==100){
    if(101 - X < X){
  		std::cout<<"101";
    }
    else{
      std::cout<<"0";
    }
  }
  else{
    for(int i=0; i<N; i++){
      int k;
      std::cin>>k;
      v[k-1] = 0;
    }
 
    for(int i0=0; i0<100; i0++){
    
      if(v[i0]==1 && abs(i0 - X +1) < ansdiff){
        //std::cout<<abs(i0 - X +1)<<std::endl;
      	ansdiff = abs(i0 - X +1);
        ans = i0+1;
      }
      
    }
    
    if(X <= ansdiff){
    	std::cout<<"0";
    }else if(101 - X < ansdiff){
    	std::cout<<"101";
    }
    else{
    	std::cout<<ans;
    }
  }
  
  
 
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
#define ri register int
const int M=998244353;
int n,u,v,head[1000005],Next[2000005],adj[2000005],f[1000005],i,root,p[1000005],ans,k,d[1000005];
inline char nc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read(){
    char ch=nc();int sum=0;
    while(!(ch>='0'&&ch<='9'))ch=nc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=nc();
    return sum;
}
void Push(int u,int v)
{
	Next[++k]=head[u];
	head[u]=k;
	adj[k]=v;
}
void dfs(int i,int fa)
{
	int j,flag=0;
	if(d[i]<=2)
		p[i]=1;
	for(j=head[i];j!=0;j=Next[j])
		if(adj[j]!=fa)
		{
			dfs(adj[j],i);
			p[i]&=p[adj[j]];
			if(p[adj[j]]==1)
				flag=1;
			else
				f[i]+=f[adj[j]];
		}
	f[i]+=flag;
}
int main()
{
	n=read();
	for(i=1;i<n;i++)
	{
		u=read();
		v=read();
		u++;
		v++;
		Push(u,v);
		Push(v,u);
		d[u]++;
		d[v]++;
	}
	for(i=1;i<=n;i++)
		if(d[i]>2)
			root=i;
	for(i=1;i<=n;i++)
		if(d[i]==1)
			ans++;
	if(root==0)
	{
		printf("1");
		return 0;
	}
	dfs(root,0);
	cout<<ans-f[root];
}

Measured memory_bytes: 19712
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: usize,
        k: i64,
        a: [usize; n],
    }
    const MOD: i64 = 1_000_000_007;
    let mut ans = 0;
    for i in 0..n {
        for j in 0..i {
            if a[j] > a[i] {
                ans += k;
            }
        }
        for j in 0..n {
            if a[j] > a[i] {
                ans += k * (k - 1) / 2 % MOD;
            }
        }
    }
    ans %= MOD;
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const long long INFdesu=2E10;
vector<int> p;
vector<int> c;
int D,G;

int main(){
    cin >> D >> G;
    int tmp,tmp2;
    for(int i=0;i<D;i++){
        cin >> tmp >> tmp2;
        p.push_back(tmp);
        c.push_back(tmp2);
    }

    int ans =1e9;
    for(int mask = 0; mask < (1 << D); ++mask){
        int s=0, num=0, rmax=-1;
        for(int i = 0; i < D; ++i){
            if(mask >> i & 1){
                s += 100 * (i+1) * p[i] + c[i];
                num += p[i];
            }else{
                rmax = i;
            }
        }
        int s1 = 100 * (rmax + 1);
        if(s<G){
            int need=(G-s+s1-1)/s1;
            if(need>=p[rmax]){
                continue;
            }
            num+=need;
        }
        ans=min(ans,num);

    }
    cout << ans << endl;
    
}


Measured memory_bytes: 256
n,w=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]

lim=n*10**3+1
#dp=[[float('inf') for i in range(lim)] for i in range(n+1)]
dp=[[10**15 for i in range(lim)] for i in range(n+1)]

for i in range(n+1):
 dp[i][0]=0

#dp[0][0]=0

for i in range(n):
 for sum_v in range(lim):

  if sum_v-l[i][1]>=0:
   dp[i+1][sum_v] = min(dp[i+1][sum_v],dp[i][sum_v-l[i][1]]+l[i][0])

  dp[i+1][sum_v]=min(dp[i+1][sum_v],dp[i][sum_v])

ans=0
for i in range(lim):
 if dp[-1][i]<=w:
  ans=max(ans,i)
print(ans)

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N-1);
    rep(i, N) {
        cin >> A[i];
        A[i]--;
    }
    rep(i, N) cin >> B[i]; 
    rep(i, N-1) cin >> C[i];

    int prev = -1;
    int res = 0;
    rep(i, N) {
        res += B[A[i]];
        if(prev != -1) {
            if(A[i] == prev+1) res += C[prev];
        }
        prev = A[i];
    }

    cout << res << endl;
    return 0;
}

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

typedef long long ll;

main()
{
    ll a, b, c, d, x, y;
    cin >> a >> b >> c >> d;
    if(a * c >= a * d && a * c >= b * c && a * c >= b * d){
        cout << a * c;
    }
    else if(a * d >= a * c && a * d >= b * d && a * d >= b * c ){
        cout << a * d;
    }
    else if(b * c >= a * c && b * c >= b * d && b * c >= a * d){
        cout << b * c;
    }
    else{
        cout << b * d;
    }



}





///promy_pompom
//hello world


Measured memory_bytes: 3588
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    n = int(input())
    as_ = list(map(int, input().split()))
    num_div = 0
    for a in as_:
        i = 0
        while True:
            if a & (1 << i) == 0:
                num_div += 1
                i += 1
            else:
                break
    print(num_div)




if __name__ == '__main__':
    main()

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

int main()
{
    char s[1001],t[1001];
    cin>>s>>t;
    int l1=strlen(s),l2=strlen(t);
    int m=l2;
    for(int i=0;i<(l1-l2)+1;i++)
    {
        int ct=0;
        for(int j=0;j<l2;j++)
        {
            if(s[i+j]==t[j])
                ct++;
        }
        m=min(m,l2-ct);
    }
    cout<<m;
    return 0;
}


Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (Math.abs(x-a) > Math.abs(x-b))
            System.out.println("B");
        else
            System.out.println("A");
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32692
def insertion_sort(A, N):
    for i in range(1, N):
        v = A[i]
        j = i - 1
        print(*A)

        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v

    return A

N = int(input())
A = list(map(int, input().split()))

A = insertion_sort(A, N)
print(*A)

Measured memory_bytes: 8052
import itertools
 
N = int(input())
P = map(int, input().split())
Q = map(int, input().split())

P = tuple(P)
Q = tuple(Q)
dlist = range(1, N+1)
permlist = list(itertools.permutations(dlist))

a = 0
b = 0
for i, p in enumerate(permlist):
	if P == p:
		a = i
	if Q == p:
		b = i
    
print(abs(a-b))

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

int main(){
    int K,S;
    //cin >> K >> S;
    scanf("%d%d",&K,&S);
    int match = 0;
    for (int i=0;i<=K;i++) {
        for (int j=0;j<=K;j++) {
            int k = S - (i + j);
            if (k>=0&&k<=K) match++;
        }
    }
    //cout << match << endl;
    printf("%d",match);
    cout << endl;
}

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


int main() {
    string s;
    string t;

    cin >> s >> t;

    if( s == t.erase(t.length() -1, 1)){
        if(1 <=s.length() && s.length() <= 10) {
            
            cout << "Yes";
        }
    }
    else {
        cout << "No";
    }

}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;

int main()
{
    long long n, tmp_a, tmp_b;
    cin >> n;
    int max = sqrt(n) + 1;
    int a, b, fab, ans;
    ans = 150;
    for(int i=1; i<=max; ++i){
        if(n % i != 0){
            continue;
        }
        tmp_a = (long long)i;
        tmp_b = (long long)(n) / (long long)i;
        a = (int)((to_string(tmp_a)).length());
        b = (int)((to_string(tmp_b)).length());
        fab = (a >= b) ? a : b;
        ans = min(ans, fab);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

const int md = 998244353;

const int N = 3007;

int dp[N][N];

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  dp[a][b] = 1;
  for (int i = a; i <= c; ++i) {
    for (int j = b; j <= d; ++j) {
      if (i == a && j == b) continue;
      dp[i][j] = ((ll)dp[i - 1][j] * j + (ll)dp[i][j - 1] * i) % md;
      dp[i][j] -= ((ll)(i - 1) * (j - 1) * dp[i - 1][j - 1]) % md;
      if (dp[i][j] < 0) dp[i][j] += md;
    }
  }
  cout << dp[c][d] << '\n';
}



Measured memory_bytes: 38776
N, Y = map(int, input().split())

for i in range(N+1):
    for j in range(N-i+1):
        k = N-i-j
        if 0 <= k <= 2000 and 10000*i + 5000*j + 1000*k == Y:
            print(i, j, k)
            exit()
print(-1, -1, -1)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int P,Q,R;
  cin>>P>>Q>>R;
  cout<<P+Q+R-max(P,max(Q,R))<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
int main(void) {
double a,b,c,d;
double e;
scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
e=(a-c)*(a-c)+(b-d)*(b-d);
e=sqrt(e);
printf("%f",e);
  return 0;
}


Measured memory_bytes: 2148
import math
N = int(input())
C = [0] * (N - 1)
S = [0] * (N - 1)
F = [0] * (N - 1)
for i in range(N - 1):
  c, s, f = map(int, input().split())
  C[i] = c
  S[i] = s
  F[i] = f
T = [0] * N
for i in range(N - 1):
  for j in range(i + 1):
    T[j] = max(S[i], T[j])
    T[j] = math.ceil(T[j] / F[i]) * F[i]
    T[j] += C[i]
for t in T:
  print(t)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;

int main() {
  string s, t;
  cin >> s >> t;

  int ans = 0;
  int size = s.size();
  for (int i = 0; i < size; i++) {
    if (s[i] != t[i]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3440
S = input()
T = input()
ans = 10**10
for k in range(len(S)-len(T)+1):
    U = S[k:k+len(T)]
    temp = 0
    for l in range(len(T)):
        if U[l] != T[l]:
            temp += 1
    ans = min(temp,ans)
print(ans)


Measured memory_bytes: 73176
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a[]={0,1,3,1,2,1,2,1,1,2,1,2,1};
  int x,y;
  cin >> x >> y;
  if (a[x]==a[y]){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

int main() {
  string input(a, b);
  ll cnt = 0;
  REP(i, a.size()) {
    cnt += a[i] != b[i];
  }

  cout << cnt << endl;
}


Measured memory_bytes: 3924
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		int sum=s,count=0;
		int[] array=new int[10000];
		array[0]=sum;
		do{
			count++;
			//System.out.println(sum);
			if(sum%2==0) {
				sum=sum/2;
			}else {
				sum=sum*3+1;
			}
			array[count]=sum;
			for(int i=0;i<=count-1;i++) {
				for(int j=i+1;j<=count;j++) {
					if(array[j]==array[i]) {
						System.out.println(count+1);
						System.exit(0);
					}
				}
			}
		}while(sum!=s);
	}
}

//Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));




Measured memory_bytes: 23636
#include<stdio.h>

int main(void){
    int i,n,cnt;
    cnt = 0;
    scanf("%d",&n);
    int a[n];
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
    }

    for(i=0; i<n-2; i++){
        if(a[i] < a[i+1] && a[i+1] < a[i+2] ||
           a[i+2] < a[i+1] && a[i+1] < a[i] ){
               cnt++;
           }
    }

    printf("%d\n",cnt);

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#define _USE_MATH_DEFINES // for C
#include <math.h>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#include<iomanip>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

//度数からラジアン
double deg_to_rad(double a) {
	return a * M_PI / 180;
}

//ラジアンから度数
double rad_to_deg(double a) {
	return a * 180 / M_PI;
}

int main() {
	double a, b, x;
	cin >> a >> b >> x;

	double ans = 0;
	if (a * a * b / 2 <= x) {
		double space = a * a * b - x;
		double c = (2 * space) / (a * a);
		ans = atan(a / c);
	}
	else {
		double c = (2 * x) / (a * b);
		ans = atan(c / b);
	}
	
	cout << fixed << setprecision(10) << 90 - rad_to_deg(ans) << endl;

	return 0;
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	ll n;
	double x;
	string u;
	double ans = 0.0;

	cin >> n;

	REP(i, n) {
		cin >> x >> u;

		if (u == "JPY") {
			ans += x;
		}
		else {
			ans += x * 380000.0;
		}
	}

	cout << ans << endl;
}

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

int main()
{
  int N;
  cin >> N;
  int min_p = N + 1;
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    int p;
    cin >> p;
    if (min_p > p)
    {
      ans++;
    }
    min_p = min(min_p, p);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int d, g;
    cin >> d >> g;
    vector<int> p(d), c(d);
    rep(i, 0, d) cin >> p[i] >> c[i];
    int ans = INF;
    for(int mask = 0; mask < (1 << d); mask++){
        int point = 0;
        int tmp = 0;
        rep(i, 0, d){
            if(mask & (1 << i)){
                point += 100 * (i + 1) * p[i] + c[i];
                tmp += p[i];
            }
        }
        if(point >= g){
            chmin(ans, tmp);
        }else{
            repr(i, d - 1, 0){
                if(mask & (1 << i)) continue;
                int rest = g - point;
                int tmp2 = (rest + 100 * (i + 1) - 1) / (100 * (i + 1));
                if(tmp2 <= p[i]){
                    tmp += tmp2;
                    point += tmp2 * 100 * (i + 1);
                }
                break;
            }
            if(point >= g){
                chmin(ans, tmp);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;

class Program
{
  static void Main(string[] args)
  {
    string str = Console.ReadLine();
	string result = "";
	switch( str )
    {
    	case "Sunny":
        	result = "Cloudy";
        	break;
        case "Cloudy":
        	result = "Rainy";
       		break;
        case "Rainy":
        	result = "Sunny";
        	break;
        default:
        	break;
    }

    Console.WriteLine(result); 
  }
}

Measured memory_bytes: 11092