akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.Scanner;

class Main {

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

		Scanner scan = new Scanner(System.in);

		int a, b,c;
		int counter = 0;

		a = scan.nextInt();
		b = scan.nextInt();
		c = scan.nextInt();

		for(int i = a; i<=b;i++){

			if((c%i)==0){
				counter++;
			}
		}
		System.out.println(counter);



	}
}

Measured memory_bytes: 26180
def cl(i1,j1,i2,j2):
  if i1>i2 or j1>j2 or i1<0 or j1<0 or i2<0 or j2<0:
    return 0
  v=l[i2][j2]
  if i1>0:
    v-=l[i1-1][j2]
  if j1>0:
    v-=l[i2][j1-1]
  if i1>0 and j1>0:
    v+=l[i1-1][j1-1]
  return v

N,K=map(int,input().split())
K2=2*K
l=[[0]*K2 for _ in range(K2)]

for i in range(N):
  xi,yi,ci=input().split()
  xi,yi=int(xi),int(yi)
  if ci=="W":yi+=K
  l[xi%K2][yi%K2]+=1

for y in range(K2):
  for x in range(1,K2):
    l[x][y]+=l[x-1][y]
for y in range(1,K2):
  for x in range(K2):
    l[x][y]+=l[x][y-1]

ans=0
for i in range(K):
  for j in range(K):
    tmp=0
    tmp+=cl(0,0,i-1,j-1)
    tmp+=cl(0,j+K,i-1,K2-1)
    tmp+=cl(i+K,j+K,K2-1,K2-1)
    tmp+=cl(i+K,0,K2-1,j-1)
    tmp+=cl(i,j,i+K-1,j+K-1)
    ans = max(ans,tmp,N-tmp)
print(ans)


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N-1);
    for(int i=0;i<N-1;i++) cin >> B.at(i);

    A.at(0) = B.at(0);
    A.at(N-1) = B.at(N-2);
    for(int i=1;i<N-1;i++){
        A.at(i) = min(B.at(i-1),B.at(i));
    }
    cout << accumulate(A.begin(),A.end(),0) << endl;

}

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

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

    vector<int> snuke(n);

    rep(i, k){
        int d;
        cin >> d;

        rep(j, d){
            int tmp;
            cin >> tmp;
            snuke[tmp - 1]++;
        }
    }

    int ans = 0;

    rep(i, n){
        if(snuke[i] == 0) ans++;
    }

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


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}

ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
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 keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}

        
//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;

int main(){
  ll X,K,D;cin>>X>>K>>D;
  if(X<0)X *=-1;
  ll cntp=X/D;
  
  ll ans=0;
  if( K >= cntp){
    ans = X-D*cntp-D*((K-cntp)%2);
  }
  else{
    ans = X-D*K;
  }
  if(ans<0)ans*=-1;
  cout<<ans<<endl;
}

Measured memory_bytes: 3720
n, m = map(int, input().split())
a_set = set()
b_set = set()
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        a_set.add(b)
    elif b == n:
        b_set.add(a)
if a_set & b_set:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 18936
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int ans=0;
    int max=0;
    if(s.charAt(0)=='R'){
      ans++;
      max=Math.max(max,ans);
    }
    for(int i=1;i<s.length();i++){
      if(s.charAt(i)==s.charAt(i-1) && s.charAt(i)=='R'){
        ans++;
        max=Math.max(max,ans);
      }
      else if(s.charAt(i)=='R'){
        ans=0;
        ans++;
        Math.max(max,ans);
      }
    }
    max =Math.max(max,ans);
    System.out.println(max);
  }
}
      

Measured memory_bytes: 35672
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>

using namespace std;

// 書き方程式を解く
// ax + by = c
// dx + ey = f
int main() {

    double a, b, c, d, e, f;
    vector<double> ansX;
    vector<double> ansY;
    
    double k1, k2, x, y;
    while (cin >> a >> b >> c >> d >> e >> f) {
        // (a * e)x + (e * b)y = (e * c)
        // (b * d)x + (b * e)y = (f * b)
        k1 = (e * c - f * b);
        k2 = (a * e - b * d);
        if (k1 == 0 && k2 < 0) k2 *= -1;
        x = k1 / k2;
        //(d * a)x + (d * b)y = (d * c)
        //(a * d)x + (a * e)y = (a * f)
        k1 = (d * c - a * f);
        k2 = (d * b - a * e);
        if (k1 == 0 && k2 < 0) k2 *= -1;
        y = k1 / k2;
        ansX.push_back(x);
        ansY.push_back(y);
    }
    
    for (int i = 0; i < ansX.size(); i++) {
        cout << fixed;
        cout << setprecision(3) << ansX[i] << " " << ansY[i] << endl;
    }
    
    return 0;
}


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

using namespace std;

int main(){
	int n;
	scanf("%d", &n);

	bool ok = true;
	for(int i = 1; i <= n; i++){
		int x; scanf("%d", &x);

		if(x % 2 == 0){
			if(!((x % 3 == 0) || (x % 5 == 0))) ok = false;
		}
	}

	if(ok) printf("APPROVED\n");
	else printf("DENIED\n");
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

vector<pair<int,int> >red;
vector<pair<int,int> >blue;
vector<pair<int,int> >ok;
int used[105];


int main() {

	int N;

	scanf("%d",&N);

	int i,j;

	for(i=0;i<N;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		red.push_back(make_pair(a,b));
	}
	for(i=0;i<N;i++){
		int c,d;
		scanf("%d %d",&c,&d);
		blue.push_back(make_pair(c,d));
	}

	sort(red.begin(),red.end());
	sort(blue.begin(),blue.end());

	int ans=0;

	for(i=0;i<N;i++){
		ok.clear();
		for(j=0;j<N;j++){
			if(blue[i].first>red[j].first && used[j]==0){
				ok.push_back(make_pair(red[j].second,j));
			}
		}
		sort(ok.begin(),ok.end());
		for(j=ok.size()-1;j>=0;j--){
			if(blue[i].second>ok[j].first){
				used[ok[j].second]=1;
				ans++;
				break;
			}
		}
	}

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

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, m, L, R;
vector<int> val[N];
int lch[N << 2], rch[N << 2], Max[N << 2], lazy[N << 2];
inline void update(int x, int v) {
    lazy[x] += v; Max[x] += v;
}
inline void pushup(int x) {Max[x] = max(Max[x << 1], Max[x << 1 | 1]);}
inline void pushdown(int x) {
    if(lazy[x]) {
        update(x << 1, lazy[x]); update(x << 1 | 1, lazy[x]); lazy[x] = 0; 
    }
}
void build(int x,int l, int r) {
    lch[x] = l; rch[x] = r;
    if(l == r) {
        Max[x] = l; return;
    }
    int mid = (l + r) / 2;
    build(x << 1, l, mid); build(x << 1 | 1, mid + 1, r);
    pushup(x);
}
void update(int x, int l, int r, int v) {
    if(l <= lch[x] && rch[x] <= r) {
        update(x, v); return;
    }
    pushdown(x);
    int mid = (lch[x] + rch[x]) / 2;
    if(r <= mid) update(x << 1, l, r, v);
    else if(l > mid) update(x << 1 | 1, l, r, v);
    else update(x << 1, l, mid, v), update(x << 1 | 1, mid + 1, r, v);
    pushup(x);
}
int query(int x, int l, int r) {
    if(l <= lch[x] && rch[x] <= r) {
        return Max[x];
    }
    pushdown(x);
    int mid = (lch[x] + rch[x]) / 2,cur_ans=-0x3f3f3f3f;
    //if(r <= mid) return query(x << 1, l, r);
    //else if(l > mid) return query(x << 1 | 1, l, r);
    //else return max(query(x << 1, l, mid), query(x << 1 | 1, mid + 1, r));
    if(l <= mid) cur_ans=max(cur_ans,query(x << 1, l, r));
    if(r > mid) cur_ans=max(cur_ans, query(x << 1 | 1, l, r));
    return cur_ans;
}
int ans = 0;
int main() {
    //freopen("ce.in","r",stdin);
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; ++i) {
        scanf("%d%d", &L, &R); val[L].push_back(R);
    }
    build(1, 0, m + 1);
    for(int i = 0; i <= m; ++i) {
        for(int j = 0; j < val[i].size(); ++j) {
            update(1, 0, val[i][j], 1);
        }
        ans = max(ans, query(1, i + 1, m + 1) - m - i - 1);
    }
    printf("%d\n", max(ans, n - m));
    return 0;
}

Measured memory_bytes: 20992
object Main extends App {
  val input = io.StdIn.readLine()
  val in = input.split(" ").map(_.toInt)

  if (in(0) % in(1) == 0) {
    println((in(0) / in(1)))
  } else {
    println((in(0) / in(1) + 1))
  }
}


Measured memory_bytes: 27200
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

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

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    for(int i = 1; i < 10; i++) for(int j = 1; j < 10; j++) if(i * j == n)
    {
        cout << "Yes";
        return 0;
    }
    cout << "No";

    return 0;
}


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

 #define maxn 2000000
 #define INF maxn*10
 #define pb push_back
 #define popb pop_back()
 #define all(x) (x).begin(), (x).end()
 #define rall(x) (x).rbegin(), (x).rend()
 #define f first
 #define s second
 #define forn(i, n) for (int i = 0; i < (int)(n); ++i)
 #define ROF(i, n) for (int i = (int)(n)-1; i <= 0; --i)
 #define see_tree for(int i = 1; i <2*n ; i++)cout << tree[i] << " "
 #define mid (l+r)/2
 #define mod 1000000007

 using namespace std;

    int n, a, b, c, ar[200];
    bool mk[200];
 int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

        cin >> b >> c >> a;
        cout << a << " " << b << " " << c;
 return 0;
 }




Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def fi(): return float(input())
def mfi(): return map(float, input().rstrip().split())
def lmfi(): return list(map(float, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template


def main():
    a, b, x = mfi()
    if x > a * a * b / 2:
        tt = (a * a * b - x) / (a * a) * 2
        # print(tt)
        print(math.degrees(math.atan(tt / a)))
    else:
        tt = (x) / (a * b) * 2
        # print(tt)
        print(math.degrees(math.atan(b / tt)))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<stdio.h>
int main(void){
    int a,b,c,d,x=0,y=0;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    for(int i=1;100>=i;++i){
        if(a-i*d>0)
        ++x;/*何回の攻撃に耐えられるか*/
    }
    for(int i=1;100>=i;++i){
        if(c-i*b>0)
        ++y;/*何回の攻撃に耐えられるか*/
    }
    if(x>=y)
    printf("Yes");
    else
    {
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 1724
#include<iostream>
using namespace std;
int main()
{
  int n,flag=1;
  unsigned long long a,product,max=1e18;
  cin>>n;
   cin>>a;
   product=a;
   for(int i=2;i<=n;i++)
  {
     max=max/a;
     cin>>a;
     if(a==0)
     {
       cout<<0<<endl;
       exit(0);
     }
     if(a<=max)
      product*=a;
     else{
       flag=-1;
     }  
  }
  if(flag==1)
  cout<<product;
  else
  {
    cout<<-1;
  }
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double
#define TIME ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
///__builtin_popcount(x) -- > sum of 1
    const ll N = 1e3 + 7;
    const ll mod = 1e9 + 7;
int n , m , k , cnt , sum;

int main(){
    TIME
    cin >> n >> m >> k;
    while(cnt < k){
        cnt += max(n , m);
        sum ++;
    }
    cout << sum;
}
///...


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

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

typedef long long ll;

const int INF = 1e8;

int main() {
  int N, M; cin >> N >> M;
  vector<int> a(N); rep(i, N) cin >> a[i];
      
  vector<int> sum(N+1); sum[0] = 0;
  rep(i, N) sum[i+1] = (sum[i] + a[i]) % M;

  ll ans = 0;
  map<int, int> m;
  rep(i, sum.size()){
    ans += m[sum[i]];
    m[sum[i]]++;
  }

  cout << ans << endl;
  
}


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

using namespace std;

#define INF 1000000007
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main()
{
    int N;
    cin >> N;
    int p[N];
    int ans[N];
    rep(i, N)
    {
        cin >> p[i];
        ans[i] = i + 1;
    }
    int check = 0;
    rep(i, N)
    {
        if (ans[i] != p[i])
        {
            check++;
        }
    }
    if (check <= 2)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    ll X;
    cin >> X;

    cout << X/500*1000+(X%500)/5*5 << endl;
}

Measured memory_bytes: 256
// ~/Remember,remember the 6th of March

#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-9;
const ll MOD = 1e9 + 7;
using namespace std;
int main()
{
    int n,d;
    cin>>n>>d;
    d=d+d+1;
    cout<<((n+d-1)/d)<<endl;
    return 0;
}


Measured memory_bytes: 256
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0079
// ???????????????????????????????§???¢?????¢???????????¨???????¶????????????????
// ????????????
#include <bits/stdc++.h>
using namespace std;
typedef pair<double, double> P;
double x, y;
double S, z;
vector<P> points;
int main() {
    while (~scanf("%lf,%lf",&x,&y)) {
        points.push_back(P(x,y));
    }
    S = 0.0;
    for (int i=1; i<points.size()-1; i++) {
        double a=sqrt(pow(points[0].first-points[i].first,2.0)+
                pow(points[0].second-points[i].second,2.0));
        double b=sqrt(pow(points[i].first-points[i+1].first,2.0)+
                pow(points[i].second-points[i+1].second,2.0));
        double c=sqrt(pow(points[i+1].first-points[0].first,2.0)+
                pow(points[i+1].second-points[0].second,2.0));
        z = (a+b+c)/2;
        S += sqrt(z*(z-a)*(z-b)*(z-c));
    }
    printf("%.6f\n",S);
}

Measured memory_bytes: 1240
from collections import defaultdict, deque
import sys


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


n = I()
if n >= 1000:
    ans = 'ABD'
    if len(str(n - 999)) == 1:
        ans += '00' + str(n - 999)
    elif len(str(n - 999)) == 2:
        ans += '0' + str(n - 999)
    else:
        ans += str(n - 999)

else:
    ans = 'ABC'
    if len(str(n)) == 1:
        ans += '00' + str(n)
    elif len(str(n)) == 2:
        ans += '0' + str(n)
    else:
        ans += str(n)
print(ans[:3])


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <cstring>
#include <string.h>
#include <sstream>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using vec = vector<T>;
template<typename T> using prior = priority_queue<T>;

const ll MOD = 1e9+7;
const ll SPMOD = 998244353;
const double PI  = 3.14159265358;
const double EPS = 1e-8;
 
#define INT_MX 2147483647
#define INF ((int)1e9)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define siz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define Unique(v) v.rs(unique(ALL(v))-v.begin())
#define EB emplace_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define __ <<' '<<
#define kiyohime ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

// template
ll POW();
int gcd(int a, int b);
// end of template

#define N 200010

bool check(int n, int k){
//    return true;
    while(n >= k){
        if(n % k == 0) n /= k;
        else    n -= k;
    }
    return n == 1;
}

void solve(){
    ll n, ans = 0;
    
    cin >> n;
    
    if(n == 2){
        cout << 1 << '\n';
        return ;
    }
    
    REP(i, 2, sqrt(n)){
        if(n % i == 0){
            ll t = n;
            while(t % i == 0) t /= i;
            if((t - 1) % i == 0){
//                cout << i __ check(n, i) << '\n';
                ans++;
            }
        }
    }
    
    n--;
    REP(i, 2, sqrt(n)){
        if(n % i == 0){
//            cout << i __ check(n+1, i) << '\n';
            ans++;
            if(n/i != i){
//                cout << n/i __ check(n+1, n/i) << '\n';
                ans++;
            }
        }
    }
    cout << ans + 2 << '\n';
}



int main(){
    kiyohime
    int T = 1;
    
//    cin >> T;
    while(T--){
        solve();
    }
}


// templates

ll POW(ll a, ll b, ll m = MOD){
    ll res = 1;
    while(b){
        if(b&1) res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,k,l,a,b,c,d,m;
    cin>>n>>m;
    ll arr[m+10];
    vector<ll>vc;
    for(i=0;i<m;i++)
    {
        cin>>arr[i];
    }
    sort(arr+0,arr+m);
    for(i=1;i<m;i++)
    {
        k=abs(arr[i]-arr[i-1]);
        vc.push_back(k);
    }
    sort(vc.begin(),vc.end());
    l=vc.size();
    l-=(n-1);
    c=0;
    for(i=0;i<l;i++)
    {
        c+=vc[i];
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 2168
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

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

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v) os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v) os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

template <class K, class T>
ostream& operator<<(ostream& os, map<K, T> v) {
    os << "[";
    for (auto vv : v) os << vv << ",";
    return os << "]";
}

const ll MOD = 1000000007;
// const ll MOD = 998244353;
const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const ld PI = acos(-1);
// const ld EPS = 1e-10;
// mt19937 mt(ll(time(0)));

template <typename T>
inline T sq(T a) { return a * a; }

template <typename T>
inline T iceil(T n, T d) { return (n + d - 1) / d; }

template <typename T>
T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    return b == 0 ? a : gcd(b, a % b);
}

template <typename T, typename U>
T ipow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b;
    return n % 2 == 0 ? ipow(b * b, n / 2) : ipow(b, n - 1) * b;
}

template <typename T, typename U>
T mpow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b % MOD;
    return n % 2 == 0 ? mpow(b * b % MOD, n / 2) : mpow(b, n - 1) * b % MOD;
}

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

    int ans = INF;
    for (int t = 0; t < ipow(4, N); ++t) {
        int l[3] = {0, 0, 0};
        int cnt = 0;
        for (int i = 0; i < N; ++i) {
            int k = t / ipow(4, i) % 4;
            if (k < 3) {
                l[k] += L[i];
                ++cnt;
            }
        }

        int cost = 0;
        for (int k = 0; k < 3; ++k) {
            if (l[k] == 0) {
                cost = INF;
                break;
            }
            cost += abs(A[k] - l[k]);
        }
        ans = min(ans, cost + (cnt - 3) * 10);
    }

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int Array[1000][2];
	int i;
	for (i = 0;; i++) {
		int a, b;
		cin >> a >> b;
		if (a == 0 && b == 0) break;
		Array[i][0] = a;
		Array[i][1] = b;
	}
	for (int n = 0; n < i; n++){
		for (int k = 0; k < Array[n][0]; k++) {
			for (int i = 0; i < Array[n][1]; i++){
				if ((k + i) % 2 == 0)cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
}

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
using namespace std;
#define loop(i,a,b) for(int i = a; i < b; i++)
#define rep(i,a) loop(i,0,a)
#define shosu(x) fixed<<setprecision(x)
typedef long long ll;

int main()
{	
	ll N,x;
	
	cin>>N>>x;
	ll a[2];
	cin>>a[1];
	ll cnt=0;
	ll temp;
	
	rep(i,N-1){
		cin>>a[i%2];
		temp=a[0]+a[1]-x;
		if(temp<0)
			temp=0;
		cnt+=temp;
		if(temp>0){
			if(a[i%2]>=temp)
					a[i%2]-=temp;
			else{
					temp-=a[i%2];
					a[i%2]=0;
					a[(i+1)%2]-=temp;
			}
		}
	}
	cout<<cnt<<endl;
}



Measured memory_bytes: 256
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

emp = [[0] * 3 for _ in range(3)]
#print(n, b)

for i in range(n) :
    for j in range(3) :
        for k in range(3) :
            if a[j][k] == b[i] :
                emp[j][k] = 1

x = [0, 1, 2, 0, 0, 0, 0, 2]
y = [0, 0, 0, 0, 1, 2, 0, 0]
dx = [0, 0, 0, 1, 1, 1, 1, -1]
dy = [1, 1, 1, 0, 0, 0, 1, 1]

flag = True
ans = False

for i in range(8) :
    xx = x[i]
    yy = y[i]
    flag = True
    for j in range(3) :
        #print(i, j, xx, yy, emp[xx][yy])
        if emp[xx][yy] != 1 :
            flag = False
            break
        xx += dx[i]
        yy += dy[i]
    if flag == True :
        ans = True
if ans :
    print('Yes')
else :
    print('No')


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

typedef long long lint;
typedef long double louble;

const char lf = '\n';

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

inline int fuck(int x){int ans=0;while(x)ans+=x%10,x/=10;return ans;}

int main()
{	
	int n=ty(),ans=1e9;
	for(int i=1;i<n;i++)ans=min(ans,fuck(i)+fuck(n-i));
	cout<<ans<<lf;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=998244353;
const int INF=1e9;
const ll LINF=(ll)1e18;

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

int main(){
    int n;
    cin>>n;
    int a[n];
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    ll dp1[n*300+1]={};
    ll dp2[n*300+1]={};
    dp1[0]=dp2[0]=1;
    for(int i=0;i<n;i++){
        for(int j=n*300-1;j>=0;j--){
            if(dp1[j]){
                dp1[j+a[i]]=(dp1[j+a[i]]+dp1[j])%MOD;
                dp1[j]=(dp1[j]*2)%MOD;
            }
            if(dp2[j])dp2[j+a[i]]=(dp2[j+a[i]]+dp2[j])%MOD;
        }
    }
    ll ans=0;
    for(int i=(sum+1)/2;i<=n*300;i++){
        ans=(ans+3*dp1[i])%MOD;
    }
    if(sum%2==0){
        ans=(ans-3*dp2[sum/2])%MOD;
    }
    ans=(modpow(3,n)-ans+MOD)%MOD;
    cout<<ans<<endl;
}


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

namespace ConsoleApp2
{
    public class Program
    {
        public static void Main(string[] args)
        {
            long H = long.Parse(Console.ReadLine());
            Console.WriteLine(N(H));
            Console.ReadLine();
        }

        static long N(long n)
        {
            if (n == 1) return 1;
            return 1+2 * N(n / 2);
        }

    }


}


Measured memory_bytes: 13140
def main():
    import sys
    readline = sys.stdin.buffer.readline
    sys.setrecursionlimit(10 ** 7)

    from collections import Counter

    n = int(readline())
    s = [readline().rstrip().decode() for _ in range(n)]
    counter = Counter(s)
    print('AC x {}'.format(counter['AC']))
    print('WA x {}'.format(counter['WA']))
    print('TLE x {}'.format(counter['TLE']))
    print('RE x {}'.format(counter['RE']))


if __name__ == '__main__':
    main()


Measured memory_bytes: 79656
#include <iostream>

using namespace std;

int main() {
    int x;
    cin >> x;
    int m=1;
    for(int i=2; i*i<=x; ++i){
        int y=i;
        while(y<=x){
            m=max(y, m);
            y*=i;
        }
    }
    cout << m << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define LL long long
#define st first
#define nd second
#define endl '\n'
using namespace std;

const int MAXN=105;
int n,dep[MAXN],ch[MAXN],ex[MAXN],ey[MAXN],vis[MAXN],depmx[MAXN];
LL a1=1e18,a2;
vector<int> v[MAXN];

void solve(int x,int y) {

	memset(vis,0,sizeof vis);
	memset(depmx,0,sizeof depmx);
	queue<int> q;
	int mxdep=0;
	vis[x]=dep[x]=1;
	q.push(x);
	if(y!=-1){
		vis[y]=dep[y]=1;
		q.push(y);
	}
	while(!q.empty()) {
		int a=q.front();
		q.pop();
		mxdep=max(mxdep,dep[a]);
		depmx[dep[a]]=max(depmx[dep[a]],(int)(v[a].size())-(int)(dep[a]!=1||y!=-1));
		for(int i=0;i<v[a].size();++i) {
			if(!vis[v[a][i]]) {
				vis[v[a][i]]=1;
				dep[v[a][i]]=dep[a]+1;
				q.push(v[a][i]);
			}
		}
	}
	LL ax=1;
	for(int i=1;i<=mxdep-1;++i) {
		//if(x==3&&y==6) cout<<" d "<<i<<" "<<depmx[i]<<endl;
		ax*=depmx[i];
	}
	if(y!=-1)
		ax*=2;
	else if(v[x].size()==1) ++ax;
	if(mxdep<a1) {
		a1=mxdep;
		a2=ax;
	}
	else if(mxdep==a1)
		a2=min(a2,ax);
	//if(x==3&&y==6)
	//	cout<<" a "<<mxdep<<" "<<ax<<endl;

}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	if(n==2) {
		cout<<"1 2"<<endl;
		return 0;
	}
	for(int i=0;i<n-1;++i) {
		cin>>ex[i]>>ey[i];
		v[ex[i]].pb(ey[i]);
		v[ey[i]].pb(ex[i]);
	}
	for(int i=1;i<=n;++i)
		solve(i,-1);
	for(int i=0;i<n-1;++i)
		solve(ex[i],ey[i]);
	cout<<a1<<" "<<a2<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
    vector<int> a(3);
    rep(i,3)cin >> a[i];
    sort(a.begin(),a.end());
    rep(i,3){
        cout << a[i];
        if(i != 2)cout << " ";
        else cout << endl;
    }
}


Measured memory_bytes: 3164
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.math;

void main() {
  auto N = readln.chomp.to!int;
  auto Bn = readln.split.to!(int[]);

  int total = Bn[0] + Bn[N-2];
  foreach(i; 0..N-2) {
    total += min(Bn[i], Bn[i+1]);
  }

  writeln(total);
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,a,b=map(int, input().split())
    l=list(map(int,input().split()))
    ans=0
    for i in range(n-1):
        x=l[i+1]-l[i]
        ans+=min(x*a,b)
    print(ans)
resolve()

Measured memory_bytes: 62704
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define MAX 100
#define INF 1<<30
int n;
double cost[MAX][MAX];
double mincost[MAX];
bool used[MAX];
double prim(){
  for(int i=0;i<n;i++)mincost[i]=INF,used[i]=false;
    mincost[0]=0;
  double res=0;
  while(1){
    int v=-1;
    for(int u=0;u<n;u++)
      if(!used[u]&&(v==-1||mincost[u]<mincost[v]))v=u;
    if(v==-1)break;
    used[v]=1;
    res+=mincost[v];
    for(int u=0;u<n;u++)mincost[u]=min(mincost[u],cost[v][u]);
  }
return res;
}
main(){
  while(cin>>n,n){
    double a[n][3],r[n];
    r(i,n)cin>>a[i][0]>>a[i][1]>>a[i][2]>>r[i];
    r(i,n)r(j,n){
      double t=sqrt(abs((a[i][0]-a[j][0])*(a[i][0]-a[j][0]))+abs((a[i][1]-a[j][1])*(a[i][1]-a[j][1]))+abs((a[i][2]-a[j][2])*(a[i][2]-a[j][2])));
      t-=r[i]+r[j];
      if(t<0)t=0;
      cost[i][j]=t;
    }
    double ans=prim();
    printf("%.3f\n",ans);
  }
}

Measured memory_bytes: 3176
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n;
  long long sum = 0, x = 0,ans =1000000000000LL;
  cin >> n;
  vector<long long> a(n);
  
  for(int i = 0;i < n;i++){
    cin >> a[i];
    sum += a[i];
  }

  for(int i = 0;i < n;i++){
    x += a[i];
    if(i+1 < n) ans =min(ans ,abs(sum-2*x));
  }

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

Measured memory_bytes: 1792
// Problem : D - ModSum
// Contest : AtCoder - AtCoder Beginner Contest 139
// URL : https://atcoder.jp/contests/abc139/tasks/abc139_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
void solve()
{
	int n;
	cin >> n;
	cout << (n*(n-1))/2;	
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3636
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n,m,c = LI()
    b = LI()
    ans = 0
    for _ in range(n):
        a = LI()
        cul = 0
        for x, y in zip(a,b):
            cul += x*y
        cul += c
        ans += 1 if cul > 0 else 0
    
    print(ans)
main()

Measured memory_bytes: 74624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll N=5e5;

  ll n,c,k;
  ll a[N];
void in()
{
  cin>>n;
  for (ll i=0;++i<=n;)
    scanf("%d",a+i);
}

ll che(ll x)
{
  ll s=0;
  for (ll i=0;++i<=x;)
    s+=a[i];
  for (ll i=x;++i<=n;)
    if (s+s<a[i])
      return 1;
    else
      s+=a[i];
  return 0;
}

  ll A;
void wor()
{
  sort(a+1,a+n+1);
  for (ll i=20;~--i;)
    if (A+(1<<i)<=n)
      A+=che(A+(1<<i))<<i;
}

void out()
{
  cout<<n-A;
}

int main()
{
  in();
  wor();
  out();
  exit(0);
}

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

int main(){
	long long n, mi = 1000000000, ma = -1, in; cin >> n;
	for( int i = 0; i < n; ++i ){
		cin >> in;
		ma = max(in, ma);
		mi = min(mi, in);
	}
	cout << abs(ma-mi) << endl;
	return 0;
}

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

int N;

bool isRed(const vector<int>& v) {
    assert(v.size() == N);
    cout << "?";
    for (auto num : v)cout << " " << (num + 1);
    cout << endl;

    string s;
    cin >> s;
    return s == "Red";
}

bool isChange(const int idx, const bool base) {
    vector<int> v;
    rep(i, N)v.push_back(idx + i);
    return isRed(v) != base;
}

int changeIdx(const bool base, vector<int>& v) {
    int l = 0, r = N;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        (isChange(mid, base) ? r : l) = mid;
    }
    while (isChange(l, base))l--;
    return l + 1;
}

int main()
{
    cin >> N;
    vector<int> v;
    rep(i, N)v.push_back(i);

    bool baseRed = isRed(v);
    const int change = changeIdx(baseRed, v);

    vector<int> res(2 * N, -1);
    vector<int> normal, next;
    rep(i, N - 1)normal.push_back(i + change);

    rep(i, change) {
        normal.push_back(i);
        res[i] = isRed(normal) ? 1 : 0;
        normal.pop_back();
    }
    REP(i, change + N, 2 * N) {
        normal.push_back(i);
        res[i] = isRed(normal) ? 1 : 0;
        normal.pop_back();
    }

    int bcnt = (N - 1) / 2;
    int rcnt = (N - 1) / 2;
    rep(i, 2 * N) {
        if (res[i] == 0) {
            if (bcnt <= 0)continue;
            bcnt--;
            next.push_back(i);
        }
        if (res[i] == 1) {
            if (rcnt <= 0)continue;
            rcnt--;
            next.push_back(i);
        }
    }
    assert(next.size() == N - 1);
    rep(i, 2 * N)if (res[i] == -1) {
        next.push_back(i);
        res[i] = isRed(next) ? 1 : 0;
        next.pop_back();
    }
    cout << "! ";
    for (bool isred : res) {
        cout << (isred ? "R" : "B");
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using db = double;
using pll = pair < ll, ll >;
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
 
#define pb push_back
#define mp make_pair
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
 
int main(){   
    ll ans = 0;
    string s, t; cin >> s >> t;
    for(ll i = 0; i < s.size(); i++) {
       if(s[i] != t[i]) ans++; 
    }
    cout << ans << endl;
}
    

Measured memory_bytes: 3916
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {
	
	int w, h, x, y;
	scanf("%d%d%d%d", &w, &h, &x, &y);
	printdb((double)w * (double)h / (double)2);
	printf("%d\n", ((double)x == (double)w / (double)2 && (double)y == (double)h / (double)2));

	Please AC;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int diff(int a[], int n);

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

  int a[n];

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

    cout << diff(a, n);
    return 0;
}

int diff(int a[], int n)
{
  int max = a[0];
  int min = a[0];

  for(int i = 1; i < n; i++)
  {
    if(max < a[i])
    max = a[i];

    if(min > a[i])
    min = a[i];
  }

  return max - min;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <array>
using namespace std;

const double EPS = 1e-8;
#define X real()
#define Y imag()
typedef complex<double> P;
typedef vector<P> VP;
struct L: array<P,2>{
	L(P a, P b){ at(0)=a; at(1)=b; }
	L(){}
};
double dot(P a, P b){
	return (conj(a)*b).X;
}
double cross(P a, P b){
	return (conj(a)*b).Y;
}

int ccw(P a, P b, P c){
	b -= a;
	c -= a;
	if(cross(b,c) > EPS) return +1;
	if(cross(b,c) <-EPS) return -1;
	return 0;
}
P crosspointLL(const L& l, const L& m){
	double A = cross(l[1]-l[0], m[1]-m[0]);
	double B = cross(l[1]-l[0], l[1]-m[0]);
	return m[0] + B/A * (m[1]-m[0]);
}
bool isParallel(const P &a, const P &b){
    return abs(cross(a,b)) < EPS;
}
bool isParallel(const L &a, const L &b){
    return isParallel(a[1]-a[0], b[1]-b[0]);
}


int ope(P& from, P& to, P& move, P& fixed){
	if(isParallel(L(from, to), L(move, fixed))){
		from = to;
		return 1;
	}else if(ccw(from, to, fixed) == 0){
		return 100;
	}else{
		L l1(fixed, fixed +to -from);
		L l2(move, move +from -fixed);
		move = crosspointLL(l1, l2);
		from = to;
		return 2;
	}
}

int main(){
	int x,y;
	
	while(cin >> x){
		vector<VP> tri(2, VP(3));
		for(int i=0; i<2; i++){
			for(int j=0; j<3; j++){
				if(i!=0 || j!=0) cin >> x;
				cin >> y;
				tri[i][j] = P(x,y);
			}
		}
		
		for(int i=0; i<2; i++){
			if(ccw(tri[i][0], tri[i][1], tri[i][2]) != -1){
				swap(tri[i][1], tri[i][2]);
			}
		}
		
		int ans = 5;
		for(int i=0; i<3; i++){
			for(int j=0; j<3; j++){
				for(int v=1; v<=2; v++){
					for(int q=1; q<=2; q++){
						vector<VP> t = tri;
						int ret1 = ope(t[0][i], t[1][j], t[0][(i+v)%3], t[0][(i+2*v)%3]);
						int ret2 = ope(t[0][(i+q)%3], t[1][(j+q)%3], t[0][(i+2*q)%3], t[0][i]);
						ans = min(ans, ret1 +ret2 +1);
					}
				}
			}
		}
		if(ans == 5) cout << "Many" << endl;
		else cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <iomanip>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll K,S;
    cin >> K >> S;
    ll count = 0;
    for (int i = 0; i <= K; ++i) {
        for (int j = 0; j <= K; ++j) {
            if(0 <= (S-i-j) && (S-i-j) <= K){
                count++;
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [String; n],
    }

    let mut tf = HashMap::new();
    for a in a {
        let s = a.split('.').collect_vec();
        let bunbo = if s.len() == 1 { 1 } else { 10i64.pow(s[1].len() as u32) };
        let ipart = s[0].parse::<i64>().unwrap();
        let dpart = if s.len() == 1 { 0 } else { s[1].parse::<i64>().unwrap() };
        let bunsi = ipart * bunbo + dpart;
        let bunsi2p = div_num(bunsi, 2);
        let bunsi5p = div_num(bunsi, 5);
        let bunbo2p = div_num(bunbo, 2);
        let bunbo5p = div_num(bunbo, 5);
        let two = bunsi2p - bunbo2p;
        let five = bunsi5p - bunbo5p;
        *tf.entry((two, five)).or_insert(0i64) += 1;
    }

    let mut ans = 0;
    for (&(t, f), &num) in tf.iter() {
        let mut res = 0;
        for two in -t..=45 {
            for five in -f..=45 {
                if two == t && five == f {
                    continue;
                }
                if let Some(&v) = tf.get(&(two, five)) {
                    res += v;
                }
            }
        }
        res *= num;
        if t >= 0 && f >= 0 {
            res += num * (num - 1);
        }
        ans += res;
    } 
    println!("{}", ans / 2);
}

fn div_num(mut x: i64, p: i64) -> i64 {
    let mut res = 0;
    while x % p == 0 {
        x /= p;
        res += 1;
    }
    res
} 

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

#define MAX 100

int main(void){
  int i;
  int n, G_list[MAX];
  int G[MAX+1][MAX+1]={0};
  
  scanf("%d", &n);

  for(i=0; i<n; i++){
    int cnt, num, m;

    scanf("%d %d", &num, &cnt);
    G_list[i]=num;

    for(int j=0; j<cnt; j++){
      scanf("%d", &m);
      G[G_list[i]][m]=1;
    }
  }

  for(int i=0; i<n; i++){
    int num=G_list[i];
    for(int j=0; j<n; j++){
      int m=G_list[j];

      if(j) printf(" ");
      printf("%d", G[num][m]);
    }
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 3268
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, k) = (v[0], v[1]);
    if k == 0 {
        println!("{}", n * n);
        return;
    }

    let mut ans = 0i64;
    for b in (k + 1..n + 1).rev() {
        let all_included = n / b;
        let temp1 = (b - k) * all_included;
        let temp2 = max(n - all_included * b - k + 1, 0);
        ans += temp1 + temp2;
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352